Ejecute el reformateo global del codigo en intellij

This commit is contained in:
Daniel Cortés
2019-06-19 00:54:33 -04:00
parent aa8a4734f2
commit 4ffad28c0c
71 changed files with 1006 additions and 1001 deletions

View File

@@ -21,6 +21,16 @@ public abstract class AbstractCorreoCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
private void setupListeners() {
this.view.getCorreoField().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();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -36,14 +46,4 @@ public abstract class AbstractCorreoCreateController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
private void setupListeners() {
this.view.getCorreoField().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();
} }

View File

@@ -25,6 +25,28 @@ public abstract class AbstractCorreoSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
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 search();
protected abstract void view();
protected abstract void edit();
protected abstract void delete();
protected abstract void volver();
@Override @Override
public void show() { public void show() {
this.reload(); this.reload();
@@ -40,28 +62,6 @@ public abstract class AbstractCorreoSearchController extends BaseController {
this.view.getCorreosTable().clearSelection(); this.view.getCorreosTable().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 loadCorreosTable(); protected abstract void loadCorreosTable();
protected void loadCorreosTable(List<Correo> correos) { protected void loadCorreosTable(List<Correo> correos) {

View File

@@ -24,30 +24,6 @@ public abstract class AbstractCorreoUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public LaunchController getParentController() {
return this.parentController;
}
@Override
public void show() {
this.view.getCorreoField().requestFocus();
this.fillCorreo();
}
@Override
public BasePanel getView() {
return this.view;
}
public void setCorreo(Correo correo) {
this.correo = correo;
}
protected void fillCorreo() {
this.view.getCorreoField().setText(this.correo.getCorreo());
}
private void setupListeners() { private void setupListeners() {
this.view.getCorreoField().addActionListener(e -> this.update()); this.view.getCorreoField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -75,4 +51,28 @@ public abstract class AbstractCorreoUpdateController extends BaseController {
} }
protected abstract void volver(); protected abstract void volver();
@Override
public LaunchController getParentController() {
return this.parentController;
}
@Override
public void show() {
this.view.getCorreoField().requestFocus();
this.fillCorreo();
}
@Override
public BasePanel getView() {
return this.view;
}
protected void fillCorreo() {
this.view.getCorreoField().setText(this.correo.getCorreo());
}
public void setCorreo(Correo correo) {
this.correo = correo;
}
} }

View File

@@ -17,6 +17,12 @@ public abstract class AbstractCorreoViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.volver());
}
protected abstract void volver();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -32,18 +38,12 @@ public abstract class AbstractCorreoViewController extends BaseController {
return this.view; return this.view;
} }
public void setCorreo(Correo correo) {
this.correo = correo;
}
protected void fillCorreo() { protected void fillCorreo() {
this.view.getCorreoField().setText(this.correo.getCorreo()); this.view.getCorreoField().setText(this.correo.getCorreo());
} }
private void setupListeners() { public void setCorreo(Correo correo) {
this.view.getVolverButton().addActionListener(e -> this.volver()); this.correo = correo;
} }
protected abstract void volver();
} }

View File

@@ -21,6 +21,16 @@ public abstract class AbstractDireccionCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
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();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -37,14 +47,4 @@ public abstract class AbstractDireccionCreateController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; 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();
} }

View File

@@ -25,6 +25,28 @@ public abstract class AbstractDireccionSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
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 search();
protected abstract void view();
protected abstract void edit();
protected abstract void delete();
protected abstract void volver();
@Override @Override
public void show() { public void show() {
this.reload(); this.reload();
@@ -40,28 +62,6 @@ public abstract class AbstractDireccionSearchController extends BaseController {
this.view.getDireccionesTable().clearSelection(); 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(); protected abstract void loadDireccionesTable();
protected void loadDireccionesTable(List<Direccion> direccions) { protected void loadDireccionesTable(List<Direccion> direccions) {

View File

@@ -24,31 +24,6 @@ public abstract class AbstractDireccionUpdateController extends BaseController {
this.setupListeners(); 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());
}
protected void setupListeners() { protected void setupListeners() {
this.view.getNumeroField().addActionListener(e -> this.update()); this.view.getNumeroField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -85,4 +60,29 @@ public abstract class AbstractDireccionUpdateController extends BaseController {
} }
protected abstract void volver(); protected abstract void volver();
@Override
public LaunchController getParentController() {
return this.parentController;
}
@Override
public void show() {
this.view.getCalleField().requestFocus();
this.fillDireccion();
}
@Override
public BasePanel getView() {
return this.view;
}
protected void fillDireccion() {
this.view.getCalleField().setText(this.direccion.getCalle());
this.view.getNumeroField().setText(this.direccion.getNumero());
}
public void setDireccion(Direccion direccion) {
this.direccion = direccion;
}
} }

View File

@@ -17,6 +17,12 @@ public abstract class AbstractDireccionViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.volver());
}
protected abstract void volver();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -32,18 +38,12 @@ public abstract class AbstractDireccionViewController extends BaseController {
return this.view; return this.view;
} }
public void setDireccion(Direccion direccion) {
this.direccion = direccion;
}
public void fillDireccion() { public void fillDireccion() {
this.view.getCalleField().setText(this.direccion.getCalle()); this.view.getCalleField().setText(this.direccion.getCalle());
this.view.getNumeroField().setText(this.direccion.getNumero()); this.view.getNumeroField().setText(this.direccion.getNumero());
} }
private void setupListeners() { public void setDireccion(Direccion direccion) {
this.view.getVolverButton().addActionListener(e -> this.volver()); this.direccion = direccion;
} }
protected abstract void volver();
} }

View File

@@ -21,6 +21,16 @@ public abstract class AbstractTelefonoCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
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();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -37,14 +47,4 @@ public abstract class AbstractTelefonoCreateController extends BaseController {
return this.view; 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();
} }

View File

@@ -25,6 +25,28 @@ public abstract class AbstractTelefonoSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
protected 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 search();
protected abstract void view();
protected abstract void edit();
protected abstract void delete();
protected abstract void volver();
@Override @Override
public void show() { public void show() {
this.reload(); this.reload();
@@ -40,28 +62,6 @@ public abstract class AbstractTelefonoSearchController extends BaseController {
this.view.getTelefonosTable().clearSelection(); this.view.getTelefonosTable().clearSelection();
} }
protected 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(); protected abstract void loadTelefonosTable();
protected void loadTelefonosTable(List<Telefono> telefonos) { protected void loadTelefonosTable(List<Telefono> telefonos) {

View File

@@ -17,6 +17,12 @@ public abstract class AbstractTelefonoViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
protected void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.volver());
}
protected abstract void volver();
@Override @Override
public LaunchController getParentController() { public LaunchController getParentController() {
return this.parentController; return this.parentController;
@@ -32,18 +38,12 @@ public abstract class AbstractTelefonoViewController extends BaseController {
return this.view; return this.view;
} }
public void setTelefono(Telefono telefono) {
this.telefono = telefono;
}
protected void fillTelefono() { protected void fillTelefono() {
this.view.getTelefonoField().setText(this.telefono.getNumero()); this.view.getTelefonoField().setText(this.telefono.getNumero());
} }
protected void setupListeners() { public void setTelefono(Telefono telefono) {
this.view.getVolverButton().addActionListener(e -> this.volver()); this.telefono = telefono;
} }
protected abstract void volver();
} }

View File

@@ -24,11 +24,6 @@ public class AutorCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getApellidoMaternoField().addActionListener(e -> this.save()); this.view.getApellidoMaternoField().addActionListener(e -> this.save());
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
@@ -69,6 +64,11 @@ public class AutorCreateController extends BaseController {
this.view.getNombreField().requestFocus(); this.view.getNombreField().requestFocus();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -27,16 +27,6 @@ public class AutorSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.reload();
this.view.getAutorTable().clearSelection();
}
public void reload() {
this.loadAutorTable();
}
private void setupListeners() { private void setupListeners() {
this.view.getCrearButton().addActionListener(e -> this.getParentController().showCard(PanelName.AUTOR_CREATE)); this.view.getCrearButton().addActionListener(e -> this.getParentController().showCard(PanelName.AUTOR_CREATE));
this.view.getSearchField().addActionListener(e -> this.search()); this.view.getSearchField().addActionListener(e -> this.search());
@@ -46,6 +36,21 @@ public class AutorSearchController extends BaseController {
this.view.getEliminarButton().addActionListener(e -> this.delete()); this.view.getEliminarButton().addActionListener(e -> this.delete());
} }
private void search() {
String term = this.view.getSearchField().getText();
List<Autor> autores = this.autorRepository.search(term);
this.loadAutorTable(autores);
}
private void view() {
Autor autor = this.getSelectedAutor();
if (autor != null) {
AutorViewController controller = (AutorViewController) this.getParentController().getCard(PanelName.AUTOR_VIEW);
controller.setAutor(autor);
this.getParentController().showCard(PanelName.AUTOR_VIEW);
}
}
private void edit() { private void edit() {
Autor autor = this.getSelectedAutor(); Autor autor = this.getSelectedAutor();
if (autor != null) { if (autor != null) {
@@ -80,26 +85,6 @@ public class AutorSearchController extends BaseController {
this.reload(); this.reload();
} }
private void view() {
Autor autor = this.getSelectedAutor();
if (autor != null) {
AutorViewController controller = (AutorViewController) this.getParentController().getCard(PanelName.AUTOR_VIEW);
controller.setAutor(autor);
this.getParentController().showCard(PanelName.AUTOR_VIEW);
}
}
private void search() {
String term = this.view.getSearchField().getText();
List<Autor> autores = this.autorRepository.search(term);
this.loadAutorTable(autores);
}
private void loadAutorTable() {
List<Autor> autores = this.autorRepository.getAll();
this.loadAutorTable(autores);
}
private void loadAutorTable(List<Autor> autores) { private void loadAutorTable(List<Autor> autores) {
BaseTableModel<Autor> model = this.view.getAutorModel(); BaseTableModel<Autor> model = this.view.getAutorModel();
model.setRows(autores); model.setRows(autores);
@@ -120,6 +105,21 @@ public class AutorSearchController extends BaseController {
return this.view.getAutorModel().getRow(selectedRow); return this.view.getAutorModel().getRow(selectedRow);
} }
public void reload() {
this.loadAutorTable();
}
private void loadAutorTable() {
List<Autor> autores = this.autorRepository.getAll();
this.loadAutorTable(autores);
}
@Override
public void show() {
this.reload();
this.view.getAutorTable().clearSelection();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -25,25 +25,6 @@ public class AutorUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
public void setAutor(Autor autor) {
this.autor = autor;
}
@Override
public void show() {
this.fillAutor();
this.view.getNombreField().requestFocus();
}
private void fillAutor() {
if (this.autor == null)
return;
this.view.getNombreField().setText(this.autor.getNombre());
this.view.getApellidoPaternoField().setText(this.autor.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.autor.getApellidoMaterno());
}
private void setupListeners() { private void setupListeners() {
this.view.getApellidoPaternoField().addActionListener(e -> this.update()); this.view.getApellidoPaternoField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -88,6 +69,25 @@ public class AutorUpdateController extends BaseController {
this.getParentController().showCard(PanelName.AUTOR_SEARCH); this.getParentController().showCard(PanelName.AUTOR_SEARCH);
} }
public void setAutor(Autor autor) {
this.autor = autor;
}
@Override
public void show() {
this.fillAutor();
this.view.getNombreField().requestFocus();
}
private void fillAutor() {
if (this.autor == null)
return;
this.view.getNombreField().setText(this.autor.getNombre());
this.view.getApellidoPaternoField().setText(this.autor.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.autor.getApellidoMaterno());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -18,21 +18,17 @@ public class AutorViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillAutor();
}
public void setAutor(Autor autor) {
this.autor = autor;
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> { this.view.getVolverButton().addActionListener(e -> {
this.getParentController().showCard(PanelName.AUTOR_SEARCH); this.getParentController().showCard(PanelName.AUTOR_SEARCH);
}); });
} }
@Override
public void show() {
this.fillAutor();
}
private void fillAutor() { private void fillAutor() {
if (this.autor == null) if (this.autor == null)
return; return;
@@ -46,4 +42,8 @@ public class AutorViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setAutor(Autor autor) {
this.autor = autor;
}
} }

View File

@@ -25,11 +25,6 @@ public class CategoriaCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.save()); this.view.getNombreField().addActionListener(e -> this.save());
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
@@ -53,6 +48,11 @@ public class CategoriaCreateController extends BaseController {
this.view.getNombreField().requestFocus(); this.view.getNombreField().requestFocus();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -29,10 +29,9 @@ public class CategoriaSearchController extends BaseController {
} }
@Override private void loadCategoriaTable() {
public void show() { List<Categoria> categorias = this.categoriaRepository.getAll();
this.reload(); this.loadCategoriaTable(categorias);
this.view.getCategoriaTable().clearSelection();
} }
private void setupListeners() { private void setupListeners() {
@@ -44,6 +43,26 @@ public class CategoriaSearchController extends BaseController {
this.view.getEliminarButton().addActionListener(e -> this.delete()); this.view.getEliminarButton().addActionListener(e -> this.delete());
} }
private void loadCategoriaTable(List<Categoria> categorias) {
BaseTableModel<Categoria> model = this.view.getCategoriaModel();
model.setRows(categorias);
}
private void search() {
String term = this.view.getSearchField().getText();
List<Categoria> categorias = this.categoriaRepository.search(term);
this.loadCategoriaTable(categorias);
}
private void view() {
Categoria categoria = this.getSelectedCategoria();
if (categoria != null) {
CategoriaViewController controller = (CategoriaViewController) this.getParentController().getCard(PanelName.CATEGORIA_VIEW);
controller.setCategoria(categoria);
this.getParentController().showCard(PanelName.CATEGORIA_VIEW);
}
}
private void edit() { private void edit() {
Categoria categoria = this.getSelectedCategoria(); Categoria categoria = this.getSelectedCategoria();
if (categoria != null) { if (categoria != null) {
@@ -78,35 +97,6 @@ public class CategoriaSearchController extends BaseController {
this.reload(); this.reload();
} }
private void view() {
Categoria categoria = this.getSelectedCategoria();
if (categoria != null) {
CategoriaViewController controller = (CategoriaViewController) this.getParentController().getCard(PanelName.CATEGORIA_VIEW);
controller.setCategoria(categoria);
this.getParentController().showCard(PanelName.CATEGORIA_VIEW);
}
}
private void search() {
String term = this.view.getSearchField().getText();
List<Categoria> categorias = this.categoriaRepository.search(term);
this.loadCategoriaTable(categorias);
}
public void reload() {
this.loadCategoriaTable();
}
private void loadCategoriaTable() {
List<Categoria> categorias = this.categoriaRepository.getAll();
this.loadCategoriaTable(categorias);
}
private void loadCategoriaTable(List<Categoria> categorias) {
BaseTableModel<Categoria> model = this.view.getCategoriaModel();
model.setRows(categorias);
}
private Categoria getSelectedCategoria() { private Categoria getSelectedCategoria() {
int selectedRow = this.view.getCategoriaTable().getSelectedRow(); int selectedRow = this.view.getCategoriaTable().getSelectedRow();
if (selectedRow == -1) { if (selectedRow == -1) {
@@ -122,6 +112,16 @@ public class CategoriaSearchController extends BaseController {
return this.view.getCategoriaModel().getRow(selectedRow); return this.view.getCategoriaModel().getRow(selectedRow);
} }
public void reload() {
this.loadCategoriaTable();
}
@Override
public void show() {
this.reload();
this.view.getCategoriaTable().clearSelection();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -25,17 +25,6 @@ public class CategoriaUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillCategoria();
this.view.getNombreField().requestFocus();
}
private void fillCategoria() {
if (this.categoria != null)
this.view.getNombreField().setText(this.categoria.getNombre());
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.update()); this.view.getNombreField().addActionListener(e -> this.update());
this.view.getUpdateButton().addActionListener(e -> this.update()); this.view.getUpdateButton().addActionListener(e -> this.update());
@@ -63,6 +52,17 @@ public class CategoriaUpdateController extends BaseController {
this.getParentController().showCard(PanelName.CATEGORIA_SEARCH); this.getParentController().showCard(PanelName.CATEGORIA_SEARCH);
} }
@Override
public void show() {
this.fillCategoria();
this.view.getNombreField().requestFocus();
}
private void fillCategoria() {
if (this.categoria != null)
this.view.getNombreField().setText(this.categoria.getNombre());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -18,12 +18,17 @@ public class CategoriaViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CATEGORIA_SEARCH));
}
public void setCategoria(Categoria categoria) { public void setCategoria(Categoria categoria) {
this.categoria = categoria; this.categoria = categoria;
} }
private void setupListeners() { @Override
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CATEGORIA_SEARCH)); public void show() {
this.fillCategoria();
} }
private void fillCategoria() { private void fillCategoria() {
@@ -31,11 +36,6 @@ public class CategoriaViewController extends BaseController {
this.view.getNombreField().setText(this.categoria.getNombre()); this.view.getNombreField().setText(this.categoria.getNombre());
} }
@Override
public void show() {
this.fillCategoria();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -25,11 +25,6 @@ public class ClienteCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getRutField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH));
@@ -83,6 +78,11 @@ public class ClienteCreateController extends BaseController {
this.getParentController().showCard(PanelName.CLIENTE_SEARCH); this.getParentController().showCard(PanelName.CLIENTE_SEARCH);
} }
@Override
public void show() {
this.view.getRutField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -26,27 +26,6 @@ public class ClienteUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
@Override
public void show() {
this.fillCliente();
this.view.getRutField().requestFocus();
}
private void fillCliente() {
if (this.clienteRespository == null)
return;
this.view.getRutField().setText(this.cliente.getRut());
this.view.getNombreField().setText(this.cliente.getNombre());
this.view.getApellidoPaternoField().setText(this.cliente.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.cliente.getApellidoMaterno());
this.view.getFechaNacimientoField().setDate(this.cliente.getFechaNacimiento());
}
private void setupListeners() { private void setupListeners() {
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH));
@@ -99,6 +78,27 @@ public class ClienteUpdateController extends BaseController {
this.getParentController().showCard(PanelName.CLIENTE_SEARCH); this.getParentController().showCard(PanelName.CLIENTE_SEARCH);
} }
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
@Override
public void show() {
this.fillCliente();
this.view.getRutField().requestFocus();
}
private void fillCliente() {
if (this.clienteRespository == null)
return;
this.view.getRutField().setText(this.cliente.getRut());
this.view.getNombreField().setText(this.cliente.getNombre());
this.view.getApellidoPaternoField().setText(this.cliente.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.cliente.getApellidoMaterno());
this.view.getFechaNacimientoField().setDate(this.cliente.getFechaNacimiento());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -30,6 +30,25 @@ public class ClienteCorreoSearchController extends AbstractCorreoSearchControlle
this.getParentController().showCard(PanelName.CLIENTE_CORREO_CREATE); this.getParentController().showCard(PanelName.CLIENTE_CORREO_CREATE);
} }
@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 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 @Override
protected void edit() { protected void edit() {
Correo correo = this.getSelectedCorreo(); Correo correo = this.getSelectedCorreo();
@@ -63,25 +82,6 @@ public class ClienteCorreoSearchController extends AbstractCorreoSearchControlle
this.reload(); 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 @Override
protected void volver() { protected void volver() {
ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW); ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW);

View File

@@ -30,6 +30,25 @@ public class ClienteDireccionSearchController extends AbstractDireccionSearchCon
this.getParentController().showCard(PanelName.CLIENTE_DIRECCION_CREATE); this.getParentController().showCard(PanelName.CLIENTE_DIRECCION_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.cliente);
this.loadDireccionesTable(direccion);
}
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
ClienteDireccionViewController controller = (ClienteDireccionViewController) this.getParentController()
.getCard(PanelName.CLIENTE_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setCliente(this.cliente);
this.getParentController().showCard(PanelName.CLIENTE_DIRECCION_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Direccion direccion = this.getSelectedDireccion(); Direccion direccion = this.getSelectedDireccion();
@@ -63,25 +82,6 @@ public class ClienteDireccionSearchController extends AbstractDireccionSearchCon
this.reload(); this.reload();
} }
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
ClienteDireccionViewController controller = (ClienteDireccionViewController) this.getParentController()
.getCard(PanelName.CLIENTE_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setCliente(this.cliente);
this.getParentController().showCard(PanelName.CLIENTE_DIRECCION_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.cliente);
this.loadDireccionesTable(direccion);
}
@Override @Override
protected void volver() { protected void volver() {
ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW); ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW);

View File

@@ -19,16 +19,6 @@ public class ClienteTelefonoSearchController extends AbstractTelefonoSearchContr
super(view, parent); super(view, parent);
} }
@Override
public void show() {
this.reload();
}
@Override
public BasePanel getView() {
return this.view;
}
@Override @Override
protected void create() { protected void create() {
ClienteTelefonoCreateController controller = (ClienteTelefonoCreateController) this.getParentController() ClienteTelefonoCreateController controller = (ClienteTelefonoCreateController) this.getParentController()
@@ -37,6 +27,25 @@ public class ClienteTelefonoSearchController extends AbstractTelefonoSearchContr
this.getParentController().showCard(PanelName.CLIENTE_TELEFONO_CREATE); this.getParentController().showCard(PanelName.CLIENTE_TELEFONO_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.cliente);
this.loadTelefonosTable(telefono);
}
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
ClienteTelefonoViewController controller = (ClienteTelefonoViewController) this.getParentController()
.getCard(PanelName.CLIENTE_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setCliente(this.cliente);
this.getParentController().showCard(PanelName.CLIENTE_TELEFONO_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Telefono telefono = this.getSelectedTelefono(); Telefono telefono = this.getSelectedTelefono();
@@ -70,25 +79,6 @@ public class ClienteTelefonoSearchController extends AbstractTelefonoSearchContr
this.reload(); this.reload();
} }
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
ClienteTelefonoViewController controller = (ClienteTelefonoViewController) this.getParentController()
.getCard(PanelName.CLIENTE_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setCliente(this.cliente);
this.getParentController().showCard(PanelName.CLIENTE_TELEFONO_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.cliente);
this.loadTelefonosTable(telefono);
}
@Override @Override
protected void volver() { protected void volver() {
ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW); ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW);
@@ -96,6 +86,16 @@ public class ClienteTelefonoSearchController extends AbstractTelefonoSearchContr
this.getParentController().showCard(PanelName.CLIENTE_VIEW); this.getParentController().showCard(PanelName.CLIENTE_VIEW);
} }
@Override
public void show() {
this.reload();
}
@Override
public BasePanel getView() {
return this.view;
}
@Override @Override
protected void loadTelefonosTable() { protected void loadTelefonosTable() {
List<Telefono> telefonos = this.cliente.getTelefonos(); List<Telefono> telefonos = this.cliente.getTelefonos();

View File

@@ -28,22 +28,11 @@ public class DistribuidorCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillEmpresasCombobox();
this.view.getRutField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH));
} }
private void fillEmpresasCombobox() {
this.view.getEmpresaModel().removeAllElements();
this.view.getEmpresaModel().addAll(this.empresaRepository.getAll());
}
private void save() { private void save() {
String rut = this.view.getRutField().getText(); String rut = this.view.getRutField().getText();
ValidationResult rutValidation = this.validator.validateRut(rut); ValidationResult rutValidation = this.validator.validateRut(rut);
@@ -68,6 +57,17 @@ public class DistribuidorCreateController extends BaseController {
this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH); this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH);
} }
@Override
public void show() {
this.fillEmpresasCombobox();
this.view.getRutField().requestFocus();
}
private void fillEmpresasCombobox() {
this.view.getEmpresaModel().removeAllElements();
this.view.getEmpresaModel().addAll(this.empresaRepository.getAll());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -29,30 +29,6 @@ public class DistribuidorUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
public void setDistribuidor(Distribuidor distribuidor) {
this.distribuidor = distribuidor;
}
@Override
public void show() {
this.fillEmpresaCombobox();
this.fillDistribuidor();
this.view.getRutField().requestFocus();
}
private void fillEmpresaCombobox() {
this.view.getEmpresaModel().removeAllElements();
this.view.getEmpresaModel().addAll(this.empresaRepository.getAll());
}
private void fillDistribuidor() {
if (this.distribuidorRepository == null)
return;
this.view.getRutField().setText(this.distribuidor.getRut());
this.view.getEmpresaCombobox().setSelectedItem(this.distribuidor.getEmpresa());
}
private void setupListeners() { private void setupListeners() {
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH));
@@ -87,6 +63,30 @@ public class DistribuidorUpdateController extends BaseController {
this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH); this.getParentController().showCard(PanelName.DISTRIBUIDOR_SEARCH);
} }
public void setDistribuidor(Distribuidor distribuidor) {
this.distribuidor = distribuidor;
}
@Override
public void show() {
this.fillEmpresaCombobox();
this.fillDistribuidor();
this.view.getRutField().requestFocus();
}
private void fillEmpresaCombobox() {
this.view.getEmpresaModel().removeAllElements();
this.view.getEmpresaModel().addAll(this.empresaRepository.getAll());
}
private void fillDistribuidor() {
if (this.distribuidorRepository == null)
return;
this.view.getRutField().setText(this.distribuidor.getRut());
this.view.getEmpresaCombobox().setSelectedItem(this.distribuidor.getEmpresa());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -21,15 +21,6 @@ public class DistribuidorViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillDistribuidor();
}
public void setDistribuidor(Distribuidor distribuidor) {
this.distribuidor = distribuidor;
}
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());
@@ -37,6 +28,20 @@ public class DistribuidorViewController extends BaseController {
this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView()); this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
} }
private void gotoCorreosView() {
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
}
private void gotoTelefonoView() {
DistribuidorTelefonoSearchController controller = (DistribuidorTelefonoSearchController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_TELEFONO_SEARCH);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_SEARCH);
}
private void gotoDireccionView() { private void gotoDireccionView() {
DistribuidorDireccionSearchController controller = (DistribuidorDireccionSearchController) this.getParentController() DistribuidorDireccionSearchController controller = (DistribuidorDireccionSearchController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_DIRECCION_SEARCH); .getCard(PanelName.DISTRIBUIDOR_DIRECCION_SEARCH);
@@ -44,19 +49,9 @@ public class DistribuidorViewController extends BaseController {
this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_SEARCH); this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_SEARCH);
} }
@Override
private void gotoTelefonoView() { public void show() {
DistribuidorTelefonoSearchController controller = (DistribuidorTelefonoSearchController) this.getParentController() this.fillDistribuidor();
.getCard(PanelName.DISTRIBUIDOR_TELEFONO_SEARCH);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_SEARCH);
}
private void gotoCorreosView() {
DistribuidorCorreoSearchController controller = (DistribuidorCorreoSearchController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_SEARCH);
} }
private void fillDistribuidor() { private void fillDistribuidor() {
@@ -71,4 +66,8 @@ public class DistribuidorViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setDistribuidor(Distribuidor distribuidor) {
this.distribuidor = distribuidor;
}
} }

