Implementing validators for Reference persist models (not completed)
This commit is contained in:
parent
8bccb9a224
commit
c4ec41bec1
|
@ -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}")
|
||||
public static final String _authMethod = "authMethod";
|
||||
|
||||
private String authTokenPath;
|
||||
@NotNull(message = "{validation.empty}")
|
||||
|
||||
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<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(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<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()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<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<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ReferenceTypeFieldPersist> {
|
||||
|
||||
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<Specification> specifications(ReferenceTypeFieldPersist item) {
|
||||
return null;
|
||||
return Arrays.asList(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Specification> 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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<QueryConfigPersist> 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<ReferenceTypeSourceExternalApiConfigurationPersist> {
|
||||
|
||||
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<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) {
|
||||
return null;
|
||||
List<Specification> specifications = getBaseSpecifications(item);
|
||||
specifications.addAll(Arrays.asList(
|
||||
|
||||
));
|
||||
return specifications;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
@Valid
|
||||
List<ReferenceTypeStaticOptionPersist> options;
|
||||
|
||||
public static final String _options = "options";
|
||||
|
||||
public List<ReferenceTypeStaticOptionPersist> 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<ReferenceTypeSourceStaticOptionConfigurationPersist> {
|
||||
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<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()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<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(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ResultFieldsMappingConfigurationPersist> fieldsMapping;
|
||||
|
||||
public static final String _fieldsMapping = "fieldsMapping";
|
||||
|
||||
public String getResultsArrayPath() {
|
||||
return resultsArrayPath;
|
||||
}
|
||||
|
@ -31,4 +37,31 @@ public class ResultsConfigurationPersist {
|
|||
public void setFieldsMapping(List<ResultFieldsMappingConfigurationPersist> 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(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue