Correos para clientes y distribuidores <3
This commit is contained in:
12
create.sql
12
create.sql
@@ -17,7 +17,7 @@ drop table if exists correo;
|
|||||||
drop table if exists direccion;
|
drop table if exists direccion;
|
||||||
drop table if exists telefono;
|
drop table if exists telefono;
|
||||||
drop table if exists empresa;
|
drop table if exists empresa;
|
||||||
drop table if exists distribuidor;
|
drop table if exists cliente;
|
||||||
drop table if exists cliente;
|
drop table if exists cliente;
|
||||||
drop table if exists trabajador;
|
drop table if exists trabajador;
|
||||||
drop table if exists distribuidor_direccion;
|
drop table if exists distribuidor_direccion;
|
||||||
@@ -163,7 +163,7 @@ create table empresa
|
|||||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
create table distribuidor
|
create table cliente
|
||||||
(
|
(
|
||||||
id int unsigned primary key auto_increment,
|
id int unsigned primary key auto_increment,
|
||||||
empresa_id int unsigned not null,
|
empresa_id int unsigned not null,
|
||||||
@@ -198,7 +198,7 @@ create table distribuidor_direccion
|
|||||||
(
|
(
|
||||||
distribuidor_id int unsigned,
|
distribuidor_id int unsigned,
|
||||||
direccion_id int unsigned,
|
direccion_id int unsigned,
|
||||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade,
|
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
|
||||||
foreign key (direccion_id) references direccion (id) on delete cascade on update cascade
|
foreign key (direccion_id) references direccion (id) on delete cascade on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ create table distribuidor_telefono
|
|||||||
(
|
(
|
||||||
distribuidor_id int unsigned,
|
distribuidor_id int unsigned,
|
||||||
telefono_id int unsigned,
|
telefono_id int unsigned,
|
||||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade,
|
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
|
||||||
foreign key (telefono_id) references telefono (id) on delete cascade on update cascade
|
foreign key (telefono_id) references telefono (id) on delete cascade on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ create table distribuidor_correo
|
|||||||
(
|
(
|
||||||
distribuidor_id int unsigned,
|
distribuidor_id int unsigned,
|
||||||
correo_id int unsigned,
|
correo_id int unsigned,
|
||||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade,
|
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
|
||||||
foreign key (correo_id) references correo (id) on delete cascade on update cascade
|
foreign key (correo_id) references correo (id) on delete cascade on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ create table compra
|
|||||||
distribuidor_id int unsigned not null,
|
distribuidor_id int unsigned not null,
|
||||||
inserted_at timestamp default CURRENT_TIMESTAMP,
|
inserted_at timestamp default CURRENT_TIMESTAMP,
|
||||||
foreign key (factura_id) references factura (id) on delete restrict on update cascade,
|
foreign key (factura_id) references factura (id) on delete restrict on update cascade,
|
||||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade
|
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
create table venta
|
create table venta
|
||||||
|
|||||||
10
data.sql
10
data.sql
@@ -118,13 +118,13 @@ LOCK TABLES `direccion` WRITE;
|
|||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `distribuidor`
|
-- Dumping data for table `cliente`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `distribuidor` WRITE;
|
LOCK TABLES `cliente` WRITE;
|
||||||
/*!40000 ALTER TABLE `distribuidor` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `cliente` DISABLE KEYS */;
|
||||||
INSERT INTO `distribuidor` VALUES (2,1,'14166920-6','2019-06-13 03:08:17'),(3,2,'8425080-5','2019-06-13 03:08:23'),(4,1,'21629388-6','2019-06-13 03:08:25'),(5,1,'13510176-1','2019-06-13 03:08:27');
|
INSERT INTO `cliente` VALUES (2,1,'14166920-6','2019-06-13 03:08:17'),(3,2,'8425080-5','2019-06-13 03:08:23'),(4,1,'21629388-6','2019-06-13 03:08:25'),(5,1,'13510176-1','2019-06-13 03:08:27');
|
||||||
/*!40000 ALTER TABLE `distribuidor` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `cliente` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
2
info.md
2
info.md
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
## Datos
|
## Datos
|
||||||
- Libros comprados
|
- Libros comprados
|
||||||
- distribuidor involucrado
|
- cliente involucrado
|
||||||
- Factura.
|
- Factura.
|
||||||
|
|
||||||
# Factura
|
# Factura
|
||||||
|
|||||||
@@ -18,10 +18,18 @@ import xyz.danielcortes.controllers.mantenedores.cliente.ClienteCreateController
|
|||||||
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteSearchController;
|
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteUpdateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteViewController;
|
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteViewController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.correo.ClienteCorreoCreateController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.correo.ClienteCorreoSearchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.correo.ClienteCorreoUpdateController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.correo.ClienteCorreoViewController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorCreateController;
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorCreateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorSearchController;
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorUpdateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorViewController;
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorViewController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.correo.DistribuidorCorreoCreateController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.correo.DistribuidorCorreoSearchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.correo.DistribuidorCorreoUpdateController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.correo.DistribuidorCorreoViewController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialCreateController;
|
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialCreateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialSearchController;
|
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.editorial.EditorialUpdateController;
|
||||||
@@ -42,10 +50,10 @@ import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorCreateCont
|
|||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorUpdateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorViewController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.TrabajadorViewController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.CorreoCreateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.TrabajadorCorreoCreateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.CorreoSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.TrabajadorCorreoSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.CorreoUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.TrabajadorCorreoUpdateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.CorreoViewController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.TrabajadorCorreoViewController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionCreateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionCreateController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionUpdateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionUpdateController;
|
||||||
@@ -182,10 +190,20 @@ public class LaunchController {
|
|||||||
this.controllers.put(PanelName.USUARIO_CREATE, new UsuarioCreateController(new UsuarioCreatePanel(), this));
|
this.controllers.put(PanelName.USUARIO_CREATE, new UsuarioCreateController(new UsuarioCreatePanel(), this));
|
||||||
this.controllers.put(PanelName.USUARIO_UPDATE, new UsuarioUpdateController(new UsuarioUpdatePanel(), this));
|
this.controllers.put(PanelName.USUARIO_UPDATE, new UsuarioUpdateController(new UsuarioUpdatePanel(), this));
|
||||||
|
|
||||||
this.controllers.put(PanelName.CORREO_SEARCH, new CorreoSearchController(new CorreoSearchPanel(), this));
|
this.controllers.put(PanelName.DISTRIBUIDOR_CORREO_SEARCH, new DistribuidorCorreoSearchController(new CorreoSearchPanel(), this));
|
||||||
this.controllers.put(PanelName.CORREO_VIEW, new CorreoViewController(new CorreoViewPanel(), this));
|
this.controllers.put(PanelName.DISTRIBUIDOR_CORREO_VIEW, new DistribuidorCorreoViewController(new CorreoViewPanel(), this));
|
||||||
this.controllers.put(PanelName.CORREO_CREATE, new CorreoCreateController(new CorreoCreatePanel(), this));
|
this.controllers.put(PanelName.DISTRIBUIDOR_CORREO_CREATE, new DistribuidorCorreoCreateController(new CorreoCreatePanel(), this));
|
||||||
this.controllers.put(PanelName.CORREO_UPDATE, new CorreoUpdateController(new CorreoUpdatePanel(), this));
|
this.controllers.put(PanelName.DISTRIBUIDOR_CORREO_UPDATE, new DistribuidorCorreoUpdateController(new CorreoUpdatePanel(), this));
|
||||||
|
|
||||||
|
this.controllers.put(PanelName.TRABAJADOR_CORREO_SEARCH, new TrabajadorCorreoSearchController(new CorreoSearchPanel(), this));
|
||||||
|
this.controllers.put(PanelName.TRABAJADOR_CORREO_VIEW, new TrabajadorCorreoViewController(new CorreoViewPanel(), this));
|
||||||
|
this.controllers.put(PanelName.TRABAJADOR_CORREO_CREATE, new TrabajadorCorreoCreateController(new CorreoCreatePanel(), this));
|
||||||
|
this.controllers.put(PanelName.TRABAJADOR_CORREO_UPDATE, new TrabajadorCorreoUpdateController(new CorreoUpdatePanel(), this));
|
||||||
|
|
||||||
|
this.controllers.put(PanelName.CLIENTE_CORREO_SEARCH, new ClienteCorreoSearchController(new CorreoSearchPanel(), this));
|
||||||
|
this.controllers.put(PanelName.CLIENTE_CORREO_VIEW, new ClienteCorreoViewController(new CorreoViewPanel(), this));
|
||||||
|
this.controllers.put(PanelName.CLIENTE_CORREO_CREATE, new ClienteCorreoCreateController(new CorreoCreatePanel(), this));
|
||||||
|
this.controllers.put(PanelName.CLIENTE_CORREO_UPDATE, new ClienteCorreoUpdateController(new CorreoUpdatePanel(), this));
|
||||||
|
|
||||||
this.controllers.put(PanelName.TELEFONO_SEARCH, new TelefonoSearchController(new TelefonoSearchPanel(), this));
|
this.controllers.put(PanelName.TELEFONO_SEARCH, new TelefonoSearchController(new TelefonoSearchPanel(), this));
|
||||||
this.controllers.put(PanelName.TELEFONO_VIEW, new TelefonoViewController(new TelefonoViewPanel(), this));
|
this.controllers.put(PanelName.TELEFONO_VIEW, new TelefonoViewController(new TelefonoViewPanel(), this));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.danielcortes.controllers.mantenedores.cliente;
|
|||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.correo.ClienteCorreoSearchController;
|
||||||
import xyz.danielcortes.framework.BaseController;
|
import xyz.danielcortes.framework.BaseController;
|
||||||
import xyz.danielcortes.framework.BasePanel;
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
@@ -30,7 +31,7 @@ public class ClienteViewController extends BaseController {
|
|||||||
|
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH));
|
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH));
|
||||||
// this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView());
|
this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView());
|
||||||
// this.view.getTelefonosButton().addActionListener(e -> this.gotoTelefonoView());
|
// this.view.getTelefonosButton().addActionListener(e -> this.gotoTelefonoView());
|
||||||
// this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
|
// this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
|
||||||
}
|
}
|
||||||
@@ -46,12 +47,12 @@ public class ClienteViewController extends BaseController {
|
|||||||
// controller.setCliente(cliente);
|
// controller.setCliente(cliente);
|
||||||
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// private void gotoCorreosView() {
|
private void gotoCorreosView() {
|
||||||
// CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
ClienteCorreoSearchController controller = (ClienteCorreoSearchController) this.getParentController().getCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
// controller.setCliente(cliente);
|
controller.setCliente(this.cliente);
|
||||||
// this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
// }
|
}
|
||||||
|
|
||||||
private void fillCliente() {
|
private void fillCliente() {
|
||||||
if (this.cliente == null)
|
if (this.cliente == null)
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.cliente.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoCreateController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
|
import xyz.danielcortes.models.Cliente;
|
||||||
|
import xyz.danielcortes.models.Correo;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoCreatePanel;
|
||||||
|
|
||||||
|
public class ClienteCorreoCreateController extends AbstractCorreoCreateController {
|
||||||
|
|
||||||
|
private Cliente cliente;
|
||||||
|
|
||||||
|
public ClienteCorreoCreateController(CorreoCreatePanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void save() {
|
||||||
|
String sCorreo = this.view.getCorreoField().getText();
|
||||||
|
|
||||||
|
ValidationResult correoValidation = this.validator.validateCorreo(sCorreo);
|
||||||
|
if (correoValidation.hasError()) {
|
||||||
|
correoValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Correo correo = new Correo();
|
||||||
|
correo.setCorreo(sCorreo);
|
||||||
|
correo.getClientes().add(this.cliente);
|
||||||
|
|
||||||
|
this.repository.save(correo);
|
||||||
|
this.cliente.getCorreos().add(correo);
|
||||||
|
|
||||||
|
this.volver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
ClienteCorreoSearchController controller = (ClienteCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.cliente.correo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoSearchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.cliente.ClienteViewController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Cliente;
|
||||||
|
import xyz.danielcortes.models.Correo;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoSearchPanel;
|
||||||
|
|
||||||
|
public class ClienteCorreoSearchController extends AbstractCorreoSearchController {
|
||||||
|
|
||||||
|
private Cliente cliente;
|
||||||
|
|
||||||
|
public ClienteCorreoSearchController(CorreoSearchPanel view, LaunchController parent) {
|
||||||
|
super(view, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void create() {
|
||||||
|
ClienteCorreoCreateController controller = (ClienteCorreoCreateController) this.getParentController()
|
||||||
|
.getCard(PanelName.CLIENTE_CORREO_CREATE);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void edit() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo != null) {
|
||||||
|
ClienteCorreoUpdateController controller = (ClienteCorreoUpdateController) this.getParentController()
|
||||||
|
.getCard(PanelName.CLIENTE_CORREO_UPDATE);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
controller.setCorreo(correo);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_UPDATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void delete() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"¿Estas seguro de que deseas eliminar el correo?",
|
||||||
|
"Confirmacion",
|
||||||
|
JOptionPane.YES_NO_OPTION,
|
||||||
|
JOptionPane.QUESTION_MESSAGE
|
||||||
|
);
|
||||||
|
if (option == JOptionPane.NO_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.correoRepository.delete(correo);
|
||||||
|
this.cliente.getCorreos().remove(correo);
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void view() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo != null) {
|
||||||
|
ClienteCorreoViewController controller = (ClienteCorreoViewController) this.getParentController()
|
||||||
|
.getCard(PanelName.CLIENTE_CORREO_VIEW);
|
||||||
|
controller.setCorreo(correo);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_VIEW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void search() {
|
||||||
|
String term = this.view.getSearchField().getText();
|
||||||
|
List<Correo> correo = this.correoRepository.search(term, this.cliente);
|
||||||
|
this.loadCorreosTable(correo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_VIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadCorreosTable() {
|
||||||
|
List<Correo> correos = this.cliente.getCorreos();
|
||||||
|
this.loadCorreosTable(correos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.cliente.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoUpdateController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Cliente;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoUpdatePanel;
|
||||||
|
|
||||||
|
public class ClienteCorreoUpdateController extends AbstractCorreoUpdateController {
|
||||||
|
|
||||||
|
private Cliente cliente;
|
||||||
|
|
||||||
|
public ClienteCorreoUpdateController(CorreoUpdatePanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
ClienteCorreoSearchController controller = (ClienteCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.cliente.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoViewController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Cliente;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoViewPanel;
|
||||||
|
|
||||||
|
public class ClienteCorreoViewController extends AbstractCorreoViewController {
|
||||||
|
|
||||||
|
private Cliente cliente;
|
||||||
|
|
||||||
|
public ClienteCorreoViewController(CorreoViewPanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCliente(Cliente cliente) {
|
||||||
|
this.cliente = cliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
ClienteCorreoSearchController controller = (ClienteCorreoSearchController) this.getParentController().getCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
controller.setCliente(this.cliente);
|
||||||
|
this.getParentController().showCard(PanelName.CLIENTE_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package xyz.danielcortes.controllers.mantenedores.distribuidor;
|
package xyz.danielcortes.controllers.mantenedores.distribuidor;
|
||||||
|
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.correo.DistribuidorCorreoSearchController;
|
||||||
import xyz.danielcortes.framework.BaseController;
|
import xyz.danielcortes.framework.BaseController;
|
||||||
import xyz.danielcortes.framework.BasePanel;
|
import xyz.danielcortes.framework.BasePanel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
@@ -29,28 +30,29 @@ public class DistribuidorViewController extends BaseController {
|
|||||||
|
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH));
|
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH));
|
||||||
// this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView());
|
this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView());
|
||||||
// this.view.getTelefonosButton().addActionListener(e -> this.gotoTelefonoView());
|
// this.view.getTelefonosButton().addActionListener(e -> this.gotoTelefonoView());
|
||||||
// this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
|
// this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void gotoDireccionView() {
|
// private void gotoDireccionView() {
|
||||||
// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH);
|
||||||
// controller.setDistribuidor(distribuidor);
|
// controller.setCliente(distribuidor);
|
||||||
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
// this.getParentController().showCard(PanelName.DIRECCION_SEARCH);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// private void gotoTelefonoView() {
|
// private void gotoTelefonoView() {
|
||||||
// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH);
|
||||||
// controller.setDistribuidor(distribuidor);
|
// controller.setCliente(distribuidor);
|
||||||
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
// this.getParentController().showCard(PanelName.TELEFONO_SEARCH);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// private void gotoCorreosView() {
|
private void gotoCorreosView() {
|
||||||
// CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
|
||||||
// controller.setDistribuidor(distribuidor);
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
// this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
controller.setDistribuidor(this.distribuidor);
|
||||||
// }
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
|
||||||
private void fillDistribuidor() {
|
private void fillDistribuidor() {
|
||||||
if (this.distribuidor == null)
|
if (this.distribuidor == null)
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.distribuidor.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoCreateController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
|
import xyz.danielcortes.models.Correo;
|
||||||
|
import xyz.danielcortes.models.Distribuidor;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoCreatePanel;
|
||||||
|
|
||||||
|
public class DistribuidorCorreoCreateController extends AbstractCorreoCreateController {
|
||||||
|
|
||||||
|
private Distribuidor distribuidor;
|
||||||
|
|
||||||
|
public DistribuidorCorreoCreateController(CorreoCreatePanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistribuidor(Distribuidor distribuidor) {
|
||||||
|
this.distribuidor = distribuidor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void save() {
|
||||||
|
String sCorreo = this.view.getCorreoField().getText();
|
||||||
|
|
||||||
|
ValidationResult correoValidation = this.validator.validateCorreo(sCorreo);
|
||||||
|
if (correoValidation.hasError()) {
|
||||||
|
correoValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Correo correo = new Correo();
|
||||||
|
correo.setCorreo(sCorreo);
|
||||||
|
correo.getDistribuidores().add(this.distribuidor);
|
||||||
|
|
||||||
|
this.repository.save(correo);
|
||||||
|
this.distribuidor.getCorreos().add(correo);
|
||||||
|
|
||||||
|
this.volver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.distribuidor.correo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoSearchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorViewController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Correo;
|
||||||
|
import xyz.danielcortes.models.Distribuidor;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoSearchPanel;
|
||||||
|
|
||||||
|
public class DistribuidorCorreoSearchController extends AbstractCorreoSearchController {
|
||||||
|
|
||||||
|
private Distribuidor distribuidor;
|
||||||
|
|
||||||
|
public DistribuidorCorreoSearchController(CorreoSearchPanel view, LaunchController parent) {
|
||||||
|
super(view, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistribuidor(Distribuidor distribuidor) {
|
||||||
|
this.distribuidor = distribuidor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void create() {
|
||||||
|
DistribuidorCorreoCreateController controller = (DistribuidorCorreoCreateController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_CREATE);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void edit() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo != null) {
|
||||||
|
DistribuidorCorreoUpdateController controller = (DistribuidorCorreoUpdateController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_UPDATE);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
controller.setCorreo(correo);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_UPDATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void delete() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"¿Estas seguro de que deseas eliminar el correo?",
|
||||||
|
"Confirmacion",
|
||||||
|
JOptionPane.YES_NO_OPTION,
|
||||||
|
JOptionPane.QUESTION_MESSAGE
|
||||||
|
);
|
||||||
|
if (option == JOptionPane.NO_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.correoRepository.delete(correo);
|
||||||
|
this.distribuidor.getCorreos().remove(correo);
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void view() {
|
||||||
|
Correo correo = this.getSelectedCorreo();
|
||||||
|
if (correo != null) {
|
||||||
|
DistribuidorCorreoViewController controller = (DistribuidorCorreoViewController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_VIEW);
|
||||||
|
controller.setCorreo(correo);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_VIEW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void search() {
|
||||||
|
String term = this.view.getSearchField().getText();
|
||||||
|
List<Correo> correo = this.correoRepository.search(term, this.distribuidor);
|
||||||
|
this.loadCorreosTable(correo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_VIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadCorreosTable() {
|
||||||
|
List<Correo> correos = this.distribuidor.getCorreos();
|
||||||
|
this.loadCorreosTable(correos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.distribuidor.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoUpdateController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Distribuidor;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoUpdatePanel;
|
||||||
|
|
||||||
|
public class DistribuidorCorreoUpdateController extends AbstractCorreoUpdateController {
|
||||||
|
|
||||||
|
private Distribuidor distribuidor;
|
||||||
|
|
||||||
|
public DistribuidorCorreoUpdateController(CorreoUpdatePanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistribuidor(Distribuidor distribuidor) {
|
||||||
|
this.distribuidor = distribuidor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package xyz.danielcortes.controllers.mantenedores.distribuidor.correo;
|
||||||
|
|
||||||
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.controllers.mantenedores.abstract_correo.AbstractCorreoViewController;
|
||||||
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.models.Distribuidor;
|
||||||
|
import xyz.danielcortes.views.mantenedores.correo.CorreoViewPanel;
|
||||||
|
|
||||||
|
public class DistribuidorCorreoViewController extends AbstractCorreoViewController {
|
||||||
|
|
||||||
|
private Distribuidor distribuidor;
|
||||||
|
|
||||||
|
public DistribuidorCorreoViewController(CorreoViewPanel view, LaunchController parentController) {
|
||||||
|
super(view, parentController);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistribuidor(Distribuidor distribuidor) {
|
||||||
|
this.distribuidor = distribuidor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void volver() {
|
||||||
|
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
controller.setDistribuidor(this.distribuidor);
|
||||||
|
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package xyz.danielcortes.controllers.mantenedores.trabajador;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.CorreoSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.correo.TrabajadorCorreoSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.direccion.DireccionSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.telefono.TelefonoSearchController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.telefono.TelefonoSearchController;
|
||||||
import xyz.danielcortes.controllers.mantenedores.trabajador.usuario.UsuarioCreateController;
|
import xyz.danielcortes.controllers.mantenedores.trabajador.usuario.UsuarioCreateController;
|
||||||
@@ -54,9 +54,10 @@ public class TrabajadorViewController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void gotoCorreosView() {
|
private void gotoCorreosView() {
|
||||||
CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gotoUsuarioView() {
|
private void gotoUsuarioView() {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import xyz.danielcortes.models.Correo;
|
|||||||
import xyz.danielcortes.models.Trabajador;
|
import xyz.danielcortes.models.Trabajador;
|
||||||
import xyz.danielcortes.views.mantenedores.correo.CorreoCreatePanel;
|
import xyz.danielcortes.views.mantenedores.correo.CorreoCreatePanel;
|
||||||
|
|
||||||
public class CorreoCreateController extends AbstractCorreoCreateController {
|
public class TrabajadorCorreoCreateController extends AbstractCorreoCreateController {
|
||||||
|
|
||||||
private Trabajador trabajador;
|
private Trabajador trabajador;
|
||||||
|
|
||||||
public CorreoCreateController(CorreoCreatePanel view, LaunchController parentController) {
|
public TrabajadorCorreoCreateController(CorreoCreatePanel view, LaunchController parentController) {
|
||||||
super(view, parentController);
|
super(view, parentController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,9 +42,10 @@ public class CorreoCreateController extends AbstractCorreoCreateController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void volver() {
|
protected void volver() {
|
||||||
CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,11 @@ import xyz.danielcortes.models.Correo;
|
|||||||
import xyz.danielcortes.models.Trabajador;
|
import xyz.danielcortes.models.Trabajador;
|
||||||
import xyz.danielcortes.views.mantenedores.correo.CorreoSearchPanel;
|
import xyz.danielcortes.views.mantenedores.correo.CorreoSearchPanel;
|
||||||
|
|
||||||
public class CorreoSearchController extends AbstractCorreoSearchController {
|
public class TrabajadorCorreoSearchController extends AbstractCorreoSearchController {
|
||||||
|
|
||||||
private Trabajador trabajador;
|
private Trabajador trabajador;
|
||||||
|
|
||||||
public CorreoSearchController(CorreoSearchPanel view, LaunchController parent) {
|
public TrabajadorCorreoSearchController(CorreoSearchPanel view, LaunchController parent) {
|
||||||
super(view, parent);
|
super(view, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,19 +24,21 @@ public class CorreoSearchController extends AbstractCorreoSearchController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void create() {
|
protected void create() {
|
||||||
CorreoCreateController controller = (CorreoCreateController) this.getParentController().getCard(PanelName.CORREO_CREATE);
|
TrabajadorCorreoCreateController controller = (TrabajadorCorreoCreateController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_CREATE);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_CREATE);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void edit() {
|
protected void edit() {
|
||||||
Correo correo = this.getSelectedCorreo();
|
Correo correo = this.getSelectedCorreo();
|
||||||
if (correo != null) {
|
if (correo != null) {
|
||||||
CorreoUpdateController controller = (CorreoUpdateController) this.getParentController().getCard(PanelName.CORREO_UPDATE);
|
TrabajadorCorreoUpdateController controller = (TrabajadorCorreoUpdateController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_UPDATE);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
controller.setCorreo(correo);
|
controller.setCorreo(correo);
|
||||||
this.getParentController().showCard(PanelName.CORREO_UPDATE);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_UPDATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +67,11 @@ public class CorreoSearchController extends AbstractCorreoSearchController {
|
|||||||
protected void view() {
|
protected void view() {
|
||||||
Correo correo = this.getSelectedCorreo();
|
Correo correo = this.getSelectedCorreo();
|
||||||
if (correo != null) {
|
if (correo != null) {
|
||||||
CorreoViewController controller = (CorreoViewController) this.getParentController().getCard(PanelName.CORREO_VIEW);
|
TrabajadorCorreoViewController controller = (TrabajadorCorreoViewController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_VIEW);
|
||||||
controller.setCorreo(correo);
|
controller.setCorreo(correo);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_VIEW);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_VIEW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,11 +6,11 @@ import xyz.danielcortes.framework.PanelName;
|
|||||||
import xyz.danielcortes.models.Trabajador;
|
import xyz.danielcortes.models.Trabajador;
|
||||||
import xyz.danielcortes.views.mantenedores.correo.CorreoUpdatePanel;
|
import xyz.danielcortes.views.mantenedores.correo.CorreoUpdatePanel;
|
||||||
|
|
||||||
public class CorreoUpdateController extends AbstractCorreoUpdateController {
|
public class TrabajadorCorreoUpdateController extends AbstractCorreoUpdateController {
|
||||||
|
|
||||||
private Trabajador trabajador;
|
private Trabajador trabajador;
|
||||||
|
|
||||||
public CorreoUpdateController(CorreoUpdatePanel view, LaunchController parentController) {
|
public TrabajadorCorreoUpdateController(CorreoUpdatePanel view, LaunchController parentController) {
|
||||||
super(view, parentController);
|
super(view, parentController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,8 +20,9 @@ public class CorreoUpdateController extends AbstractCorreoUpdateController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void volver() {
|
protected void volver() {
|
||||||
CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,11 @@ import xyz.danielcortes.framework.PanelName;
|
|||||||
import xyz.danielcortes.models.Trabajador;
|
import xyz.danielcortes.models.Trabajador;
|
||||||
import xyz.danielcortes.views.mantenedores.correo.CorreoViewPanel;
|
import xyz.danielcortes.views.mantenedores.correo.CorreoViewPanel;
|
||||||
|
|
||||||
public class CorreoViewController extends AbstractCorreoViewController {
|
public class TrabajadorCorreoViewController extends AbstractCorreoViewController {
|
||||||
|
|
||||||
private Trabajador trabajador;
|
private Trabajador trabajador;
|
||||||
|
|
||||||
public CorreoViewController(CorreoViewPanel view, LaunchController parentController) {
|
public TrabajadorCorreoViewController(CorreoViewPanel view, LaunchController parentController) {
|
||||||
super(view, parentController);
|
super(view, parentController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,9 +20,10 @@ public class CorreoViewController extends AbstractCorreoViewController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void volver() {
|
protected void volver() {
|
||||||
CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH);
|
TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController()
|
||||||
|
.getCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
controller.setTrabajador(this.trabajador);
|
controller.setTrabajador(this.trabajador);
|
||||||
this.getParentController().showCard(PanelName.CORREO_SEARCH);
|
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_SEARCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,10 +52,20 @@ public enum PanelName {
|
|||||||
USUARIO_CREATE,
|
USUARIO_CREATE,
|
||||||
USUARIO_UPDATE,
|
USUARIO_UPDATE,
|
||||||
|
|
||||||
CORREO_VIEW,
|
TRABAJADOR_CORREO_VIEW,
|
||||||
CORREO_SEARCH,
|
TRABAJADOR_CORREO_SEARCH,
|
||||||
CORREO_CREATE,
|
TRABAJADOR_CORREO_CREATE,
|
||||||
CORREO_UPDATE,
|
TRABAJADOR_CORREO_UPDATE,
|
||||||
|
|
||||||
|
DISTRIBUIDOR_CORREO_VIEW,
|
||||||
|
DISTRIBUIDOR_CORREO_SEARCH,
|
||||||
|
DISTRIBUIDOR_CORREO_CREATE,
|
||||||
|
DISTRIBUIDOR_CORREO_UPDATE,
|
||||||
|
|
||||||
|
CLIENTE_CORREO_VIEW,
|
||||||
|
CLIENTE_CORREO_SEARCH,
|
||||||
|
CLIENTE_CORREO_CREATE,
|
||||||
|
CLIENTE_CORREO_UPDATE,
|
||||||
|
|
||||||
TELEFONO_VIEW,
|
TELEFONO_VIEW,
|
||||||
TELEFONO_SEARCH,
|
TELEFONO_SEARCH,
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ public class Correo {
|
|||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "distribuidor_direccion",
|
name = "distribuidor_correo",
|
||||||
joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"),
|
joinColumns = @JoinColumn(name = "correo_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "distribuidor_id", referencedColumnName = "id")
|
inverseJoinColumns = @JoinColumn(name = "distribuidor_id", referencedColumnName = "id")
|
||||||
)
|
)
|
||||||
private List<Distribuidor> distribuidores;
|
private List<Distribuidor> distribuidores;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "cliente_direccion",
|
name = "cliente_correo",
|
||||||
joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"),
|
joinColumns = @JoinColumn(name = "correo_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id")
|
inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id")
|
||||||
)
|
)
|
||||||
private List<Cliente> clientes;
|
private List<Cliente> clientes;
|
||||||
|
|||||||
@@ -58,4 +58,28 @@ public class Distribuidor {
|
|||||||
public void setEmpresa(Empresa empresa) {
|
public void setEmpresa(Empresa empresa) {
|
||||||
this.empresa = empresa;
|
this.empresa = empresa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Correo> getCorreos() {
|
||||||
|
return this.correos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorreos(List<Correo> correos) {
|
||||||
|
this.correos = correos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Telefono> getTelefonos() {
|
||||||
|
return this.telefonos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTelefonos(List<Telefono> telefonos) {
|
||||||
|
this.telefonos = telefonos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Direccion> getDirecciones() {
|
||||||
|
return this.direcciones;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirecciones(List<Direccion> direcciones) {
|
||||||
|
this.direcciones = direcciones;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ public class Telefono {
|
|||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "distribuidor_direccion",
|
name = "distribuidor_telefono",
|
||||||
joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"),
|
joinColumns = @JoinColumn(name = "telefono_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "distribuidor_id", referencedColumnName = "id")
|
inverseJoinColumns = @JoinColumn(name = "distribuidor_id", referencedColumnName = "id")
|
||||||
)
|
)
|
||||||
private List<Distribuidor> distribuidores;
|
private List<Distribuidor> distribuidores;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "cliente_direccion",
|
name = "cliente_telefono",
|
||||||
joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"),
|
joinColumns = @JoinColumn(name = "telefono_id", referencedColumnName = "id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id")
|
inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id")
|
||||||
)
|
)
|
||||||
private List<Cliente> clientes;
|
private List<Cliente> clientes;
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import java.util.List;
|
|||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import xyz.danielcortes.framework.BaseRepository;
|
import xyz.danielcortes.framework.BaseRepository;
|
||||||
|
import xyz.danielcortes.models.Cliente;
|
||||||
import xyz.danielcortes.models.Correo;
|
import xyz.danielcortes.models.Correo;
|
||||||
|
import xyz.danielcortes.models.Distribuidor;
|
||||||
import xyz.danielcortes.models.Trabajador;
|
import xyz.danielcortes.models.Trabajador;
|
||||||
|
|
||||||
public class CorreoRepository extends BaseRepository<Correo> {
|
public class CorreoRepository extends BaseRepository<Correo> {
|
||||||
@@ -26,4 +28,18 @@ public class CorreoRepository extends BaseRepository<Correo> {
|
|||||||
query.setParameter("term", "%" + term.toLowerCase() + "%");
|
query.setParameter("term", "%" + term.toLowerCase() + "%");
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Correo> search(String term, Distribuidor distribuidor) {
|
||||||
|
Query query = this.em.createQuery("SELECT c FROM Correo c JOIN c.distribuidores d WHERE d.id = :id AND LOWER(c.correo) LIKE :term ");
|
||||||
|
query.setParameter("id", distribuidor.getId());
|
||||||
|
query.setParameter("term", "%" + term.toLowerCase() + "%");
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Correo> search(String term, Cliente cliente) {
|
||||||
|
Query query = this.em.createQuery("SELECT c FROM Correo c JOIN c.clientes d WHERE d.id = :id AND LOWER(c.correo) LIKE :term ");
|
||||||
|
query.setParameter("id", cliente.getId());
|
||||||
|
query.setParameter("term", "%" + term.toLowerCase() + "%");
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.distribuidor.DistribuidorCreatePanel">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.cliente.DistribuidorCreatePanel">
|
||||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="20" left="20" bottom="20" right="20"/>
|
<margin top="20" left="20" bottom="20" right="20"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.distribuidor.DistribuidorSearchPanel">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.cliente.DistribuidorSearchPanel">
|
||||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="20" left="20" bottom="20" right="20"/>
|
<margin top="20" left="20" bottom="20" right="20"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.distribuidor.DistribuidorUpdatePanel">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.cliente.DistribuidorUpdatePanel">
|
||||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="20" left="20" bottom="20" right="20"/>
|
<margin top="20" left="20" bottom="20" right="20"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.distribuidor.DistribuidorViewPanel">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.mantenedores.cliente.DistribuidorViewPanel">
|
||||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="20" left="20" bottom="20" right="20"/>
|
<margin top="20" left="20" bottom="20" right="20"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
|
|||||||
Reference in New Issue
Block a user