prefilling small changes

This commit is contained in:
amentis 2024-03-01 11:14:27 +02:00
parent b1ebc6b35a
commit a5c194ac95
3 changed files with 17 additions and 38 deletions

View File

@ -13,17 +13,13 @@ import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DescriptionProfilingRequest { public class DescriptionProfilingRequest {
private String prefillId; private UUID prefillingSourceId;
public static final String _prefillId = "prefillId";
private String configId; public static final String _prefillingSourceId = "prefillingSourceId";
public static final String _configId = "configId";
private UUID descriptionTemplateId; private UUID descriptionTemplateId;
@ -31,22 +27,14 @@ public class DescriptionProfilingRequest {
private BaseFieldSet project; private BaseFieldSet project;
public static final String _project = "project"; public static final String _project = "project";
public String getPrefillId() {
return prefillId; public UUID getPrefillingSourceId() {
return prefillingSourceId;
} }
public void setPrefillId(String prefillId) { public void setPrefillingSourceId(UUID prefillingSourceId) {
this.prefillId = prefillId; this.prefillingSourceId = prefillingSourceId;
}
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
} }
public UUID getDescriptionTemplateId() { public UUID getDescriptionTemplateId() {
@ -91,11 +79,8 @@ public class DescriptionProfilingRequest {
.must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getConfigId())) .must(() -> this.isValidGuid(item.getPrefillingSourceId()))
.failOn(DescriptionProfilingRequest._configId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._configId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getPrefillId()))
.failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> item.getProject() != null) .must(() -> item.getProject() != null)
.failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale())) .failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale()))

View File

@ -21,7 +21,7 @@ public class DescriptionProfilingWithDataRequest {
private Map<String, Object> data; private Map<String, Object> data;
public static final String _data = "data"; public static final String _data = "data";
private String prefillingSourceId; private UUID prefillingSourceId;
public static final String _prefillingSourceId = "prefillingSourceId"; public static final String _prefillingSourceId = "prefillingSourceId";
@ -40,11 +40,11 @@ public class DescriptionProfilingWithDataRequest {
this.data = data; this.data = data;
} }
public String getPrefillingSourceId() { public UUID getPrefillingSourceId() {
return prefillingSourceId; return prefillingSourceId;
} }
public void setPrefillingSourceId(String prefillingSourceId) { public void setPrefillingSourceId(UUID prefillingSourceId) {
this.prefillingSourceId = prefillingSourceId; this.prefillingSourceId = prefillingSourceId;
} }
@ -90,7 +90,7 @@ public class DescriptionProfilingWithDataRequest {
.must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getPrefillingSourceId())) .must(() -> this.isValidGuid(item.getPrefillingSourceId()))
.failOn(DescriptionProfilingWithDataRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._prefillingSourceId}, LocaleContextHolder.getLocale())), .failOn(DescriptionProfilingWithDataRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._prefillingSourceId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> item.getData() != null) .must(() -> item.getData() != null)

View File

@ -14,12 +14,9 @@ import eu.eudat.commons.types.externalfetcher.*;
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity;
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFixedValueFieldEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFixedValueFieldEntity;
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.*; import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionTemplateBuilder; import eu.eudat.model.builder.DescriptionTemplateBuilder;
@ -36,11 +33,8 @@ import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinit
import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition; import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition;
import eu.eudat.model.referencedefinition.Definition; import eu.eudat.model.referencedefinition.Definition;
import eu.eudat.query.PrefillingSourceQuery; import eu.eudat.query.PrefillingSourceQuery;
import eu.eudat.query.ReferenceTypeQuery;
import eu.eudat.query.lookup.ReferenceSearchLookup; import eu.eudat.query.lookup.ReferenceSearchLookup;
import eu.eudat.service.externalfetcher.ExternalFetcherService; import eu.eudat.service.externalfetcher.ExternalFetcherService;
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.externalfetcher.models.ExternalDataResult; import eu.eudat.service.externalfetcher.models.ExternalDataResult;
import eu.eudat.service.reference.ReferenceService; import eu.eudat.service.reference.ReferenceService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
@ -315,11 +309,11 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
} }
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(UUID.fromString(model.getPrefillId())).isActive(IsActive.Active).first(); PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).isActive(IsActive.Active).first();
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest(); DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
descriptionProfilingWithDataRequest.setPrefillingSourceId(model.getConfigId()); descriptionProfilingWithDataRequest.setPrefillingSourceId(model.getPrefillingSourceId());
descriptionProfilingWithDataRequest.setProject(model.getProject()); descriptionProfilingWithDataRequest.setProject(model.getProject());
descriptionProfilingWithDataRequest.setDescriptionTemplateId(model.getDescriptionTemplateId()); descriptionProfilingWithDataRequest.setDescriptionTemplateId(model.getDescriptionTemplateId());
validatorFactory.validator(DescriptionProfilingWithDataRequest.DescriptionProfilingWithDataRequestValidator.ValidatorName).validateForce(descriptionProfilingWithDataRequest); validatorFactory.validator(DescriptionProfilingWithDataRequest.DescriptionProfilingWithDataRequestValidator.ValidatorName).validateForce(descriptionProfilingWithDataRequest);
@ -328,7 +322,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(UUID.fromString(model.getPrefillingSourceId())).first(); PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(model.getPrefillingSourceId()).first();
if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition()); PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());