upgrade validations

This commit is contained in:
Efstratios Giannopoulos 2024-01-19 14:52:39 +02:00
parent 9356352e7d
commit c94d57f3a0
27 changed files with 51 additions and 34 deletions

View File

@ -32,7 +32,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>validation</artifactId> <artifactId>validation</artifactId>
<version>3.0.1</version> <version>3.0.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>

View File

@ -223,7 +223,7 @@ public class DescriptionPersist {
.iff(() -> !this.isNull(item.getReferences())) .iff(() -> !this.isNull(item.getReferences()))
.on(DescriptionPersist._references) .on(DescriptionPersist._references)
.over(item.getReferences()) .over(item.getReferences())
.using(() -> this.validatorFactory.validator(DescriptionReferencePersist.DescriptionReferencePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DescriptionReferencePersist.DescriptionReferencePersistValidator.class))
); );
} }
} }

View File

@ -198,7 +198,7 @@ public class DescriptionTemplatePersist {
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isNull(item.getUsers()))
.on(DescriptionTemplatePersist._users) .on(DescriptionTemplatePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using(() -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))
); );
} }
} }

View File

@ -4,6 +4,9 @@ package eu.eudat.model.persist;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.validation.*; import eu.eudat.commons.validation.*;
import eu.eudat.model.persist.dmpproperties.DmpBlueprintValuePersist;
import eu.eudat.model.persist.dmpproperties.DmpPropertiesPersist;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
@ -15,6 +18,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DescriptionTemplateTypePersist { public class DescriptionTemplateTypePersist {
@ -33,6 +37,17 @@ public class DescriptionTemplateTypePersist {
private DescriptionTemplateTypeStatus status; private DescriptionTemplateTypeStatus status;
private Map<UUID, DescriptionTemplateTypePersist> test;
public final static String _test = "test";
public Map<UUID, DescriptionTemplateTypePersist> getTest() {
return test;
}
public void setTest(Map<UUID, DescriptionTemplateTypePersist> test) {
this.test = test;
}
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -71,10 +86,12 @@ public class DescriptionTemplateTypePersist {
public static final String ValidatorName = "DescriptionTemplateTypePersistValidator"; public static final String ValidatorName = "DescriptionTemplateTypePersistValidator";
private final MessageSource messageSource; private final MessageSource messageSource;
private final ValidatorFactory validatorFactory;
public DescriptionTemplateTypePersistValidator(MessageSource messageSource, ConventionService conventionService, ErrorThesaurusProperties errors) { public DescriptionTemplateTypePersistValidator(MessageSource messageSource, ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory) {
super(conventionService, errors); super(conventionService, errors);
this.messageSource = messageSource; this.messageSource = messageSource;
this.validatorFactory = validatorFactory;
} }
@Override @Override

View File

@ -201,7 +201,7 @@ public class DmpPersist {
.iff(() -> !this.isNull(item.getDescriptionTemplates())) .iff(() -> !this.isNull(item.getDescriptionTemplates()))
.on(DmpPersist._descriptionTemplates) .on(DmpPersist._descriptionTemplates)
.over(item.getDescriptionTemplates()) .over(item.getDescriptionTemplates())
.using(() -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class))
); );
} }
} }

View File

@ -76,7 +76,7 @@ public class DmpUserInvitePersist {
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isNull(item.getUsers()))
.on(DmpUserInvitePersist._users) .on(DmpUserInvitePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using(() -> this.validatorFactory.validator(DmpUserInviteTypePersist.DmpUserInviteTypePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DmpUserInviteTypePersist.DmpUserInviteTypePersistValidator.class))
); );
} }
} }

View File

@ -189,7 +189,7 @@ public class NewVersionDescriptionTemplatePersist {
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isNull(item.getUsers()))
.on(NewVersionDescriptionTemplatePersist._users) .on(NewVersionDescriptionTemplatePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using(() -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))
); );
} }
} }

View File

@ -64,7 +64,7 @@ public class PropertyDefinitionPersist {
.iff(() -> !this.isNull(item.getFields())) .iff(() -> !this.isNull(item.getFields()))
.on(PropertyDefinitionPersist._fields) .on(PropertyDefinitionPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
); );
} }

View File

@ -149,7 +149,7 @@ public class FieldPersist {
.iff(() -> !this.isNull(item.getVisibilityRules())) .iff(() -> !this.isNull(item.getVisibilityRules()))
.on(FieldPersist._visibilityRules) .on(FieldPersist._visibilityRules)
.over(item.getVisibilityRules()) .over(item.getVisibilityRules())
.using(() -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)),
this.refSpec() this.refSpec()
.iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() != null) .iff(() -> !this.isNull(item.getData()) && item.getData().getFieldType() != null)
.on(FieldPersist._data) .on(FieldPersist._data)

View File

@ -179,7 +179,7 @@ public class FieldSetPersist {
.iff(() -> !this.isNull(item.getFields())) .iff(() -> !this.isNull(item.getFields()))
.on(FieldSetPersist._fields) .on(FieldSetPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
); );
} }
} }

View File

