diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java index 75a718ede..f852e3bca 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java @@ -1,26 +1,44 @@ package eu.eudat.model.persist.referencetypedefinition; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; -import eu.eudat.commons.validation.old.ValidEnum; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class AuthenticationConfigurationPersist { - @NotNull(message = "{validation.empty}") private Boolean enabled; - @NotNull(message = "{validation.empty}") + + public static final String _enabled = "enabled"; + private String authUrl; - @ValidEnum(message = "{validation.empty}") + public static final String _authUrl = "authUrl"; + private ReferenceTypeExternalApiHTTPMethodType authMethod; - @NotNull(message = "{validation.empty}") - private String authTokenPath ; - @NotNull(message = "{validation.empty}") + public static final String _authMethod = "authMethod"; + + private String authTokenPath; + + public static final String _authTokenPath = "authTokenPath"; + private String authRequestBody; - @NotNull(message = "{validation.empty}") + + public static final String _authRequestBody = "authRequestBody"; + private String type; + public static final String _type = "type"; + public Boolean getEnabled() { return enabled; } @@ -68,4 +86,31 @@ public class AuthenticationConfigurationPersist { public void setType(String type) { this.type = type; } + + @Component(AuthenticationConfigurationPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class AuthenticationConfigurationPersistValidator extends BaseValidator { + + public static final String ValidatorName = "AuthenticationConfigurationPersistValidator"; + + private final MessageSource messageSource; + + protected AuthenticationConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return AuthenticationConfigurationPersist.class; + } + + @Override + protected List specifications(AuthenticationConfigurationPersist item) { + return Arrays.asList( + + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DependencyPropertyPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DependencyPropertyPersist.java index ecfcd8bc5..c0b97c40c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DependencyPropertyPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DependencyPropertyPersist.java @@ -1,22 +1,32 @@ package eu.eudat.model.persist.referencetypedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import java.util.Arrays; +import java.util.List; public class DependencyPropertyPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _code = "code"; + private String target; - @NotNull(message = "{validation.empty}") + public static final String _target = "target"; + private Boolean required; + public static final String _required = "required"; + public String getCode() { return code; } @@ -40,4 +50,39 @@ public class DependencyPropertyPersist { public void setRequired(Boolean required) { this.required = required; } + + @Component(DependencyPropertyPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class DependencyPropertyPersistValidator extends BaseValidator { + + public static final String ValidatorName = "DependencyPropertyPersistValidator"; + + private final MessageSource messageSource; + + protected DependencyPropertyPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return DependencyPropertyPersist.class; + } + + @Override + protected List specifications(DependencyPropertyPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getCode())) + .failOn(DependencyPropertyPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{DependencyPropertyPersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getTarget())) + .failOn(DependencyPropertyPersist._target).failWith(messageSource.getMessage("Validation_Required", new Object[]{DependencyPropertyPersist._target}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getRequired())) + .failOn(DependencyPropertyPersist._required).failWith(messageSource.getMessage("Validation_Required", new Object[]{DependencyPropertyPersist._required}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java index 0c0bdf7f1..e2aac28fc 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java @@ -1,14 +1,26 @@ package eu.eudat.model.persist.referencetypedefinition; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; import jakarta.xml.bind.annotation.XmlElement; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; public class QueryConfigPersist { private String condition; - private String separator; - private String value; - private Integer ordinal; + private String separator; + + private String value; + + private Integer ordinal; public String getCondition() { return condition; @@ -45,4 +57,26 @@ public class QueryConfigPersist { public void setOrdinal(Integer ordinal) { this.ordinal = ordinal; } + + @Component(QueryConfigPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class QueryConfigPersistValidator extends BaseValidator { + + public static final String ValidatorName = "QueryConfigPersistValidator"; + + protected QueryConfigPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + } + + @Override + protected Class modelClass() { + return QueryConfigPersist.class; + } + + @Override + protected List specifications(QueryConfigPersist item) { + return new ArrayList<>(); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeFieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeFieldPersist.java index 1b26cf6a9..5140be51c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeFieldPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeFieldPersist.java @@ -8,25 +8,28 @@ import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class ReferenceTypeFieldPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code = null; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _code = "code"; + private String label = null; + public static final String _label = "label"; private String description; - @ValidEnum(message = "{validation.empty}") private ReferenceFieldDataType dataType; + public static final String _dataType = "dataType"; public String getCode() { return code; @@ -60,8 +63,12 @@ public class ReferenceTypeFieldPersist { this.dataType = dataType; } + @Component(ReferenceTypeFieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class ReferenceTypeFieldPersistValidator extends BaseValidator { + public static final String ValidatorName = "ReferenceTypeFieldPersistValidator"; + protected ReferenceTypeFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { super(conventionService, errors); } @@ -73,7 +80,9 @@ public class ReferenceTypeFieldPersist { @Override protected List specifications(ReferenceTypeFieldPersist item) { - return null; + return Arrays.asList( + + ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseDependencyPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseDependencyPersist.java index 8e4cfaf64..98958cfa0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseDependencyPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseDependencyPersist.java @@ -1,15 +1,14 @@ package eu.eudat.model.persist.referencetypedefinition; import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Component; import java.util.Arrays; @@ -73,9 +72,12 @@ public class ReferenceTypeSourceBaseDependencyPersist { private final MessageSource messageSource; - protected ReferenceTypeSourceBaseDependencyPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + private final ValidatorFactory validatorFactory; + + protected ReferenceTypeSourceBaseDependencyPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors); this.messageSource = messageSource; + this.validatorFactory = validatorFactory; } @Override @@ -86,7 +88,24 @@ public class ReferenceTypeSourceBaseDependencyPersist { @Override protected List specifications(ReferenceTypeSourceBaseDependencyPersist item) { return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getReferenceTypeCode())) + .failOn(ReferenceTypeSourceBaseDependencyPersist._referenceTypeCode).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseDependencyPersist._referenceTypeCode}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getKey())) + .failOn(ReferenceTypeSourceBaseDependencyPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseDependencyPersist._key}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getRequired())) + .failOn(ReferenceTypeSourceBaseDependencyPersist._required).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseDependencyPersist._required}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getProperties())) + .failOn(ReferenceTypeSourceBaseDependencyPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseDependencyPersist._properties}, LocaleContextHolder.getLocale())), + this.navSpec() + .iff(() -> !this.isNull(item.getProperties())) + .on(ReferenceTypeSourceBaseDependencyPersist._properties) + .over(item.getProperties()) + .using(() -> this.validatorFactory.validator(DependencyPropertyPersist.DependencyPropertyPersistValidator.class)) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java index 351f95969..0eff5caa8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java @@ -9,44 +9,52 @@ import eu.eudat.errorcode.ErrorThesaurusProperties; import jakarta.validation.Valid; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String url; - @Valid + public static final String _uri = "uri"; + private ResultsConfigurationPersist results; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _results = "results"; + private String paginationPath; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _paginationPath = "paginationPath"; + private String contentType; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _contentType = "contentType"; + private String firstPage; - @ValidEnum(message = "{validation.empty}") + public static final String _firstPage = "firstPage"; + private ReferenceTypeExternalApiHTTPMethodType httpMethod; + public static final String _httpMethod = "httpMethod"; + private String requestBody = ""; private String filterType = "remote"; - @Valid private AuthenticationConfigurationPersist auth; - @Valid + public static final String _auth = "auth"; + private List queries; + public static final String _queries = "queries"; + public String getUrl() { return url; } @@ -127,8 +135,12 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc this.queries = queries; } + @Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { + public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator"; + protected ReferenceTypeSourceExternalApiConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors, messageSource, validatorFactory); } @@ -140,7 +152,11 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc @Override protected List specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) { - return null; + List specifications = getBaseSpecifications(item); + specifications.addAll(Arrays.asList( + + )); + return specifications; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java index 36777d1c7..962d7be06 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java @@ -1,20 +1,22 @@ package eu.eudat.model.persist.referencetypedefinition; - import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.specification.Specification; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; -import jakarta.validation.Valid; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import java.util.List; -public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist{ +public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { - @Valid List options; + public static final String _options = "options"; + public List getOptions() { return options; } @@ -23,8 +25,12 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen this.options = options; } + @Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { + public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator"; + protected ReferenceTypeSourceStaticOptionConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { super(conventionService, errors, messageSource, validatorFactory); } @@ -36,7 +42,15 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen @Override protected List specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) { - return null; + List specifications = getBaseSpecifications(item); + specifications.add( + this.refSpec() + .iff(() -> !this.isNull(item.getOptions())) + .on(ReferenceTypeSourceStaticOptionConfigurationPersist._options) + .over(item.getOptions()) + .using(() -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class)) + ); + return specifications; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java index a97814c98..0c3a02ebb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java @@ -1,18 +1,28 @@ package eu.eudat.model.persist.referencetypedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ReferenceTypeStaticOptionPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _code = "code"; + private String value; + public static final String _value = "value"; + public String getCode() { return code; } @@ -28,4 +38,36 @@ public class ReferenceTypeStaticOptionPersist { public void setValue(String value) { this.value = value; } + + @Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "ReferenceTypeStaticOptionPersistValidator"; + + private final MessageSource messageSource; + + protected ReferenceTypeStaticOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return ReferenceTypeStaticOptionPersist.class; + } + + @Override + protected List specifications(ReferenceTypeStaticOptionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isEmpty(item.getCode())) + .failOn(ReferenceTypeStaticOptionPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._code}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getValue())) + .failOn(ReferenceTypeStaticOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._value}, LocaleContextHolder.getLocale())) + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java index 7616066bb..fbc3bd638 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java @@ -1,18 +1,26 @@ package eu.eudat.model.persist.referencetypedefinition; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; public class ResultFieldsMappingConfigurationPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String code; - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") + public static final String _code = "code"; + private String responsePath; + public static final String _responsePath = "responsePath"; + public String getCode() { return code; } @@ -28,4 +36,28 @@ public class ResultFieldsMappingConfigurationPersist { public void setResponsePath(String responsePath) { this.responsePath = responsePath; } + + @Component(ResultFieldsMappingConfigurationPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ResultFieldsMappingConfigurationPersistValidator extends BaseValidator { + + public static final String ValidatorName = "ResultFieldsMappingConfigurationPersistValidator"; + + protected ResultFieldsMappingConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { + super(conventionService, errors); + } + + @Override + protected Class modelClass() { + return ResultFieldsMappingConfigurationPersist.class; + } + + @Override + protected List specifications(ResultFieldsMappingConfigurationPersist item) { + return Arrays.asList( + + ); + } + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java index bd35e4051..9dca6c620 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java @@ -1,21 +1,27 @@ package eu.eudat.model.persist.referencetypedefinition; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.commons.validation.specification.Specification; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.List; public class ResultsConfigurationPersist { - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") private String resultsArrayPath; - @NotNull(message = "{validation.empty}") - @Valid + public static final String _resultsArrayPath = "resultsArrayPath"; + private List fieldsMapping; + public static final String _fieldsMapping = "fieldsMapping"; + public String getResultsArrayPath() { return resultsArrayPath; } @@ -31,4 +37,31 @@ public class ResultsConfigurationPersist { public void setFieldsMapping(List fieldsMapping) { this.fieldsMapping = fieldsMapping; } + + @Component(ResultsConfigurationPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class ResultsConfigurationPersistValidator extends BaseValidator { + + public static final String ValidatorName = "ResultsConfigurationPersistValidator"; + + private final MessageSource messageSource; + + protected ResultsConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) { + super(conventionService, errors); + this.messageSource = messageSource; + } + + @Override + protected Class modelClass() { + return ResultsConfigurationPersist.class; + } + + @Override + protected List specifications(ResultsConfigurationPersist item) { + return Arrays.asList( + + ); + } + } + }