mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-19 15:20:20 +00:00
movidos los ficheros por funciones
This commit is contained in:
@ -1,85 +0,0 @@
|
||||
package com.imprimelibros.erp.config.Presupuestador;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ImagenPresupuesto {
|
||||
|
||||
private String id;
|
||||
private String imagen;
|
||||
private String alt;
|
||||
private String texto;
|
||||
private boolean selected = false;
|
||||
private Map<String, String> extra_data;
|
||||
|
||||
// Constructores
|
||||
public ImagenPresupuesto() {}
|
||||
|
||||
|
||||
public ImagenPresupuesto(String id, String imagen, String alt, String texto, boolean selected) {
|
||||
this.id = id;
|
||||
this.imagen = imagen;
|
||||
this.alt = alt;
|
||||
this.texto = texto;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
|
||||
public ImagenPresupuesto(String id, String imagen, String alt, String texto, Map<String, String> extra_data,boolean selected) {
|
||||
this.id = id;
|
||||
this.imagen = imagen;
|
||||
this.alt = alt;
|
||||
this.texto = texto;
|
||||
this.selected = selected;
|
||||
this.extra_data = extra_data;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getImagen() {
|
||||
return imagen;
|
||||
}
|
||||
|
||||
public void setImagen(String imagen) {
|
||||
this.imagen = imagen;
|
||||
}
|
||||
|
||||
public String getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(String alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public String getTexto() {
|
||||
return texto;
|
||||
}
|
||||
|
||||
public void setTexto(String texto) {
|
||||
this.texto = texto;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public Map<String, String> getExtra_data() {
|
||||
return extra_data;
|
||||
}
|
||||
|
||||
public void setExtra_data(Map<String, String> extra_data) {
|
||||
this.extra_data = extra_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,129 +0,0 @@
|
||||
package com.imprimelibros.erp.config.Presupuestador;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class PresupuestadorItems {
|
||||
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
public ImagenPresupuesto getImpresionNegro(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"negro",
|
||||
"/assets/images/imprimelibros/presupuestador/blancoYnegro.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.blanco-negro", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionNegroPremium(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"negrohq",
|
||||
"/assets/images/imprimelibros/presupuestador/negroFoto.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.blanco-negro-premium", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionColor(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"color",
|
||||
"/assets/images/imprimelibros/presupuestador/color.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.color", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionColorPremium(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"colorhq",
|
||||
"/assets/images/imprimelibros/presupuestador/colorFoto.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.color-premium", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetBlanco(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-blanco",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-blanco.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-blanco", null, locale),
|
||||
Map.of("sk-id", "3"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetBlancoVolumen(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-blanco-volumen",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-blanco.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-blanco-volumen", null, locale),
|
||||
Map.of("sk-id", "7"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetAhuesado(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-ahuesado",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-ahuesado.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-ahuesado", null, locale),
|
||||
Map.of("sk-id", "4"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetAhuesadoVolumen(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-ahuesado-volumen",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-ahuesado-volumen.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-ahuesado-volumen", null, locale),
|
||||
Map.of("sk-id", "6"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelEstucadoMate(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"estucado-mate",
|
||||
"/assets/images/imprimelibros/presupuestador/estucado-mate.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.estucado-mate", null, locale),
|
||||
Map.of("sk-id", "2"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getCartulinaGraficaCubierta(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"cartulina-grafica-cubierta",
|
||||
"/assets/images/imprimelibros/presupuestador/cartulina-grafica.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.cartulina-grafica-cubierta", null, locale),
|
||||
Map.of("sk-id", "3"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getEstucadoMateCubierta(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"estucado-mate-cubierta",
|
||||
"/assets/images/imprimelibros/presupuestador/estucado-mate-cubierta.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.estucado-mate-cubierta", null, locale),
|
||||
Map.of("sk-id", "2"),
|
||||
false);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Constraint(validatedBy = ConsistentTiradasValidator.class)
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ConsistentTiradas {
|
||||
String message() default "Las tiradas deben ser todas mayores o todas menores al valor POD";
|
||||
Class<?>[] groups() default {};
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import com.imprimelibros.erp.entity.Presupuesto;
|
||||
import com.imprimelibros.erp.service.VariableService;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
public class ConsistentTiradasValidator implements ConstraintValidator<ConsistentTiradas, Presupuesto> {
|
||||
|
||||
@Autowired
|
||||
private VariableService variableService;
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
@Override
|
||||
public boolean isValid(Presupuesto presupuesto, ConstraintValidatorContext context) {
|
||||
if (presupuesto == null)
|
||||
return true;
|
||||
|
||||
Integer[] tiradas = presupuesto.getTiradas();
|
||||
Integer podValue = variableService.getValorEntero("POD");
|
||||
|
||||
boolean allAbove = true;
|
||||
boolean allBelow = true;
|
||||
|
||||
for (Integer t : tiradas) {
|
||||
if (t == null)
|
||||
continue;
|
||||
if (t <= podValue)
|
||||
allAbove = false;
|
||||
else // (t > podValue)
|
||||
allBelow = false;
|
||||
}
|
||||
|
||||
if (!(allAbove || allBelow)) {
|
||||
|
||||
String mensajeInterpolado = messageSource.getMessage(
|
||||
"presupuesto.errores.tiradas.consistentes", // clave del mensaje
|
||||
new Object[] { podValue }, // parámetros para {0}
|
||||
LocaleContextHolder.getLocale() // respeta el idioma actual
|
||||
);
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(mensajeInterpolado)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Constraint(validatedBy = ParValidator.class)
|
||||
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Par {
|
||||
String message() default "El valor debe ser un número par";
|
||||
Class<?>[] groups() default {};
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
public class ParValidator implements ConstraintValidator<Par, Integer> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||
if (value == null) return true; // se permite null, usa @NotNull aparte si lo necesitas
|
||||
return value % 2 == 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
public class PresupuestoValidationGroups {
|
||||
|
||||
public interface DatosGenerales {}
|
||||
public interface Interior {}
|
||||
public interface Cubierta {}
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Constraint(validatedBy = TamanioValidator.class)
|
||||
@Target({ ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Tamanio {
|
||||
|
||||
String message() default "{presupuesto.errores.tamanio.invalido}";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import com.imprimelibros.erp.entity.Presupuesto;
|
||||
import com.imprimelibros.erp.service.VariableService;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
public class TamanioValidator implements ConstraintValidator<Tamanio, Presupuesto>{
|
||||
|
||||
@Autowired
|
||||
private VariableService variableService;
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
@Override
|
||||
public boolean isValid(Presupuesto presupuesto, ConstraintValidatorContext context) {
|
||||
|
||||
if (presupuesto == null)
|
||||
return true;
|
||||
|
||||
Integer min = variableService.getValorEntero("ancho_alto_min");
|
||||
Integer max = variableService.getValorEntero("ancho_alto_max");
|
||||
|
||||
|
||||
if (presupuesto.getAncho() <= min || presupuesto.getAncho() >= max) {
|
||||
|
||||
String mensajeInterpolado = messageSource.getMessage(
|
||||
"presupuesto.errores.ancho.min_max", // clave del mensaje
|
||||
new Object[] { min, max }, // parámetros para {0}
|
||||
LocaleContextHolder.getLocale() // respeta el idioma actual
|
||||
);
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(mensajeInterpolado)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
else if (presupuesto.getAlto() <= min || presupuesto.getAlto() >= max) {
|
||||
|
||||
String mensajeInterpolado = messageSource.getMessage(
|
||||
"presupuesto.errores.alto.min_max", // clave del mensaje
|
||||
new Object[] { min, max }, // parámetros para {0}
|
||||
LocaleContextHolder.getLocale() // respeta el idioma actual
|
||||
);
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(mensajeInterpolado)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user