@ -174,7 +174,7 @@ public class SectionPersist {
.iff(() -> !this.isNull(item.getSections())) .iff(() -> !this.isNull(item.getSections()))
.on(SectionPersist._sections) .on(SectionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using(() -> this.validatorFactory.validator(SectionPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(SectionPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getFieldSets())) .must(() -> !this.isNull(item.getFieldSets()))
.failOn(SectionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._fieldSets}, LocaleContextHolder.getLocale())), .failOn(SectionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._fieldSets}, LocaleContextHolder.getLocale())),
@ -182,7 +182,7 @@ public class SectionPersist {
.iff(() -> !this.isNull(item.getFieldSets())) .iff(() -> !this.isNull(item.getFieldSets()))
.on(SectionPersist._fieldSets) .on(SectionPersist._fieldSets)
.over(item.getFieldSets()) .over(item.getFieldSets())
.using(() -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class))
); );
} }
} }

View File

@ -68,7 +68,7 @@ public class AutoCompleteDataPersist extends BaseFieldDataPersist {
.iff(() -> !this.isNull(item.getAutoCompleteSingleDataList())) .iff(() -> !this.isNull(item.getAutoCompleteSingleDataList()))
.on(AutoCompleteDataPersist._autoCompleteSingleDataList) .on(AutoCompleteDataPersist._autoCompleteSingleDataList)
.over(item.getAutoCompleteSingleDataList()) .over(item.getAutoCompleteSingleDataList())
.using(() -> this.validatorFactory.validator(AutoCompleteSingleDataPersist.AutoCompleteSingleDataPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(AutoCompleteSingleDataPersist.AutoCompleteSingleDataPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -56,7 +56,7 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist {
.iff(() -> !this.isNull(item.getOptions())) .iff(() -> !this.isNull(item.getOptions()))
.on(RadioBoxDataPersist._options) .on(RadioBoxDataPersist._options)
.over(item.getOptions()) .over(item.getOptions())
.using(() -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -73,7 +73,7 @@ public class UploadDataPersist extends BaseFieldDataPersist {
.iff(() -> !this.isNull(item.getTypes())) .iff(() -> !this.isNull(item.getTypes()))
.on(UploadDataPersist._types) .on(UploadDataPersist._types)
.over(item.getTypes()) .over(item.getTypes())
.using(() -> this.validatorFactory.validator(UploadOptionPersist.UploadOptionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(UploadOptionPersist.UploadOptionPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -72,7 +72,7 @@ public class WordListDataPersist extends BaseFieldDataPersist {
.iff(() -> !this.isNull(item.getOptions())) .iff(() -> !this.isNull(item.getOptions()))
.on(WordListDataPersist._options) .on(WordListDataPersist._options)
.over(item.getOptions()) .over(item.getOptions())
.using(() -> this.validatorFactory.validator(ComboBoxOptionPersist.ComboBoxOptionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(ComboBoxOptionPersist.ComboBoxOptionPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -59,7 +59,7 @@ public class DefinitionPersist {
.iff(() -> !this.isNull(item.getSections())) .iff(() -> !this.isNull(item.getSections()))
.on(DefinitionPersist._sections) .on(DefinitionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using(() -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class))
); );
} }
} }

View File

@ -144,12 +144,12 @@ public class SectionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(SectionPersist._fields) .on(SectionPersist._fields)
.over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).toList()) .over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.System).toList())
.using(() -> this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(SystemFieldPersist.SystemFieldPersistValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(SectionPersist._fields) .on(SectionPersist._fields)
.over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).toList()) .over(item.getFields().stream().filter(x -> x.getCategory() == DmpBlueprintFieldCategory.Extra).toList())
.using(() -> this.validatorFactory.validator(ExtraFieldPersist.ExtraFieldPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(ExtraFieldPersist.ExtraFieldPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates())) .must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.failOn(SectionPersist._descriptionTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), .failOn(SectionPersist._descriptionTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._descriptionTemplates}, LocaleContextHolder.getLocale())),
@ -157,7 +157,7 @@ public class SectionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates())) .iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.on(SectionPersist._descriptionTemplates) .on(SectionPersist._descriptionTemplates)
.over(item.getDescriptionTemplates()) .over(item.getDescriptionTemplates())
.using(() -> this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class))
); );
} }

View File

@ -60,7 +60,7 @@ public class DefinitionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(DefinitionPersist._fields) .on(DefinitionPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
); );
} }
} }

View File

