57 lines
2.2 KiB
Java
57 lines
2.2 KiB
Java
package eu.eudat.model.persist.dmpblueprintdefinition;
|
|
|
|
import eu.eudat.convention.ConventionService;
|
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|
import gr.cite.tools.validation.specification.Specification;
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
import org.springframework.context.MessageSource;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
public class ReferenceFieldPersist extends FieldPersist {
|
|
|
|
private UUID referenceTypeId;
|
|
|
|
public static final String _referenceTypeId = "referenceTypeId";
|
|
|
|
public UUID getReferenceTypeId() {
|
|
return referenceTypeId;
|
|
}
|
|
|
|
public void setReferenceTypeId(UUID referenceTypeId) {
|
|
this.referenceTypeId = referenceTypeId;
|
|
}
|
|
|
|
@Component(ReferenceFieldPersistPersistValidator.ValidatorName)
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
public static class ReferenceFieldPersistPersistValidator extends BaseFieldPersistValidator<ReferenceFieldPersist> {
|
|
|
|
public static final String ValidatorName = "DmpBlueprint.ReferenceFieldPersistPersistValidator";
|
|
|
|
protected ReferenceFieldPersistPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
super(conventionService, errors, messageSource);
|
|
}
|
|
|
|
@Override
|
|
protected Class<ReferenceFieldPersist> modelClass() {
|
|
return ReferenceFieldPersist.class;
|
|
}
|
|
|
|
@Override
|
|
protected List<Specification> specifications(ReferenceFieldPersist item) {
|
|
List<Specification> specifications = getBaseSpecifications(item);
|
|
specifications.add(
|
|
this.spec()
|
|
.must(() -> !this.isNull(item.getReferenceTypeId()))
|
|
.failOn(ReferenceFieldPersist._referenceTypeId).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceFieldPersist._referenceTypeId}, LocaleContextHolder.getLocale()))
|
|
);
|
|
return specifications;
|
|
}
|
|
}
|
|
|
|
}
|