Implementing validators for Description template related persist models (completed)

This commit is contained in:
Thomas Georgios Giannos 2024-01-02 11:50:32 +02:00
parent 28238c7a6d
commit 1462b9944d
26 changed files with 842 additions and 103 deletions

View File

@ -43,8 +43,12 @@ public abstract class BaseValidator<T> extends AbstractValidator<T> {
return value == null;
}
protected Boolean lessEqual(String value, int size) {
protected Boolean lessEqualLength(String value, int size) {
return value.length() <= size;
}
protected Boolean lessEqual(Integer value, int target) {
return value <= target;
}
}

View File

@ -188,7 +188,7 @@ public class DescriptionPersist {
.failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqual(item.getLabel(), DescriptionPersist._labelLength))
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionPersist._labelLength))
.failOn(DescriptionPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> this.isValidGuid(item.getDmpId()))

View File

@ -169,7 +169,7 @@ public class DescriptionTemplatePersist {
.failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqual(item.getLabel(), DescriptionTemplatePersist._labelLength))
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplatePersist._labelLength))
.failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getDescription()))
@ -199,7 +199,7 @@ public class DescriptionTemplatePersist {
.iff(() -> !this.isNull(item.getUsers()))
.on(DescriptionTemplatePersist._users)
.over(item.getUsers())
.using(() -> null) //TODO (thgiannos)
.using(() -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))
);
}
}

View File

@ -33,14 +33,6 @@ public class DescriptionTemplateTypePersist {
private DescriptionTemplateTypeStatus status;
// private List<DescriptionTemplateTypePersist> nested;
//
// public final static String _nested = "nested";
//
// private DescriptionTemplateTypePersist obj;
//
// public final static String _obj = "obj";
public UUID getId() {
return id;
}
@ -106,18 +98,8 @@ public class DescriptionTemplateTypePersist {
.failOn(DescriptionTemplateTypePersist._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplateTypePersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqual(item.getName(), DescriptionTemplateTypeEntity._nameLength))
.must(() -> this.lessEqualLength(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))
);
}
}

View File

@ -186,7 +186,7 @@ public class ReferencePersist {
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqual(item.getLabel(), ReferencePersist._labelLength))
.must(() -> this.lessEqualLength(item.getLabel(), ReferencePersist._labelLength))
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getType()))
@ -196,21 +196,21 @@ public class ReferencePersist {
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getReference()))
.must(() -> this.lessEqual(item.getReference(), ReferencePersist._referenceLength))
.must(() -> this.lessEqualLength(item.getReference(), ReferencePersist._referenceLength))
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getAbbreviation()))
.failOn(ReferencePersist._abbreviation).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._abbreviation}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getAbbreviation()))
.must(() -> this.lessEqual(item.getAbbreviation(), ReferencePersist._abbreviationLength))
.must(() -> this.lessEqualLength(item.getAbbreviation(), ReferencePersist._abbreviationLength))
.failOn(ReferencePersist._abbreviation).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._abbreviation}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getSource()))
.failOn(ReferencePersist._source).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._source}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getSource()))
.must(() -> this.lessEqual(item.getSource(), ReferencePersist._sourceLength))
.must(() -> this.lessEqualLength(item.getSource(), ReferencePersist._sourceLength))
.failOn(ReferencePersist._source).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._source}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getSourceType()))

View File

@ -87,7 +87,7 @@ public class TagPersist {
.failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqual(item.getLabel(), TagEntity._labelLength))
.must(() -> this.lessEqualLength(item.getLabel(), TagEntity._labelLength))
.failOn(TagPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{TagPersist._label}, LocaleContextHolder.getLocale()))
);
}

View File