@ -69,7 +69,7 @@ public class ReferenceTypeDefinitionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(ReferenceTypeDefinitionPersist._fields) .on(ReferenceTypeDefinitionPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using(() -> this.validatorFactory.validator(ReferenceTypeFieldPersist.ReferenceTypeFieldPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(ReferenceTypeFieldPersist.ReferenceTypeFieldPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isListNullOrEmpty(item.getSources())) .must(() -> !this.isListNullOrEmpty(item.getSources()))
.failOn(ReferenceTypeDefinitionPersist._sources).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeDefinitionPersist._sources}, LocaleContextHolder.getLocale())), .failOn(ReferenceTypeDefinitionPersist._sources).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeDefinitionPersist._sources}, LocaleContextHolder.getLocale())),
@ -77,12 +77,12 @@ public class ReferenceTypeDefinitionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getSources())) .iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(ReferenceTypeDefinitionPersist._sources) .on(ReferenceTypeDefinitionPersist._sources)
.over(item.getSources().stream().filter(x -> x.getType() == ReferenceTypeSourceType.API).toList()) .over(item.getSources().stream().filter(x -> x.getType() == ReferenceTypeSourceType.API).toList())
.using(() -> this.validatorFactory.validator(ReferenceTypeSourceExternalApiConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(ReferenceTypeSourceExternalApiConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getSources())) .iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(ReferenceTypeDefinitionPersist._sources) .on(ReferenceTypeDefinitionPersist._sources)
.over(item.getSources().stream().filter(x -> x.getType() == ReferenceTypeSourceType.STATIC).toList()) .over(item.getSources().stream().filter(x -> x.getType() == ReferenceTypeSourceType.STATIC).toList())
.using(() -> this.validatorFactory.validator(ReferenceTypeSourceStaticOptionConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(ReferenceTypeSourceStaticOptionConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class))
); );
} }
} }

View File

@ -118,7 +118,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
.iff(() -> !this.isListNullOrEmpty(item.getDependencies())) .iff(() -> !this.isListNullOrEmpty(item.getDependencies()))
.on(ReferenceTypeSourceBaseConfigurationPersist._dependencies) .on(ReferenceTypeSourceBaseConfigurationPersist._dependencies)
.over(item.getDependencies()) .over(item.getDependencies())
.using(() -> this.validatorFactory.validator(ReferenceTypeSourceBaseDependencyPersist.ReferenceTypeSourceBaseDependencyPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(ReferenceTypeSourceBaseDependencyPersist.ReferenceTypeSourceBaseDependencyPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -105,7 +105,7 @@ public class ReferenceTypeSourceBaseDependencyPersist {
.iff(() -> !this.isListNullOrEmpty(item.getProperties())) .iff(() -> !this.isListNullOrEmpty(item.getProperties()))
.on(ReferenceTypeSourceBaseDependencyPersist._properties) .on(ReferenceTypeSourceBaseDependencyPersist._properties)
.over(item.getProperties()) .over(item.getProperties())
.using(() -> this.validatorFactory.validator(DependencyPropertyPersist.DependencyPropertyPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DependencyPropertyPersist.DependencyPropertyPersistValidator.class))
); );
} }
} }

View File

@ -187,7 +187,7 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
.iff(() -> !this.isListNullOrEmpty(item.getQueries())) .iff(() -> !this.isListNullOrEmpty(item.getQueries()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._queries) .on(ReferenceTypeSourceExternalApiConfigurationPersist._queries)
.over(item.getQueries()) .over(item.getQueries())
.using(() -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class))
)); ));
return specifications; return specifications;
} }

View File

@ -49,7 +49,7 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen
.iff(() -> !this.isListNullOrEmpty(item.getOptions())) .iff(() -> !this.isListNullOrEmpty(item.getOptions()))
.on(ReferenceTypeSourceStaticOptionConfigurationPersist._options) .on(ReferenceTypeSourceStaticOptionConfigurationPersist._options)
.over(item.getOptions()) .over(item.getOptions())
.using(() -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class))
); );
return specifications; return specifications;
} }

View File

@ -75,7 +75,7 @@ public class ResultsConfigurationPersist {
.iff(() -> !this.isListNullOrEmpty(item.getFieldsMapping())) .iff(() -> !this.isListNullOrEmpty(item.getFieldsMapping()))
.on(ResultsConfigurationPersist._fieldsMapping) .on(ResultsConfigurationPersist._fieldsMapping)
.over(item.getFieldsMapping()) .over(item.getFieldsMapping())
.using(() -> this.validatorFactory.validator(ResultFieldsMappingConfigurationPersist.ResultFieldsMappingConfigurationPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(ResultFieldsMappingConfigurationPersist.ResultFieldsMappingConfigurationPersistValidator.class))
); );
} }
} }

View File

@ -51,7 +51,7 @@ public class TenantDepositConfigPersist {
.iff(() -> !this.isListNullOrEmpty(item.getSources())) .iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(TenantDepositConfigPersist._sources) .on(TenantDepositConfigPersist._sources)
.over(item.getSources()) .over(item.getSources())
.using(() -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class))
); );
} }
} }

View File

@ -51,7 +51,7 @@ public class TenantFileTransformersConfigPersist {
.iff(() -> !this.isListNullOrEmpty(item.getSources())) .iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(TenantFileTransformersConfigPersist._sources) .on(TenantFileTransformersConfigPersist._sources)
.over(item.getSources()) .over(item.getSources())
.using(() -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(TenantSourcePersist.TenantSourcePersistValidator.class))
); );
} }
} }

View File

@ -330,7 +330,7 @@
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>
<artifactId>validation</artifactId> <artifactId>validation</artifactId>
<version>3.0.1</version> <version>3.0.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>gr.cite</groupId> <groupId>gr.cite</groupId>