View File

@@ -30,6 +30,25 @@ public class DistribuidorCorreoSearchController extends AbstractCorreoSearchCont
this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_CREATE); this.getParentController().showCard(PanelName.DISTRIBUIDOR_CORREO_CREATE);
} }
@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 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 @Override
protected void edit() { protected void edit() {
Correo correo = this.getSelectedCorreo(); Correo correo = this.getSelectedCorreo();
@@ -63,25 +82,6 @@ public class DistribuidorCorreoSearchController extends AbstractCorreoSearchCont
this.reload(); 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 @Override
protected void volver() { protected void volver() {
DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW); DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW);

View File

@@ -30,6 +30,25 @@ public class DistribuidorDireccionSearchController extends AbstractDireccionSear
this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_CREATE); this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.distribuidor);
this.loadDireccionesTable(direccion);
}
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
DistribuidorDireccionViewController controller = (DistribuidorDireccionViewController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Direccion direccion = this.getSelectedDireccion(); Direccion direccion = this.getSelectedDireccion();
@@ -63,25 +82,6 @@ public class DistribuidorDireccionSearchController extends AbstractDireccionSear
this.reload(); this.reload();
} }
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
DistribuidorDireccionViewController controller = (DistribuidorDireccionViewController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_DIRECCION_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.distribuidor);
this.loadDireccionesTable(direccion);
}
@Override @Override
protected void volver() { protected void volver() {
DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW); DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW);

View File

