Resolving some validations applying based on status 'Finalized'
This commit is contained in:
parent
34df0b640c
commit
e8553b1605
|
@ -220,7 +220,7 @@ public class DescriptionPersist {
|
|||
.must(() -> !this.isNull(item.getReferences()))
|
||||
.failOn(DescriptionPersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._references}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> item.getStatus() == DescriptionStatus.Finalized && !this.isNull(item.getReferences()))
|
||||
.iff(() -> !this.isNull(item.getReferences()))
|
||||
.on(DescriptionPersist._references)
|
||||
.over(item.getReferences())
|
||||
.using(() -> this.validatorFactory.validator(DescriptionReferencePersist.DescriptionReferencePersistValidator.class))
|
||||
|
|
|
@ -166,12 +166,15 @@ public class DescriptionTemplatePersist {
|
|||
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplateEntity._labelLength))
|
||||
.failOn(DescriptionTemplatePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> !this.isEmpty(item.getDescription()))
|
||||
.failOn(DescriptionTemplatePersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._description}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> !this.isEmpty(item.getLanguage()))
|
||||
.failOn(DescriptionTemplatePersist._language).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._language}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> this.isValidGuid(item.getType()))
|
||||
.failOn(DescriptionTemplatePersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._type}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
|
@ -179,6 +182,7 @@ public class DescriptionTemplatePersist {
|
|||
.failOn(DescriptionTemplatePersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._status}, LocaleContextHolder.getLocale())),
|
||||
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> !this.isNull(item.getDefinition()))
|
||||
.failOn(DescriptionTemplatePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._definition}, LocaleContextHolder.getLocale())),
|
||||
this.refSpec()
|
||||
|
@ -187,6 +191,7 @@ public class DescriptionTemplatePersist {
|
|||
.over(item.getDefinition())
|
||||
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> !this.isNull(item.getUsers()))
|
||||
.failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
|
|
|
@ -127,6 +127,7 @@ public class DmpBlueprintPersist {
|
|||
.failOn(DmpBlueprintPersist._status).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._status}, LocaleContextHolder.getLocale())),
|
||||
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DmpBlueprintStatus.Finalized)
|
||||
.must(() -> !this.isNull(item.getDefinition()))
|
||||
.failOn(DmpBlueprintPersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpBlueprintPersist._definition}, LocaleContextHolder.getLocale())),
|
||||
this.refSpec()
|
||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.commons.validation.BaseValidator;
|
|||
import eu.eudat.commons.validation.specification.Specification;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import eu.eudat.model.persist.validation.StatusAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
@ -44,7 +43,7 @@ public class DmpDescriptionTemplatePersist {
|
|||
|
||||
@Component(DmpDescriptionTemplatePersistValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class DmpDescriptionTemplatePersistValidator extends BaseValidator<DmpDescriptionTemplatePersist> implements StatusAware<DmpStatus> {
|
||||
public static class DmpDescriptionTemplatePersistValidator extends BaseValidator<DmpDescriptionTemplatePersist> {
|
||||
|
||||
public static final String ValidatorName = "DmpDescriptionTemplatePersistValidator";
|
||||
|
||||
|
@ -66,21 +65,14 @@ public class DmpDescriptionTemplatePersist {
|
|||
protected List<Specification> specifications(DmpDescriptionTemplatePersist item) {
|
||||
return Arrays.asList(
|
||||
this.spec()
|
||||
.iff(() -> this.status == DmpStatus.Finalized)
|
||||
.must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId()))
|
||||
.failOn(DmpDescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpDescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> this.status == DmpStatus.Finalized)
|
||||
.must(() -> this.isValidGuid(item.getSectionId()))
|
||||
.failOn(DmpDescriptionTemplatePersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpDescriptionTemplatePersist._sectionId}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DmpDescriptionTemplatePersistValidator setStatus(DmpStatus status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class DmpPersist {
|
|||
.must(() -> !this.isNull(item.getReferences()))
|
||||
.failOn(DmpPersist._references).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpPersist._references}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> item.getStatus() == DmpStatus.Finalized && !this.isNull(item.getReferences()))
|
||||
.iff(() -> !this.isNull(item.getReferences()))
|
||||
.on(DmpPersist._references)
|
||||
.over(item.getReferences())
|
||||
.using(() -> this.validatorFactory.validator(DmpReferencePersist.DmpReferencePersistValidator.class)),
|
||||
|
@ -218,7 +218,7 @@ public class DmpPersist {
|
|||
.iff(() -> !this.isNull(item.getDescriptionTemplates()))
|
||||
.on(DmpPersist._descriptionTemplates)
|
||||
.over(item.getDescriptionTemplates())
|
||||
.using(() -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class).setStatus(item.getStatus()))
|
||||
.using(() -> this.validatorFactory.validator(DmpDescriptionTemplatePersist.DmpDescriptionTemplatePersistValidator.class))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PropertyDefinitionPersist {
|
|||
.must(() -> !this.isNull(item.getFields()))
|
||||
.failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> this.status == DescriptionStatus.Finalized && !this.isNull(item.getFields()))
|
||||
.iff(() -> !this.isNull(item.getFields()))
|
||||
.on(PropertyDefinitionPersist._fields)
|
||||
.over(item.getFields())
|
||||
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
|
||||
|
|
Loading…
Reference in New Issue