From 4fa4cdc6712d20eee94642b827009a0cf09ebf0d Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 19 Dec 2023 15:11:22 +0200 Subject: [PATCH] DescriptionTemplateTypePersist remove old validators --- .../DescriptionTemplateTypePersist.java | 67 ++++++------------- 1 file changed, 19 insertions(+), 48 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplateTypePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplateTypePersist.java index 59b9bb274..94c19c901 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplateTypePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionTemplateTypePersist.java @@ -8,7 +8,6 @@ import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.errorcode.ErrorThesaurusProperties; -import eu.eudat.model.Description; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; @@ -17,25 +16,16 @@ import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Component; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; - -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; -@FieldNotNullIfOtherSet(message = "{validation.hashempty}") public class DescriptionTemplateTypePersist { - @ValidId(message = "{validation.invalidid}") private UUID id; public final static String _id = "id"; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - @Size(max = DescriptionTemplateTypeEntity._nameLength, message = "{validation.largerthanmax}") private String name = null; public final static String _name = "name"; @@ -44,16 +34,15 @@ public class DescriptionTemplateTypePersist { public final static String _hash = "hash"; - @ValidEnum(message = "{validation.empty}") private DescriptionTemplateTypeStatus status; - private List nested; - - public final static String _nested = "nested"; - - private DescriptionTemplateTypePersist obj; - - public final static String _obj = "obj"; +// private List nested; +// +// public final static String _nested = "nested"; +// +// private DescriptionTemplateTypePersist obj; +// +// public final static String _obj = "obj"; public UUID getId() { return id; @@ -87,34 +76,16 @@ public class DescriptionTemplateTypePersist { this.status = status; } - public List getNested() { - return nested; - } - - public void setNested(List nested) { - this.nested = nested; - } - - public DescriptionTemplateTypePersist getObj() { - return obj; - } - - public void setObj(DescriptionTemplateTypePersist obj) { - this.obj = obj; - } - @Component(DescriptionTemplateTypePersistValidator.ValidatorName) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class DescriptionTemplateTypePersistValidator extends BaseValidator { public static final String ValidatorName = "DescriptionTemplateTypePersistValidator"; - private final ValidatorFactory validatorFactory; private final MessageSource messageSource; - public DescriptionTemplateTypePersistValidator(MessageSource messageSource, ValidatorFactory validatorFactory, ConventionService conventionService, ErrorThesaurusProperties errors) { + public DescriptionTemplateTypePersistValidator(MessageSource messageSource, ConventionService conventionService, ErrorThesaurusProperties errors) { super(conventionService, errors); this.messageSource = messageSource; - this.validatorFactory = validatorFactory; } @Override @@ -139,17 +110,17 @@ public class DescriptionTemplateTypePersist { this.spec() .iff(() -> !this.isEmpty(item.getName())) .must(() -> this.lessEqual(item.getName(), DescriptionTemplateTypeEntity._nameLength)) - .failOn(DescriptionTemplateTypePersist._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplateTypePersist._name}, LocaleContextHolder.getLocale())), - this.refSpec() - .iff(() -> item.getObj() != null) - .on(DescriptionTemplateTypePersist._obj) - .over(item.getObj()) - .using(() -> this.validatorFactory.validator(DescriptionTemplateTypePersistValidator.class)), - this.navSpec() - .iff(() -> item.getNested() != null) - .on(DescriptionTemplateTypePersist._nested) - .over(item.getNested()) - .using(() -> this.validatorFactory.validator(DescriptionTemplateTypePersistValidator.class)) + .failOn(DescriptionTemplateTypePersist._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplateTypePersist._name}, LocaleContextHolder.getLocale())) +// this.refSpec() +// .iff(() -> item.getObj() != null) +// .on(DescriptionTemplateTypePersist._obj) +// .over(item.getObj()) +// .using(() -> this.validatorFactory.validator(DescriptionTemplateTypePersistValidator.class)), +// this.navSpec() +// .iff(() -> item.getNested() != null) +// .on(DescriptionTemplateTypePersist._nested) +// .over(item.getNested()) +// .using(() -> this.validatorFactory.validator(DescriptionTemplateTypePersistValidator.class)) ); } }