@@ -30,6 +30,25 @@ public class DistribuidorTelefonoSearchController extends AbstractTelefonoSearch
this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_CREATE); this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.distribuidor);
this.loadTelefonosTable(telefono);
}
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
DistribuidorTelefonoViewController controller = (DistribuidorTelefonoViewController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Telefono telefono = this.getSelectedTelefono(); Telefono telefono = this.getSelectedTelefono();
@@ -63,25 +82,6 @@ public class DistribuidorTelefonoSearchController extends AbstractTelefonoSearch
this.reload(); this.reload();
} }
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
DistribuidorTelefonoViewController controller = (DistribuidorTelefonoViewController) this.getParentController()
.getCard(PanelName.DISTRIBUIDOR_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setDistribuidor(this.distribuidor);
this.getParentController().showCard(PanelName.DISTRIBUIDOR_TELEFONO_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.distribuidor);
this.loadTelefonosTable(telefono);
}
@Override @Override
protected void volver() { protected void volver() {
DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW); DistribuidorViewController controller = (DistribuidorViewController) this.getParentController().getCard(PanelName.DISTRIBUIDOR_VIEW);

View File

@@ -25,11 +25,6 @@ public class EditorialCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getNombreField().addActionListener(e -> this.save()); this.view.getNombreField().addActionListener(e -> this.save());
@@ -53,6 +48,11 @@ public class EditorialCreateController extends BaseController {
this.view.getNombreField().requestFocus(); this.view.getNombreField().requestFocus();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -28,13 +28,9 @@ public class EditorialSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override private void loadEditorialTable() {
public void show() { List<Editorial> editoriales = this.editorialRepository.getAll();
this.reload(); this.loadEditorialTable(editoriales);
}
public void reload() {
this.loadEditorialTable();
} }
private void setupListeners() { private void setupListeners() {
@@ -46,22 +42,15 @@ public class EditorialSearchController extends BaseController {
this.view.getVerButton().addActionListener(e -> this.view()); this.view.getVerButton().addActionListener(e -> this.view());
} }
private void view() { private void loadEditorialTable(List<Editorial> editoriales) {
Editorial editorial = this.getSelectedEditorial(); BaseTableModel<Editorial> model = this.view.getEditorialModel();
if (editorial != null) { model.setRows(editoriales);
EditorialViewController controller = (EditorialViewController) this.getParentController().getCard(PanelName.EDITORIAL_VIEW);
controller.setEditorial(editorial);
this.getParentController().showCard(PanelName.EDITORIAL_VIEW);
}
} }
private void edit() { private void search() {
Editorial editorial = this.getSelectedEditorial(); String term = this.view.getBuscarField().getText();
if (editorial != null) { List<Editorial> editoriales = this.editorialRepository.search(term);
EditorialUpdateController controller = (EditorialUpdateController) this.getParentController().getCard(PanelName.EDITORIAL_UPDATE); this.loadEditorialTable(editoriales);
controller.setEditorial(editorial);
this.getParentController().showCard(PanelName.EDITORIAL_UPDATE);
}
} }
private void delete() { private void delete() {
@@ -88,20 +77,22 @@ public class EditorialSearchController extends BaseController {
this.reload(); this.reload();
} }
private void search() { private void edit() {
String term = this.view.getBuscarField().getText(); Editorial editorial = this.getSelectedEditorial();
List<Editorial> editoriales = this.editorialRepository.search(term); if (editorial != null) {
this.loadEditorialTable(editoriales); EditorialUpdateController controller = (EditorialUpdateController) this.getParentController().getCard(PanelName.EDITORIAL_UPDATE);
controller.setEditorial(editorial);
this.getParentController().showCard(PanelName.EDITORIAL_UPDATE);
}
} }
private void loadEditorialTable(List<Editorial> editoriales) { private void view() {
BaseTableModel<Editorial> model = this.view.getEditorialModel(); Editorial editorial = this.getSelectedEditorial();
model.setRows(editoriales); if (editorial != null) {
} EditorialViewController controller = (EditorialViewController) this.getParentController().getCard(PanelName.EDITORIAL_VIEW);
controller.setEditorial(editorial);
private void loadEditorialTable() { this.getParentController().showCard(PanelName.EDITORIAL_VIEW);
List<Editorial> editoriales = this.editorialRepository.getAll(); }
this.loadEditorialTable(editoriales);
} }
private Editorial getSelectedEditorial() { private Editorial getSelectedEditorial() {
@@ -119,6 +110,15 @@ public class EditorialSearchController extends BaseController {
return this.view.getEditorialModel().getRow(selectedRow); return this.view.getEditorialModel().getRow(selectedRow);
} }
public void reload() {
this.loadEditorialTable();
}
@Override
public void show() {
this.reload();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -25,19 +25,6 @@ public class EditorialUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
if (this.editorial == null)
return;
this.view.getNombreField().setText(this.editorial.getNombre());
this.view.getNombreField().requestFocus();
}
public void setEditorial(Editorial editorial) {
this.editorial = editorial;
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.update()); this.view.getNombreField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -64,8 +51,21 @@ public class EditorialUpdateController extends BaseController {
this.getParentController().showCard(PanelName.EDITORIAL_SEARCH); this.getParentController().showCard(PanelName.EDITORIAL_SEARCH);
} }
@Override
public void show() {
if (this.editorial == null)
return;
this.view.getNombreField().setText(this.editorial.getNombre());
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setEditorial(Editorial editorial) {
this.editorial = editorial;
}
} }

View File

@@ -18,21 +18,17 @@ public class EditorialViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillEditorial();
}
public void setEditorial(Editorial editorial) {
this.editorial = editorial;
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> { this.view.getVolverButton().addActionListener(e -> {
this.getParentController().showCard(PanelName.EDITORIAL_SEARCH); this.getParentController().showCard(PanelName.EDITORIAL_SEARCH);
}); });
} }
@Override
public void show() {
this.fillEditorial();
}
private void fillEditorial() { private void fillEditorial() {
if (this.editorial == null) if (this.editorial == null)
return; return;
@@ -44,4 +40,8 @@ public class EditorialViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setEditorial(Editorial editorial) {
this.editorial = editorial;
}
} }

View File

@@ -25,11 +25,6 @@ public class EmpresaCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getNombreField().addActionListener(e -> this.save()); this.view.getNombreField().addActionListener(e -> this.save());
@@ -53,6 +48,11 @@ public class EmpresaCreateController extends BaseController {
this.view.getNombreField().requestFocus(); this.view.getNombreField().requestFocus();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -27,13 +27,9 @@ public class EmpresaSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override private void loadEmpresaTable() {
public void show() { List<Empresa> empresas = this.empresaRepository.getAll();
this.reload(); this.loadEmpresaTable(empresas);
}
public void reload() {
this.loadEmpresaTable();
} }
private void setupListeners() { private void setupListeners() {
@@ -45,22 +41,15 @@ public class EmpresaSearchController extends BaseController {
this.view.getVerButton().addActionListener(e -> this.view()); this.view.getVerButton().addActionListener(e -> this.view());
} }
private void view() { private void loadEmpresaTable(List<Empresa> empresas) {
Empresa empresa = this.getSelectedEmpresa(); BaseTableModel<Empresa> model = this.view.getEmpresaModel();
if (empresa != null) { model.setRows(empresas);
EmpresaViewController controller = (EmpresaViewController) this.getParentController().getCard(PanelName.EMPRESA_VIEW);
controller.setEmpresa(empresa);
this.getParentController().showCard(PanelName.EMPRESA_VIEW);
}
} }
private void edit() { private void search() {
Empresa empresa = this.getSelectedEmpresa(); String term = this.view.getBuscarField().getText();
if (empresa != null) { List<Empresa> empresaes = this.empresaRepository.search(term);
EmpresaUpdateController controller = (EmpresaUpdateController) this.getParentController().getCard(PanelName.EMPRESA_UPDATE); this.loadEmpresaTable(empresaes);
controller.setEmpresa(empresa);
this.getParentController().showCard(PanelName.EMPRESA_UPDATE);
}
} }
private void delete() { private void delete() {
@@ -82,20 +71,22 @@ public class EmpresaSearchController extends BaseController {
this.reload(); this.reload();
} }
private void search() { private void edit() {
String term = this.view.getBuscarField().getText(); Empresa empresa = this.getSelectedEmpresa();
List<Empresa> empresaes = this.empresaRepository.search(term); if (empresa != null) {
this.loadEmpresaTable(empresaes); EmpresaUpdateController controller = (EmpresaUpdateController) this.getParentController().getCard(PanelName.EMPRESA_UPDATE);
controller.setEmpresa(empresa);
this.getParentController().showCard(PanelName.EMPRESA_UPDATE);
}
} }
private void loadEmpresaTable(List<Empresa> empresas) { private void view() {
BaseTableModel<Empresa> model = this.view.getEmpresaModel(); Empresa empresa = this.getSelectedEmpresa();
model.setRows(empresas); if (empresa != null) {
} EmpresaViewController controller = (EmpresaViewController) this.getParentController().getCard(PanelName.EMPRESA_VIEW);
controller.setEmpresa(empresa);
private void loadEmpresaTable() { this.getParentController().showCard(PanelName.EMPRESA_VIEW);
List<Empresa> empresas = this.empresaRepository.getAll(); }
this.loadEmpresaTable(empresas);
} }
private Empresa getSelectedEmpresa() { private Empresa getSelectedEmpresa() {
@@ -113,6 +104,15 @@ public class EmpresaSearchController extends BaseController {
return this.view.getEmpresaModel().getRow(selectedRow); return this.view.getEmpresaModel().getRow(selectedRow);
} }
public void reload() {
this.loadEmpresaTable();
}
@Override
public void show() {
this.reload();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -25,19 +25,6 @@ public class EmpresaUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
if (this.empresa == null)
return;
this.view.getNombreField().setText(this.empresa.getNombre());
this.view.getNombreField().requestFocus();
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.update()); this.view.getNombreField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -64,8 +51,21 @@ public class EmpresaUpdateController extends BaseController {
this.getParentController().showCard(PanelName.EMPRESA_SEARCH); this.getParentController().showCard(PanelName.EMPRESA_SEARCH);
} }
@Override
public void show() {
if (this.empresa == null)
return;
this.view.getNombreField().setText(this.empresa.getNombre());
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
} }

View File

@@ -18,21 +18,17 @@ public class EmpresaViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillEmpresa();
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> { this.view.getVolverButton().addActionListener(e -> {
this.getParentController().showCard(PanelName.EMPRESA_SEARCH); this.getParentController().showCard(PanelName.EMPRESA_SEARCH);
}); });
} }
@Override
public void show() {
this.fillEmpresa();
}
private void fillEmpresa() { private void fillEmpresa() {
if (this.empresa == null) if (this.empresa == null)
return; return;
@@ -44,4 +40,8 @@ public class EmpresaViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
} }

View File

