Compare commits

...

2 Commits

Author SHA1 Message Date
amentis 7d38ab742d update validators with list null or empty 2024-01-24 13:55:28 +02:00
amentis d0faa6713d update validators with list null or empty 2024-01-24 13:54:26 +02:00
13 changed files with 26 additions and 26 deletions

View File

@ -203,7 +203,7 @@ public class DescriptionPersist {
.failOn(DescriptionPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())), .failOn(DescriptionPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._status}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getTags())) .must(() -> !this.isListNullOrEmpty(item.getTags()))
.failOn(DescriptionPersist._tags).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._tags}, LocaleContextHolder.getLocale())), .failOn(DescriptionPersist._tags).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._tags}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
@ -217,10 +217,10 @@ public class DescriptionPersist {
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus())), .using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus())),
this.spec() this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getReferences())) .must(() -> !this.isListNullOrEmpty(item.getReferences()))
.failOn(DescriptionPersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._references}, LocaleContextHolder.getLocale())), .failOn(DescriptionPersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._references}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getReferences())) .iff(() -> !this.isListNullOrEmpty(item.getReferences()))
.on(DescriptionPersist._references) .on(DescriptionPersist._references)
.over(item.getReferences()) .over(item.getReferences())
.using((itm) -> this.validatorFactory.validator(DescriptionReferencePersist.DescriptionReferencePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DescriptionReferencePersist.DescriptionReferencePersistValidator.class))

View File

@ -192,10 +192,10 @@ public class DescriptionTemplatePersist {
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)), .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
this.spec() this.spec()
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized) .iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
.must(() -> !this.isNull(item.getUsers())) .must(() -> !this.isListNullOrEmpty(item.getUsers()))
.failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())), .failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(DescriptionTemplatePersist._users) .on(DescriptionTemplatePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))

View File

@ -195,10 +195,10 @@ public class DmpPersist {
.using(() -> this.validatorFactory.validator(DmpPropertiesPersist.DmpPropertiesPersistValidator.class).setStatus(item.getStatus())), .using(() -> this.validatorFactory.validator(DmpPropertiesPersist.DmpPropertiesPersistValidator.class).setStatus(item.getStatus())),
this.spec() this.spec()
.iff(() -> item.getStatus() == DmpStatus.Finalized) .iff(() -> item.getStatus() == DmpStatus.Finalized)
.must(() -> !this.isNull(item.getDescriptionTemplates())) .must(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.failOn(DmpPersist._descriptionTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._descriptionTemplates}, LocaleContextHolder.getLocale())), .failOn(DmpPersist._descriptionTemplates).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._descriptionTemplates}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getDescriptionTemplates())) .iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.on(DmpPersist._descriptionTemplates) .on(DmpPersist._descriptionTemplates)
.over(item.getDescriptionTemplates()) .over(item.getDescriptionTemplates())
.using((itm) -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class))

View File

@ -70,10 +70,10 @@ public class DmpUserInvitePersist {
.failOn(DmpUserInvitePersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserInvitePersist._role}, LocaleContextHolder.getLocale())), .failOn(DmpUserInvitePersist._role).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserInvitePersist._role}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getUsers())) .must(() -> !this.isListNullOrEmpty(item.getUsers()))
.failOn(DmpUserInvitePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserInvitePersist._users}, LocaleContextHolder.getLocale())), .failOn(DmpUserInvitePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserInvitePersist._users}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(DmpUserInvitePersist._users) .on(DmpUserInvitePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using((itm) -> this.validatorFactory.validator(DmpUserInviteTypePersist.DmpUserInviteTypePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DmpUserInviteTypePersist.DmpUserInviteTypePersistValidator.class))

View File

@ -183,10 +183,10 @@ public class NewVersionDescriptionTemplatePersist {
.over(item.getDefinition()) .over(item.getDefinition())
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)), .using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getUsers())) .must(() -> !this.isListNullOrEmpty(item.getUsers()))
.failOn(NewVersionDescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())), .failOn(NewVersionDescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getUsers())) .iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(NewVersionDescriptionTemplatePersist._users) .on(NewVersionDescriptionTemplatePersist._users)
.over(item.getUsers()) .over(item.getUsers())
.using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))

View File

@ -80,7 +80,7 @@ public class UserRolePatchPersist {
.must(() -> !this.isValidHash(item.getHash())) .must(() -> !this.isValidHash(item.getHash()))
.failOn(UserRolePatchPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), .failOn(UserRolePatchPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getRoles())) .must(() -> !this.isListNullOrEmpty(item.getRoles()))
.failOn(UserRolePatchPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserRolePatchPersist._roles}, LocaleContextHolder.getLocale())) .failOn(UserRolePatchPersist._roles).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserRolePatchPersist._roles}, LocaleContextHolder.getLocale()))
); );
} }

