70 lines
2.6 KiB
Java
70 lines
2.6 KiB
Java
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
|
|
|
|
import eu.eudat.commons.enums.FieldDataExternalDatasetType;
|
|
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.Arrays;
|
|
import java.util.List;
|
|
|
|
public class ExternalDatasetDataPersist extends BaseFieldDataPersist {
|
|
|
|
private Boolean multipleSelect = null;
|
|
|
|
public static final String _multipleSelect = "multipleSelect";
|
|
|
|
private FieldDataExternalDatasetType type;
|
|
|
|
public static final String _type = "type";
|
|
|
|
public Boolean getMultipleSelect() {
|
|
return multipleSelect;
|
|
}
|
|
|
|
public void setMultipleSelect(Boolean multipleSelect) {
|
|
this.multipleSelect = multipleSelect;
|
|
}
|
|
|
|
public FieldDataExternalDatasetType getType() {
|
|
return type;
|
|
}
|
|
|
|
public void setType(FieldDataExternalDatasetType type) {
|
|
this.type = type;
|
|
}
|
|
|
|
@Component(ExternalDatasetDataPersist.ExternalDatasetDataPersistValidator.ValidatorName)
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
public static class ExternalDatasetDataPersistValidator extends BaseFieldDataPersistValidator<ExternalDatasetDataPersist> {
|
|
|
|
public static final String ValidatorName = "DescriptionTemplate.ExternalDatasetDataPersistValidator";
|
|
|
|
protected ExternalDatasetDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
super(conventionService, errors, messageSource);
|
|
}
|
|
|
|
@Override
|
|
protected Class<ExternalDatasetDataPersist> modelClass() {
|
|
return ExternalDatasetDataPersist.class;
|
|
}
|
|
|
|
@Override
|
|
protected List<Specification> specifications(ExternalDatasetDataPersist item) {
|
|
List<Specification> specifications = getBaseSpecifications(item);
|
|
specifications.addAll(Arrays.asList(
|
|
this.spec()
|
|
.must(() -> !this.isNull(item.getMultipleSelect()))
|
|
.failOn(ExternalDatasetDataPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._multipleSelect}, LocaleContextHolder.getLocale()))
|
|
));
|
|
return specifications;
|
|
}
|
|
}
|
|
|
|
}
|