@@ -25,11 +25,6 @@ public class IdiomaCreateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.save()); this.view.getNombreField().addActionListener(e -> this.save());
this.view.getGuardarButton().addActionListener(e -> this.save()); this.view.getGuardarButton().addActionListener(e -> this.save());
@@ -53,6 +48,11 @@ public class IdiomaCreateController extends BaseController {
this.view.getNombreField().requestFocus(); this.view.getNombreField().requestFocus();
} }
@Override
public void show() {
this.view.getNombreField().requestFocus();
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -28,13 +28,9 @@ public class IdiomaSearchController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override private void loadIdiomaTable() {
public void show() { List<Idioma> idiomas = this.idiomaRepository.getAll();
this.reload(); this.loadIdiomaTable(idiomas);
}
public void reload() {
this.loadIdiomaTable();
} }
private void setupListeners() { private void setupListeners() {
@@ -46,22 +42,15 @@ public class IdiomaSearchController extends BaseController {
this.view.getVerButton().addActionListener(e -> this.view()); this.view.getVerButton().addActionListener(e -> this.view());
} }
private void view() { private void loadIdiomaTable(List<Idioma> idiomas) {
Idioma idioma = this.getSelectedIdioma(); BaseTableModel<Idioma> model = this.view.getIdiomaTableModel();
if (idioma != null) { model.setRows(idiomas);
IdiomaViewController controller = (IdiomaViewController) this.getParentController().getCard(PanelName.IDIOMA_VIEW);
controller.setIdioma(idioma);
this.getParentController().showCard(PanelName.IDIOMA_VIEW);
}
} }
private void edit() { private void search() {
Idioma idioma = this.getSelectedIdioma(); String term = this.view.getBuscarField().getText();
if (idioma != null) { List<Idioma> idiomas = this.idiomaRepository.search(term);
IdiomaUpdateController controller = (IdiomaUpdateController) this.getParentController().getCard(PanelName.IDIOMA_UPDATE); this.loadIdiomaTable(idiomas);
controller.setIdioma(idioma);
this.getParentController().showCard(PanelName.IDIOMA_UPDATE);
}
} }
private void delete() { private void delete() {
@@ -89,25 +78,22 @@ public class IdiomaSearchController extends BaseController {
this.reload(); this.reload();
} }
private void search() { private void edit() {
String term = this.view.getBuscarField().getText(); Idioma idioma = this.getSelectedIdioma();
List<Idioma> idiomas = this.idiomaRepository.search(term); if (idioma != null) {
this.loadIdiomaTable(idiomas); IdiomaUpdateController controller = (IdiomaUpdateController) this.getParentController().getCard(PanelName.IDIOMA_UPDATE);
controller.setIdioma(idioma);
this.getParentController().showCard(PanelName.IDIOMA_UPDATE);
}
} }
private void loadIdiomaTable(List<Idioma> idiomas) { private void view() {
BaseTableModel<Idioma> model = this.view.getIdiomaTableModel(); Idioma idioma = this.getSelectedIdioma();
model.setRows(idiomas); if (idioma != null) {
} IdiomaViewController controller = (IdiomaViewController) this.getParentController().getCard(PanelName.IDIOMA_VIEW);
controller.setIdioma(idioma);
private void loadIdiomaTable() { this.getParentController().showCard(PanelName.IDIOMA_VIEW);
List<Idioma> idiomas = this.idiomaRepository.getAll(); }
this.loadIdiomaTable(idiomas);
}
@Override
public BasePanel getView() {
return this.view;
} }
private Idioma getSelectedIdioma() { private Idioma getSelectedIdioma() {
@@ -124,4 +110,18 @@ public class IdiomaSearchController extends BaseController {
return this.view.getIdiomaTableModel().getRow(selectedRow); return this.view.getIdiomaTableModel().getRow(selectedRow);
} }
public void reload() {
this.loadIdiomaTable();
}
@Override
public void show() {
this.reload();
}
@Override
public BasePanel getView() {
return this.view;
}
} }

View File

@@ -25,18 +25,6 @@ public class IdiomaUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
if (this.idioma == null)
return;
this.fillIdioma();
}
private void fillIdioma() {
this.view.getNombreField().setText(this.idioma.getNombre());
}
private void setupListeners() { private void setupListeners() {
this.view.getNombreField().addActionListener(e -> this.update()); this.view.getNombreField().addActionListener(e -> this.update());
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
@@ -64,6 +52,18 @@ public class IdiomaUpdateController extends BaseController {
this.getParentController().showCard(PanelName.IDIOMA_SEARCH); this.getParentController().showCard(PanelName.IDIOMA_SEARCH);
} }
@Override
public void show() {
if (this.idioma == null)
return;
this.fillIdioma();
}
private void fillIdioma() {
this.view.getNombreField().setText(this.idioma.getNombre());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -18,21 +18,17 @@ public class IdiomaViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillIdioma();
}
public void setIdioma(Idioma idioma) {
this.idioma = idioma;
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> { this.view.getVolverButton().addActionListener(e -> {
this.getParentController().showCard(PanelName.IDIOMA_SEARCH); this.getParentController().showCard(PanelName.IDIOMA_SEARCH);
}); });
} }
@Override
public void show() {
this.fillIdioma();
}
private void fillIdioma() { private void fillIdioma() {
if (this.idioma == null) if (this.idioma == null)
return; return;
@@ -44,4 +40,8 @@ public class IdiomaViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setIdioma(Idioma idioma) {
this.idioma = idioma;
}
} }

View File

@@ -26,27 +26,6 @@ public class TrabajadorUpdateController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
@Override
public void show() {
this.fillTrabajador();
this.view.getRutField().requestFocus();
}
private void fillTrabajador() {
if (this.trabajadorRespository == null)
return;
this.view.getRutField().setText(this.trabajador.getRut());
this.view.getNombreField().setText(this.trabajador.getNombre());
this.view.getApellidoPaternoField().setText(this.trabajador.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.trabajador.getApellidoMaterno());
this.view.getFechaContratoField().setDate(this.trabajador.getFechaContrato());
}
private void setupListeners() { private void setupListeners() {
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH));
@@ -99,6 +78,27 @@ public class TrabajadorUpdateController extends BaseController {
this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH); this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH);
} }
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
@Override
public void show() {
this.fillTrabajador();
this.view.getRutField().requestFocus();
}
private void fillTrabajador() {
if (this.trabajadorRespository == null)
return;
this.view.getRutField().setText(this.trabajador.getRut());
this.view.getNombreField().setText(this.trabajador.getNombre());
this.view.getApellidoPaternoField().setText(this.trabajador.getApellidoPaterno());
this.view.getApellidoMaternoField().setText(this.trabajador.getApellidoMaterno());
this.view.getFechaContratoField().setDate(this.trabajador.getFechaContrato());
}
@Override @Override
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;

View File