View File

@ -58,10 +58,10 @@ public class PropertyDefinitionPersist {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.iff(() -> this.status == DescriptionStatus.Finalized) .iff(() -> this.status == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getFields())) .must(() -> !this.isListNullOrEmpty(item.getFields()))
.failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())), .failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(PropertyDefinitionPersist._fields) .on(PropertyDefinitionPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))

View File

@ -65,18 +65,18 @@ public class DefinitionPersist {
protected List<Specification> specifications(DefinitionPersist item) { protected List<Specification> specifications(DefinitionPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isNull(item.getSections())) .must(() -> !this.isListNullOrEmpty(item.getSections()))
.failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._sections}, LocaleContextHolder.getLocale())), .failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._sections}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getSections())) .iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(DefinitionPersist._sections) .on(DefinitionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getPages())) .must(() -> !this.isListNullOrEmpty(item.getPages()))
.failOn(DefinitionPersist._pages).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._pages}, LocaleContextHolder.getLocale())), .failOn(DefinitionPersist._pages).failWith(messageSource.getMessage("Validation_Required", new Object[]{DefinitionPersist._pages}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getPages())) .iff(() -> !this.isListNullOrEmpty(item.getPages()))
.on(DefinitionPersist._pages) .on(DefinitionPersist._pages)
.over(item.getPages()) .over(item.getPages())
.using((itm) -> this.validatorFactory.validator(PagePersist.PagePersistValidator.class)) .using((itm) -> this.validatorFactory.validator(PagePersist.PagePersistValidator.class))

View File

@ -146,7 +146,7 @@ public class FieldPersist {
.failOn(FieldPersist._includeInExport).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._includeInExport}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._includeInExport).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._includeInExport}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getVisibilityRules())) .iff(() -> !this.isListNullOrEmpty(item.getVisibilityRules()))
.on(FieldPersist._visibilityRules) .on(FieldPersist._visibilityRules)
.over(item.getVisibilityRules()) .over(item.getVisibilityRules())
.using((itm) -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)),

View File

@ -176,7 +176,7 @@ public class FieldSetPersist {
.over(item.getMultiplicity()) .over(item.getMultiplicity())
.using(() -> this.validatorFactory.validator(MultiplicityPersist.MultiplicityValidator.class)), .using(() -> this.validatorFactory.validator(MultiplicityPersist.MultiplicityValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getFields())) .iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(FieldSetPersist._fields) .on(FieldSetPersist._fields)
.over(item.getFields()) .over(item.getFields())
.using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))

View File

@ -171,15 +171,15 @@ public class SectionPersist {
.failOn(SectionPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._description}, LocaleContextHolder.getLocale())), .failOn(SectionPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._description}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getSections())) .iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(SectionPersist._sections) .on(SectionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersistValidator.class)), .using((itm) -> this.validatorFactory.validator(SectionPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getFieldSets())) .must(() -> !this.isListNullOrEmpty(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())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getFieldSets())) .iff(() -> !this.isListNullOrEmpty(item.getFieldSets()))
.on(SectionPersist._fieldSets) .on(SectionPersist._fieldSets)
.over(item.getFieldSets()) .over(item.getFieldSets())
.using((itm) -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class))

View File

@ -53,10 +53,10 @@ public class DefinitionPersist {
protected List<Specification> specifications(DefinitionPersist item) { protected List<Specification> specifications(DefinitionPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isNull(item.getSections())) .must(() -> !this.isListNullOrEmpty(item.getSections()))
.failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{eu.eudat.model.persist.descriptiontemplatedefinition.DefinitionPersist._sections}, LocaleContextHolder.getLocale())), .failOn(DefinitionPersist._sections).failWith(messageSource.getMessage("Validation_Required", new Object[]{eu.eudat.model.persist.descriptiontemplatedefinition.DefinitionPersist._sections}, LocaleContextHolder.getLocale())),
this.navSpec() this.navSpec()
.iff(() -> !this.isNull(item.getSections())) .iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(DefinitionPersist._sections) .on(DefinitionPersist._sections)
.over(item.getSections()) .over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class))

View File

@ -72,7 +72,7 @@ public class DmpPropertiesPersist {
.mapKey((k) -> ((UUID)k).toString()) .mapKey((k) -> ((UUID)k).toString())
.using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> this.status == DmpStatus.Finalized && !this.isNull(item.getContacts())) .iff(() -> this.status == DmpStatus.Finalized && !this.isListNullOrEmpty(item.getContacts()))
.on(DmpPropertiesPersist._contacts) .on(DmpPropertiesPersist._contacts)
.over(item.getContacts()) .over(item.getContacts())
.using((itm) -> this.validatorFactory.validator(DmpContactPersist.DmpContactPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(DmpContactPersist.DmpContactPersistValidator.class))