Implementing validators for Reference persist models (not completed)

This commit is contained in:
Thomas Georgios Giannos 2024-01-03 18:09:14 +02:00
parent 8bccb9a224
commit c4ec41bec1
10 changed files with 355 additions and 66 deletions

View File

@ -1,26 +1,44 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.validation.old.ValidEnum; import eu.eudat.commons.validation.BaseValidator;
import jakarta.validation.constraints.NotNull; 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 { public class AuthenticationConfigurationPersist {
@NotNull(message = "{validation.empty}")
private Boolean enabled; private Boolean enabled;
@NotNull(message = "{validation.empty}")
public static final String _enabled = "enabled";
private String authUrl; private String authUrl;
@ValidEnum(message = "{validation.empty}") public static final String _authUrl = "authUrl";
private ReferenceTypeExternalApiHTTPMethodType authMethod; private ReferenceTypeExternalApiHTTPMethodType authMethod;
@NotNull(message = "{validation.empty}") public static final String _authMethod = "authMethod";
private String authTokenPath ;
@NotNull(message = "{validation.empty}") private String authTokenPath;
public static final String _authTokenPath = "authTokenPath";
private String authRequestBody; private String authRequestBody;
@NotNull(message = "{validation.empty}")
public static final String _authRequestBody = "authRequestBody";
private String type; private String type;
public static final String _type = "type";
public Boolean getEnabled() { public Boolean getEnabled() {
return enabled; return enabled;
} }
@ -68,4 +86,31 @@ public class AuthenticationConfigurationPersist {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
@Component(AuthenticationConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class AuthenticationConfigurationPersistValidator extends BaseValidator<AuthenticationConfigurationPersist> {
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<AuthenticationConfigurationPersist> modelClass() {
return AuthenticationConfigurationPersist.class;
}
@Override
protected List<Specification> specifications(AuthenticationConfigurationPersist item) {
return Arrays.asList(
);
}
}
} }

View File

@ -1,22 +1,32 @@
package eu.eudat.model.persist.referencetypedefinition; 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 java.util.Arrays;
import jakarta.validation.constraints.NotNull; import java.util.List;
public class DependencyPropertyPersist { public class DependencyPropertyPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code; private String code;
@NotNull(message = "{validation.empty}") public static final String _code = "code";
@NotEmpty(message = "{validation.empty}")
private String target; private String target;
@NotNull(message = "{validation.empty}") public static final String _target = "target";
private Boolean required; private Boolean required;
public static final String _required = "required";
public String getCode() { public String getCode() {
return code; return code;
} }
@ -40,4 +50,39 @@ public class DependencyPropertyPersist {
public void setRequired(Boolean required) { public void setRequired(Boolean required) {
this.required = required; this.required = required;
} }
@Component(DependencyPropertyPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DependencyPropertyPersistValidator extends BaseValidator<DependencyPropertyPersist> {
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<DependencyPropertyPersist> modelClass() {
return DependencyPropertyPersist.class;
}
@Override
protected List<Specification> 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()))
);
}
}
} }

View File