@ -1,23 +1,30 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.UserDescriptionTemplateRole;
import eu.eudat.commons.validation.old.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.old.ValidEnum;
import eu.eudat.commons.validation.old.ValidId;
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;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class UserDescriptionTemplatePersist {
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID userId = null;
@ValidEnum(message = "{validation.empty}")
public static final String _userId = "userId";
private UserDescriptionTemplateRole role;
public static final String _role = "role";
public UUID getUserId() {
return userId;
}
@ -33,4 +40,36 @@ public class UserDescriptionTemplatePersist {
public void setRole(UserDescriptionTemplateRole role) {
this.role = role;
}
@Component(UserDescriptionTemplatePersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UserDescriptionTemplatePersistValidator extends BaseValidator<UserDescriptionTemplatePersist> {
public static final String ValidatorName = "UserDescriptionTemplatePersistValidator";
private final MessageSource messageSource;
protected UserDescriptionTemplatePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<UserDescriptionTemplatePersist> modelClass() {
return UserDescriptionTemplatePersist.class;
}
@Override
protected List<Specification> specifications(UserDescriptionTemplatePersist item) {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getUserId()))
.failOn(UserDescriptionTemplatePersist._userId).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserDescriptionTemplatePersist._userId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getRole()))
.failOn(UserDescriptionTemplatePersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserDescriptionTemplatePersist._role}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -207,7 +207,87 @@ public class FieldPersist {
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.RADIO_BOX)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class))
.using(() -> this.validatorFactory.validator(RadioBoxDataPersist.RadioBoxDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.REGISTRIES)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(RegistryDataPersist.RegistryDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(ResearcherAutoCompleteDataPersist.ResearcherAutoCompleteDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.RESEARCHERS)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(ResearcherDataPersist.ResearcherDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.RICH_TEXT_AREA)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(RichTextAreaDataPersist.RichTextAreaDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.SERVICES)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(ServiceDataPersist.ServiceDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.TAGS)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(TagDataPersist.TagDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.TAXONOMIES)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(TaxonomyDataPersist.TaxonomyDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.TEXT_AREA)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(TextAreaDataPersist.TextAreaDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.UPLOAD)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(UploadDataPersist.UploadDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.VALIDATION)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(ValidationDataPersist.ValidationDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.DATASET_IDENTIFIER)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(DatasetIdentifierDataPersist.DatasetIdentifierDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.CURRENCY)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(CurrencyDataPersist.CurrencyDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.WORD_LIST)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(WordListDataPersist.WordListDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.DATA_REPOSITORIES)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(DataRepositoryDataPersist.DataRepositoryDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.JOURNAL_REPOSITORIES)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(JournalRepositoryDataPersist.JournalRepositoryDataPersistValidator.class)),
this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() == FieldType.PUBLICATIONS)
.on(FieldPersist._data)
.over(item.getData())
.using(() -> this.validatorFactory.validator(PublicationRepositoryDataPersist.PublicationRepositoryDataPersistValidator.class))
);
}
}

View File