@@ -24,15 +24,6 @@ public class TrabajadorViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public void show() {
this.fillTrabajador();
}
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH)); this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.TRABAJADOR_SEARCH));
this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView()); this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView());
@@ -41,20 +32,6 @@ public class TrabajadorViewController extends BaseController {
this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView()); this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView());
} }
private void gotoDireccionView() {
TrabajadorDireccionSearchController controller = (TrabajadorDireccionSearchController) this.getParentController()
.getCard(PanelName.TRABAJADOR_DIRECCION_SEARCH);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_SEARCH);
}
private void gotoTelefonoView() {
TrabajadorTelefonoSearchController controller = (TrabajadorTelefonoSearchController) this.getParentController()
.getCard(PanelName.TRABAJADOR_TELEFONO_SEARCH);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_SEARCH);
}
private void gotoCorreosView() { private void gotoCorreosView() {
TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController() TrabajadorCorreoSearchController controller = (TrabajadorCorreoSearchController) this.getParentController()
.getCard(PanelName.TRABAJADOR_CORREO_SEARCH); .getCard(PanelName.TRABAJADOR_CORREO_SEARCH);
@@ -83,6 +60,25 @@ public class TrabajadorViewController extends BaseController {
} }
} }
private void gotoTelefonoView() {
TrabajadorTelefonoSearchController controller = (TrabajadorTelefonoSearchController) this.getParentController()
.getCard(PanelName.TRABAJADOR_TELEFONO_SEARCH);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_SEARCH);
}
private void gotoDireccionView() {
TrabajadorDireccionSearchController controller = (TrabajadorDireccionSearchController) this.getParentController()
.getCard(PanelName.TRABAJADOR_DIRECCION_SEARCH);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_SEARCH);
}
@Override
public void show() {
this.fillTrabajador();
}
private void fillTrabajador() { private void fillTrabajador() {
if (this.trabajador == null) if (this.trabajador == null)
return; return;
@@ -98,4 +94,8 @@ public class TrabajadorViewController extends BaseController {
public BasePanel getView() { public BasePanel getView() {
return this.view; return this.view;
} }
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
} }

View File

@@ -30,6 +30,25 @@ public class TrabajadorCorreoSearchController extends AbstractCorreoSearchContro
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_CREATE); this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Correo> correo = this.correoRepository.search(term, this.trabajador);
this.loadCorreosTable(correo);
}
@Override
protected void view() {
Correo correo = this.getSelectedCorreo();
if (correo != null) {
TrabajadorCorreoViewController controller = (TrabajadorCorreoViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_CORREO_VIEW);
controller.setCorreo(correo);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Correo correo = this.getSelectedCorreo(); Correo correo = this.getSelectedCorreo();
@@ -63,25 +82,6 @@ public class TrabajadorCorreoSearchController extends AbstractCorreoSearchContro
this.reload(); this.reload();
} }
@Override
protected void view() {
Correo correo = this.getSelectedCorreo();
if (correo != null) {
TrabajadorCorreoViewController controller = (TrabajadorCorreoViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_CORREO_VIEW);
controller.setCorreo(correo);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_CORREO_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Correo> correo = this.correoRepository.search(term, this.trabajador);
this.loadCorreosTable(correo);
}
@Override @Override
protected void volver() { protected void volver() {
TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW); TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW);

View File

@@ -31,6 +31,25 @@ public class TrabajadorDireccionSearchController extends AbstractDireccionSearch
this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_CREATE); this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.trabajador);
this.loadDireccionesTable(direccion);
}
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
TrabajadorDireccionViewController controller = (TrabajadorDireccionViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Direccion direccion = this.getSelectedDireccion(); Direccion direccion = this.getSelectedDireccion();
@@ -64,25 +83,6 @@ public class TrabajadorDireccionSearchController extends AbstractDireccionSearch
this.reload(); this.reload();
} }
@Override
protected void view() {
Direccion direccion = this.getSelectedDireccion();
if (direccion != null) {
TrabajadorDireccionViewController controller = (TrabajadorDireccionViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_DIRECCION_VIEW);
controller.setDireccion(direccion);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_DIRECCION_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Direccion> direccion = this.direccionRepository.search(term, this.trabajador);
this.loadDireccionesTable(direccion);
}
@Override @Override
protected void volver() { protected void volver() {
TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW); TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW);

View File

@@ -19,16 +19,6 @@ public class TrabajadorTelefonoSearchController extends AbstractTelefonoSearchCo
super(view, parent); super(view, parent);
} }
@Override
public void show() {
this.reload();
}
@Override
public BasePanel getView() {
return this.view;
}
@Override @Override
protected void create() { protected void create() {
TrabajadorTelefonoCreateController controller = (TrabajadorTelefonoCreateController) this.getParentController() TrabajadorTelefonoCreateController controller = (TrabajadorTelefonoCreateController) this.getParentController()
@@ -37,6 +27,25 @@ public class TrabajadorTelefonoSearchController extends AbstractTelefonoSearchCo
this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_CREATE); this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_CREATE);
} }
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.trabajador);
this.loadTelefonosTable(telefono);
}
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
TrabajadorTelefonoViewController controller = (TrabajadorTelefonoViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_VIEW);
}
}
@Override @Override
protected void edit() { protected void edit() {
Telefono telefono = this.getSelectedTelefono(); Telefono telefono = this.getSelectedTelefono();
@@ -70,25 +79,6 @@ public class TrabajadorTelefonoSearchController extends AbstractTelefonoSearchCo
this.reload(); this.reload();
} }
@Override
protected void view() {
Telefono telefono = this.getSelectedTelefono();
if (telefono != null) {
TrabajadorTelefonoViewController controller = (TrabajadorTelefonoViewController) this.getParentController()
.getCard(PanelName.TRABAJADOR_TELEFONO_VIEW);
controller.setTelefono(telefono);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_TELEFONO_VIEW);
}
}
@Override
protected void search() {
String term = this.view.getSearchField().getText();
List<Telefono> telefono = this.telefonoRepository.search(term, this.trabajador);
this.loadTelefonosTable(telefono);
}
@Override @Override
protected void volver() { protected void volver() {
TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW); TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW);
@@ -96,6 +86,16 @@ public class TrabajadorTelefonoSearchController extends AbstractTelefonoSearchCo
this.getParentController().showCard(PanelName.TRABAJADOR_VIEW); this.getParentController().showCard(PanelName.TRABAJADOR_VIEW);
} }
@Override
public void show() {
this.reload();
}
@Override
public BasePanel getView() {
return this.view;
}
@Override @Override
protected void loadTelefonosTable() { protected void loadTelefonosTable() {
List<Telefono> telefonos = this.trabajador.getTelefonos(); List<Telefono> telefonos = this.trabajador.getTelefonos();

View File

@@ -43,14 +43,14 @@ public class UsuarioUpdateController extends BaseController {
return this.view; return this.view;
} }
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
public void fillUser() { public void fillUser() {
this.view.getUserField().setText(this.trabajador.getUsuario().getNombre()); this.view.getUserField().setText(this.trabajador.getUsuario().getNombre());
} }
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
private void setupListeners() { private void setupListeners() {
this.view.getActualizarButton().addActionListener(e -> this.update()); this.view.getActualizarButton().addActionListener(e -> this.update());
this.view.getVolverButton().addActionListener(e -> this.volver()); this.view.getVolverButton().addActionListener(e -> this.volver());

View File

@@ -24,36 +24,18 @@ public class UsuarioViewController extends BaseController {
this.setupListeners(); this.setupListeners();
} }
@Override
public LaunchController getParentController() {
return this.parentController;
}
@Override
public void show() {
this.view.getUserField().requestFocus();
this.fillUsuario();
}
@Override
public BasePanel getView() {
return this.view;
}
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
}
public void fillUsuario() {
this.view.getUserField().setText(this.trabajador.getUsuario().getNombre());
}
private void setupListeners() { private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.volver()); this.view.getVolverButton().addActionListener(e -> this.volver());
this.view.getEditarButton().addActionListener(e -> this.editar()); this.view.getEditarButton().addActionListener(e -> this.editar());
this.view.getEliminarButton().addActionListener(e -> this.eliminar()); this.view.getEliminarButton().addActionListener(e -> this.eliminar());
} }
private void volver() {
TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW);
controller.setTrabajador(this.trabajador);
this.getParentController().showCard(PanelName.TRABAJADOR_VIEW);
}
private void editar() { private void editar() {
UsuarioUpdateController controller = (UsuarioUpdateController) this.getParentController().getCard(PanelName.USUARIO_UPDATE); UsuarioUpdateController controller = (UsuarioUpdateController) this.getParentController().getCard(PanelName.USUARIO_UPDATE);
controller.setTrabajador(this.trabajador); controller.setTrabajador(this.trabajador);
@@ -79,10 +61,28 @@ public class UsuarioViewController extends BaseController {
this.volver(); this.volver();
} }
private void volver() { @Override
TrabajadorViewController controller = (TrabajadorViewController) this.getParentController().getCard(PanelName.TRABAJADOR_VIEW); public LaunchController getParentController() {
controller.setTrabajador(this.trabajador); return this.parentController;
this.getParentController().showCard(PanelName.TRABAJADOR_VIEW); }
@Override
public void show() {
this.view.getUserField().requestFocus();
this.fillUsuario();
}
@Override
public BasePanel getView() {
return this.view;
}
public void fillUsuario() {
this.view.getUserField().setText(this.trabajador.getUsuario().getNombre());
}
public void setTrabajador(Trabajador trabajador) {
this.trabajador = trabajador;
} }
} }

View File