@ -1,14 +1,26 @@
package eu.eudat.model.persist.referencetypedefinition; 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 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 { public class QueryConfigPersist {
private String condition; private String condition;
private String separator;
private String value;
private Integer ordinal;
private String separator;
private String value;
private Integer ordinal;
public String getCondition() { public String getCondition() {
return condition; return condition;
@ -45,4 +57,26 @@ public class QueryConfigPersist {
public void setOrdinal(Integer ordinal) { public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal; this.ordinal = ordinal;
} }
@Component(QueryConfigPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class QueryConfigPersistValidator extends BaseValidator<QueryConfigPersist> {
public static final String ValidatorName = "QueryConfigPersistValidator";
protected QueryConfigPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) {
super(conventionService, errors);
}
@Override
protected Class<QueryConfigPersist> modelClass() {
return QueryConfigPersist.class;
}
@Override
protected List<Specification> specifications(QueryConfigPersist item) {
return new ArrayList<>();
}
}
} }

View File

@ -8,25 +8,28 @@ import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; 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; import java.util.List;
public class ReferenceTypeFieldPersist { public class ReferenceTypeFieldPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code = null; private String code = null;
@NotNull(message = "{validation.empty}") public static final String _code = "code";
@NotEmpty(message = "{validation.empty}")
private String label = null; private String label = null;
public static final String _label = "label";
private String description; private String description;
@ValidEnum(message = "{validation.empty}")
private ReferenceFieldDataType dataType; private ReferenceFieldDataType dataType;
public static final String _dataType = "dataType";
public String getCode() { public String getCode() {
return code; return code;
@ -60,8 +63,12 @@ public class ReferenceTypeFieldPersist {
this.dataType = dataType; this.dataType = dataType;
} }
@Component(ReferenceTypeFieldPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeFieldPersistValidator extends BaseValidator<ReferenceTypeFieldPersist> { public static class ReferenceTypeFieldPersistValidator extends BaseValidator<ReferenceTypeFieldPersist> {
public static final String ValidatorName = "ReferenceTypeFieldPersistValidator";
protected ReferenceTypeFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) { protected ReferenceTypeFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) {
super(conventionService, errors); super(conventionService, errors);
} }
@ -73,7 +80,9 @@ public class ReferenceTypeFieldPersist {
@Override @Override
protected List<Specification> specifications(ReferenceTypeFieldPersist item) { protected List<Specification> specifications(ReferenceTypeFieldPersist item) {
return null; return Arrays.asList(
);
} }
} }

View File

@ -1,15 +1,14 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification; import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; 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.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -73,9 +72,12 @@ public class ReferenceTypeSourceBaseDependencyPersist {
private final MessageSource messageSource; 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); super(conventionService, errors);
this.messageSource = messageSource; this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
} }
@Override @Override
@ -86,7 +88,24 @@ public class ReferenceTypeSourceBaseDependencyPersist {
@Override @Override
protected List<Specification> specifications(ReferenceTypeSourceBaseDependencyPersist item) { protected List<Specification> specifications(ReferenceTypeSourceBaseDependencyPersist item) {
return Arrays.asList( 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))
); );
} }
} }

View File

@ -9,44 +9,52 @@ import eu.eudat.errorcode.ErrorThesaurusProperties;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String url; private String url;
@Valid public static final String _uri = "uri";
private ResultsConfigurationPersist results; private ResultsConfigurationPersist results;
@NotNull(message = "{validation.empty}") public static final String _results = "results";
@NotEmpty(message = "{validation.empty}")
private String paginationPath; private String paginationPath;
@NotNull(message = "{validation.empty}") public static final String _paginationPath = "paginationPath";
@NotEmpty(message = "{validation.empty}")
private String contentType; private String contentType;
@NotNull(message = "{validation.empty}") public static final String _contentType = "contentType";
@NotEmpty(message = "{validation.empty}")
private String firstPage; private String firstPage;
@ValidEnum(message = "{validation.empty}") public static final String _firstPage = "firstPage";
private ReferenceTypeExternalApiHTTPMethodType httpMethod; private ReferenceTypeExternalApiHTTPMethodType httpMethod;
public static final String _httpMethod = "httpMethod";
private String requestBody = ""; private String requestBody = "";
private String filterType = "remote"; private String filterType = "remote";
@Valid
private AuthenticationConfigurationPersist auth; private AuthenticationConfigurationPersist auth;
@Valid public static final String _auth = "auth";
private List<QueryConfigPersist> queries; private List<QueryConfigPersist> queries;
public static final String _queries = "queries";
public String getUrl() { public String getUrl() {
return url; return url;
} }
@ -127,8 +135,12 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
this.queries = queries; this.queries = queries;
} }
@Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceExternalApiConfigurationPersist> { public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceExternalApiConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator";
protected ReferenceTypeSourceExternalApiConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { protected ReferenceTypeSourceExternalApiConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource, validatorFactory); super(conventionService, errors, messageSource, validatorFactory);
} }
@ -140,7 +152,11 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
@Override @Override
protected List<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) { protected List<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) {
return null; List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList(
));
return specifications;
} }
} }

View File