@ -1,5 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class CurrencyDataPersist extends BaseFieldDataPersist {
@Component(CurrencyDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class CurrencyDataPersistValidator extends BaseFieldDataPersistValidator<CurrencyDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.CurrencyDataPersistValidator";
protected CurrencyDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<CurrencyDataPersist> modelClass() {
return CurrencyDataPersist.class;
}
@Override
protected List<Specification> specifications(CurrencyDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,11 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class DataRepositoryDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -13,4 +24,32 @@ public class DataRepositoryDataPersist extends BaseFieldDataPersist {
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Component(DataRepositoryDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DataRepositoryDataPersistValidator extends BaseFieldDataPersistValidator<DataRepositoryDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.DataRepositoryDataPersistValidator";
protected DataRepositoryDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<DataRepositoryDataPersist> modelClass() {
return DataRepositoryDataPersist.class;
}
@Override
protected List<Specification> specifications(DataRepositoryDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(DataRepositoryDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{DataRepositoryDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,6 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class DatasetIdentifierDataPersist extends BaseFieldDataPersist {
@Component(DatasetIdentifierDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DatasetIdentifierDataPersistValidator extends BaseFieldDataPersistValidator<DatasetIdentifierDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.DatasetIdentifierDataPersistValidator";
protected DatasetIdentifierDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<DatasetIdentifierDataPersist> modelClass() {
return DatasetIdentifierDataPersist.class;
}
@Override
protected List<Specification> specifications(DatasetIdentifierDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,11 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class JournalRepositoryDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -13,4 +24,32 @@ public class JournalRepositoryDataPersist extends BaseFieldDataPersist {
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Component(JournalRepositoryDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class JournalRepositoryDataPersistValidator extends BaseFieldDataPersistValidator<JournalRepositoryDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.JournalRepositoryDataPersistValidator";
protected JournalRepositoryDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<JournalRepositoryDataPersist> modelClass() {
return JournalRepositoryDataPersist.class;
}
@Override
protected List<Specification> specifications(JournalRepositoryDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(JournalRepositoryDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{JournalRepositoryDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,11 +1,23 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
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.List;
public class PublicationRepositoryDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -13,4 +25,32 @@ public class PublicationRepositoryDataPersist extends BaseFieldDataPersist {
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Component(PublicationRepositoryDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PublicationRepositoryDataPersistValidator extends BaseFieldDataPersistValidator<PublicationRepositoryDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.PublicationRepositoryDataPersistValidator";
protected PublicationRepositoryDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<PublicationRepositoryDataPersist> modelClass() {
return PublicationRepositoryDataPersist.class;
}
@Override
protected List<Specification> specifications(PublicationRepositoryDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(PublicationRepositoryDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{PublicationRepositoryDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -47,7 +47,8 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist {
@Override
protected List<Specification> specifications(RadioBoxDataPersist item) {
return Arrays.asList(
List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getOptions()))
.failOn(RadioBoxDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxDataPersist._options}, LocaleContextHolder.getLocale())),
@ -56,7 +57,8 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist {
.on(RadioBoxDataPersist._options)
.over(item.getOptions())
.using(() -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class))
);
));
return specifications;
}
}

View File

@ -1,12 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.NotNull;
import java.util.List;
public class RegistryDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -15,4 +25,31 @@ public class RegistryDataPersist extends BaseFieldDataPersist {
this.multiAutoComplete = multiAutoComplete;
}
@Component(RegistryDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class RegistryDataPersistValidator extends BaseFieldDataPersistValidator<RegistryDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.RegistryDataPersistValidator";
protected RegistryDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<RegistryDataPersist> modelClass() {
return RegistryDataPersist.class;
}
@Override
protected List<Specification> specifications(RegistryDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(RegistryDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{RegistryDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,15 +1,54 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class ResearcherAutoCompleteDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Component(ResearcherAutoCompleteDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ResearcherAutoCompleteDataPersistValidator extends BaseFieldDataPersistValidator<ResearcherAutoCompleteDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.ResearcherAutoCompleteDataPersistValidator";
protected ResearcherAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<ResearcherAutoCompleteDataPersist> modelClass() {
return ResearcherAutoCompleteDataPersist.class;
}
@Override
protected List<Specification> specifications(ResearcherAutoCompleteDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(ResearcherAutoCompleteDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResearcherAutoCompleteDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,12 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.NotNull;
import java.util.List;
public class ResearcherDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -15,4 +25,31 @@ public class ResearcherDataPersist extends BaseFieldDataPersist {
this.multiAutoComplete = multiAutoComplete;
}
@Component(ResearcherDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ResearcherDataPersistValidator extends BaseFieldDataPersistValidator<ResearcherDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.ResearcherDataPersistValidator";
protected ResearcherDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<ResearcherDataPersist> modelClass() {
return ResearcherDataPersist.class;
}
@Override
protected List<Specification> specifications(ResearcherDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(ResearcherDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{ResearcherDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,6 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class RichTextAreaDataPersist extends BaseFieldDataPersist {
@Component(RichTextAreaDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class RichTextAreaDataPersistValidator extends BaseFieldDataPersistValidator<RichTextAreaDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.RichTextAreaDataPersistValidator";
protected RichTextAreaDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<RichTextAreaDataPersist> modelClass() {
return RichTextAreaDataPersist.class;
}
@Override
protected List<Specification> specifications(RichTextAreaDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,12 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.NotNull;
import java.util.List;
public class ServiceDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -14,4 +24,32 @@ public class ServiceDataPersist extends BaseFieldDataPersist {
public void setMultiAutoComplete(Boolean multiAutoComplete) {
this.multiAutoComplete = multiAutoComplete;
}
@Component(ServiceDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ServiceDataPersistValidator extends BaseFieldDataPersistValidator<ServiceDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.ServiceDataPersistValidator";
protected ServiceDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<ServiceDataPersist> modelClass() {
return ServiceDataPersist.class;
}
@Override
protected List<Specification> specifications(ServiceDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(ServiceDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{ServiceDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,5 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class TagDataPersist extends BaseFieldDataPersist {
@Component(TagDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TagDataPersistValidator extends BaseFieldDataPersistValidator<TagDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.TagDataPersistValidator";
protected TagDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<TagDataPersist> modelClass() {
return TagDataPersist.class;
}
@Override
protected List<Specification> specifications(TagDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,12 +1,22 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.NotNull;
import java.util.List;
public class TaxonomyDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
private Boolean multiAutoComplete = null;
public static final String _multiAutoComplete = "multiAutoComplete";
public Boolean getMultiAutoComplete() {
return multiAutoComplete;
}
@ -15,4 +25,31 @@ public class TaxonomyDataPersist extends BaseFieldDataPersist {
this.multiAutoComplete = multiAutoComplete;
}
@Component(TaxonomyDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TaxonomyDataPersistValidator extends BaseFieldDataPersistValidator<TaxonomyDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.TaxonomyDataPersistValidator";
protected TaxonomyDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<TaxonomyDataPersist> modelClass() {
return TaxonomyDataPersist.class;
}
@Override
protected List<Specification> specifications(TaxonomyDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getMultiAutoComplete()))
.failOn(TaxonomyDataPersist._multiAutoComplete).failWith(messageSource.getMessage("Validation_Required", new Object[]{TaxonomyDataPersist._multiAutoComplete}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}

View File

@ -1,5 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class TextAreaDataPersist extends BaseFieldDataPersist {
@Component(TextAreaDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class TextAreaDataPersistValidator extends BaseFieldDataPersistValidator<TextAreaDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.TextAreaDataPersistValidator";
protected TextAreaDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<TextAreaDataPersist> modelClass() {
return TextAreaDataPersist.class;
}
@Override
protected List<Specification> specifications(TextAreaDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,16 +1,24 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
import eu.eudat.commons.validation.ValidatorFactory;
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.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
public class UploadDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
@Valid
private List<UploadOptionPersist> types = null;
public static final String _types = "types";
public List<UploadOptionPersist> getTypes() {
return types;
}
@ -21,6 +29,8 @@ public class UploadDataPersist extends BaseFieldDataPersist {
private Integer maxFileSizeInMB;
public static final String _maxFileSizeInMB = "maxFileSizeInMB";
public Integer getMaxFileSizeInMB() {
return maxFileSizeInMB;
}
@ -29,6 +39,45 @@ public class UploadDataPersist extends BaseFieldDataPersist {
this.maxFileSizeInMB = maxFileSizeInMB;
}
@Component(UploadDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UploadDataPersistValidator extends BaseFieldDataPersistValidator<UploadDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.UploadDataPersistValidator";
private final ValidatorFactory validatorFactory;
protected UploadDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource);
this.validatorFactory = validatorFactory;
}
@Override
protected Class<UploadDataPersist> modelClass() {
return UploadDataPersist.class;
}
@Override
protected List<Specification> specifications(UploadDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList(
this.spec()
.iff(() -> !this.isNull(item.getMaxFileSizeInMB()))
.must(() -> !this.lessEqual(item.getMaxFileSizeInMB(), Integer.MAX_VALUE))
.failOn(UploadDataPersist._maxFileSizeInMB).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{UploadDataPersist._types}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getTypes()))
.failOn(UploadDataPersist._types).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadDataPersist._types}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isNull(item.getTypes()))
.on(UploadDataPersist._types)
.over(item.getTypes())
.using(() -> this.validatorFactory.validator(UploadOptionPersist.UploadOptionPersistValidator.class))
));
return specifications;
}
}
}

View File

@ -1,18 +1,28 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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 UploadOptionPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String label = null;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
public static final String _label = "label";
private String value = null;
public static final String _value = "value";
public String getLabel() {
return label;
}
@ -28,4 +38,36 @@ public class UploadOptionPersist {
public void setValue(String value) {
this.value = value;
}
@Component(UploadOptionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class UploadOptionPersistValidator extends BaseValidator<UploadOptionPersist> {
public static final String ValidatorName = "DescriptionTemplate.UploadOptionPersistValidator";
private final MessageSource messageSource;
protected UploadOptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<UploadOptionPersist> modelClass() {
return UploadOptionPersist.class;
}
@Override
protected List<Specification> specifications(UploadOptionPersist item) {
return Arrays.asList(
this.spec()
.must(() -> !this.isEmpty(item.getLabel()))
.failOn(UploadOptionPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadOptionPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getValue()))
.failOn(UploadOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{UploadOptionPersist._value}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -1,5 +1,36 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
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.List;
public class ValidationDataPersist extends BaseFieldDataPersist {
@Component(ValidationDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ValidationDataPersistValidator extends BaseFieldDataPersistValidator<ValidationDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.ValidationDataPersistValidator";
protected ValidationDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<ValidationDataPersist> modelClass() {
return ValidationDataPersist.class;
}
@Override
protected List<Specification> specifications(ValidationDataPersist item) {
return getBaseSpecifications(item);
}
}
}

View File

@ -1,17 +1,28 @@
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import eu.eudat.commons.validation.ValidatorFactory;
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 WordListDataPersist extends BaseFieldDataPersist {
@NotNull(message = "{validation.empty}")
@Valid
private List<ComboBoxOptionPersist> options = null;
@NotNull(message = "{validation.empty}")
public static final String _options = "options";
private Boolean multiList = null;
public static final String _multiList = "multiList";
public List<ComboBoxOptionPersist> getOptions() {
return options;
}
@ -27,4 +38,44 @@ public class WordListDataPersist extends BaseFieldDataPersist {
public void setMultiList(Boolean multiList) {
this.multiList = multiList;
}
@Component(WordListDataPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class WordListDataPersistValidator extends BaseFieldDataPersistValidator<WordListDataPersist> {
public static final String ValidatorName = "DescriptionTemplate.WordListDataPersistValidator";
private final ValidatorFactory validatorFactory;
protected WordListDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
super(conventionService, errors, messageSource);
this.validatorFactory = validatorFactory;
}
@Override
protected Class<WordListDataPersist> modelClass() {
return WordListDataPersist.class;
}
@Override
protected List<Specification> specifications(WordListDataPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList(
this.spec()
.must(() -> !this.isNull(item.getMultiList()))
.failOn(WordListDataPersist._multiList).failWith(messageSource.getMessage("Validation_Required", new Object[]{WordListDataPersist._multiList}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getOptions()))
.failOn(WordListDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{WordListDataPersist._options}, LocaleContextHolder.getLocale())),
this.navSpec()
.iff(() -> !this.isNull(item.getOptions()))
.on(WordListDataPersist._options)
.over(item.getOptions())
.using(() -> this.validatorFactory.validator(ComboBoxOptionPersist.ComboBoxOptionPersistValidator.class))
));
return specifications;
}
}
}