|
|
|
@ -208,4 +208,73 @@ public class ReferencePersist {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Component(ReferencePersistValidator.ValidatorName)
|
|
|
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
|
|
|
public static class ReferenceWithoutTypePersistValidator extends BaseValidator<ReferencePersist> {
|
|
|
|
|
|
|
|
|
|
public static final String ValidatorName = "ReferencePersistValidator";
|
|
|
|
|
|
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
|
|
|
|
|
|
private final ValidatorFactory validatorFactory;
|
|
|
|
|
|
|
|
|
|
protected ReferenceWithoutTypePersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
|
|
|
|
super(conventionService, errors);
|
|
|
|
|
this.messageSource = messageSource;
|
|
|
|
|
this.validatorFactory = validatorFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Class<ReferencePersist> modelClass() {
|
|
|
|
|
return ReferencePersist.class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected List<Specification> specifications(ReferencePersist item) {
|
|
|
|
|
return Arrays.asList(
|
|
|
|
|
this.spec()
|
|
|
|
|
.iff(() -> this.isValidGuid(item.getId()))
|
|
|
|
|
.must(() -> this.isValidHash(item.getHash()))
|
|
|
|
|
.failOn(ReferencePersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._hash}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.iff(() -> !this.isValidGuid(item.getId()))
|
|
|
|
|
.must(() -> !this.isValidHash(item.getHash()))
|
|
|
|
|
.failOn(ReferencePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.must(() -> !this.isEmpty(item.getLabel()))
|
|
|
|
|
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.iff(() -> !this.isEmpty(item.getLabel()))
|
|
|
|
|
.must(() -> this.lessEqualLength(item.getLabel(), ReferenceEntity._labelLength))
|
|
|
|
|
.failOn(ReferencePersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._label}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.must(() -> !this.isEmpty(item.getReference()))
|
|
|
|
|
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.iff(() -> !this.isEmpty(item.getReference()))
|
|
|
|
|
.must(() -> this.lessEqualLength(item.getReference(), ReferenceEntity._referenceLength))
|
|
|
|
|
.failOn(ReferencePersist._reference).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._reference}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.iff(() -> !this.isEmpty(item.getAbbreviation()))
|
|
|
|
|
.must(() -> this.lessEqualLength(item.getAbbreviation(), ReferenceEntity._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.lessEqualLength(item.getSource(), ReferenceEntity._sourceLength))
|
|
|
|
|
.failOn(ReferencePersist._source).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{ReferencePersist._source}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.spec()
|
|
|
|
|
.must(() -> !this.isNull(item.getSourceType()))
|
|
|
|
|
.failOn(ReferencePersist._sourceType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferencePersist._sourceType}, LocaleContextHolder.getLocale())),
|
|
|
|
|
this.refSpec()
|
|
|
|
|
.iff(() -> !this.isNull(item.getDefinition()))
|
|
|
|
|
.on(ReferencePersist._definition)
|
|
|
|
|
.over(item.getDefinition())
|
|
|
|
|
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|