2024-01-05 17:32:24 +01:00
|
|
|
package eu.eudat.model.persist;
|
|
|
|
|
|
|
|
import eu.eudat.commons.validation.BaseValidator;
|
2024-01-17 10:20:02 +01:00
|
|
|
import gr.cite.tools.validation.specification.Specification;
|
2024-01-05 17:32:24 +01:00
|
|
|
import eu.eudat.convention.ConventionService;
|
|
|
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|
|
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
|
|
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;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
public class DescriptionProfilingRequest {
|
|
|
|
|
2024-03-01 10:14:27 +01:00
|
|
|
private UUID prefillingSourceId;
|
2024-01-05 17:32:24 +01:00
|
|
|
|
2024-03-01 10:14:27 +01:00
|
|
|
public static final String _prefillingSourceId = "prefillingSourceId";
|
2024-01-05 17:32:24 +01:00
|
|
|
|
|
|
|
private UUID descriptionTemplateId;
|
|
|
|
|
|
|
|
public static final String _descriptionTemplateId = "descriptionTemplateId";
|
|
|
|
|
|
|
|
private BaseFieldSet project;
|
|
|
|
public static final String _project = "project";
|
|
|
|
|
|
|
|
|
2024-03-01 10:14:27 +01:00
|
|
|
public UUID getPrefillingSourceId() {
|
|
|
|
return prefillingSourceId;
|
2024-01-05 17:32:24 +01:00
|
|
|
}
|
|
|
|
|
2024-03-01 10:14:27 +01:00
|
|
|
public void setPrefillingSourceId(UUID prefillingSourceId) {
|
|
|
|
this.prefillingSourceId = prefillingSourceId;
|
2024-01-05 17:32:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public UUID getDescriptionTemplateId() {
|
|
|
|
return descriptionTemplateId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
|
|
|
|
this.descriptionTemplateId = descriptionTemplateId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public BaseFieldSet getProject() {
|
|
|
|
return project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProject(BaseFieldSet project) {
|
|
|
|
this.project = project;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component(DescriptionProfilingRequestValidator.ValidatorName)
|
|
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
|
|
public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionProfilingRequest> {
|
|
|
|
|
|
|
|
public static final String ValidatorName = "DescriptionProfilingRequestValidator";
|
|
|
|
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
|
|
|
|
|
|
|
|
protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
|
|
super(conventionService, errors);
|
|
|
|
this.messageSource = messageSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Class<DescriptionProfilingRequest> modelClass() {
|
|
|
|
return DescriptionProfilingRequest.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Specification> specifications(DescriptionProfilingRequest item) {
|
|
|
|
return Arrays.asList(
|
|
|
|
this.spec()
|
|
|
|
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
|
|
|
|
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
|
|
|
|
this.spec()
|
2024-03-01 10:14:27 +01:00
|
|
|
.must(() -> this.isValidGuid(item.getPrefillingSourceId()))
|
|
|
|
.failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
|
2024-01-05 17:32:24 +01:00
|
|
|
this.spec()
|
|
|
|
.must(() -> item.getProject() != null)
|
|
|
|
.failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale()))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|