@@ -41,9 +41,9 @@ public class BaseTableModel<T> extends AbstractTableModel {
return this.columns[index]; return this.columns[index];
} }
@Override public void addRow(T item) {
public Object getValueAt(int rowIndex, int columnIndex) { this.rows.add(item);
return this.valueAt.apply(this.rows, rowIndex, columnIndex); this.fireTableRowsInserted(this.getRowCount() - 1, this.getRowCount() - 1);
} }
@Override @Override
@@ -56,9 +56,9 @@ public class BaseTableModel<T> extends AbstractTableModel {
return this.columns.length; return this.columns.length;
} }
public void addRow(T item) { @Override
this.rows.add(item); public Object getValueAt(int rowIndex, int columnIndex) {
this.fireTableRowsInserted(this.getRowCount() - 1, this.getRowCount() - 1); return this.valueAt.apply(this.rows, rowIndex, columnIndex);
} }
public void setRows(List<T> items) { public void setRows(List<T> items) {
@@ -67,11 +67,6 @@ public class BaseTableModel<T> extends AbstractTableModel {
this.fireTableRowsInserted(0, this.getRowCount() - 1); this.fireTableRowsInserted(0, this.getRowCount() - 1);
} }
public void removeRow(int row) {
this.rows.remove(row);
this.fireTableRowsDeleted(row, row);
}
public void removeRows() { public void removeRows() {
int rowCount = this.getRowCount(); int rowCount = this.getRowCount();
if (rowCount > 0) { if (rowCount > 0) {
@@ -80,6 +75,11 @@ public class BaseTableModel<T> extends AbstractTableModel {
} }
} }
public void removeRow(int row) {
this.rows.remove(row);
this.fireTableRowsDeleted(row, row);
}
public T getRow(int row) { public T getRow(int row) {
if (row > -1 || row < this.getRowCount()) { if (row > -1 || row < this.getRowCount()) {
return this.rows.get(row); return this.rows.get(row);

View File

@@ -4,6 +4,7 @@ import java.time.DateTimeException;
import java.time.Year; import java.time.Year;
public class GeneralValidator { public class GeneralValidator {
public static boolean isLong(String number) { public static boolean isLong(String number) {
try { try {
Long.parseLong(number); Long.parseLong(number);

View File

@@ -11,10 +11,9 @@ public class LoggedEvent extends EventObject {
private Usuario user; private Usuario user;
/** /**
* Crea el objeto y almacena los datos entregados * Crea el objeto y almacena los datos entregados
* *
* El metodo lanza un {@code IllegalArgumentException} en caso que * El metodo lanza un {@code IllegalArgumentException} en caso que {@code source} y {@code user} sean nulos.
* {@code source} y {@code user} sean nulos.
* *
* @param source El objeto en el que el evento se origino * @param source El objeto en el que el evento se origino
* @param user El usuario que fue logeado en el sistema * @param user El usuario que fue logeado en el sistema
@@ -26,6 +25,6 @@ public class LoggedEvent extends EventObject {
} }
public Usuario getUser() { public Usuario getUser() {
return user; return this.user;
} }
} }

View File

@@ -9,7 +9,8 @@ public interface LoggedListener extends EventListener {
/** /**
* Se invoca cuando un usuario se logra logear al sistema. * Se invoca cuando un usuario se logra logear al sistema.
*
* @param e El evento que se ejecutara * @param e El evento que se ejecutara
*/ */
public void loginTry(LoggedEvent e); void loginTry(LoggedEvent e);
} }

View File

@@ -9,11 +9,13 @@ import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEKeySpec;
public class Passwords { public class Passwords {
private static final Random RANDOM = new SecureRandom(); private static final Random RANDOM = new SecureRandom();
private static final int ITERATIONS = 10000; private static final int ITERATIONS = 10000;
private static final int KEY_LENGHT = 256; private static final int KEY_LENGHT = 256;
private Passwords(){} private Passwords() {
}
public static byte[] getNextSalt() { public static byte[] getNextSalt() {
byte[] salt = new byte[16]; byte[] salt = new byte[16];
@@ -21,10 +23,22 @@ public class Passwords {
return salt; return salt;
} }
public static byte[] hash(char[] password, byte[] salt){ public static boolean isExpectedPassword(char[] password, byte[] salt, byte[] expectedHash) {
byte[] pwdHash = hash(password, salt);
Arrays.fill(password, Character.MIN_VALUE);
if (pwdHash.length != expectedHash.length)
return false;
for (int i = 0; i < pwdHash.length; i++) {
if (pwdHash[i] != expectedHash[i])
return false;
}
return true;
}
public static byte[] hash(char[] password, byte[] salt) {
PBEKeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, KEY_LENGHT); PBEKeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, KEY_LENGHT);
Arrays.fill(password, Character.MIN_VALUE); Arrays.fill(password, Character.MIN_VALUE);
try{ try {
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
return skf.generateSecret(spec).getEncoded(); return skf.generateSecret(spec).getEncoded();
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) { } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
@@ -33,14 +47,4 @@ public class Passwords {
spec.clearPassword(); spec.clearPassword();
} }
} }
public static boolean isExpectedPassword(char[] password, byte[] salt, byte[] expectedHash){
byte[] pwdHash = hash(password, salt);
Arrays.fill(password, Character.MIN_VALUE);
if(pwdHash.length != expectedHash.length) return false;
for(int i = 0; i < pwdHash.length; i++){
if(pwdHash[i] != expectedHash[i]) return false;
}
return true;
}
} }

View File

@@ -1,5 +1,6 @@
package xyz.danielcortes.framework; package xyz.danielcortes.framework;
public interface TriFunction<A, B, C, D> { public interface TriFunction<A, B, C, D> {
D apply(A a, B b, C c); D apply(A a, B b, C c);
} }

View File

@@ -26,9 +26,21 @@ public class LoginController {
} }
private void setupListeners() { private void setupListeners() {
this.view.getUserField().addActionListener(e -> login()); this.view.getUserField().addActionListener(e -> this.login());
this.view.getPassField().addActionListener(e -> login()); this.view.getPassField().addActionListener(e -> this.login());
this.view.getLoginButton().addActionListener(e -> login()); this.view.getLoginButton().addActionListener(e -> this.login());
}
private void createFrame() {
Dimension dimension = new Dimension(400, 400);
this.frame = new JFrame();
this.frame.setSize(dimension);
this.frame.setMinimumSize(dimension);
this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.frame.setLocationRelativeTo(null);
this.frame.setTitle("Login");
this.frame.setContentPane(this.view.getContentPane());
this.frame.setVisible(true);
} }
private void login() { private void login() {
@@ -48,7 +60,7 @@ public class LoginController {
char[] pass = this.view.getPassField().getPassword(); char[] pass = this.view.getPassField().getPassword();
if (Passwords.isExpectedPassword(pass, user.getSalt(), user.getPassword())) { if (Passwords.isExpectedPassword(pass, user.getSalt(), user.getPassword())) {
this.frame.dispose(); this.frame.dispose();
loggedListener.loginTry(new LoggedEvent(this, user)); this.loggedListener.loginTry(new LoggedEvent(this, user));
} else { } else {
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
null, null,
@@ -59,18 +71,6 @@ public class LoginController {
} }
} }
private void createFrame() {
Dimension dimension = new Dimension(400, 400);
this.frame = new JFrame();
this.frame.setSize(dimension);
this.frame.setMinimumSize(dimension);
this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.frame.setLocationRelativeTo(null);
this.frame.setTitle("Login");
this.frame.setContentPane(this.view.getContentPane());
this.frame.setVisible(true);
}
public void setLoggedListener(LoggedListener listener) { public void setLoggedListener(LoggedListener listener) {
this.loggedListener = listener; this.loggedListener = listener;
} }

View File

@@ -19,27 +19,27 @@ public class LoginPanel {
private JPasswordField passField; private JPasswordField passField;
private JTextField userField; private JTextField userField;
public JButton getLoginButton() {
return loginButton;
}
public JPanel getContentPane() {
return contentPane;
}
public JPasswordField getPassField() {
return passField;
}
public JTextField getUserField() {
return userField;
}
{ {
// GUI initializer generated by IntelliJ IDEA GUI Designer // GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<< // >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE! // DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$(); this.$$$setupUI$$$();
}
public JButton getLoginButton() {
return this.loginButton;
}
public JPanel getContentPane() {
return this.contentPane;
}
public JPasswordField getPassField() {
return this.passField;
}
public JTextField getUserField() {
return this.userField;
} }
/** /**

View File

@@ -9,12 +9,13 @@ import xyz.danielcortes.models.Distribuidor;
public class DistribuidorRepository extends BaseRepository<Distribuidor> { public class DistribuidorRepository extends BaseRepository<Distribuidor> {
public List<Distribuidor> getAll() { public List<Distribuidor> getAll() {
TypedQuery<Distribuidor> query = em.createQuery("SELECT d FROM Distribuidor d", Distribuidor.class); TypedQuery<Distribuidor> query = this.em.createQuery("SELECT d FROM Distribuidor d", Distribuidor.class);
return query.getResultList(); return query.getResultList();
} }
public List<Distribuidor> search(String term) { public List<Distribuidor> search(String term) {
Query query = em.createQuery("SELECT d FROM Distribuidor d JOIN d.empresa e WHERE e.id = d.empresa.id AND (LOWER(e.nombre) LIKE :term OR LOWER(d.rut) LIKE :term)" ); Query query = this.em.createQuery(
"SELECT d FROM Distribuidor d JOIN d.empresa e WHERE e.id = d.empresa.id AND (LOWER(e.nombre) LIKE :term OR LOWER(d.rut) LIKE :term)");
query.setParameter("term", "%" + term + "%"); query.setParameter("term", "%" + term + "%");
return query.getResultList(); return query.getResultList();
} }

View File

@@ -9,12 +9,12 @@ import xyz.danielcortes.models.Empresa;
public class EmpresaRepository extends BaseRepository<Empresa> { public class EmpresaRepository extends BaseRepository<Empresa> {
public List<Empresa> getAll() { public List<Empresa> getAll() {
TypedQuery<Empresa> query = em.createQuery("SELECT e FROM Empresa e", Empresa.class); TypedQuery<Empresa> query = this.em.createQuery("SELECT e FROM Empresa e", Empresa.class);
return query.getResultList(); return query.getResultList();
} }
public List<Empresa> search(String term) { public List<Empresa> search(String term) {
Query query = em.createQuery("SELECT e FROM Empresa e WHERE LOWER(e.nombre) LIKE :term" ); Query query = this.em.createQuery("SELECT e FROM Empresa e WHERE LOWER(e.nombre) LIKE :term");
query.setParameter("term", "%" + term.toLowerCase() + "%"); query.setParameter("term", "%" + term.toLowerCase() + "%");
return query.getResultList(); return query.getResultList();
} }

View File

@@ -9,13 +9,13 @@ import xyz.danielcortes.models.Usuario;
public class UsuarioRepository extends BaseRepository<Usuario> { public class UsuarioRepository extends BaseRepository<Usuario> {
public Optional<Usuario> getByName(String name) { public Optional<Usuario> getByName(String name) {
TypedQuery<Usuario> query = em.createQuery("SELECT u FROM Usuario u WHERE nombre = :nombre", Usuario.class); TypedQuery<Usuario> query = this.em.createQuery("SELECT u FROM Usuario u WHERE nombre = :nombre", Usuario.class);
query.setParameter("nombre", name); query.setParameter("nombre", name);
try{ try {
Usuario user = query.getSingleResult(); Usuario user = query.getSingleResult();
return Optional.of(user); return Optional.of(user);
}catch (NoResultException e){ } catch (NoResultException e) {
return Optional.empty(); return Optional.empty();
} }
} }

View File

@@ -41,14 +41,14 @@ public class AutorValidator {
public ValidationResult validateOriginal(Autor original) { public ValidationResult validateOriginal(Autor original) {
if (original == null) { if (original == null) {
return new ValidationResult("No hay Autor seleccionado"); return new ValidationResult("No hay Autor seleccionado");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult isDeleteable(Autor autor){ public ValidationResult isDeleteable(Autor autor) {
if(autor.getLibros().size() > 0){ if (autor.getLibros().size() > 0) {
return new ValidationResult("No se puede eliminar el autor ya que tiene libros asociados"); return new ValidationResult("No se puede eliminar el autor ya que tiene libros asociados");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }

View File

@@ -14,23 +14,23 @@ public class CategoriaValidator {
public ValidationResult validateNombre(String nombre) { public ValidationResult validateNombre(String nombre) {
if (nombre == null) { if (nombre == null) {
return new ValidationResult("El nombre es nulo"); return new ValidationResult("El nombre es nulo");
} else if (nombre.isEmpty()) { } else if (nombre.isEmpty()) {
return new ValidationResult("El nombre esta vacío"); return new ValidationResult("El nombre esta vacío");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult validateOriginal(Categoria categoria){ public ValidationResult validateOriginal(Categoria categoria) {
if(categoria == null){ if (categoria == null) {
return new ValidationResult("No hay categoria seleccionada"); return new ValidationResult("No hay categoria seleccionada");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult isDeleteable(Categoria categoria){ public ValidationResult isDeleteable(Categoria categoria) {
if(categoria.getLibros().size() > 0){ if (categoria.getLibros().size() > 0) {
return new ValidationResult("No se puede eliminar la categoria ya que tiene libros asociados"); return new ValidationResult("No se puede eliminar la categoria ya que tiene libros asociados");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }

View File

@@ -54,14 +54,6 @@ public class ClienteValidator {
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult validateFechaNacimiento(LocalDate fecha) {
if (fecha == null) {
return new ValidationResult("La fecha es nula");
}
return ValidationResult.NON_ERROR;
}
private boolean rutChecksum(String rut) { private boolean rutChecksum(String rut) {
char lastchar = rut.charAt(rut.length() - 1); char lastchar = rut.charAt(rut.length() - 1);
rut = rut.toLowerCase().replaceAll("[^\\dkK]", ""); rut = rut.toLowerCase().replaceAll("[^\\dkK]", "");
@@ -85,4 +77,11 @@ public class ClienteValidator {
return lastchar == digitoVerificador; return lastchar == digitoVerificador;
} }
public ValidationResult validateFechaNacimiento(LocalDate fecha) {
if (fecha == null) {
return new ValidationResult("La fecha es nula");
}
return ValidationResult.NON_ERROR;
}
} }

View File

@@ -18,30 +18,16 @@ public class DistribuidorValidator {
return new ValidationResult("El rut es nulo"); return new ValidationResult("El rut es nulo");
} else if (rut.isEmpty()) { } else if (rut.isEmpty()) {
return new ValidationResult("El rut esta vacío"); return new ValidationResult("El rut esta vacío");
} else if(rut.length() < 4){ } else if (rut.length() < 4) {
return new ValidationResult("El rut es muy corto"); return new ValidationResult("El rut es muy corto");
} }
if (!rutChecksum(rut)) { if (!this.rutChecksum(rut)) {
return new ValidationResult("El rut es invalido"); return new ValidationResult("El rut es invalido");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult validateEmpresa(Empresa empresa) {
if(empresa == null) {
return new ValidationResult("La empresa no existe");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateOriginal(Distribuidor distribuidor) {
if(distribuidor == null){
return new ValidationResult("El distribuidor es nulo");
}
return ValidationResult.NON_ERROR;
}
private boolean rutChecksum(String rut) { private boolean rutChecksum(String rut) {
char lastchar = rut.charAt(rut.length() - 1); char lastchar = rut.charAt(rut.length() - 1);
rut = rut.toLowerCase().replaceAll("[^\\dkK]", ""); rut = rut.toLowerCase().replaceAll("[^\\dkK]", "");
@@ -66,4 +52,18 @@ public class DistribuidorValidator {
return lastchar == digitoVerificador; return lastchar == digitoVerificador;
} }
public ValidationResult validateEmpresa(Empresa empresa) {
if (empresa == null) {
return new ValidationResult("La empresa no existe");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateOriginal(Distribuidor distribuidor) {
if (distribuidor == null) {
return new ValidationResult("El distribuidor es nulo");
}
return ValidationResult.NON_ERROR;
}
} }

View File

@@ -14,23 +14,23 @@ public class EditorialValidator {
public ValidationResult validateNombre(String nombre) { public ValidationResult validateNombre(String nombre) {
if (nombre == null) { if (nombre == null) {
return new ValidationResult("El nombre es nulo"); return new ValidationResult("El nombre es nulo");
} else if (nombre.isEmpty()) { } else if (nombre.isEmpty()) {
return new ValidationResult("El nombre esta vacío"); return new ValidationResult("El nombre esta vacío");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult validateOriginal(Editorial original) { public ValidationResult validateOriginal(Editorial original) {
if (original == null) { if (original == null) {
return new ValidationResult("No hay Editorial seleccionada"); return new ValidationResult("No hay Editorial seleccionada");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult isDeleteable(Editorial editorial){ public ValidationResult isDeleteable(Editorial editorial) {
if(editorial.getLibros().size() > 0){ if (editorial.getLibros().size() > 0) {
return new ValidationResult("No se puede eliminar la editorial ya que tiene libros asociados"); return new ValidationResult("No se puede eliminar la editorial ya que tiene libros asociados");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }

View File

@@ -13,13 +13,13 @@ public class EjemplarValidator {
public ValidationResult validateSerie(String serie, Integer libro_id) { public ValidationResult validateSerie(String serie, Integer libro_id) {
if (serie == null) { if (serie == null) {
return new ValidationResult("La serie es nula"); return new ValidationResult("La serie es nula");
} }
if (serie.isEmpty()) { if (serie.isEmpty()) {
return new ValidationResult("La serie esta vacia"); return new ValidationResult("La serie esta vacia");
} }
if (ejemplarRepository.exists(serie, libro_id)) { if (this.ejemplarRepository.exists(serie, libro_id)) {
return new ValidationResult("El numero de serie ya existe"); return new ValidationResult("El numero de serie ya existe");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;

View File

@@ -23,7 +23,7 @@ public class EmpresaValidator {
} }
public ValidationResult validateOriginal(Empresa empresa) { public ValidationResult validateOriginal(Empresa empresa) {
if(empresa == null){ if (empresa == null) {
return new ValidationResult("El empresa es nula"); return new ValidationResult("El empresa es nula");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;

View File

@@ -35,14 +35,61 @@ public class LibroValidator {
} }
isbn = isbn.replaceAll("[^\\d]", ""); isbn = isbn.replaceAll("[^\\d]", "");
if ((isbn.length() == 13 && !ISBN13CheckSum(isbn)) if ((isbn.length() == 13 && !this.ISBN13CheckSum(isbn))
|| (isbn.length() == 10 && !ISBN10CheckSum(isbn)) || (isbn.length() == 10 && !this.ISBN10CheckSum(isbn))
|| (isbn.length() != 10 && isbn.length() != 13)) { || (isbn.length() != 10 && isbn.length() != 13)) {
return new ValidationResult("El ISBN no es valido"); return new ValidationResult("El ISBN no es valido");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
private boolean ISBN13CheckSum(String isbn) {
if (isbn.length() != 13)
return false;
int sum = 0;
for (int i = 0; i < 12; i++) {
int digit = isbn.charAt(i) - '0';
if (0 > digit || 9 < digit)
return false;
if (i % 2 == 0) {
sum += digit;
} else {
sum += digit * 3;
}
}
char last = isbn.charAt(12);
if (((last < '0') || (last > '9')))
return false;
return (10 - (sum % 10) == last - '0');
}
private boolean ISBN10CheckSum(String isbn) {
if (isbn.length() != 10)
return false;
int sum = 0;
for (int i = 0; i < 9; i++) {
int digit = isbn.charAt(i) - '0';
if (0 > digit || 9 < digit)
return false;
sum += (digit * (10 - i));
}
char last = isbn.charAt(9);
if ((last != 'X') && ((last < '0') || (last > '9')))
return false;
if (last == 'X')
sum += 10;
else
sum += last - '0';
return (sum % 11 == 0);
}
public ValidationResult validateTitulo(String titulo) { public ValidationResult validateTitulo(String titulo) {
if (titulo == null) { if (titulo == null) {
return new ValidationResult("El titulo es nulo"); return new ValidationResult("El titulo es nulo");
@@ -137,51 +184,4 @@ public class LibroValidator {
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
private boolean ISBN10CheckSum(String isbn) {
if (isbn.length() != 10)
return false;
int sum = 0;
for (int i = 0; i < 9; i++) {
int digit = isbn.charAt(i) - '0';
if (0 > digit || 9 < digit)
return false;
sum += (digit * (10 - i));
}
char last = isbn.charAt(9);
if ((last != 'X') && ((last < '0') || (last > '9')))
return false;
if (last == 'X')
sum += 10;
else
sum += last - '0';
return (sum % 11 == 0);
}
private boolean ISBN13CheckSum(String isbn) {
if (isbn.length() != 13)
return false;
int sum = 0;
for (int i = 0; i < 12; i++) {
int digit = isbn.charAt(i) - '0';
if (0 > digit || 9 < digit)
return false;
if (i % 2 == 0) {
sum += digit;
} else {
sum += digit * 3;
}
}
char last = isbn.charAt(12);
if (((last < '0') || (last > '9')))
return false;
return (10 - (sum % 10) == last - '0');
}
} }

View File

@@ -47,20 +47,13 @@ public class TrabajadorValidator {
} else if (rut.length() < 4) { } else if (rut.length() < 4) {
return new ValidationResult("El rut es muy corto"); return new ValidationResult("El rut es muy corto");
} }
if (!rutChecksum(rut)) { if (!this.rutChecksum(rut)) {
return new ValidationResult("El rut es invalido"); return new ValidationResult("El rut es invalido");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;
} }
public ValidationResult validateFechaContrato(LocalDate date) {
if (date == null) {
return new ValidationResult("La fecha es nula");
}
return ValidationResult.NON_ERROR;
}
private boolean rutChecksum(String rut) { private boolean rutChecksum(String rut) {
char lastchar = rut.charAt(rut.length() - 1); char lastchar = rut.charAt(rut.length() - 1);
rut = rut.toLowerCase().replaceAll("[^\\dkK]", ""); rut = rut.toLowerCase().replaceAll("[^\\dkK]", "");
@@ -84,4 +77,11 @@ public class TrabajadorValidator {
return lastchar == digitoVerificador; return lastchar == digitoVerificador;
} }
public ValidationResult validateFechaContrato(LocalDate date) {
if (date == null) {
return new ValidationResult("La fecha es nula");
}
return ValidationResult.NON_ERROR;
}
} }

View File

@@ -33,7 +33,7 @@ public class UsuarioValidator {
} }
public ValidationResult validateOriginal(Usuario usuario) { public ValidationResult validateOriginal(Usuario usuario) {
if(usuario == null){ if (usuario == null) {
return new ValidationResult("El usuario no existe"); return new ValidationResult("El usuario no existe");
} }
return ValidationResult.NON_ERROR; return ValidationResult.NON_ERROR;

View File

@@ -10,16 +10,16 @@ public class ComprarLibroPanel extends BasePanel {
private JPanel contentPane; private JPanel contentPane;
@Override
public JPanel getContentPane() {
return null;
}
{ {
// GUI initializer generated by IntelliJ IDEA GUI Designer // GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<< // >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE! // DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$(); this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return null;
} }
/** /**