From a5c194ac95fae239db83d0eb602f5c84a9b3a342 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 1 Mar 2024 11:14:27 +0200 Subject: [PATCH] prefilling small changes --- .../persist/DescriptionProfilingRequest.java | 33 +++++-------------- .../DescriptionProfilingWithDataRequest.java | 8 ++--- .../PrefillingSourceServiceImpl.java | 14 +++----- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingRequest.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingRequest.java index 67b4f2714..0b4a577b0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingRequest.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingRequest.java @@ -13,17 +13,13 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.UUID; public class DescriptionProfilingRequest { - private String prefillId; - public static final String _prefillId = "prefillId"; + private UUID prefillingSourceId; - private String configId; - - public static final String _configId = "configId"; + public static final String _prefillingSourceId = "prefillingSourceId"; private UUID descriptionTemplateId; @@ -31,22 +27,14 @@ public class DescriptionProfilingRequest { private BaseFieldSet project; public static final String _project = "project"; - - public String getPrefillId() { - return prefillId; + + public UUID getPrefillingSourceId() { + return prefillingSourceId; } - public void setPrefillId(String prefillId) { - this.prefillId = prefillId; - } - - public String getConfigId() { - return configId; - } - - public void setConfigId(String configId) { - this.configId = configId; + public void setPrefillingSourceId(UUID prefillingSourceId) { + this.prefillingSourceId = prefillingSourceId; } public UUID getDescriptionTemplateId() { @@ -91,11 +79,8 @@ public class DescriptionProfilingRequest { .must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), this.spec() - .must(() -> !this.isEmpty(item.getConfigId())) - .failOn(DescriptionProfilingRequest._configId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._configId}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isEmpty(item.getPrefillId())) - .failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale())), + .must(() -> this.isValidGuid(item.getPrefillingSourceId())) + .failOn(DescriptionProfilingRequest._prefillingSourceId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillingSourceId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> item.getProject() != null) .failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale())) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingWithDataRequest.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingWithDataRequest.java index da6331bed..87de6af19 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingWithDataRequest.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionProfilingWithDataRequest.java @@ -21,7 +21,7 @@ public class DescriptionProfilingWithDataRequest { private Map data; public static final String _data = "data"; - private String prefillingSourceId; + private UUID prefillingSourceId; public static final String _prefillingSourceId = "prefillingSourceId"; @@ -40,11 +40,11 @@ public class DescriptionProfilingWithDataRequest { this.data = data; } - public String getPrefillingSourceId() { + public UUID getPrefillingSourceId() { return prefillingSourceId; } - public void setPrefillingSourceId(String prefillingSourceId) { + public void setPrefillingSourceId(UUID prefillingSourceId) { this.prefillingSourceId = prefillingSourceId; } @@ -90,7 +90,7 @@ public class DescriptionProfilingWithDataRequest { .must(() -> this.isValidGuid(item.getDescriptionTemplateId())) .failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())), 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())), this.spec() .must(() -> item.getData() != null) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java index bbde6df63..8ce773a54 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java @@ -14,12 +14,9 @@ import eu.eudat.commons.types.externalfetcher.*; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity; import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFixedValueFieldEntity; -import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity; import eu.eudat.convention.ConventionService; import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.PrefillingSourceEntity; -import eu.eudat.data.ReferenceEntity; -import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.model.*; 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.referencedefinition.Definition; import eu.eudat.query.PrefillingSourceQuery; -import eu.eudat.query.ReferenceTypeQuery; import eu.eudat.query.lookup.ReferenceSearchLookup; 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.reference.ReferenceService; 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 { - PrefillingSourceEntity prefillingSourceEntity = this.queryFactory.query(PrefillingSourceQuery.class).ids(UUID.fromString(model.getPrefillId())).isActive(IsActive.Active).first(); - if (prefillingSourceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPrefillId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); + 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.getPrefillingSourceId(), PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale())); DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest(); - descriptionProfilingWithDataRequest.setPrefillingSourceId(model.getConfigId()); + descriptionProfilingWithDataRequest.setPrefillingSourceId(model.getPrefillingSourceId()); descriptionProfilingWithDataRequest.setProject(model.getProject()); descriptionProfilingWithDataRequest.setDescriptionTemplateId(model.getDescriptionTemplateId()); 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 { - 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())); PrefillingSourceDefinitionEntity prefillingSourceDefinition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, prefillingSourceEntity.getDefinition());