update validators with list null or empty

This commit is contained in:
amentis 2024-01-24 13:54:26 +02:00
parent b5c31590d3
commit d0faa6713d
14 changed files with 28 additions and 28 deletions

View File

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

View File

@ -192,10 +192,10 @@ public class DescriptionTemplatePersist {
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
this.spec()
.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())),
this.navSpec()
.iff(() -> !this.isNull(item.getUsers()))
.iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(DescriptionTemplatePersist._users)
.over(item.getUsers())
.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())),
this.spec()
.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())),
this.navSpec()
.iff(() -> !this.isNull(item.getDescriptionTemplates()))
.iff(() -> !this.isListNullOrEmpty(item.getDescriptionTemplates()))
.on(DmpPersist._descriptionTemplates)
.over(item.getDescriptionTemplates())
.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())),
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getUsers()))
.iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(DmpUserInvitePersist._users)
.over(item.getUsers())
.using((itm) -> this.validatorFactory.validator(DmpUserInviteTypePersist.DmpUserInviteTypePersistValidator.class))

View File

@ -183,10 +183,10 @@ public class NewVersionDescriptionTemplatePersist {
.over(item.getDefinition())
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getUsers()))
.iff(() -> !this.isListNullOrEmpty(item.getUsers()))
.on(NewVersionDescriptionTemplatePersist._users)
.over(item.getUsers())
.using((itm) -> this.validatorFactory.validator(UserDescriptionTemplatePersist.UserDescriptionTemplatePersistValidator.class))

View File

@ -80,7 +80,7 @@ public class UserRolePatchPersist {
.must(() -> !this.isValidHash(item.getHash()))
.failOn(UserRolePatchPersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
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()))
);
}

View File

@ -58,10 +58,10 @@ public class PropertyDefinitionPersist {
return Arrays.asList(
this.spec()
.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())),
this.navSpec()
.iff(() -> !this.isNull(item.getFields()))
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(PropertyDefinitionPersist._fields)
.over(item.getFields())
.using((itm) -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))

View File

@ -65,18 +65,18 @@ public class DefinitionPersist {
protected List<Specification> specifications(DefinitionPersist item) {
return Arrays.asList(
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getSections()))
.iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(DefinitionPersist._sections)
.over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class)),
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getPages()))
.iff(() -> !this.isListNullOrEmpty(item.getPages()))
.on(DefinitionPersist._pages)
.over(item.getPages())
.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())),
this.navSpec()
.iff(() -> !this.isNull(item.getVisibilityRules()))
.iff(() -> !this.isListNullOrEmpty(item.getVisibilityRules()))
.on(FieldPersist._visibilityRules)
.over(item.getVisibilityRules())
.using((itm) -> this.validatorFactory.validator(RulePersist.RulePersistValidator.class)),

View File

@ -176,7 +176,7 @@ public class FieldSetPersist {
.over(item.getMultiplicity())
.using(() -> this.validatorFactory.validator(MultiplicityPersist.MultiplicityValidator.class)),
this.navSpec()
.iff(() -> !this.isNull(item.getFields()))
.iff(() -> !this.isListNullOrEmpty(item.getFields()))
.on(FieldSetPersist._fields)
.over(item.getFields())
.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())),
this.navSpec()
.iff(() -> !this.isNull(item.getSections()))
.iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(SectionPersist._sections)
.over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersistValidator.class)),
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getFieldSets()))
.iff(() -> !this.isListNullOrEmpty(item.getFieldSets()))
.on(SectionPersist._fieldSets)
.over(item.getFieldSets())
.using((itm) -> this.validatorFactory.validator(FieldSetPersist.FieldSetPersistValidator.class))

View File

@ -53,10 +53,10 @@ public class DefinitionPersist {
protected List<Specification> specifications(DefinitionPersist item) {
return Arrays.asList(
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())),
this.navSpec()
.iff(() -> !this.isNull(item.getSections()))
.iff(() -> !this.isListNullOrEmpty(item.getSections()))
.on(DefinitionPersist._sections)
.over(item.getSections())
.using((itm) -> this.validatorFactory.validator(SectionPersist.SectionPersistValidator.class))

View File

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

View File

@ -137,14 +137,14 @@ public class DmpController {
public Dmp Persist(@RequestBody DmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException {
logger.debug(new MapLogEntry("persisting" + Dmp.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
Dmp persisted = this.dmpService.persist(model, fieldSet);
//Dmp persisted = this.dmpService.persist(model, fieldSet);
this.auditService.track(AuditableAction.Dmp_Persist, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("model", model),
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
));
return persisted;
return null;
}
@DeleteMapping("{id}")