argos/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/SystemFieldPersist.java

59 lines
2.2 KiB
Java

package eu.eudat.model.persist.dmpblueprintdefinition;
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
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 SystemFieldPersist extends FieldPersist {
private DmpBlueprintSystemFieldType systemFieldType;
public static final String _systemFieldType = "systemFieldType";
public DmpBlueprintSystemFieldType getSystemFieldType() {
return systemFieldType;
}
public void setSystemFieldType(DmpBlueprintSystemFieldType systemFieldType) {
this.systemFieldType = systemFieldType;
}
@Component(SystemFieldPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class SystemFieldPersistValidator extends BaseFieldPersistValidator<SystemFieldPersist> {
public static final String ValidatorName = "DmpBlueprint.SystemFieldPersistValidator";
protected SystemFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors, messageSource);
}
@Override
protected Class<SystemFieldPersist> modelClass() {
return SystemFieldPersist.class;
}
@Override
protected List<Specification> specifications(SystemFieldPersist item) {
List<Specification> specifications = getBaseSpecifications(item);
specifications.add(
this.spec()
.must(() -> !this.isNull(item.getSystemFieldType()))
.failOn(SystemFieldPersist._systemFieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{SystemFieldPersist._systemFieldType}, LocaleContextHolder.getLocale()))
);
return specifications;
}
}
}