diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionCreateController.java b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionCreateController.java new file mode 100644 index 0000000..06a6734 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionCreateController.java @@ -0,0 +1,50 @@ +package xyz.danielcortes.controllers.abstract_direccion; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.repository.DireccionRepository; +import xyz.danielcortes.validator.DireccionValidator; +import xyz.danielcortes.views.direccion.DireccionCreatePanel; + +public abstract class AbstractDireccionCreateController extends BaseController { + + private DireccionCreatePanel view; + private DireccionRepository repository; + private DireccionValidator validator; + + public AbstractDireccionCreateController(DireccionCreatePanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.repository = new DireccionRepository(); + this.validator = new DireccionValidator(this.repository); + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.view.getCalleField().requestFocus(); + this.view.getCalleField().setText(""); + this.view.getNumeroField().setText(""); + } + + @Override + public BasePanel getView() { + return this.view; + } + + private void setupListeners() { + this.view.getGuardarButton().addActionListener(e -> this.save()); + this.view.getNumeroField().addActionListener(e -> this.save()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void save(); + + protected abstract void volver(); +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionSearchController.java b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionSearchController.java new file mode 100644 index 0000000..e53ec44 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionSearchController.java @@ -0,0 +1,86 @@ +package xyz.danielcortes.controllers.abstract_direccion; + +import java.util.List; +import javax.swing.JOptionPane; +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.BaseTableModel; +import xyz.danielcortes.models.Direccion; +import xyz.danielcortes.repository.DireccionRepository; +import xyz.danielcortes.validator.DireccionValidator; +import xyz.danielcortes.views.direccion.DireccionSearchPanel; + +public abstract class AbstractDireccionSearchController extends BaseController { + + private DireccionSearchPanel view; + private DireccionRepository direccionRepository; + private DireccionValidator validator; + + public AbstractDireccionSearchController(DireccionSearchPanel view, LaunchController parent) { + super(parent); + this.view = view; + this.direccionRepository = new DireccionRepository(); + this.validator = new DireccionValidator(this.direccionRepository); + this.setupListeners(); + } + + @Override + public void show() { + this.reload(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void reload() { + this.loadDireccionesTable(); + this.view.getDireccionesTable().clearSelection(); + } + + private void setupListeners() { + this.view.getCrearButton().addActionListener(e -> this.create()); + this.view.getSearchField().addActionListener(e -> this.search()); + this.view.getBuscarButton().addActionListener(e -> this.search()); + this.view.getVerButton().addActionListener(e -> this.view()); + this.view.getEditarButton().addActionListener(e -> this.edit()); + this.view.getEliminarButton().addActionListener(e -> this.delete()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void create(); + + protected abstract void edit(); + + protected abstract void delete(); + + protected abstract void view(); + + protected abstract void search(); + + protected abstract void volver(); + + protected abstract void loadDireccionesTable(); + + private void loadDireccionesTable(List direccions) { + BaseTableModel model = this.view.getDireccionModel(); + model.setRows(direccions); + } + + private Direccion getSelectedDireccion() { + int selectedRow = this.view.getDireccionesTable().getSelectedRow(); + if (selectedRow == -1) { + JOptionPane.showMessageDialog( + null, + "No hay abstract_direccion seleccionada", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return null; + } + + return this.view.getDireccionModel().getRow(selectedRow); + } +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionUpdateController.java b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionUpdateController.java new file mode 100644 index 0000000..3951333 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionUpdateController.java @@ -0,0 +1,88 @@ +package xyz.danielcortes.controllers.abstract_direccion; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.ValidationResult; +import xyz.danielcortes.models.Direccion; +import xyz.danielcortes.repository.DireccionRepository; +import xyz.danielcortes.validator.DireccionValidator; +import xyz.danielcortes.views.direccion.DireccionUpdatePanel; + +public abstract class AbstractDireccionUpdateController extends BaseController { + + private Direccion direccion; + private DireccionUpdatePanel view; + private DireccionRepository repository; + private DireccionValidator validator; + + public AbstractDireccionUpdateController(DireccionUpdatePanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.repository = new DireccionRepository(); + this.validator = new DireccionValidator(this.repository); + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.view.getCalleField().requestFocus(); + this.fillDireccion(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void setDireccion(Direccion direccion) { + this.direccion = direccion; + } + + protected void fillDireccion() { + this.view.getCalleField().setText(this.direccion.getCalle()); + this.view.getNumeroField().setText(this.direccion.getNumero()); + } + + private void setupListeners() { + this.view.getNumeroField().addActionListener(e -> this.update()); + this.view.getActualizarButton().addActionListener(e -> this.update()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + private void update() { + String calle = this.view.getCalleField().getText(); + String numero = this.view.getNumeroField().getText(); + + ValidationResult originalValidation = this.validator.validateOriginal(this.direccion); + if (originalValidation.hasError()) { + originalValidation.showErrorDialog(); + return; + } + + ValidationResult direccionValidation = this.validator.validateCalle(calle); + if (direccionValidation.hasError()) { + direccionValidation.showErrorDialog(); + return; + } + + ValidationResult numeroValidation = this.validator.validateNumero(numero); + if (numeroValidation.hasError()) { + numeroValidation.showErrorDialog(); + return; + } + + this.direccion.setCalle(calle); + this.direccion.setNumero(numero); + this.repository.update(this.direccion); + + this.volver(); + } + + protected abstract void volver(); +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionViewController.java b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionViewController.java new file mode 100644 index 0000000..3b7f17b --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_direccion/AbstractDireccionViewController.java @@ -0,0 +1,49 @@ +package xyz.danielcortes.controllers.abstract_direccion; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.models.Direccion; +import xyz.danielcortes.views.direccion.DireccionViewPanel; + +public abstract class AbstractDireccionViewController extends BaseController { + + private Direccion direccion; + private DireccionViewPanel view; + + public AbstractDireccionViewController(DireccionViewPanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.fillDireccion(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void setDireccion(Direccion direccion) { + this.direccion = direccion; + } + + public void fillDireccion() { + this.view.getCalleField().setText(this.direccion.getCalle()); + this.view.getNumeroField().setText(this.direccion.getNumero()); + } + + private void setupListeners() { + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void volver(); +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoCreateController.java b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoCreateController.java new file mode 100644 index 0000000..807394e --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoCreateController.java @@ -0,0 +1,50 @@ +package xyz.danielcortes.controllers.abstract_telefono; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.repository.TelefonoRepository; +import xyz.danielcortes.validator.TelefonoValidator; +import xyz.danielcortes.views.telefono.TelefonoCreatePanel; + +public abstract class AbstractTelefonoCreateController extends BaseController { + + private TelefonoCreatePanel view; + private TelefonoRepository repository; + private TelefonoValidator validator; + + public AbstractTelefonoCreateController(TelefonoCreatePanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.repository = new TelefonoRepository(); + this.validator = new TelefonoValidator(this.repository); + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.view.getNumeroField().requestFocus(); + this.view.getNumeroField().setText(""); + } + + @Override + public BasePanel getView() { + return this.view; + } + + private void setupListeners() { + this.view.getNumeroField().addActionListener(e -> this.save()); + this.view.getGuardarButton().addActionListener(e -> this.save()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void save(); + + protected abstract void volver(); + +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoSearchController.java b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoSearchController.java new file mode 100644 index 0000000..0a005c5 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoSearchController.java @@ -0,0 +1,86 @@ +package xyz.danielcortes.controllers.abstract_telefono; + +import java.util.List; +import javax.swing.JOptionPane; +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.BaseTableModel; +import xyz.danielcortes.models.Telefono; +import xyz.danielcortes.repository.TelefonoRepository; +import xyz.danielcortes.validator.TelefonoValidator; +import xyz.danielcortes.views.telefono.TelefonoSearchPanel; + +public abstract class AbstractTelefonoSearchController extends BaseController { + + private TelefonoSearchPanel view; + private TelefonoRepository telefonoRepository; + private TelefonoValidator validator; + + public AbstractTelefonoSearchController(TelefonoSearchPanel view, LaunchController parent) { + super(parent); + this.view = view; + this.telefonoRepository = new TelefonoRepository(); + this.validator = new TelefonoValidator(this.telefonoRepository); + this.setupListeners(); + } + + @Override + public void show() { + this.reload(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void reload() { + this.loadTelefonosTable(); + this.view.getTelefonosTable().clearSelection(); + } + + private void setupListeners() { + this.view.getCrearButton().addActionListener(e -> this.create()); + this.view.getSearchField().addActionListener(e -> this.search()); + this.view.getBuscarButton().addActionListener(e -> this.search()); + this.view.getVerButton().addActionListener(e -> this.view()); + this.view.getEditarButton().addActionListener(e -> this.edit()); + this.view.getEliminarButton().addActionListener(e -> this.delete()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void create(); + + protected abstract void edit(); + + protected abstract void delete(); + + protected abstract void view(); + + protected abstract void search(); + + protected abstract void volver(); + + protected abstract void loadTelefonosTable(); + + private void loadTelefonosTable(List telefonos) { + BaseTableModel model = this.view.getTelefonoModel(); + model.setRows(telefonos); + } + + private Telefono getSelectedTelefono() { + int selectedRow = this.view.getTelefonosTable().getSelectedRow(); + if (selectedRow == -1) { + JOptionPane.showMessageDialog( + null, + "No hay abstract_telefono seleccionado", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return null; + } + + return this.view.getTelefonoModel().getRow(selectedRow); + } +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoUpdateController.java b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoUpdateController.java new file mode 100644 index 0000000..8bd1b59 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoUpdateController.java @@ -0,0 +1,78 @@ +package xyz.danielcortes.controllers.abstract_telefono; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.ValidationResult; +import xyz.danielcortes.models.Telefono; +import xyz.danielcortes.repository.TelefonoRepository; +import xyz.danielcortes.validator.TelefonoValidator; +import xyz.danielcortes.views.telefono.TelefonoUpdatePanel; + +public abstract class AbstractTelefonoUpdateController extends BaseController { + + private Telefono telefono; + private TelefonoUpdatePanel view; + private TelefonoRepository repository; + private TelefonoValidator validator; + + public AbstractTelefonoUpdateController(TelefonoUpdatePanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.repository = new TelefonoRepository(); + this.validator = new TelefonoValidator(this.repository); + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.view.getTelefonoField().requestFocus(); + this.fillTelefono(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void setTelefono(Telefono telefono) { + this.telefono = telefono; + } + + public void fillTelefono() { + this.view.getTelefonoField().setText(this.telefono.getNumero()); + } + + private void setupListeners() { + this.view.getTelefonoField().addActionListener(e -> this.update()); + this.view.getActualizarButton().addActionListener(e -> this.update()); + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + private void update() { + String telefono = this.view.getTelefonoField().getText(); + + ValidationResult originalValidation = this.validator.validateOriginal(this.telefono); + if (originalValidation.hasError()) { + originalValidation.showErrorDialog(); + return; + } + ValidationResult telefonoValidation = this.validator.validateTelefono(telefono); + if (telefonoValidation.hasError()) { + telefonoValidation.showErrorDialog(); + return; + } + + this.telefono.setNumero(telefono); + this.repository.update(this.telefono); + + this.volver(); + } + + protected abstract void volver(); +} diff --git a/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoViewController.java b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoViewController.java new file mode 100644 index 0000000..502c973 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/abstract_telefono/AbstractTelefonoViewController.java @@ -0,0 +1,49 @@ +package xyz.danielcortes.controllers.abstract_telefono; + +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.models.Telefono; +import xyz.danielcortes.views.telefono.TelefonoViewPanel; + +public abstract class AbstractTelefonoViewController extends BaseController { + + private Telefono telefono; + private TelefonoViewPanel view; + + public AbstractTelefonoViewController(TelefonoViewPanel view, LaunchController parentController) { + super(parentController); + this.view = view; + this.setupListeners(); + } + + @Override + public LaunchController getParentController() { + return this.parentController; + } + + @Override + public void show() { + this.fillTelefono(); + } + + @Override + public BasePanel getView() { + return this.view; + } + + public void setTelefono(Telefono telefono) { + this.telefono = telefono; + } + + public void fillTelefono() { + this.view.getTelefonoField().setText(this.telefono.getNumero()); + } + + private void setupListeners() { + this.view.getVolverButton().addActionListener(e -> this.volver()); + } + + protected abstract void volver(); + +} diff --git a/src/main/java/xyz/danielcortes/controllers/cliente/ClienteViewController.java b/src/main/java/xyz/danielcortes/controllers/cliente/ClienteViewController.java index a574a7c..374279a 100644 --- a/src/main/java/xyz/danielcortes/controllers/cliente/ClienteViewController.java +++ b/src/main/java/xyz/danielcortes/controllers/cliente/ClienteViewController.java @@ -37,13 +37,13 @@ public class ClienteViewController extends BaseController { } // private void gotoDireccionView() { -// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH); +// AbstractDireccionSearchController controller = (AbstractDireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH); // controller.setCliente(cliente); // this.getParentController().showCard(PanelName.DIRECCION_SEARCH); // } // // private void gotoTelefonoView() { -// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH); +// AbstractTelefonoSearchController controller = (AbstractTelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH); // controller.setCliente(cliente); // this.getParentController().showCard(PanelName.TELEFONO_SEARCH); // } diff --git a/src/main/java/xyz/danielcortes/controllers/distribuidor/DistribuidorViewController.java b/src/main/java/xyz/danielcortes/controllers/distribuidor/DistribuidorViewController.java index f0a2727..db1ea04 100644 --- a/src/main/java/xyz/danielcortes/controllers/distribuidor/DistribuidorViewController.java +++ b/src/main/java/xyz/danielcortes/controllers/distribuidor/DistribuidorViewController.java @@ -36,13 +36,13 @@ public class DistribuidorViewController extends BaseController { } // private void gotoDireccionView() { -// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH); +// AbstractDireccionSearchController controller = (AbstractDireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH); // controller.setCliente(distribuidor); // this.getParentController().showCard(PanelName.DIRECCION_SEARCH); // } // // private void gotoTelefonoView() { -// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH); +// AbstractTelefonoSearchController controller = (AbstractTelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH); // controller.setCliente(distribuidor); // this.getParentController().showCard(PanelName.TELEFONO_SEARCH); // } diff --git a/src/main/java/xyz/danielcortes/controllers/trabajador/direccion/DireccionSearchController.java b/src/main/java/xyz/danielcortes/controllers/trabajador/direccion/DireccionSearchController.java index 136054c..cb9e89e 100644 --- a/src/main/java/xyz/danielcortes/controllers/trabajador/direccion/DireccionSearchController.java +++ b/src/main/java/xyz/danielcortes/controllers/trabajador/direccion/DireccionSearchController.java @@ -81,7 +81,7 @@ public class DireccionSearchController extends BaseController { int option = JOptionPane.showConfirmDialog( null, - "¿Estas seguro de que deseas eliminar la direccion?", + "¿Estas seguro de que deseas eliminar la abstract_direccion?", "Confirmacion", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE @@ -131,7 +131,7 @@ public class DireccionSearchController extends BaseController { if (selectedRow == -1) { JOptionPane.showMessageDialog( null, - "No hay direccion seleccionada", + "No hay abstract_direccion seleccionada", "Error", JOptionPane.ERROR_MESSAGE ); diff --git a/src/main/java/xyz/danielcortes/controllers/trabajador/telefono/TelefonoSearchController.java b/src/main/java/xyz/danielcortes/controllers/trabajador/telefono/TelefonoSearchController.java index 612426f..adfdc72 100644 --- a/src/main/java/xyz/danielcortes/controllers/trabajador/telefono/TelefonoSearchController.java +++ b/src/main/java/xyz/danielcortes/controllers/trabajador/telefono/TelefonoSearchController.java @@ -81,7 +81,7 @@ public class TelefonoSearchController extends BaseController { int option = JOptionPane.showConfirmDialog( null, - "¿Estas seguro de que deseas eliminar el telefono?", + "¿Estas seguro de que deseas eliminar el abstract_telefono?", "Confirmacion", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE @@ -131,7 +131,7 @@ public class TelefonoSearchController extends BaseController { if (selectedRow == -1) { JOptionPane.showMessageDialog( null, - "No hay telefono seleccionado", + "No hay abstract_telefono seleccionado", "Error", JOptionPane.ERROR_MESSAGE ); diff --git a/src/main/java/xyz/danielcortes/validator/DireccionValidator.java b/src/main/java/xyz/danielcortes/validator/DireccionValidator.java index c8aa7cf..b6586e8 100644 --- a/src/main/java/xyz/danielcortes/validator/DireccionValidator.java +++ b/src/main/java/xyz/danielcortes/validator/DireccionValidator.java @@ -5,14 +5,15 @@ import xyz.danielcortes.models.Direccion; import xyz.danielcortes.repository.DireccionRepository; public class DireccionValidator { + private DireccionRepository direccionRepository; - public DireccionValidator(DireccionRepository direccionRepository) { + public DireccionValidator(DireccionRepository direccionRepository) { this.direccionRepository = direccionRepository; } public ValidationResult validateCalle(String calle) { - if(calle == null) { + if (calle == null) { return new ValidationResult("La calle es nula"); } else if (calle.isEmpty()) { return new ValidationResult("La calle esta vacia"); @@ -21,7 +22,7 @@ public class DireccionValidator { } public ValidationResult validateNumero(String numero) { - if(numero == null) { + if (numero == null) { return new ValidationResult("La calle es nula"); } else if (numero.isEmpty()) { return new ValidationResult("La calle esta vacia"); @@ -30,8 +31,8 @@ public class DireccionValidator { } public ValidationResult validateOriginal(Direccion original) { - if(original == null) { - return new ValidationResult("El direccion seleccionada no existe"); + if (original == null) { + return new ValidationResult("El abstract_direccion seleccionada no existe"); } return ValidationResult.NON_ERROR; } diff --git a/src/main/java/xyz/danielcortes/validator/TelefonoValidator.java b/src/main/java/xyz/danielcortes/validator/TelefonoValidator.java index 81223b8..606d160 100644 --- a/src/main/java/xyz/danielcortes/validator/TelefonoValidator.java +++ b/src/main/java/xyz/danielcortes/validator/TelefonoValidator.java @@ -5,24 +5,25 @@ import xyz.danielcortes.models.Telefono; import xyz.danielcortes.repository.TelefonoRepository; public class TelefonoValidator { + private TelefonoRepository telefonoRepository; - public TelefonoValidator(TelefonoRepository telefonoRepository) { + public TelefonoValidator(TelefonoRepository telefonoRepository) { this.telefonoRepository = telefonoRepository; } public ValidationResult validateTelefono(String telefono) { - if(telefono == null) { - return new ValidationResult("El telefono es nulo"); + if (telefono == null) { + return new ValidationResult("El abstract_telefono es nulo"); } else if (telefono.isEmpty()) { - return new ValidationResult("El telefono esta vacio"); + return new ValidationResult("El abstract_telefono esta vacio"); } return ValidationResult.NON_ERROR; } public ValidationResult validateOriginal(Telefono original) { - if(original == null) { - return new ValidationResult("El telefono seleccionado no existe"); + if (original == null) { + return new ValidationResult("El abstract_telefono seleccionado no existe"); } return ValidationResult.NON_ERROR; }