@ -1,20 +1,22 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.validation.ValidatorFactory; import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.commons.validation.specification.Specification; import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; 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.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist{ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist {
@Valid
List<ReferenceTypeStaticOptionPersist> options; List<ReferenceTypeStaticOptionPersist> options;
public static final String _options = "options";
public List<ReferenceTypeStaticOptionPersist> getOptions() { public List<ReferenceTypeStaticOptionPersist> getOptions() {
return options; return options;
} }
@ -23,8 +25,12 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen
this.options = options; this.options = options;
} }
@Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceStaticOptionConfigurationPersist> { public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceStaticOptionConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator";
protected ReferenceTypeSourceStaticOptionConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { protected ReferenceTypeSourceStaticOptionConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource, validatorFactory); super(conventionService, errors, messageSource, validatorFactory);
} }
@ -36,7 +42,15 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen
@Override @Override
protected List<Specification> specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) { protected List<Specification> specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) {
return null; List<Specification> 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;
} }
} }

View File

@ -1,18 +1,28 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.constraints.NotEmpty; import eu.eudat.commons.validation.BaseValidator;
import jakarta.validation.constraints.NotNull; 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 { public class ReferenceTypeStaticOptionPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code; private String code;
@NotNull(message = "{validation.empty}") public static final String _code = "code";
@NotEmpty(message = "{validation.empty}")
private String value; private String value;
public static final String _value = "value";
public String getCode() { public String getCode() {
return code; return code;
} }
@ -28,4 +38,36 @@ public class ReferenceTypeStaticOptionPersist {
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
@Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator<ReferenceTypeStaticOptionPersist> {
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<ReferenceTypeStaticOptionPersist> modelClass() {
return ReferenceTypeStaticOptionPersist.class;
}
@Override
protected List<Specification> 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()))
);
}
}
} }

View File

@ -1,18 +1,26 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.constraints.NotEmpty; import eu.eudat.commons.validation.BaseValidator;
import jakarta.validation.constraints.NotNull; 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 { public class ResultFieldsMappingConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code; private String code;
@NotNull(message = "{validation.empty}") public static final String _code = "code";
@NotEmpty(message = "{validation.empty}")
private String responsePath; private String responsePath;
public static final String _responsePath = "responsePath";
public String getCode() { public String getCode() {
return code; return code;
} }
@ -28,4 +36,28 @@ public class ResultFieldsMappingConfigurationPersist {
public void setResponsePath(String responsePath) { public void setResponsePath(String responsePath) {
this.responsePath = responsePath; this.responsePath = responsePath;
} }
@Component(ResultFieldsMappingConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ResultFieldsMappingConfigurationPersistValidator extends BaseValidator<ResultFieldsMappingConfigurationPersist> {
public static final String ValidatorName = "ResultFieldsMappingConfigurationPersistValidator";
protected ResultFieldsMappingConfigurationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors) {
super(conventionService, errors);
}
@Override
protected Class<ResultFieldsMappingConfigurationPersist> modelClass() {
return ResultFieldsMappingConfigurationPersist.class;
}
@Override
protected List<Specification> specifications(ResultFieldsMappingConfigurationPersist item) {
return Arrays.asList(
);
}
}
} }

View File

@ -1,21 +1,27 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.Valid; import eu.eudat.commons.validation.BaseValidator;
import jakarta.validation.constraints.NotEmpty; import eu.eudat.commons.validation.specification.Specification;
import jakarta.validation.constraints.NotNull; 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; import java.util.List;
public class ResultsConfigurationPersist { public class ResultsConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String resultsArrayPath; private String resultsArrayPath;
@NotNull(message = "{validation.empty}") public static final String _resultsArrayPath = "resultsArrayPath";
@Valid
private List<ResultFieldsMappingConfigurationPersist> fieldsMapping; private List<ResultFieldsMappingConfigurationPersist> fieldsMapping;
public static final String _fieldsMapping = "fieldsMapping";
public String getResultsArrayPath() { public String getResultsArrayPath() {
return resultsArrayPath; return resultsArrayPath;
} }
@ -31,4 +37,31 @@ public class ResultsConfigurationPersist {
public void setFieldsMapping(List<ResultFieldsMappingConfigurationPersist> fieldsMapping) { public void setFieldsMapping(List<ResultFieldsMappingConfigurationPersist> fieldsMapping) {
this.fieldsMapping = fieldsMapping; this.fieldsMapping = fieldsMapping;
} }
@Component(ResultsConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ResultsConfigurationPersistValidator extends BaseValidator<ResultsConfigurationPersist> {
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<ResultsConfigurationPersist> modelClass() {
return ResultsConfigurationPersist.class;
}
@Override
protected List<Specification> specifications(ResultsConfigurationPersist item) {
return Arrays.asList(
);
}
}
} }