Se creo un objeto que contiene la validacion y muestra el mensaje de
error
This commit is contained in:
BIN
biblioteca.vpp
BIN
biblioteca.vpp
Binary file not shown.
@@ -89,7 +89,7 @@ create table ejemplar
|
|||||||
libro_id int unsigned not null,
|
libro_id int unsigned not null,
|
||||||
estado_id int unsigned default 1,
|
estado_id int unsigned default 1,
|
||||||
unique key serie_libro (serie, libro_id),
|
unique key serie_libro (serie, libro_id),
|
||||||
foreign key (libro_id) references libro (id) on delete restrict on update cascade,
|
foreign key (libro_id) references libro (id) on delete cascade on update cascade,
|
||||||
foreign key (estado_id) references estado (id) on delete restrict on update cascade
|
foreign key (estado_id) references estado (id) on delete restrict on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ public class App {
|
|||||||
String motif ="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
|
String motif ="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
|
||||||
String nimbus = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
|
String nimbus = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
|
||||||
String metal = "javax.swing.plaf.metal.MetalLookAndFeel";
|
String metal = "javax.swing.plaf.metal.MetalLookAndFeel";
|
||||||
|
String gtk = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
|
||||||
|
|
||||||
UIManager.setLookAndFeel(metal);
|
UIManager.setLookAndFeel(gtk);
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.danielcortes.controllers.autor;
|
|||||||
|
|
||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.repository.AutorRepository;
|
import xyz.danielcortes.repository.AutorRepository;
|
||||||
import xyz.danielcortes.validator.AutorValidator;
|
import xyz.danielcortes.validator.AutorValidator;
|
||||||
@@ -34,11 +35,24 @@ public class AutorCreateController extends BaseController {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String nombre = view.getNombreField().getText();
|
String nombre = view.getNombreField().getText();
|
||||||
if (!this.validator.validateNombre(nombre)) return;
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if (nombreValidation.hasError()) {
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
String apellidoPaterno = view.getApellidoPaternoField().getText();
|
String apellidoPaterno = view.getApellidoPaternoField().getText();
|
||||||
if (!this.validator.validateApellidoPaterno(apellidoPaterno)) return;
|
ValidationResult apellidoPaternoValidation = this.validator.validateApellidoPaterno(apellidoPaterno);
|
||||||
|
if(apellidoPaternoValidation.hasError()){
|
||||||
|
apellidoPaternoValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String apellidoMaterno = view.getApellidoMaternoField().getText();
|
String apellidoMaterno = view.getApellidoMaternoField().getText();
|
||||||
if (!this.validator.validateApellidoMaterno(apellidoMaterno)) return;
|
ValidationResult apellidoMaternoValidation = this.validator.validateApellidoMaterno(apellidoMaterno);
|
||||||
|
if(apellidoMaternoValidation.hasError()){
|
||||||
|
apellidoMaternoValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Autor autor = new Autor();
|
Autor autor = new Autor();
|
||||||
autor.setNombre(nombre);
|
autor.setNombre(nombre);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.BaseTableModel;
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.repository.AutorRepository;
|
import xyz.danielcortes.repository.AutorRepository;
|
||||||
import xyz.danielcortes.validator.AutorValidator;
|
import xyz.danielcortes.validator.AutorValidator;
|
||||||
@@ -57,8 +58,12 @@ public class AutorSearchController extends BaseController {
|
|||||||
Autor autor = this.getSelectedAutor();
|
Autor autor = this.getSelectedAutor();
|
||||||
if (autor == null)
|
if (autor == null)
|
||||||
return;
|
return;
|
||||||
if(!this.validator.isDeleteable(autor))
|
|
||||||
|
ValidationResult autorValidation = this.validator.isDeleteable(autor);
|
||||||
|
if(autorValidation.hasError()) {
|
||||||
|
autorValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package xyz.danielcortes.controllers.autor;
|
|||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.repository.AutorRepository;
|
import xyz.danielcortes.repository.AutorRepository;
|
||||||
import xyz.danielcortes.validator.AutorValidator;
|
import xyz.danielcortes.validator.AutorValidator;
|
||||||
@@ -50,20 +51,32 @@ public class AutorUpdateController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
if (!this.validator.validateOriginal(this.autor))
|
ValidationResult autorValidation = this.validator.validateOriginal(this.autor);
|
||||||
|
if(autorValidation.hasError()){
|
||||||
|
autorValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String nombre = this.view.getNombreField().getText();
|
String nombre = this.view.getNombreField().getText();
|
||||||
if (!this.validator.validateNombre(nombre))
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if (nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String apellidoPaterno = this.view.getApellidoPaternoField().getText();
|
String apellidoPaterno = view.getApellidoPaternoField().getText();
|
||||||
if (!this.validator.validateApellidoPaterno(apellidoPaterno))
|
ValidationResult apellidoPaternoValidation = this.validator.validateApellidoPaterno(apellidoPaterno);
|
||||||
|
if(apellidoPaternoValidation.hasError()){
|
||||||
|
apellidoPaternoValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String apellidoMaterno = this.view.getApellidoMaternoField().getText();
|
String apellidoMaterno = view.getApellidoMaternoField().getText();
|
||||||
if (!this.validator.validateApellidoMaterno(apellidoMaterno))
|
ValidationResult apellidoMaternoValidation = this.validator.validateApellidoMaterno(apellidoMaterno);
|
||||||
|
if(apellidoMaternoValidation.hasError()){
|
||||||
|
apellidoMaternoValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert this.autor != null;
|
assert this.autor != null;
|
||||||
this.autor.setNombre(nombre);
|
this.autor.setNombre(nombre);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.danielcortes.controllers.categoria;
|
|||||||
|
|
||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.repository.CategoriaRepository;
|
import xyz.danielcortes.repository.CategoriaRepository;
|
||||||
import xyz.danielcortes.validator.CategoriaValidator;
|
import xyz.danielcortes.validator.CategoriaValidator;
|
||||||
@@ -34,7 +35,11 @@ public class CategoriaCreateController extends BaseController {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String nombre = view.getNombreField().getText();
|
String nombre = view.getNombreField().getText();
|
||||||
if(!this.validator.validateNombre(nombre)) return;
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Categoria categoria = new Categoria();
|
Categoria categoria = new Categoria();
|
||||||
categoria.setNombre(nombre);
|
categoria.setNombre(nombre);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.BaseTableModel;
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.repository.CategoriaRepository;
|
import xyz.danielcortes.repository.CategoriaRepository;
|
||||||
import xyz.danielcortes.validator.CategoriaValidator;
|
import xyz.danielcortes.validator.CategoriaValidator;
|
||||||
@@ -55,8 +56,12 @@ public class CategoriaSearchController extends BaseController {
|
|||||||
Categoria categoria = this.getSelectedCategoria();
|
Categoria categoria = this.getSelectedCategoria();
|
||||||
if (categoria == null)
|
if (categoria == null)
|
||||||
return;
|
return;
|
||||||
if(!this.validator.isDeleteable(categoria))
|
|
||||||
|
ValidationResult deleteableValidation = this.validator.isDeleteable(categoria);
|
||||||
|
if(deleteableValidation.hasError()){
|
||||||
|
deleteableValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package xyz.danielcortes.controllers.categoria;
|
package xyz.danielcortes.controllers.categoria;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.repository.CategoriaRepository;
|
import xyz.danielcortes.repository.CategoriaRepository;
|
||||||
|
import xyz.danielcortes.validator.CategoriaValidator;
|
||||||
import xyz.danielcortes.views.BasePanel;
|
import xyz.danielcortes.views.BasePanel;
|
||||||
import xyz.danielcortes.views.categoria.CategoriaUpdatePanel;
|
import xyz.danielcortes.views.categoria.CategoriaUpdatePanel;
|
||||||
|
|
||||||
@@ -14,12 +15,13 @@ public class CategoriaUpdateController extends BaseController {
|
|||||||
private Categoria categoria;
|
private Categoria categoria;
|
||||||
private CategoriaUpdatePanel view;
|
private CategoriaUpdatePanel view;
|
||||||
private CategoriaRepository categoriaRepository;
|
private CategoriaRepository categoriaRepository;
|
||||||
|
private CategoriaValidator validator;
|
||||||
|
|
||||||
public CategoriaUpdateController(CategoriaUpdatePanel view, LaunchController parent) {
|
public CategoriaUpdateController(CategoriaUpdatePanel view, LaunchController parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.categoriaRepository = new CategoriaRepository();
|
this.categoriaRepository = new CategoriaRepository();
|
||||||
|
this.validator = new CategoriaValidator(this.categoriaRepository);
|
||||||
this.setupListeners();
|
this.setupListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,12 +43,18 @@ public class CategoriaUpdateController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
if (!validateOriginal(this.categoria))
|
ValidationResult originalValidation = this.validator.validateOriginal(this.categoria);
|
||||||
|
if(originalValidation.hasError()){
|
||||||
|
originalValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String nombre = this.view.getNombreField().getText();
|
String nombre = this.view.getNombreField().getText();
|
||||||
if (!validateNombre(nombre))
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert this.categoria != null;
|
assert this.categoria != null;
|
||||||
this.categoria.setNombre(nombre);
|
this.categoria.setNombre(nombre);
|
||||||
@@ -55,37 +63,6 @@ public class CategoriaUpdateController extends BaseController {
|
|||||||
this.getParentController().showCard(PanelName.CATEGORIA_SEARCH);
|
this.getParentController().showCard(PanelName.CATEGORIA_SEARCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateOriginal(Categoria original) {
|
|
||||||
if (original == null) {
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
null,
|
|
||||||
"No hay categoria seleccionada",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean validateNombre(String nombre) {
|
|
||||||
if (nombre == null) {
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
this.view.getContentPane(),
|
|
||||||
"El nombre es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (nombre.isEmpty()) {
|
|
||||||
JOptionPane.showMessageDialog(this.view.getContentPane(),
|
|
||||||
"El nombre esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BasePanel getView() {
|
public BasePanel getView() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.repository.CategoriaRepository;
|
|
||||||
import xyz.danielcortes.views.BasePanel;
|
import xyz.danielcortes.views.BasePanel;
|
||||||
import xyz.danielcortes.views.categoria.CategoriaViewPanel;
|
import xyz.danielcortes.views.categoria.CategoriaViewPanel;
|
||||||
|
|
||||||
@@ -12,12 +11,10 @@ public class CategoriaViewController extends BaseController {
|
|||||||
|
|
||||||
private Categoria categoria;
|
private Categoria categoria;
|
||||||
private CategoriaViewPanel view;
|
private CategoriaViewPanel view;
|
||||||
private CategoriaRepository categoriaRepository;
|
|
||||||
|
|
||||||
public CategoriaViewController(CategoriaViewPanel view, LaunchController parent) {
|
public CategoriaViewController(CategoriaViewPanel view, LaunchController parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.categoriaRepository = new CategoriaRepository();
|
|
||||||
this.setupListeners();
|
this.setupListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.danielcortes.controllers.editorial;
|
|||||||
|
|
||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
import xyz.danielcortes.repository.EditorialRepository;
|
import xyz.danielcortes.repository.EditorialRepository;
|
||||||
import xyz.danielcortes.validator.EditorialValidator;
|
import xyz.danielcortes.validator.EditorialValidator;
|
||||||
@@ -35,7 +36,11 @@ public class EditorialCreateController extends BaseController {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String nombre = this.view.getNombreField().getText();
|
String nombre = this.view.getNombreField().getText();
|
||||||
if(!this.validator.validateNombre(nombre)) return;
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Editorial editorial = new Editorial();
|
Editorial editorial = new Editorial();
|
||||||
editorial.setNombre(nombre);
|
editorial.setNombre(nombre);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.BaseTableModel;
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
import xyz.danielcortes.repository.EditorialRepository;
|
import xyz.danielcortes.repository.EditorialRepository;
|
||||||
import xyz.danielcortes.validator.EditorialValidator;
|
import xyz.danielcortes.validator.EditorialValidator;
|
||||||
@@ -64,8 +65,11 @@ public class EditorialSearchController extends BaseController {
|
|||||||
Editorial editorial = this.getSelectedEditorial();
|
Editorial editorial = this.getSelectedEditorial();
|
||||||
if (editorial == null)
|
if (editorial == null)
|
||||||
return;
|
return;
|
||||||
if(!this.validator.isDeleteable(editorial))
|
ValidationResult deleteableValidation = this.validator.isDeleteable(editorial);
|
||||||
|
if(deleteableValidation.hasError()){
|
||||||
|
deleteableValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package xyz.danielcortes.controllers.editorial;
|
|||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
import xyz.danielcortes.repository.EditorialRepository;
|
import xyz.danielcortes.repository.EditorialRepository;
|
||||||
import xyz.danielcortes.validator.EditorialValidator;
|
import xyz.danielcortes.validator.EditorialValidator;
|
||||||
@@ -43,12 +44,18 @@ public class EditorialUpdateController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
if (!this.validator.validateOriginal(this.editorial))
|
ValidationResult originalValidation = this.validator.validateOriginal(this.editorial);
|
||||||
|
if(originalValidation.hasError()){
|
||||||
|
originalValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String nombre = this.view.getNombreField().getText();
|
String nombre = this.view.getNombreField().getText();
|
||||||
if (!this.validator.validateNombre(nombre))
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert this.editorial != null;
|
assert this.editorial != null;
|
||||||
this.editorial.setNombre(nombre);
|
this.editorial.setNombre(nombre);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.danielcortes.controllers.idioma;
|
|||||||
|
|
||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Idioma;
|
import xyz.danielcortes.models.Idioma;
|
||||||
import xyz.danielcortes.repository.IdiomaRepository;
|
import xyz.danielcortes.repository.IdiomaRepository;
|
||||||
import xyz.danielcortes.validator.IdiomaValidator;
|
import xyz.danielcortes.validator.IdiomaValidator;
|
||||||
@@ -35,8 +36,11 @@ public class IdiomaCreateController extends BaseController {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String nombre = view.getNombreField().getText();
|
String nombre = view.getNombreField().getText();
|
||||||
if (!this.validator.validateNombre(nombre))
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Idioma idioma = new Idioma();
|
Idioma idioma = new Idioma();
|
||||||
idioma.setNombre(nombre);
|
idioma.setNombre(nombre);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.BaseTableModel;
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Idioma;
|
import xyz.danielcortes.models.Idioma;
|
||||||
import xyz.danielcortes.repository.IdiomaRepository;
|
import xyz.danielcortes.repository.IdiomaRepository;
|
||||||
import xyz.danielcortes.validator.IdiomaValidator;
|
import xyz.danielcortes.validator.IdiomaValidator;
|
||||||
@@ -66,8 +67,12 @@ public class IdiomaSearchController extends BaseController {
|
|||||||
Idioma idioma = this.getSelectedIdioma();
|
Idioma idioma = this.getSelectedIdioma();
|
||||||
if(idioma == null)
|
if(idioma == null)
|
||||||
return;
|
return;
|
||||||
if(!this.validator.isDeleteable(idioma))
|
|
||||||
|
ValidationResult deleteableValidation = this.validator.isDeleteable(idioma);
|
||||||
|
if(deleteableValidation.hasError()){
|
||||||
|
deleteableValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
int option = JOptionPane.showConfirmDialog(
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package xyz.danielcortes.controllers.idioma;
|
|||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Idioma;
|
import xyz.danielcortes.models.Idioma;
|
||||||
import xyz.danielcortes.repository.IdiomaRepository;
|
import xyz.danielcortes.repository.IdiomaRepository;
|
||||||
import xyz.danielcortes.validator.IdiomaValidator;
|
import xyz.danielcortes.validator.IdiomaValidator;
|
||||||
@@ -42,10 +43,18 @@ public class IdiomaUpdateController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
if (!this.validator.validateOriginal(this.idioma)) return;
|
ValidationResult originalValidation = this.validator.validateOriginal(this.idioma);
|
||||||
|
if(originalValidation.hasError()){
|
||||||
|
originalValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String nombre = this.view.getNombreField().getText();
|
String nombre = this.view.getNombreField().getText();
|
||||||
if (!this.validator.validateNombre(nombre)) return;
|
ValidationResult nombreValidation = this.validator.validateNombre(nombre);
|
||||||
|
if(nombreValidation.hasError()){
|
||||||
|
nombreValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert this.idioma != null;
|
assert this.idioma != null;
|
||||||
this.idioma.setNombre(nombre);
|
this.idioma.setNombre(nombre);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import javax.swing.JComboBox;
|
|||||||
import xyz.danielcortes.controllers.BaseController;
|
import xyz.danielcortes.controllers.BaseController;
|
||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
@@ -64,32 +65,68 @@ public class LibroCreateController extends BaseController {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String isbn = this.view.getIsbnField().getText();
|
String isbn = this.view.getIsbnField().getText();
|
||||||
if(!validator.validateISBN(isbn)) return;
|
ValidationResult isbnValidation = this.validator.validateISBN(isbn);
|
||||||
|
if(isbnValidation.hasError()){
|
||||||
|
isbnValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
isbn = isbn.replaceAll("[^\\d]", "");
|
isbn = isbn.replaceAll("[^\\d]", "");
|
||||||
|
|
||||||
String titulo = this.view.getTituloField().getText();
|
String titulo = this.view.getTituloField().getText();
|
||||||
if(!validator.validateTitulo(titulo)) return;
|
ValidationResult tituloValidation = this.validator.validateTitulo(titulo);
|
||||||
|
if(tituloValidation.hasError()){
|
||||||
|
tituloValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String numeroPaginas = this.view.getPaginasField().getText();
|
String numeroPaginas = this.view.getPaginasField().getText();
|
||||||
if(!validator.validateNumeroPaginas(numeroPaginas)) return;
|
ValidationResult numeroPaginasValidation = this.validator.validateNumeroPaginas(numeroPaginas);
|
||||||
|
if(numeroPaginasValidation.hasError()){
|
||||||
|
numeroPaginasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String anoPublicacion = this.view.getAnoPublicacionField().getText();
|
String anoPublicacion = this.view.getAnoPublicacionField().getText();
|
||||||
if(!validator.validateAnoPublicacion(anoPublicacion)) return;
|
ValidationResult anoPublicacionValidation = this.validator.validateAnoPublicacion(anoPublicacion);
|
||||||
|
if(anoPublicacionValidation.hasError()){
|
||||||
|
anoPublicacionValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String precioReferencial = this.view.getPrecioReferenciaField().getText();
|
String precioReferencial = this.view.getPrecioReferenciaField().getText();
|
||||||
if(!validator.validatePrecioReferencia(precioReferencial)) return;
|
ValidationResult precioReferencialValidation = this.validator.validatePrecioReferencia(precioReferencial);
|
||||||
|
if(precioReferencialValidation.hasError()){
|
||||||
|
precioReferencialValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Idioma> idiomas = this.view.getIdiomasList().getSelectedValuesList();
|
List<Idioma> idiomas = this.view.getIdiomasList().getSelectedValuesList();
|
||||||
if(!validator.validateIdiomas(idiomas)) return;
|
ValidationResult idiomasValidation = this.validator.validateIdiomas(idiomas);
|
||||||
|
if(idiomasValidation.hasError()){
|
||||||
|
idiomasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Autor> autores = this.view.getAutoresList().getSelectedValuesList();
|
List<Autor> autores = this.view.getAutoresList().getSelectedValuesList();
|
||||||
if(!validator.validateAutores(autores)) return;
|
ValidationResult autoresValidation = this.validator.validateAutores(autores);
|
||||||
|
if(autoresValidation.hasError()) {
|
||||||
|
autoresValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Categoria> categorias = this.view.getCategoriasList().getSelectedValuesList();
|
List<Categoria> categorias = this.view.getCategoriasList().getSelectedValuesList();
|
||||||
if(!validator.validateCategorias(categorias)) return;
|
ValidationResult categoriasValidation = this.validator.validateCategorias(categorias);
|
||||||
|
if(categoriasValidation.hasError()){
|
||||||
|
categoriasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Editorial editorial = (Editorial) this.view.getEditorialCombo().getSelectedItem();
|
Editorial editorial = (Editorial) this.view.getEditorialCombo().getSelectedItem();
|
||||||
if(!validator.validateEditorial(editorial)) return;
|
ValidationResult editorialValidation = this.validator.validateEditorial(editorial);
|
||||||
|
if(editorialValidation.hasError()){
|
||||||
|
editorialValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Libro libro = new Libro();
|
Libro libro = new Libro();
|
||||||
libro.setIsbn(isbn);
|
libro.setIsbn(isbn);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.BaseTableModel;
|
import xyz.danielcortes.framework.BaseTableModel;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Ejemplar;
|
import xyz.danielcortes.models.Ejemplar;
|
||||||
import xyz.danielcortes.models.Libro;
|
import xyz.danielcortes.models.Libro;
|
||||||
import xyz.danielcortes.repository.EjemplarRepository;
|
import xyz.danielcortes.repository.EjemplarRepository;
|
||||||
@@ -110,8 +111,11 @@ public class LibroSearchController extends BaseController {
|
|||||||
if (serie == null)
|
if (serie == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this.ejemplarValidator.validateSerie(serie, libro.getId()))
|
ValidationResult ejemplarValidation = this.ejemplarValidator.validateSerie(serie, libro.getId());
|
||||||
|
if (ejemplarValidation.hasError()){
|
||||||
|
ejemplarValidation.showErrorDialog();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Ejemplar ejemplar = new Ejemplar();
|
Ejemplar ejemplar = new Ejemplar();
|
||||||
ejemplar.setLibro(libro);
|
ejemplar.setLibro(libro);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import xyz.danielcortes.controllers.BaseController;
|
|||||||
import xyz.danielcortes.controllers.LaunchController;
|
import xyz.danielcortes.controllers.LaunchController;
|
||||||
import xyz.danielcortes.framework.JListUtils;
|
import xyz.danielcortes.framework.JListUtils;
|
||||||
import xyz.danielcortes.framework.PanelName;
|
import xyz.danielcortes.framework.PanelName;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
@@ -86,37 +87,75 @@ public class LibroUpdateController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
// @formatter:off
|
ValidationResult libroValidation = this.validator.validateLibro(this.libro);
|
||||||
if(!validator.validateLibro(libro)) return;
|
if(libroValidation.hasError()){
|
||||||
|
libroValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String isbn = this.view.getIsbnField().getText();
|
String isbn = this.view.getIsbnField().getText();
|
||||||
if(!validator.validateISBN(isbn)) return;
|
ValidationResult isbnValidation = this.validator.validateISBN(isbn);
|
||||||
|
if(isbnValidation.hasError()){
|
||||||
|
isbnValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
isbn = isbn.replaceAll("[^\\d]", "");
|
isbn = isbn.replaceAll("[^\\d]", "");
|
||||||
|
|
||||||
String titulo = this.view.getTituloField().getText();
|
String titulo = this.view.getTituloField().getText();
|
||||||
if(!validator.validateTitulo(titulo)) return;
|
ValidationResult tituloValidation = this.validator.validateTitulo(titulo);
|
||||||
|
if(tituloValidation.hasError()){
|
||||||
|
tituloValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String numeroPaginas = this.view.getPaginasField().getText();
|
String numeroPaginas = this.view.getPaginasField().getText();
|
||||||
if(!validator.validateNumeroPaginas(numeroPaginas)) return;
|
ValidationResult numeroPaginasValidation = this.validator.validateNumeroPaginas(numeroPaginas);
|
||||||
|
if(numeroPaginasValidation.hasError()){
|
||||||
|
numeroPaginasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String anoPublicacion = this.view.getAnoPublicacionField().getText();
|
String anoPublicacion = this.view.getAnoPublicacionField().getText();
|
||||||
if(!validator.validateAnoPublicacion(anoPublicacion)) return;
|
ValidationResult anoPublicacionValidation = this.validator.validateAnoPublicacion(anoPublicacion);
|
||||||
|
if(anoPublicacionValidation.hasError()){
|
||||||
|
anoPublicacionValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String precioReferencial = this.view.getPrecioReferenciaField().getText();
|
String precioReferencial = this.view.getPrecioReferenciaField().getText();
|
||||||
if(!validator.validatePrecioReferencia(precioReferencial)) return;
|
ValidationResult precioReferencialValidation = this.validator.validatePrecioReferencia(precioReferencial);
|
||||||
|
if(precioReferencialValidation.hasError()){
|
||||||
|
precioReferencialValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Idioma> idiomas = this.view.getIdiomasList().getSelectedValuesList();
|
List<Idioma> idiomas = this.view.getIdiomasList().getSelectedValuesList();
|
||||||
if(!validator.validateIdiomas(idiomas)) return;
|
ValidationResult idiomasValidation = this.validator.validateIdiomas(idiomas);
|
||||||
|
if(idiomasValidation.hasError()){
|
||||||
|
idiomasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Autor> autores = this.view.getAutoresList().getSelectedValuesList();
|
List<Autor> autores = this.view.getAutoresList().getSelectedValuesList();
|
||||||
if(!validator.validateAutores(autores)) return;
|
ValidationResult autoresValidation = this.validator.validateAutores(autores);
|
||||||
|
if(autoresValidation.hasError()) {
|
||||||
|
autoresValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<Categoria> categorias = this.view.getCategoriasList().getSelectedValuesList();
|
List<Categoria> categorias = this.view.getCategoriasList().getSelectedValuesList();
|
||||||
if(!validator.validateCategorias(categorias)) return;
|
ValidationResult categoriasValidation = this.validator.validateCategorias(categorias);
|
||||||
|
if(categoriasValidation.hasError()){
|
||||||
|
categoriasValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Editorial editorial = (Editorial) this.view.getEditorialCombo().getSelectedItem();
|
Editorial editorial = (Editorial) this.view.getEditorialCombo().getSelectedItem();
|
||||||
if(!validator.validateEditorial(editorial)) return;
|
ValidationResult editorialValidation = this.validator.validateEditorial(editorial);
|
||||||
// @formatter:on
|
if(editorialValidation.hasError()){
|
||||||
|
editorialValidation.showErrorDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert libro != null;
|
assert libro != null;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package xyz.danielcortes.framework;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
public class ValidationResult {
|
||||||
|
public static ValidationResult NON_ERROR = new ValidationResult();
|
||||||
|
private String message;
|
||||||
|
private String title;
|
||||||
|
private boolean hasError;
|
||||||
|
|
||||||
|
private ValidationResult(){
|
||||||
|
this.hasError = false;
|
||||||
|
this.message = "No hubo error";
|
||||||
|
this.title = "Info";
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationResult(String message){
|
||||||
|
this.title = "Error";
|
||||||
|
this.message = message;
|
||||||
|
this.hasError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationResult(String message, String title) {
|
||||||
|
this.title = title;
|
||||||
|
this.message = message;
|
||||||
|
this.hasError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasError() {
|
||||||
|
return hasError;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showErrorDialog() {
|
||||||
|
if(this.hasError)
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
null,
|
||||||
|
this.message,
|
||||||
|
this.title,
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package xyz.danielcortes.validator;
|
package xyz.danielcortes.validator;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.repository.AutorRepository;
|
import xyz.danielcortes.repository.AutorRepository;
|
||||||
|
|
||||||
@@ -12,87 +12,45 @@ public class AutorValidator {
|
|||||||
this.autorRepository = autorRepository;
|
this.autorRepository = autorRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateNombre(String nombre) {
|
public ValidationResult validateNombre(String nombre) {
|
||||||
if (nombre == null) {
|
if (nombre == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre es nulo");
|
||||||
null,
|
|
||||||
"El nombre es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (nombre.isEmpty()) {
|
} else if (nombre.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre esta vacio");
|
||||||
null,
|
|
||||||
"El nombre esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateApellidoPaterno(String apellidoPaterno) {
|
public ValidationResult validateApellidoPaterno(String apellidoPaterno) {
|
||||||
if (apellidoPaterno == null) {
|
if (apellidoPaterno == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El apellido paterno es nulo");
|
||||||
null,
|
|
||||||
"El apellido paterno es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (apellidoPaterno.isEmpty()) {
|
} else if (apellidoPaterno.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El apellido paterno esta vacio");
|
||||||
null,
|
|
||||||
"El apellido paterno esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateApellidoMaterno(String apellidoMaterno) {
|
public ValidationResult validateApellidoMaterno(String apellidoMaterno) {
|
||||||
if (apellidoMaterno == null) {
|
if (apellidoMaterno == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El apellido materno es nulo");
|
||||||
null,
|
|
||||||
"El apellido materno es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (apellidoMaterno.isEmpty()) {
|
} else if (apellidoMaterno.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El apellido materno esta vacío");
|
||||||
null,
|
|
||||||
"El apellido materno esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateOriginal(Autor original) {
|
public ValidationResult validateOriginal(Autor original) {
|
||||||
if (original == null) {
|
if (original == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay Autor seleccionado");
|
||||||
null,
|
|
||||||
"No hay Autor seleccionado",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleteable(Autor autor){
|
public ValidationResult isDeleteable(Autor autor){
|
||||||
if(autor.getLibros().size() > 0){
|
if(autor.getLibros().size() > 0){
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No se puede eliminar el autor ya que tiene libros asociados");
|
||||||
null,
|
|
||||||
"No se puede eliminar el autor ya que tiene libros asociados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package xyz.danielcortes.validator;
|
package xyz.danielcortes.validator;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.repository.CategoriaRepository;
|
import xyz.danielcortes.repository.CategoriaRepository;
|
||||||
|
|
||||||
@@ -12,34 +12,27 @@ public class CategoriaValidator {
|
|||||||
this.categoriaRepository = categoriaRepository;
|
this.categoriaRepository = categoriaRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateNombre(String nombre) {
|
public ValidationResult validateNombre(String nombre) {
|
||||||
if (nombre == null) {
|
if (nombre == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre es nulo");
|
||||||
null,
|
|
||||||
"El nombre es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (nombre.isEmpty()) {
|
} else if (nombre.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre esta vacío");
|
||||||
null,
|
|
||||||
"El nombre esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleteable(Categoria categoria){
|
public ValidationResult validateOriginal(Categoria categoria){
|
||||||
|
if(categoria == null){
|
||||||
|
return new ValidationResult("No hay categoria seleccionada");
|
||||||
|
}
|
||||||
|
return ValidationResult.NON_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationResult isDeleteable(Categoria categoria){
|
||||||
if(categoria.getLibros().size() > 0){
|
if(categoria.getLibros().size() > 0){
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No se puede eliminar la categoria ya que tiene libros asociados");
|
||||||
null,
|
|
||||||
"No se puede eliminar la categoria ya que tiene libros asociados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package xyz.danielcortes.validator;
|
package xyz.danielcortes.validator;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
import xyz.danielcortes.repository.EditorialRepository;
|
import xyz.danielcortes.repository.EditorialRepository;
|
||||||
|
|
||||||
@@ -12,49 +12,27 @@ public class EditorialValidator {
|
|||||||
this.editorialRepository = editorialRepository;
|
this.editorialRepository = editorialRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateNombre(String nombre) {
|
public ValidationResult validateNombre(String nombre) {
|
||||||
if (nombre == null) {
|
if (nombre == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre es nulo");
|
||||||
null,
|
|
||||||
"El nombre es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (nombre.isEmpty()) {
|
} else if (nombre.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre esta vacío");
|
||||||
null,
|
|
||||||
"El nombre esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateOriginal(Editorial original) {
|
public ValidationResult validateOriginal(Editorial original) {
|
||||||
if (original == null) {
|
if (original == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay Editorial seleccionada");
|
||||||
null,
|
|
||||||
"No hay Editorial seleccionada",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleteable(Editorial editorial){
|
public ValidationResult isDeleteable(Editorial editorial){
|
||||||
if(editorial.getLibros().size() > 0){
|
if(editorial.getLibros().size() > 0){
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No se puede eliminar la editorial ya que tiene libros asociados");
|
||||||
null,
|
|
||||||
"No se puede eliminar la editorial ya que tiene libros asociados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package xyz.danielcortes.validator;
|
package xyz.danielcortes.validator;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.repository.EjemplarRepository;
|
import xyz.danielcortes.repository.EjemplarRepository;
|
||||||
|
|
||||||
public class EjemplarValidator {
|
public class EjemplarValidator {
|
||||||
@@ -11,32 +11,17 @@ public class EjemplarValidator {
|
|||||||
this.ejemplarRepository = ejemplarRepository;
|
this.ejemplarRepository = ejemplarRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateSerie(String serie, Integer libro_id) {
|
public ValidationResult validateSerie(String serie, Integer libro_id) {
|
||||||
if (serie == null) {
|
if (serie == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("La serie es nula");
|
||||||
null,
|
|
||||||
"La serie es nula",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (serie.isEmpty()) {
|
if (serie.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("La serie esta vacia");
|
||||||
null,
|
|
||||||
"La serie esta vacia",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (ejemplarRepository.exists(serie, libro_id)) {
|
if (ejemplarRepository.exists(serie, libro_id)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El numero de serie ya existe");
|
||||||
null,
|
|
||||||
"El numero de serie ya existe",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package xyz.danielcortes.validator;
|
package xyz.danielcortes.validator;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Idioma;
|
import xyz.danielcortes.models.Idioma;
|
||||||
import xyz.danielcortes.repository.IdiomaRepository;
|
import xyz.danielcortes.repository.IdiomaRepository;
|
||||||
|
|
||||||
@@ -13,49 +13,27 @@ public class IdiomaValidator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateOriginal(Idioma original) {
|
public ValidationResult validateOriginal(Idioma original) {
|
||||||
if (original == null) {
|
if (original == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay Idioma seleccionado");
|
||||||
null,
|
|
||||||
"No hay Idioma seleccionado",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateNombre(String nombre) {
|
public ValidationResult validateNombre(String nombre) {
|
||||||
if (nombre == null) {
|
if (nombre == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre es nulo");
|
||||||
null,
|
|
||||||
"El nombre es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
} else if (nombre.isEmpty()) {
|
} else if (nombre.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El nombre esta vacío");
|
||||||
null,
|
|
||||||
"El nombre esta vacío",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleteable(Idioma idioma){
|
public ValidationResult isDeleteable(Idioma idioma) {
|
||||||
if (idioma.getLibros().size() > 0) {
|
if (idioma.getLibros().size() > 0) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No se puede eliminar el idioma ya que tiene libros asociados");
|
||||||
null,
|
|
||||||
"No se puede eliminar el idioma ya que tiene libros asociados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package xyz.danielcortes.validator;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import xyz.danielcortes.framework.GeneralValidator;
|
import xyz.danielcortes.framework.GeneralValidator;
|
||||||
|
import xyz.danielcortes.framework.ValidationResult;
|
||||||
import xyz.danielcortes.models.Autor;
|
import xyz.danielcortes.models.Autor;
|
||||||
import xyz.danielcortes.models.Categoria;
|
import xyz.danielcortes.models.Categoria;
|
||||||
import xyz.danielcortes.models.Editorial;
|
import xyz.danielcortes.models.Editorial;
|
||||||
@@ -19,239 +19,122 @@ public class LibroValidator {
|
|||||||
this.libroRepository = libroRepository;
|
this.libroRepository = libroRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateLibro(Libro libro) {
|
public ValidationResult validateLibro(Libro libro) {
|
||||||
if (libro == null) {
|
if (libro == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay Libro seleccionado");
|
||||||
null,
|
|
||||||
"No hay Libro seleccionado",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateISBN(String isbn) {
|
public ValidationResult validateISBN(String isbn) {
|
||||||
if (isbn == null) {
|
if (isbn == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El ISBN es nulo");
|
||||||
null,
|
|
||||||
"El ISBN es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (isbn.isEmpty()) {
|
if (isbn.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El ISBN esta vacio");
|
||||||
null,
|
|
||||||
"El ISBN esta vacio",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isbn = isbn.replaceAll("[^\\d]", "");
|
isbn = isbn.replaceAll("[^\\d]", "");
|
||||||
if ((isbn.length() == 13 && !ISBN13CheckSum(isbn))
|
if ((isbn.length() == 13 && !ISBN13CheckSum(isbn))
|
||||||
|| (isbn.length() == 10 && !ISBN10CheckSum(isbn))
|
|| (isbn.length() == 10 && !ISBN10CheckSum(isbn))
|
||||||
|| (isbn.length() != 10 && isbn.length() != 13)) {
|
|| (isbn.length() != 10 && isbn.length() != 13)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El ISBN no es valido");
|
||||||
null,
|
|
||||||
"El ISBN no es valido",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateTitulo(String titulo) {
|
public ValidationResult validateTitulo(String titulo) {
|
||||||
if (titulo == null) {
|
if (titulo == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El titulo es nulo");
|
||||||
null,
|
|
||||||
"El titulo es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (titulo.isEmpty()) {
|
if (titulo.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El titulo esta vacio");
|
||||||
null,
|
|
||||||
"El titulo esta vacio",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateNumeroPaginas(String numeroPaginas) {
|
public ValidationResult validateNumeroPaginas(String numeroPaginas) {
|
||||||
if (numeroPaginas == null) {
|
if (numeroPaginas == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El numero de paginas es nulo");
|
||||||
null,
|
|
||||||
"El numero de paginas es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (numeroPaginas.isEmpty()) {
|
if (numeroPaginas.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El numero de paginas esta vacio");
|
||||||
null,
|
|
||||||
"El numero de paginas esta vacio",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!GeneralValidator.isInteger(numeroPaginas)) {
|
if (!GeneralValidator.isInteger(numeroPaginas)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El numero de paginas no es un numero");
|
||||||
null,
|
}
|
||||||
"El numero de paginas no es un numero",
|
return ValidationResult.NON_ERROR;
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
public ValidationResult validatePrecioReferencia(String precioReferencia) {
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validatePrecioReferencia(String precioReferencia) {
|
|
||||||
if (precioReferencia == null) {
|
if (precioReferencia == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El precio referencial es nulo");
|
||||||
null,
|
|
||||||
"El precio referencial es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (precioReferencia.isEmpty()) {
|
if (precioReferencia.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El precio referencial esta vacio");
|
||||||
null,
|
|
||||||
"El precio referencial esta vacio",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!GeneralValidator.isInteger(precioReferencia)) {
|
if (!GeneralValidator.isInteger(precioReferencia)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El precio referencial no es un numero");
|
||||||
null,
|
|
||||||
"El precio referencial no es un numero",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateAnoPublicacion(String anoPublicacion) {
|
public ValidationResult validateAnoPublicacion(String anoPublicacion) {
|
||||||
if (anoPublicacion == null) {
|
if (anoPublicacion == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El año de publicacion es nulo");
|
||||||
null,
|
|
||||||
"El año de publicacion es nulo",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (anoPublicacion.isEmpty()) {
|
if (anoPublicacion.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El año de publicacion esta vacio");
|
||||||
null,
|
|
||||||
"El año de publicacion esta vacio",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!GeneralValidator.isInteger(anoPublicacion)) {
|
if (!GeneralValidator.isInteger(anoPublicacion)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El año de publicacion no es un numero");
|
||||||
null,
|
|
||||||
"El año de publicacion no es un numero",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (!GeneralValidator.isYear(anoPublicacion)) {
|
if (!GeneralValidator.isYear(anoPublicacion)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("El año de publicacion no es un año valido");
|
||||||
null,
|
|
||||||
"El año de publicacion no es un año valido",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateIdiomas(List<Idioma> idiomas) {
|
public ValidationResult validateIdiomas(List<Idioma> idiomas) {
|
||||||
if (idiomas.size() == 0) {
|
if (idiomas.size() == 0) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay idiomas seleccionados");
|
||||||
null,
|
|
||||||
"No hay idiomas seleccionados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (idiomas.stream().anyMatch(Objects::isNull)) {
|
if (idiomas.stream().anyMatch(Objects::isNull)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("Se selecciono un idioma no existente");
|
||||||
null,
|
|
||||||
"Se selecciono un idioma no existente",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateAutores(List<Autor> autores) {
|
public ValidationResult validateAutores(List<Autor> autores) {
|
||||||
if (autores.size() == 0) {
|
if (autores.size() == 0) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay autores seleccionados");
|
||||||
null,
|
|
||||||
"No hay autores seleccionados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (autores.stream().anyMatch(Objects::isNull)) {
|
if (autores.stream().anyMatch(Objects::isNull)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("Se selecciono un autor no existente");
|
||||||
null,
|
|
||||||
"Se selecciono un autor no existente",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateCategorias(List<Categoria> categorias) {
|
public ValidationResult validateCategorias(List<Categoria> categorias) {
|
||||||
if (categorias.size() == 0) {
|
if (categorias.size() == 0) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay categorias seleccionadas");
|
||||||
null,
|
|
||||||
"No hay autores seleccionados",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (categorias.stream().anyMatch(Objects::isNull)) {
|
if (categorias.stream().anyMatch(Objects::isNull)) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("Se selecciono una categoria no existente");
|
||||||
null,
|
|
||||||
"Se selecciono una categoria no existente",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validateEditorial(Editorial editorial) {
|
public ValidationResult validateEditorial(Editorial editorial) {
|
||||||
if (editorial == null) {
|
if (editorial == null) {
|
||||||
JOptionPane.showMessageDialog(
|
return new ValidationResult("No hay editorial seleccionada");
|
||||||
null,
|
|
||||||
"No hay editorial seleccionada",
|
|
||||||
"Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ValidationResult.NON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ISBN10CheckSum(String isbn) {
|
private boolean ISBN10CheckSum(String isbn) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class LaunchFrame extends JFrame {
|
|||||||
this.setMinimumSize(this.dimension);
|
this.setMinimumSize(this.dimension);
|
||||||
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
|
this.setTitle("Biblioteca");
|
||||||
this.setupCardPanel();
|
this.setupCardPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user