diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/AuthenticationConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/AuthenticationConfigurationEntity.java index 5aa33059a..2a40ec173 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/AuthenticationConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/AuthenticationConfigurationEntity.java @@ -1,7 +1,7 @@ package eu.eudat.commons.types.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; -import eu.eudat.service.remotefetcher.config.entities.AuthenticationConfiguration; +import eu.eudat.service.externalfetcher.config.entities.AuthenticationConfiguration; import jakarta.xml.bind.annotation.XmlElement; public class AuthenticationConfigurationEntity implements AuthenticationConfiguration { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherApiSourceConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherApiSourceConfigurationEntity.java index 05d27847b..1c59b1cc5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherApiSourceConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherApiSourceConfigurationEntity.java @@ -2,7 +2,7 @@ package eu.eudat.commons.types.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; -import eu.eudat.service.remotefetcher.config.entities.SourceExternalApiConfiguration; +import eu.eudat.service.externalfetcher.config.entities.SourceExternalApiConfiguration; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherBaseSourceConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherBaseSourceConfigurationEntity.java index dfa3ddb50..3c86c9a0f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherBaseSourceConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherBaseSourceConfigurationEntity.java @@ -1,7 +1,7 @@ package eu.eudat.commons.types.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeSourceType; -import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration; +import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationEntity.java index 79d17a0c3..a593766e8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationEntity.java @@ -1,6 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.service.remotefetcher.config.entities.SourceStaticOptionConfiguration; +import eu.eudat.service.externalfetcher.config.entities.SourceStaticOptionConfiguration; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryCaseConfigEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryCaseConfigEntity.java index 5a6863f72..c863c4181 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryCaseConfigEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryCaseConfigEntity.java @@ -1,6 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.service.remotefetcher.config.entities.QueryCaseConfig; +import eu.eudat.service.externalfetcher.config.entities.QueryCaseConfig; import jakarta.xml.bind.annotation.XmlElement; import java.util.UUID; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryConfigEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryConfigEntity.java index 3ab26d175..1720b2a9a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryConfigEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/QueryConfigEntity.java @@ -1,6 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.service.remotefetcher.config.entities.QueryConfig; +import eu.eudat.service.externalfetcher.config.entities.QueryConfig; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultFieldsMappingConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultFieldsMappingConfigurationEntity.java index 7b9f0d359..8cba08dcd 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultFieldsMappingConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultFieldsMappingConfigurationEntity.java @@ -1,6 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.service.remotefetcher.config.entities.ResultFieldsMappingConfiguration; +import eu.eudat.service.externalfetcher.config.entities.ResultFieldsMappingConfiguration; import jakarta.xml.bind.annotation.XmlElement; public class ResultFieldsMappingConfigurationEntity implements ResultFieldsMappingConfiguration { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultsConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultsConfigurationEntity.java index 5584084d6..39f36c375 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultsConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/ResultsConfigurationEntity.java @@ -1,7 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity; -import eu.eudat.service.remotefetcher.config.entities.ResultsConfiguration; +import eu.eudat.service.externalfetcher.config.entities.ResultsConfiguration; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/StaticOptionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/StaticOptionEntity.java index b9defc849..8e6ac0cc0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/StaticOptionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/externalfetcher/StaticOptionEntity.java @@ -1,6 +1,6 @@ package eu.eudat.commons.types.externalfetcher; -import eu.eudat.service.remotefetcher.config.entities.StaticOption; +import eu.eudat.service.externalfetcher.config.entities.StaticOption; import jakarta.xml.bind.annotation.XmlElement; public class StaticOptionEntity implements StaticOption { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinition.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinition.java deleted file mode 100644 index 798f8e7e5..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinition.java +++ /dev/null @@ -1,35 +0,0 @@ -package eu.eudat.commons.types.prefillingsource; - -import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceExternalApiConfiguration; - -import java.util.List; - -public class PrefillingSourceDefinition { - private ReferenceTypeSourceExternalApiConfiguration searchConfiguration; - private ReferenceTypeSourceExternalApiConfiguration getConfiguration; - private List fields; - - public ReferenceTypeSourceExternalApiConfiguration getSearchConfiguration() { - return searchConfiguration; - } - - public void setSearchConfiguration(ReferenceTypeSourceExternalApiConfiguration searchConfiguration) { - this.searchConfiguration = searchConfiguration; - } - - public ReferenceTypeSourceExternalApiConfiguration getGetConfiguration() { - return getConfiguration; - } - - public void setGetConfiguration(ReferenceTypeSourceExternalApiConfiguration getConfiguration) { - this.getConfiguration = getConfiguration; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionEntity.java new file mode 100644 index 000000000..9ca6083c7 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionEntity.java @@ -0,0 +1,42 @@ +package eu.eudat.commons.types.prefillingsource; + +import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity; +import jakarta.xml.bind.annotation.*; + +import java.util.List; + +@XmlRootElement(name = "definition") +@XmlAccessorType(XmlAccessType.FIELD) +public class PrefillingSourceDefinitionEntity { + @XmlElement(name = "searchConfiguration") + private ExternalFetcherApiSourceConfigurationEntity searchConfiguration; + @XmlElement(name = "getConfiguration") + private ExternalFetcherApiSourceConfigurationEntity getConfiguration; + @XmlElementWrapper(name = "fields") + @XmlElement(name = "field") + private List fields; + + public ExternalFetcherApiSourceConfigurationEntity getSearchConfiguration() { + return searchConfiguration; + } + + public void setSearchConfiguration(ExternalFetcherApiSourceConfigurationEntity searchConfiguration) { + this.searchConfiguration = searchConfiguration; + } + + public ExternalFetcherApiSourceConfigurationEntity getGetConfiguration() { + return getConfiguration; + } + + public void setGetConfiguration(ExternalFetcherApiSourceConfigurationEntity getConfiguration) { + this.getConfiguration = getConfiguration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionField.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionFieldEntity.java similarity index 78% rename from dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionField.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionFieldEntity.java index d54480049..f40aeb187 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionField.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/prefillingsource/PrefillingSourceDefinitionFieldEntity.java @@ -1,6 +1,8 @@ package eu.eudat.commons.types.prefillingsource; -public class PrefillingSourceDefinitionField { +import jakarta.xml.bind.annotation.XmlElement; + +public class PrefillingSourceDefinitionFieldEntity { private String code; private String systemFieldTarget; private String semanticTarget; @@ -11,6 +13,7 @@ public class PrefillingSourceDefinitionField { return code; } + @XmlElement(name = "code") public void setCode(String code) { this.code = code; } @@ -19,6 +22,7 @@ public class PrefillingSourceDefinitionField { return systemFieldTarget; } + @XmlElement(name = "systemFieldTarget") public void setSystemFieldTarget(String systemFieldTarget) { this.systemFieldTarget = systemFieldTarget; } @@ -27,6 +31,7 @@ public class PrefillingSourceDefinitionField { return semanticTarget; } + @XmlElement(name = "semanticTarget") public void setSemanticTarget(String semanticTarget) { this.semanticTarget = semanticTarget; } @@ -35,6 +40,7 @@ public class PrefillingSourceDefinitionField { return trimRegex; } + @XmlElement(name = "trimRegex") public void setTrimRegex(String trimRegex) { this.trimRegex = trimRegex; } @@ -43,6 +49,7 @@ public class PrefillingSourceDefinitionField { return fixedValue; } + @XmlElement(name = "fixedValue") public void setFixedValue(String fixedValue) { this.fixedValue = fixedValue; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/PrefillingSource.java b/dmp-backend/core/src/main/java/eu/eudat/model/PrefillingSource.java index 6531866b2..1fe4e5f66 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/PrefillingSource.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/PrefillingSource.java @@ -1,7 +1,7 @@ package eu.eudat.model; import eu.eudat.commons.enums.IsActive; -import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition; +import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition; import java.time.Instant; import java.util.UUID; @@ -14,7 +14,7 @@ public class PrefillingSource { private String label; public static final String _label = "label"; - private String definition; + private PrefillingSourceDefinition definition; public static final String _definition = "definition"; private IsActive isActive; @@ -45,11 +45,11 @@ public class PrefillingSource { this.label = label; } - public String getDefinition() { + public PrefillingSourceDefinition getDefinition() { return definition; } - public void setDefinition(String definition) { + public void setDefinition(PrefillingSourceDefinition definition) { this.definition = definition; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpAssociatedUserBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpAssociatedUserBuilder.java index a5643cd6f..23c47fe8f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpAssociatedUserBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpAssociatedUserBuilder.java @@ -1,17 +1,11 @@ package eu.eudat.model.builder; import eu.eudat.authorization.AuthorizationFlags; -import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.enums.ContactInfoType; -import eu.eudat.commons.types.user.AdditionalInfoEntity; import eu.eudat.convention.ConventionService; import eu.eudat.data.UserEntity; import eu.eudat.model.*; -import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; -import eu.eudat.query.TenantUserQuery; import eu.eudat.query.UserContactInfoQuery; -import eu.eudat.query.UserCredentialQuery; -import eu.eudat.query.UserRoleQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PrefillingSourceBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PrefillingSourceBuilder.java index 932dd0bb4..5d6b31426 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PrefillingSourceBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PrefillingSourceBuilder.java @@ -2,9 +2,11 @@ package eu.eudat.model.builder; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.XmlHandlingService; +import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; import eu.eudat.convention.ConventionService; import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.model.PrefillingSource; +import eu.eudat.model.builder.prefillingsourcedefinition.PrefillingSourceDefinitionBuilder; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; @@ -57,8 +59,10 @@ public class PrefillingSourceBuilder extends BaseBuilder { +public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final AuthorizationService authorizationService; @Autowired - public ReferenceTypeSourceExternalApiConfigurationBuilder( + public ExternalFetcherApiSourceConfigurationBuilder( ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)), builderFactory, queryFactory); + super(conventionService, new LoggerService(LoggerFactory.getLogger(ExternalFetcherApiSourceConfigurationBuilder.class)), builderFactory, queryFactory); this.builderFactory = builderFactory; this.authorizationService = authorizationService; } @Override - protected ReferenceTypeSourceExternalApiConfiguration getInstance() { - return new ReferenceTypeSourceExternalApiConfiguration(); + protected ExternalFetcherApiSourceConfiguration getInstance() { + return new ExternalFetcherApiSourceConfiguration(); } @Override - protected ReferenceTypeSourceExternalApiConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ReferenceTypeSourceExternalApiConfiguration m) { - FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._results)); - FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._auth)); - FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._queries)); + protected ExternalFetcherApiSourceConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ExternalFetcherApiSourceConfiguration m) { + FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._results)); + FieldSet authFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._auth)); + FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._queries)); if(!authorizationService.authorize(Permission.EditReferenceType)) return m; - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._url))) m.setUrl(d.getUrl()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._url))) m.setUrl(d.getUrl()); if (!resultsFields.isEmpty() && d.getResults() != null) { m.setResults(this.builderFactory.builder(ResultsConfigurationBuilder.class).authorize(this.authorize).build(resultsFields, d.getResults())); } - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._type))) m.setType(d.getType()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._contentType))) m.setContentType(d.getContentType()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._firstPage))) m.setFirstPage(d.getFirstPage()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._requestBody))) m.setRequestBody(d.getRequestBody()); - if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._filterType))) m.setFilterType(d.getFilterType()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._type))) m.setType(d.getType()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._contentType))) m.setContentType(d.getContentType()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._firstPage))) m.setFirstPage(d.getFirstPage()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._requestBody))) m.setRequestBody(d.getRequestBody()); + if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._filterType))) m.setFilterType(d.getFilterType()); if (!authFields.isEmpty() && d.getAuth() != null) { m.setAuth(this.builderFactory.builder(AuthenticationConfigurationBuilder.class).authorize(this.authorize).build(authFields, d.getAuth())); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceBaseConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherBaseSourceConfigurationBuilder.java similarity index 91% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceBaseConfigurationBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherBaseSourceConfigurationBuilder.java index 700f641b2..32f514d96 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceBaseConfigurationBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherBaseSourceConfigurationBuilder.java @@ -1,4 +1,4 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.ExternalFetcherBaseSourceConfigurationEntity; @@ -6,7 +6,7 @@ import eu.eudat.convention.ConventionService; import eu.eudat.model.ReferenceType; import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder; -import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; +import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration; import eu.eudat.query.ReferenceTypeQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -25,14 +25,14 @@ import java.util.stream.Collectors; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public abstract class ReferenceTypeSourceBaseConfigurationBuilder extends BaseBuilder { +public abstract class ExternalFetcherBaseSourceConfigurationBuilder extends BaseBuilder { protected EnumSet authorize = EnumSet.of(AuthorizationFlags.None); protected final BuilderFactory builderFactory; protected final QueryFactory queryFactory; @Autowired - public ReferenceTypeSourceBaseConfigurationBuilder( + public ExternalFetcherBaseSourceConfigurationBuilder( ConventionService conventionService, LoggerService logger, BuilderFactory builderFactory, QueryFactory queryFactory) { super(conventionService, logger); @@ -40,7 +40,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder values) { + public ExternalFetcherBaseSourceConfigurationBuilder authorize(EnumSet values) { this.authorize = values; return this; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationBuilder.java similarity index 60% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationBuilder.java index 374923a87..cb10a0215 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationBuilder.java @@ -1,10 +1,10 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity; import eu.eudat.convention.ConventionService; -import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceStaticOptionConfiguration; +import eu.eudat.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; @@ -20,34 +20,34 @@ import java.util.EnumSet; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class ReferenceTypeSourceStaticOptionConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder { +public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final AuthorizationService authorizationService; @Autowired - public ReferenceTypeSourceStaticOptionConfigurationBuilder( + public ExternalFetcherStaticOptionSourceConfigurationBuilder( ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceStaticOptionConfigurationBuilder.class)), builderFactory, queryFactory); + super(conventionService, new LoggerService(LoggerFactory.getLogger(ExternalFetcherStaticOptionSourceConfigurationBuilder.class)), builderFactory, queryFactory); this.builderFactory = builderFactory; this.authorizationService = authorizationService; } @Override - protected ReferenceTypeSourceStaticOptionConfiguration getInstance() { - return new ReferenceTypeSourceStaticOptionConfiguration(); + protected ExternalFetcherStaticOptionSourceConfiguration getInstance() { + return new ExternalFetcherStaticOptionSourceConfiguration(); } @Override - protected ReferenceTypeSourceStaticOptionConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ReferenceTypeSourceStaticOptionConfiguration m) { - FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceStaticOptionConfiguration._options)); + protected ExternalFetcherStaticOptionSourceConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ExternalFetcherStaticOptionSourceConfiguration m) { + FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherStaticOptionSourceConfiguration._options)); if(!authorizationService.authorize(Permission.EditReferenceType)) return m; if (!optionsFields.isEmpty() && d.getOptions() != null) { - m.setOptions(this.builderFactory.builder(ReferenceTypeStaticOptionBuilder.class).authorize(this.authorize).build(optionsFields, d.getOptions())); + m.setOptions(this.builderFactory.builder(StaticOptionBuilder.class).authorize(this.authorize).build(optionsFields, d.getOptions())); } return m; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryCaseConfigBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryCaseConfigBuilder.java similarity index 97% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryCaseConfigBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryCaseConfigBuilder.java index 90dee4e59..0f8c18a88 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryCaseConfigBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryCaseConfigBuilder.java @@ -1,4 +1,4 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.QueryCaseConfigEntity; @@ -6,7 +6,7 @@ import eu.eudat.convention.ConventionService; import eu.eudat.model.ReferenceType; import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder; -import eu.eudat.model.referencetypedefinition.QueryCaseConfig; +import eu.eudat.model.externalfetcher.QueryCaseConfig; import eu.eudat.query.ReferenceTypeQuery; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.query.QueryFactory; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryConfigBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryConfigBuilder.java similarity index 96% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryConfigBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryConfigBuilder.java index 5e45543e8..bcd8b690d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/QueryConfigBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/QueryConfigBuilder.java @@ -1,10 +1,10 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.QueryConfigEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.builder.BaseBuilder; -import eu.eudat.model.referencetypedefinition.QueryConfig; +import eu.eudat.model.externalfetcher.QueryConfig; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultFieldsMappingConfigurationBuilder.java similarity index 95% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultFieldsMappingConfigurationBuilder.java index d2d0c28f3..a6ed0f152 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultFieldsMappingConfigurationBuilder.java @@ -1,10 +1,10 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.builder.BaseBuilder; -import eu.eudat.model.referencetypedefinition.ResultFieldsMappingConfiguration; +import eu.eudat.model.externalfetcher.ResultFieldsMappingConfiguration; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultsConfigurationBuilder.java similarity index 95% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultsConfigurationBuilder.java index 6c0f52690..40ce9297e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/ResultsConfigurationBuilder.java @@ -1,10 +1,10 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.ResultsConfigurationEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.builder.BaseBuilder; -import eu.eudat.model.referencetypedefinition.ResultsConfiguration; +import eu.eudat.model.externalfetcher.ResultsConfiguration; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeStaticOptionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/StaticOptionBuilder.java similarity index 62% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeStaticOptionBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/StaticOptionBuilder.java index f85238878..c7d0dd510 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeStaticOptionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/externalfetcher/StaticOptionBuilder.java @@ -1,10 +1,10 @@ -package eu.eudat.model.builder.referencetypedefinition; +package eu.eudat.model.builder.externalfetcher; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.commons.types.externalfetcher.StaticOptionEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.builder.BaseBuilder; -import eu.eudat.model.referencetypedefinition.ReferenceTypeStaticOption; +import eu.eudat.model.externalfetcher.StaticOption; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; @@ -19,32 +19,32 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class ReferenceTypeStaticOptionBuilder extends BaseBuilder { +public class StaticOptionBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public ReferenceTypeStaticOptionBuilder(ConventionService conventionService) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeStaticOptionBuilder.class))); + public StaticOptionBuilder(ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(StaticOptionBuilder.class))); } - public ReferenceTypeStaticOptionBuilder authorize(EnumSet values) { + public StaticOptionBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - List models = new ArrayList<>(); + List models = new ArrayList<>(); for (StaticOptionEntity d : data) { - ReferenceTypeStaticOption m = new ReferenceTypeStaticOption(); - if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._code))) m.setCode(d.getCode()); - if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._value))) m.setValue(d.getValue()); + StaticOption m = new StaticOption(); + if (fields.hasField(this.asIndexer(StaticOption._code))) m.setCode(d.getCode()); + if (fields.hasField(this.asIndexer(StaticOption._value))) m.setValue(d.getValue()); models.add(m); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionBuilder.java new file mode 100644 index 000000000..d9c299777 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionBuilder.java @@ -0,0 +1,62 @@ +package eu.eudat.model.builder.prefillingsourcedefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.builder.externalfetcher.ExternalFetcherApiSourceConfigurationBuilder; +import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PrefillingSourceDefinitionBuilder extends BaseBuilder { + + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public PrefillingSourceDefinitionBuilder( + ConventionService conventionService, BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingSourceDefinitionBuilder.class))); + this.builderFactory = builderFactory; + } + + public PrefillingSourceDefinitionBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + FieldSet searchConfigurationFields = fields.extractPrefixed(this.asPrefix(PrefillingSourceDefinition._searchConfiguration)); + FieldSet getConfigurationFields = fields.extractPrefixed(this.asPrefix(PrefillingSourceDefinition._getConfiguration)); + FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(PrefillingSourceDefinition._fields)); + + List models = new ArrayList<>(); + for (PrefillingSourceDefinitionEntity d : data) { + PrefillingSourceDefinition m = new PrefillingSourceDefinition(); + if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(PrefillingSourceDefinitionFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields())); + + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionFieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionFieldBuilder.java new file mode 100644 index 000000000..0393df566 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/prefillingsourcedefinition/PrefillingSourceDefinitionFieldBuilder.java @@ -0,0 +1,61 @@ +package eu.eudat.model.builder.prefillingsourcedefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinitionField; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PrefillingSourceDefinitionFieldBuilder extends BaseBuilder { + + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public PrefillingSourceDefinitionFieldBuilder( + ConventionService conventionService, BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingSourceDefinitionFieldBuilder.class))); + this.builderFactory = builderFactory; + } + + public PrefillingSourceDefinitionFieldBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + for (PrefillingSourceDefinitionFieldEntity d : data) { + PrefillingSourceDefinitionField m = new PrefillingSourceDefinitionField(); + if (fields.hasField(this.asIndexer(PrefillingSourceDefinitionField._code))) m.setCode(d.getCode()); + if (fields.hasField(this.asIndexer(PrefillingSourceDefinitionField._systemFieldTarget))) m.setSystemFieldTarget(d.getSystemFieldTarget()); + if (fields.hasField(this.asIndexer(PrefillingSourceDefinitionField._semanticTarget))) m.setSemanticTarget(d.getSemanticTarget()); + if (fields.hasField(this.asIndexer(PrefillingSourceDefinitionField._trimRegex))) m.setTrimRegex(d.getTrimRegex()); + if (fields.hasField(this.asIndexer(PrefillingSourceDefinitionField._fixedValue))) m.setFixedValue(d.getFixedValue()); + + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java index a55aed47e..118a573b8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java @@ -7,8 +7,10 @@ import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurat import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity; import eu.eudat.convention.ConventionService; import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.builder.externalfetcher.ExternalFetcherApiSourceConfigurationBuilder; +import eu.eudat.model.builder.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationBuilder; import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition; -import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; +import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; @@ -59,9 +61,9 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder externalApiConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList(); List staticOptionConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ExternalFetcherStaticOptionSourceConfigurationEntity)x).toList(); m.setSources(new ArrayList<>()); - m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceExternalApiConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities)); - m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceStaticOptionConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities)); - m.getSources().sort(Comparator.comparing(ReferenceTypeSourceBaseConfiguration::getOrdinal)); + m.getSources().addAll(this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities)); + m.getSources().addAll(this.builderFactory.builder(ExternalFetcherStaticOptionSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities)); + m.getSources().sort(Comparator.comparing(ExternalFetcherBaseSourceConfiguration::getOrdinal)); } models.add(m); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryCaseConfigCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryCaseConfigCensor.java index c9055d10d..c6cca5f5b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryCaseConfigCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryCaseConfigCensor.java @@ -4,7 +4,7 @@ import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.ReferenceTypeCensor; -import eu.eudat.model.referencetypedefinition.QueryCaseConfig; +import eu.eudat.model.externalfetcher.QueryCaseConfig; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryConfigCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryConfigCensor.java index ccff583c8..4e3f63c08 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryConfigCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/QueryConfigCensor.java @@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition; import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; import eu.eudat.model.censorship.BaseCensor; -import eu.eudat.model.referencetypedefinition.QueryConfig; +import eu.eudat.model.externalfetcher.QueryConfig; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ReferenceTypeSourceBaseConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ReferenceTypeSourceBaseConfigurationCensor.java index d06001c56..c71617133 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ReferenceTypeSourceBaseConfigurationCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ReferenceTypeSourceBaseConfigurationCensor.java @@ -4,7 +4,9 @@ import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.ReferenceTypeCensor; -import eu.eudat.model.referencetypedefinition.*; +import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration; +import eu.eudat.model.externalfetcher.ExternalFetcherApiSourceConfiguration; +import eu.eudat.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -39,19 +41,19 @@ public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor { return; this.authService.authorizeForce(Permission.BrowseReferenceType); - FieldSet referenceTypeDependencyFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceBaseConfiguration._referenceTypeDependencies)); + FieldSet referenceTypeDependencyFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherBaseSourceConfiguration._referenceTypeDependencies)); this.censorFactory.censor(ReferenceTypeCensor.class).censor(referenceTypeDependencyFields, userId); - FieldSet optionsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceStaticOptionConfiguration._options)); + FieldSet optionsFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherStaticOptionSourceConfiguration._options)); this.censorFactory.censor(ReferenceTypeStaticOptionCensor.class).censor(optionsFields, userId); - FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._auth)); + FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._auth)); this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId); - FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._results)); + FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._results)); this.censorFactory.censor(ResultsConfigurationCensor.class).censor(resultsFields, userId); - FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._queries)); + FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._queries)); this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ResultsConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ResultsConfigurationCensor.java index 4f37b6fc0..b469daa48 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ResultsConfigurationCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetypedefinition/ResultsConfigurationCensor.java @@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition; import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; import eu.eudat.model.censorship.BaseCensor; -import eu.eudat.model.referencetypedefinition.ResultsConfiguration; +import eu.eudat.model.externalfetcher.ResultsConfiguration; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/AuthenticationConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/AuthenticationConfiguration.java similarity index 97% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/AuthenticationConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/AuthenticationConfiguration.java index adef7b334..b4cf575f7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/AuthenticationConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/AuthenticationConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceExternalApiConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherApiSourceConfiguration.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceExternalApiConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherApiSourceConfiguration.java index 2d8491d0e..6e4a3ad64 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceExternalApiConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherApiSourceConfiguration.java @@ -1,10 +1,10 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import java.util.List; -public class ReferenceTypeSourceExternalApiConfiguration extends ReferenceTypeSourceBaseConfiguration { +public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSourceConfiguration { public final static String _url = "url"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceBaseConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherBaseSourceConfiguration.java similarity index 92% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceBaseConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherBaseSourceConfiguration.java index 08944f9c8..4f06b3f99 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceBaseConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherBaseSourceConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.model.ReferenceType; @@ -6,7 +6,7 @@ import eu.eudat.model.ReferenceType; import java.util.List; -public abstract class ReferenceTypeSourceBaseConfiguration { +public abstract class ExternalFetcherBaseSourceConfiguration { public final static String _key = "key"; private String key; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherStaticOptionSourceConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherStaticOptionSourceConfiguration.java new file mode 100644 index 000000000..76493ddd0 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ExternalFetcherStaticOptionSourceConfiguration.java @@ -0,0 +1,18 @@ +package eu.eudat.model.externalfetcher; + + +import java.util.List; + +public class ExternalFetcherStaticOptionSourceConfiguration extends ExternalFetcherBaseSourceConfiguration { + + public final static String _options = "options"; + List options; + + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryCaseConfig.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryCaseConfig.java similarity index 96% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryCaseConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryCaseConfig.java index c2c67d54f..1ca79082b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryCaseConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryCaseConfig.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import eu.eudat.model.ReferenceType; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryConfig.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryConfig.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryConfig.java index a9b16f8c2..0756dc0b4 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/QueryConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/QueryConfig.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultFieldsMappingConfiguration.java similarity index 91% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultFieldsMappingConfiguration.java index 85cfe2e61..7d91dc391 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultFieldsMappingConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; public class ResultFieldsMappingConfiguration { diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultsConfiguration.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultsConfiguration.java index 3d52b7d8a..0ec89abde 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/ResultsConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeStaticOption.java b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/StaticOption.java similarity index 82% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeStaticOption.java rename to dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/StaticOption.java index b62c422e2..14fabab0a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeStaticOption.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/externalfetcher/StaticOption.java @@ -1,6 +1,6 @@ -package eu.eudat.model.referencetypedefinition; +package eu.eudat.model.externalfetcher; -public class ReferenceTypeStaticOption { +public class StaticOption { public final static String _code = "code"; private String code; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/PrefillingSourcePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/PrefillingSourcePersist.java index aa78ead46..a1e3da5cc 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/PrefillingSourcePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/PrefillingSourcePersist.java @@ -3,6 +3,7 @@ package eu.eudat.model.persist; import eu.eudat.commons.validation.BaseValidator; import eu.eudat.convention.ConventionService; import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionPersist; import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -23,7 +24,7 @@ public class PrefillingSourcePersist { public static final String _label = "label"; - private String definition; + private PrefillingSourceDefinitionPersist definition; public static final String _definition = "definition"; @@ -47,11 +48,11 @@ public class PrefillingSourcePersist { this.label = label; } - public String getDefinition() { + public PrefillingSourceDefinitionPersist getDefinition() { return definition; } - public void setDefinition(String definition) { + public void setDefinition(PrefillingSourceDefinitionPersist definition) { this.definition = definition; } @@ -97,7 +98,15 @@ public class PrefillingSourcePersist { .failOn(PrefillingSourcePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(PrefillingSourcePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._label}, LocaleContextHolder.getLocale())) + .failOn(PrefillingSourcePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._label}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getDefinition())) + .failOn(PrefillingSourcePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._definition}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getDefinition())) + .on(PrefillingSourcePersist._definition) + .over(item.getDefinition()) + .using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class)) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/AuthenticationConfigurationPersist.java similarity index 99% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/AuthenticationConfigurationPersist.java index c0320314d..0c26032d0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/AuthenticationConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.validation.BaseValidator; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherApiSourceConfigurationPersist.java similarity index 68% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherApiSourceConfigurationPersist.java index c88df4c67..8fe4faa4d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceExternalApiConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherApiSourceConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.convention.ConventionService; @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { +public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist { private String url; @@ -134,7 +134,7 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc @Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { + public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator"; @@ -143,49 +143,49 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc } @Override - protected Class modelClass() { - return ReferenceTypeSourceExternalApiConfigurationPersist.class; + protected Class modelClass() { + return ExternalFetcherApiSourceConfigurationPersist.class; } @Override - protected List specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) { + protected List specifications(ExternalFetcherApiSourceConfigurationPersist item) { List specifications = getBaseSpecifications(item); specifications.addAll(Arrays.asList( this.spec() .must(() -> !this.isEmpty(item.getUrl())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._url}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._url}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getPaginationPath())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._paginationPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._paginationPath}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getContentType())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._contentType}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._contentType}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getFirstPage())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getHttpMethod())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getResults())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._results).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._results}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._results).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._results}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getResults())) - .on(ReferenceTypeSourceExternalApiConfigurationPersist._results) + .on(ExternalFetcherApiSourceConfigurationPersist._results) .over(item.getResults()) .using(() -> this.validatorFactory.validator(ResultsConfigurationPersist.ResultsConfigurationPersistValidator.class)), this.spec() .must(() -> !this.isNull(item.getAuth())) - .failOn(ReferenceTypeSourceExternalApiConfigurationPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._auth}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherApiSourceConfigurationPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._auth}, LocaleContextHolder.getLocale())), this.refSpec() .iff(() -> !this.isNull(item.getAuth())) - .on(ReferenceTypeSourceExternalApiConfigurationPersist._auth) + .on(ExternalFetcherApiSourceConfigurationPersist._auth) .over(item.getAuth()) .using(() -> this.validatorFactory.validator(AuthenticationConfigurationPersist.AuthenticationConfigurationPersistValidator.class)), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getQueries())) - .on(ReferenceTypeSourceExternalApiConfigurationPersist._queries) + .on(ExternalFetcherApiSourceConfigurationPersist._queries) .over(item.getQueries()) .using((itm) -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class)) )); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherBaseSourceConfigurationPersist.java similarity index 70% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherBaseSourceConfigurationPersist.java index fcf27ba74..9ef910fbe 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceBaseConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherBaseSourceConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -22,10 +22,10 @@ import java.util.UUID; property = "type", visible = true) @JsonSubTypes({ - @JsonSubTypes.Type(value = ReferenceTypeSourceExternalApiConfigurationPersist.class, name = "0"), - @JsonSubTypes.Type(value = ReferenceTypeSourceStaticOptionConfigurationPersist.class, name = "1") + @JsonSubTypes.Type(value = ExternalFetcherApiSourceConfigurationPersist.class, name = "0"), + @JsonSubTypes.Type(value = ExternalFetcherStaticOptionSourceConfigurationPersist.class, name = "1") }) -public abstract class ReferenceTypeSourceBaseConfigurationPersist { +public abstract class ExternalFetcherBaseSourceConfigurationPersist { private String key = null; @@ -87,7 +87,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist { this.referenceTypeDependencyIds = referenceTypeDependencyIds; } - public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator extends BaseValidator { + public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator extends BaseValidator { protected final MessageSource messageSource; @@ -104,16 +104,16 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist { specifications.addAll(Arrays.asList( this.spec() .must(() -> !this.isEmpty(item.getKey())) - .failOn(ReferenceTypeSourceBaseConfigurationPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._key}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherBaseSourceConfigurationPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._key}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(ReferenceTypeSourceBaseConfigurationPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._label}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherBaseSourceConfigurationPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getOrdinal())) - .failOn(ReferenceTypeSourceBaseConfigurationPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._ordinal}, LocaleContextHolder.getLocale())), + .failOn(ExternalFetcherBaseSourceConfigurationPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._ordinal}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getType())) - .failOn(ReferenceTypeSourceBaseConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._type}, LocaleContextHolder.getLocale())) + .failOn(ExternalFetcherBaseSourceConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._type}, LocaleContextHolder.getLocale())) )); return specifications; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationPersist.java similarity index 64% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationPersist.java index 33d20602f..340a63724 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeSourceStaticOptionConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ExternalFetcherStaticOptionSourceConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; @@ -7,28 +7,27 @@ 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; -public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { +public class ExternalFetcherStaticOptionSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist { - List options; + List options; public static final String _options = "options"; - public List getOptions() { + public List getOptions() { return options; } - public void setOptions(List options) { + public void setOptions(List options) { this.options = options; } @Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { + public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator { public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator"; @@ -37,19 +36,19 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen } @Override - protected Class modelClass() { - return ReferenceTypeSourceStaticOptionConfigurationPersist.class; + protected Class modelClass() { + return ExternalFetcherStaticOptionSourceConfigurationPersist.class; } @Override - protected List specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) { + protected List specifications(ExternalFetcherStaticOptionSourceConfigurationPersist item) { List specifications = getBaseSpecifications(item); specifications.add( this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getOptions())) - .on(ReferenceTypeSourceStaticOptionConfigurationPersist._options) + .on(ExternalFetcherStaticOptionSourceConfigurationPersist._options) .over(item.getOptions()) - .using((itm) -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class)) + .using((itm) -> this.validatorFactory.validator(StaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class)) ); return specifications; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryCaseConfigPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryCaseConfigPersist.java similarity index 98% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryCaseConfigPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryCaseConfigPersist.java index 67967a0c5..47ee443ea 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryCaseConfigPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryCaseConfigPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryConfigPersist.java similarity index 98% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryConfigPersist.java index af5ba6918..e25f244d1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/QueryConfigPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/QueryConfigPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.validation.BaseValidator; import eu.eudat.convention.ConventionService; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultFieldsMappingConfigurationPersist.java similarity index 98% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultFieldsMappingConfigurationPersist.java index 12c15818c..a59f4ac6c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultFieldsMappingConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultsConfigurationPersist.java similarity index 98% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultsConfigurationPersist.java index 843ccd61a..69f36dcc6 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/ResultsConfigurationPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.validation.BaseValidator; import gr.cite.tools.validation.ValidatorFactory; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/StaticOptionPersist.java similarity index 69% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/StaticOptionPersist.java index 50dc6a851..8ee5c9e19 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeStaticOptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/externalfetcher/StaticOptionPersist.java @@ -1,4 +1,4 @@ -package eu.eudat.model.persist.referencetypedefinition; +package eu.eudat.model.persist.externalfetcher; import eu.eudat.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; -public class ReferenceTypeStaticOptionPersist { +public class StaticOptionPersist { private String code; @@ -41,7 +41,7 @@ public class ReferenceTypeStaticOptionPersist { @Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator { + public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator { public static final String ValidatorName = "ReferenceTypeStaticOptionPersistValidator"; @@ -53,19 +53,19 @@ public class ReferenceTypeStaticOptionPersist { } @Override - protected Class modelClass() { - return ReferenceTypeStaticOptionPersist.class; + protected Class modelClass() { + return StaticOptionPersist.class; } @Override - protected List specifications(ReferenceTypeStaticOptionPersist item) { + protected List specifications(StaticOptionPersist item) { return Arrays.asList( this.spec() .must(() -> !this.isEmpty(item.getCode())) - .failOn(ReferenceTypeStaticOptionPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._code}, LocaleContextHolder.getLocale())), + .failOn(StaticOptionPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{StaticOptionPersist._code}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getValue())) - .failOn(ReferenceTypeStaticOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._value}, LocaleContextHolder.getLocale())) + .failOn(StaticOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{StaticOptionPersist._value}, LocaleContextHolder.getLocale())) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java new file mode 100644 index 000000000..4a525a625 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionFieldPersist.java @@ -0,0 +1,97 @@ +package eu.eudat.model.persist.prefillingsourcedefinition; + +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import gr.cite.tools.validation.ValidatorFactory; +import gr.cite.tools.validation.specification.Specification; +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 PrefillingSourceDefinitionFieldPersist { + + private String code; + public final static String _code = "code"; + private String systemFieldTarget; + public final static String _systemFieldTarget = "systemFieldTarget"; + private String semanticTarget; + public final static String _semanticTarget = "semanticTarget"; + private String trimRegex; + public final static String _trimRegex = "trimRegex"; + private String fixedValue; + public final static String _fixedValue = "fixedValue"; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getSystemFieldTarget() { + return systemFieldTarget; + } + + public void setSystemFieldTarget(String systemFieldTarget) { + this.systemFieldTarget = systemFieldTarget; + } + + public String getSemanticTarget() { + return semanticTarget; + } + + public void setSemanticTarget(String semanticTarget) { + this.semanticTarget = semanticTarget; + } + + public String getTrimRegex() { + return trimRegex; + } + + public void setTrimRegex(String trimRegex) { + this.trimRegex = trimRegex; + } + + public String getFixedValue() { + return fixedValue; + } + + public void setFixedValue(String fixedValue) { + this.fixedValue = fixedValue; + } + + + @Component(PrefillingSourceDefinitionFieldPersist.PrefillingSourceDefinitionFieldPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PrefillingSourceDefinitionFieldPersistValidator extends BaseValidator { + + public static final String ValidatorName = "PrefillingSourceDefinitionFieldPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected PrefillingSourceDefinitionFieldPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return PrefillingSourceDefinitionFieldPersist.class; + } + + @Override + protected List specifications(PrefillingSourceDefinitionFieldPersist item) { + return Arrays.asList(); + } + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java new file mode 100644 index 000000000..007866ba5 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/prefillingsourcedefinition/PrefillingSourceDefinitionPersist.java @@ -0,0 +1,98 @@ +package eu.eudat.model.persist.prefillingsourcedefinition; + +import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.convention.ConventionService; +import eu.eudat.errorcode.ErrorThesaurusProperties; +import eu.eudat.model.persist.externalfetcher.ExternalFetcherApiSourceConfigurationPersist; +import gr.cite.tools.validation.ValidatorFactory; +import gr.cite.tools.validation.specification.Specification; +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 PrefillingSourceDefinitionPersist { + + private ExternalFetcherApiSourceConfigurationPersist searchConfiguration; + public static final String _searchConfiguration = "searchConfiguration"; + + private ExternalFetcherApiSourceConfigurationPersist getConfiguration; + public static final String _getConfiguration = "getConfiguration"; + + private List fields; + public static final String _fields = "fields"; + + public ExternalFetcherApiSourceConfigurationPersist getSearchConfiguration() { + return searchConfiguration; + } + + public void setSearchConfiguration(ExternalFetcherApiSourceConfigurationPersist searchConfiguration) { + this.searchConfiguration = searchConfiguration; + } + + public ExternalFetcherApiSourceConfigurationPersist getGetConfiguration() { + return getConfiguration; + } + + public void setGetConfiguration(ExternalFetcherApiSourceConfigurationPersist getConfiguration) { + this.getConfiguration = getConfiguration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + @Component(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.ValidatorName) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + public static class PrefillingSourceDefinitionPersistValidator extends BaseValidator { + + public static final String ValidatorName = "PrefillingSourceDefinitionPersistValidator"; + + private final MessageSource messageSource; + + private final ValidatorFactory validatorFactory; + + protected PrefillingSourceDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) { + super(conventionService, errors); + this.messageSource = messageSource; + this.validatorFactory = validatorFactory; + } + + @Override + protected Class modelClass() { + return PrefillingSourceDefinitionPersist.class; + } + + @Override + protected List specifications(PrefillingSourceDefinitionPersist item) { + return Arrays.asList( + this.spec() + .must(() -> !this.isNull(item.getSearchConfiguration())) + .failOn(PrefillingSourceDefinitionPersist._searchConfiguration).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourceDefinitionPersist._searchConfiguration}, LocaleContextHolder.getLocale())), + this.refSpec() + .iff(() -> !this.isNull(item.getSearchConfiguration())) + .on(PrefillingSourceDefinitionPersist._searchConfiguration) + .over(item.getSearchConfiguration()) + .using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class)), + this.refSpec() + .iff(() -> !this.isNull(item.getGetConfiguration())) + .on(PrefillingSourceDefinitionPersist._getConfiguration) + .over(item.getGetConfiguration()) + .using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class)), + this.navSpec() + .iff(() -> !this.isListNullOrEmpty(item.getFields())) + .on(PrefillingSourceDefinitionPersist._fields) + .over(item.getFields()) + .using((itm) -> this.validatorFactory.validator(PrefillingSourceDefinitionFieldPersist.PrefillingSourceDefinitionFieldPersistValidator.class)) + ); + } + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java index dc2ec8eb8..74dc03446 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java @@ -2,6 +2,9 @@ package eu.eudat.model.persist.referencetypedefinition; import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.validation.BaseValidator; +import eu.eudat.model.persist.externalfetcher.ExternalFetcherBaseSourceConfigurationPersist; +import eu.eudat.model.persist.externalfetcher.ExternalFetcherApiSourceConfigurationPersist; +import eu.eudat.model.persist.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationPersist; import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.specification.Specification; import eu.eudat.convention.ConventionService; @@ -21,7 +24,7 @@ public class ReferenceTypeDefinitionPersist { public static final String _fields = "fields"; - private List sources = null; + private List sources = null; public static final String _sources = "sources"; @@ -33,11 +36,11 @@ public class ReferenceTypeDefinitionPersist { this.fields = fields; } - public List getSources() { + public List getSources() { return sources; } - public void setSources(List sources) { + public void setSources(List sources) { this.sources = sources; } @@ -77,7 +80,7 @@ public class ReferenceTypeDefinitionPersist { .iff(() -> !this.isListNullOrEmpty(item.getSources())) .on(ReferenceTypeDefinitionPersist._sources) .over(item.getSources()) - .using((itm) -> ((ReferenceTypeSourceBaseConfigurationPersist) itm).getType() == ReferenceTypeSourceType.STATIC? this.validatorFactory.validator(ReferenceTypeSourceStaticOptionConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class): this.validatorFactory.validator(ReferenceTypeSourceExternalApiConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class)) + .using((itm) -> ((ExternalFetcherBaseSourceConfigurationPersist) itm).getType() == ReferenceTypeSourceType.STATIC? this.validatorFactory.validator(ExternalFetcherStaticOptionSourceConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class): this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class)) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinition.java b/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinition.java new file mode 100644 index 000000000..07e99a5ab --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinition.java @@ -0,0 +1,41 @@ +package eu.eudat.model.prefillingsourcedefinition; + +import eu.eudat.model.externalfetcher.ExternalFetcherApiSourceConfiguration; + +import java.util.List; + +public class PrefillingSourceDefinition { + + private ExternalFetcherApiSourceConfiguration searchConfiguration; + public final static String _searchConfiguration = "searchConfiguration"; + + private ExternalFetcherApiSourceConfiguration getConfiguration; + public final static String _getConfiguration = "getConfiguration"; + + private List fields; + public final static String _fields = "fields"; + + public ExternalFetcherApiSourceConfiguration getSearchConfiguration() { + return searchConfiguration; + } + + public void setSearchConfiguration(ExternalFetcherApiSourceConfiguration searchConfiguration) { + this.searchConfiguration = searchConfiguration; + } + + public ExternalFetcherApiSourceConfiguration getGetConfiguration() { + return getConfiguration; + } + + public void setGetConfiguration(ExternalFetcherApiSourceConfiguration getConfiguration) { + this.getConfiguration = getConfiguration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinitionField.java b/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinitionField.java new file mode 100644 index 000000000..73d95cb39 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/prefillingsourcedefinition/PrefillingSourceDefinitionField.java @@ -0,0 +1,55 @@ +package eu.eudat.model.prefillingsourcedefinition; + +public class PrefillingSourceDefinitionField { + + private String code; + public final static String _code = "code"; + private String systemFieldTarget; + public final static String _systemFieldTarget = "systemFieldTarget"; + private String semanticTarget; + public final static String _semanticTarget = "semanticTarget"; + private String trimRegex; + public final static String _trimRegex = "trimRegex"; + private String fixedValue; + public final static String _fixedValue = "fixedValue"; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getSystemFieldTarget() { + return systemFieldTarget; + } + + public void setSystemFieldTarget(String systemFieldTarget) { + this.systemFieldTarget = systemFieldTarget; + } + + public String getSemanticTarget() { + return semanticTarget; + } + + public void setSemanticTarget(String semanticTarget) { + this.semanticTarget = semanticTarget; + } + + public String getTrimRegex() { + return trimRegex; + } + + public void setTrimRegex(String trimRegex) { + this.trimRegex = trimRegex; + } + + public String getFixedValue() { + return fixedValue; + } + + public void setFixedValue(String fixedValue) { + this.fixedValue = fixedValue; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java index 286907884..e24e62d5d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java @@ -1,5 +1,7 @@ package eu.eudat.model.referencetypedefinition; +import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration; + import java.util.List; public class ReferenceTypeDefinition { @@ -8,7 +10,7 @@ public class ReferenceTypeDefinition { private List fields; public final static String _sources = "sources"; - private List sources; + private List sources; public List getFields() { return fields; @@ -18,11 +20,11 @@ public class ReferenceTypeDefinition { this.fields = fields; } - public List getSources() { + public List getSources() { return sources; } - public void setSources(List sources) { + public void setSources(List sources) { this.sources = sources; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceStaticOptionConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceStaticOptionConfiguration.java deleted file mode 100644 index dbd8d234b..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeSourceStaticOptionConfiguration.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.eudat.model.referencetypedefinition; - - -import java.util.List; - -public class ReferenceTypeSourceStaticOptionConfiguration extends ReferenceTypeSourceBaseConfiguration { - - public final static String _options = "options"; - List options; - - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherService.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherService.java new file mode 100644 index 000000000..625f9d8f6 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherService.java @@ -0,0 +1,12 @@ +package eu.eudat.service.externalfetcher; + +import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.models.ExternalDataResult; + +import java.util.List; + +public interface ExternalFetcherService { + ExternalDataResult getExternalData(List sources, ExternalReferenceCriteria externalReferenceCriteria, String key); + Integer countExternalData(List sources, ExternalReferenceCriteria externalReferenceCriteria, String key); +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java similarity index 97% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java index adab384fa..03c550be8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalFetcherServiceImpl.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher; +package eu.eudat.service.externalfetcher; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -11,9 +11,9 @@ import eu.eudat.convention.ConventionService; import eu.eudat.data.ReferenceEntity; import eu.eudat.model.Reference; import eu.eudat.model.referencedefinition.Field; -import eu.eudat.service.remotefetcher.config.entities.*; -import eu.eudat.service.remotefetcher.models.ExternalDataResult; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.config.entities.*; +import eu.eudat.service.externalfetcher.models.ExternalDataResult; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; import gr.cite.tools.exception.MyApplicationException; import net.minidev.json.JSONArray; import org.slf4j.Logger; @@ -31,14 +31,14 @@ import java.util.*; import java.util.stream.Collectors; @Service -public class RemoteFetcherServiceImpl implements RemoteFetcherService { - private static final Logger logger = LoggerFactory.getLogger(RemoteFetcherServiceImpl.class); +public class ExternalFetcherServiceImpl implements ExternalFetcherService { + private static final Logger logger = LoggerFactory.getLogger(ExternalFetcherServiceImpl.class); private WebClient webClient; private final ConventionService conventionService; private final JsonHandlingService jsonHandlingService; @Autowired - public RemoteFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) { + public ExternalFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) { this.conventionService = conventionService; this.jsonHandlingService = jsonHandlingService; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/ExternalUrlConfigProvider.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalUrlConfigProvider.java similarity index 91% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/ExternalUrlConfigProvider.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalUrlConfigProvider.java index 828b83af3..993999b7c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/ExternalUrlConfigProvider.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/ExternalUrlConfigProvider.java @@ -1,6 +1,6 @@ -package eu.eudat.service.remotefetcher; +package eu.eudat.service.externalfetcher; -import eu.eudat.service.remotefetcher.config.ExternalUrls; +import eu.eudat.service.externalfetcher.config.ExternalUrls; import eu.eudat.service.storage.StorageFileService; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.Unmarshaller; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/ExternalUrls.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/ExternalUrls.java similarity index 78% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/ExternalUrls.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/ExternalUrls.java index a65b71b06..aaa40ca3a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/ExternalUrls.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/ExternalUrls.java @@ -1,9 +1,9 @@ -package eu.eudat.service.remotefetcher.config; +package eu.eudat.service.externalfetcher.config; -import eu.eudat.service.remotefetcher.config.prefilling.PrefillingConfigMapAdapter; +import eu.eudat.service.externalfetcher.config.prefilling.PrefillingConfigMapAdapter; -import eu.eudat.service.remotefetcher.config.entities.*; +import eu.eudat.service.externalfetcher.config.entities.*; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/UrlConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/UrlConfiguration.java similarity index 76% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/UrlConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/UrlConfiguration.java index 1682f6aad..575a2d1ac 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/UrlConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/UrlConfiguration.java @@ -1,11 +1,8 @@ -package eu.eudat.service.remotefetcher.config; +package eu.eudat.service.externalfetcher.config; import eu.eudat.commons.enums.ReferenceTypeSourceType; -import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import java.util.List; +import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration; public class UrlConfiguration implements SourceBaseConfiguration { diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/AuthenticationConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/AuthenticationConfiguration.java similarity index 84% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/AuthenticationConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/AuthenticationConfiguration.java index 306a03052..c698b6bae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/AuthenticationConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/AuthenticationConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/DefaultPrefillingMapping.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/DefaultPrefillingMapping.java similarity index 95% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/DefaultPrefillingMapping.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/DefaultPrefillingMapping.java index 02fb6e062..3cabf5b10 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/DefaultPrefillingMapping.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/DefaultPrefillingMapping.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/GenericUrls.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/GenericUrls.java similarity index 68% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/GenericUrls.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/GenericUrls.java index 777f4788c..a27d50a01 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/GenericUrls.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/GenericUrls.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingConfig.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingConfig.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingConfig.java index ecca4103d..39d2ac8f2 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingConfig.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingFixedMapping.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingFixedMapping.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingFixedMapping.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingFixedMapping.java index c46a2b1a1..76b26ecba 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingFixedMapping.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingFixedMapping.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingGet.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingGet.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingGet.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingGet.java index 36e54bb07..151e34eac 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingGet.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingGet.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingMapping.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingMapping.java similarity index 80% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingMapping.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingMapping.java index 1cd4d7a58..d44725480 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingMapping.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingMapping.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; public interface PrefillingMapping { String getTarget(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingSearch.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingSearch.java similarity index 82% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingSearch.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingSearch.java index badb541d0..ba6561c8b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/PrefillingSearch.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/PrefillingSearch.java @@ -1,6 +1,6 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; -import eu.eudat.service.remotefetcher.config.UrlConfiguration; +import eu.eudat.service.externalfetcher.config.UrlConfiguration; import jakarta.xml.bind.annotation.XmlElement; import java.util.ArrayList; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryCaseConfig.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryCaseConfig.java similarity index 78% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryCaseConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryCaseConfig.java index 1fc8ab021..52a10e7f7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryCaseConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryCaseConfig.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import java.util.UUID; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryConfig.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryConfig.java similarity index 75% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryConfig.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryConfig.java index 1ca987001..316b79272 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/QueryConfig.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/QueryConfig.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultFieldsMappingConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultFieldsMappingConfiguration.java similarity index 64% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultFieldsMappingConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultFieldsMappingConfiguration.java index 0d57682d5..5952391f1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultFieldsMappingConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultFieldsMappingConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; public interface ResultFieldsMappingConfiguration { String getResponsePath(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultsConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultsConfiguration.java similarity index 75% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultsConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultsConfiguration.java index f731d3295..5871e1cc9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/ResultsConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/ResultsConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceBaseConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceBaseConfiguration.java similarity index 78% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceBaseConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceBaseConfiguration.java index af3af135f..7dd7939da 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceBaseConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceBaseConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import eu.eudat.commons.enums.ReferenceTypeSourceType; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceExternalApiConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceExternalApiConfiguration.java similarity index 92% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceExternalApiConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceExternalApiConfiguration.java index 8b3921e21..2f4271512 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceExternalApiConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceExternalApiConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceStaticOptionConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceStaticOptionConfiguration.java similarity index 74% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceStaticOptionConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceStaticOptionConfiguration.java index d6d72adef..e7c72dbf1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/SourceStaticOptionConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/SourceStaticOptionConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/StaticOption.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/StaticOption.java similarity index 57% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/StaticOption.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/StaticOption.java index cddcda413..21c63c079 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/entities/StaticOption.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/entities/StaticOption.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.config.entities; +package eu.eudat.service.externalfetcher.config.entities; public interface StaticOption { String getCode(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/prefilling/PrefillingConfigMapAdapter.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/prefilling/PrefillingConfigMapAdapter.java similarity index 91% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/prefilling/PrefillingConfigMapAdapter.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/prefilling/PrefillingConfigMapAdapter.java index 39a165df4..37eef77d9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/config/prefilling/PrefillingConfigMapAdapter.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/config/prefilling/PrefillingConfigMapAdapter.java @@ -1,6 +1,6 @@ -package eu.eudat.service.remotefetcher.config.prefilling; +package eu.eudat.service.externalfetcher.config.prefilling; -import eu.eudat.service.remotefetcher.config.entities.PrefillingConfig; +import eu.eudat.service.externalfetcher.config.entities.PrefillingConfig; import org.w3c.dom.Element; import jakarta.xml.bind.JAXBContext; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/criteria/ExternalReferenceCriteria.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/criteria/ExternalReferenceCriteria.java similarity index 94% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/criteria/ExternalReferenceCriteria.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/criteria/ExternalReferenceCriteria.java index e8f7ffd58..5ef3139ec 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/criteria/ExternalReferenceCriteria.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/criteria/ExternalReferenceCriteria.java @@ -1,9 +1,8 @@ -package eu.eudat.service.remotefetcher.criteria; +package eu.eudat.service.externalfetcher.criteria; import eu.eudat.model.Reference; import java.util.List; -import java.util.Map; public class ExternalReferenceCriteria { private String like; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalAutocompleteFieldResult.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalAutocompleteFieldResult.java similarity index 93% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalAutocompleteFieldResult.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalAutocompleteFieldResult.java index c10820cfa..0a2beac0e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalAutocompleteFieldResult.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalAutocompleteFieldResult.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.models; +package eu.eudat.service.externalfetcher.models; public class ExternalAutocompleteFieldResult { private String id; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalDataResult.java b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalDataResult.java similarity index 96% rename from dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalDataResult.java rename to dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalDataResult.java index 41a47c42a..6d114d68f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/models/ExternalDataResult.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/externalfetcher/models/ExternalDataResult.java @@ -1,4 +1,4 @@ -package eu.eudat.service.remotefetcher.models; +package eu.eudat.service.externalfetcher.models; import java.util.ArrayList; import java.util.List; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/prefilling/PrefillingServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/prefilling/PrefillingServiceImpl.java index 06e360481..6c9276eef 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/prefilling/PrefillingServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/prefilling/PrefillingServiceImpl.java @@ -18,9 +18,9 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet; import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem; import eu.eudat.model.persist.DescriptionProfilingRequest; import eu.eudat.model.persist.DescriptionProfilingWithDataRequest; -import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider; -import eu.eudat.service.remotefetcher.config.entities.*; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider; +import eu.eudat.service.externalfetcher.config.entities.*; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyNotFoundException; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceService.java b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceService.java index f612b604e..510b23015 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceService.java @@ -7,13 +7,14 @@ import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.fieldset.FieldSet; +import jakarta.xml.bind.JAXBException; import javax.management.InvalidApplicationException; import java.util.UUID; public interface PrefillingSourceService { - PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException; + PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; } 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 1409eda3e..31cda6df1 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 @@ -4,6 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.types.externalfetcher.*; +import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity; +import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity; import eu.eudat.convention.ConventionService; import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.errorcode.ErrorThesaurusProperties; @@ -11,6 +14,9 @@ import eu.eudat.model.PrefillingSource; import eu.eudat.model.builder.PrefillingSourceBuilder; import eu.eudat.model.deleter.PrefillingSourceDeleter; import eu.eudat.model.persist.PrefillingSourcePersist; +import eu.eudat.model.persist.externalfetcher.*; +import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist; +import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionPersist; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -23,6 +29,8 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import jakarta.persistence.EntityManager; +import jakarta.xml.bind.JAXBException; +import org.jetbrains.annotations.NotNull; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -30,6 +38,7 @@ import org.springframework.stereotype.Service; import javax.management.InvalidApplicationException; import java.time.Instant; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -62,7 +71,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { } - public PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException{ + public PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException { logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields)); this.authorizationService.authorizeForce(Permission.EditPrefillingSource); @@ -84,7 +93,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { } data.setLabel(model.getLabel()); - data.setDefinition(model.getDefinition()); + data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition()))); data.setUpdatedAt(Instant.now()); if (isUpdate) this.entityManager.merge(data); @@ -95,6 +104,131 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { return this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, PrefillingSource._id), data); } + private @NotNull PrefillingSourceDefinitionEntity buildDefinitionEntity(PrefillingSourceDefinitionPersist persist) { + PrefillingSourceDefinitionEntity data = new PrefillingSourceDefinitionEntity(); + if (persist == null) + return data; + if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { + data.setFields(new ArrayList<>()); + for (PrefillingSourceDefinitionFieldPersist fieldPersist : persist.getFields()) { + data.getFields().add(this.buildFieldEntity(fieldPersist)); + } + } + + return data; + } + + private @NotNull PrefillingSourceDefinitionFieldEntity buildFieldEntity(PrefillingSourceDefinitionFieldPersist persist) { + PrefillingSourceDefinitionFieldEntity data = new PrefillingSourceDefinitionFieldEntity(); + if (persist == null) + return data; + + data.setCode(persist.getCode()); + data.setSemanticTarget(persist.getSemanticTarget()); + data.setSystemFieldTarget(persist.getSystemFieldTarget()); + data.setFixedValue(persist.getFixedValue()); + data.setTrimRegex(persist.getTrimRegex()); + + return data; + } + + private @NotNull ExternalFetcherApiSourceConfigurationEntity buildExternalFetcherApiConfigEntity(ExternalFetcherApiSourceConfigurationPersist persist) { + ExternalFetcherApiSourceConfigurationEntity data = new ExternalFetcherApiSourceConfigurationEntity(); + if (persist == null) + return data; + + data.setUrl(persist.getUrl()); + if (persist.getResults() != null ) { + data.setResults(this.buildResultsConfigEntity(persist.getResults())); + } + data.setPaginationPath(persist.getPaginationPath()); + data.setContentType(persist.getContentType()); + data.setFirstPage(persist.getFirstPage()); + data.setHttpMethod(persist.getHttpMethod()); + data.setRequestBody(persist.getRequestBody()); + data.setFilterType(persist.getFilterType()); + if (persist.getAuth() != null) { + data.setAuth(this.buildAuthConfigEntity(persist.getAuth())); + } + if (!this.conventionService.isListNullOrEmpty(persist.getQueries())){ + data.setQueries(new ArrayList<>()); + for (QueryConfigPersist queryConfigPersist: (persist.getQueries())){ + data.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist)); + } + } + + return data; + } + + private @NotNull ResultsConfigurationEntity buildResultsConfigEntity(ResultsConfigurationPersist persist){ + ResultsConfigurationEntity data = new ResultsConfigurationEntity(); + if (persist == null) return data; + + data.setResultsArrayPath(persist.getResultsArrayPath()); + + if (!this.conventionService.isListNullOrEmpty(persist.getFieldsMapping())){ + data.setFieldsMapping(new ArrayList<>()); + for (ResultFieldsMappingConfigurationPersist fieldsMappingPersist: persist.getFieldsMapping()) { + data.getFieldsMapping().add(this.buildResultFieldsMappingConfigEntity(fieldsMappingPersist)); + } + } + + return data; + } + + private @NotNull ResultFieldsMappingConfigurationEntity buildResultFieldsMappingConfigEntity(ResultFieldsMappingConfigurationPersist persist){ + ResultFieldsMappingConfigurationEntity data = new ResultFieldsMappingConfigurationEntity(); + if (persist == null) return data; + + data.setCode(persist.getCode()); + data.setResponsePath(persist.getResponsePath()); + + return data; + } + + private @NotNull AuthenticationConfigurationEntity buildAuthConfigEntity(AuthenticationConfigurationPersist persist){ + AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity(); + if (persist == null) return data; + + data.setEnabled(persist.getEnabled()); + data.setAuthUrl(persist.getAuthUrl()); + data.setAuthMethod(persist.getAuthMethod()); + data.setAuthRequestBody(persist.getAuthRequestBody()); + data.setType(persist.getType()); + data.setAuthTokenPath(persist.getAuthTokenPath()); + + return data; + } + + private @NotNull QueryConfigEntity buildQueryConfigEntity(QueryConfigPersist persist){ + QueryConfigEntity data = new QueryConfigEntity(); + if (persist == null) return data; + + data.setName(persist.getName()); + data.setDefaultValue(persist.getDefaultValue()); + if (!this.conventionService.isListNullOrEmpty(persist.getCases())){ + data.setCases(new ArrayList<>()); + for (QueryCaseConfigPersist queryCaseConfigPersist: persist.getCases()) { + data.getCases().add(this.buildQueryCaseConfigEntity(queryCaseConfigPersist)); + } + } + + return data; + } + + private @NotNull QueryCaseConfigEntity buildQueryCaseConfigEntity(QueryCaseConfigPersist persist){ + QueryCaseConfigEntity data = new QueryCaseConfigEntity(); + if (persist == null) return data; + + data.setReferenceTypeId(persist.getReferenceTypeId()); + data.setReferenceTypeSourceKey(persist.getReferenceTypeSourceKey()); + data.setSeparator(persist.getSeparator()); + data.setValue(persist.getValue()); + data.setLikePattern(persist.getLikePattern()); + + return data; + } + public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { logger.debug("deleting : {}", id); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceCacheService.java b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceCacheService.java index 7477ae463..8a3f243c5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceCacheService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceCacheService.java @@ -1,6 +1,6 @@ package eu.eudat.service.reference; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; import gr.cite.tools.cache.CacheService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java index 30068dee4..cb651d17b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/reference/ReferenceServiceImpl.java @@ -22,10 +22,10 @@ import eu.eudat.model.persist.referencedefinition.DefinitionPersist; import eu.eudat.model.persist.referencedefinition.FieldPersist; import eu.eudat.query.ReferenceQuery; import eu.eudat.query.lookup.ReferenceSearchLookup; -import eu.eudat.service.remotefetcher.RemoteFetcherService; -import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; -import eu.eudat.service.remotefetcher.models.ExternalDataResult; +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 gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -66,7 +66,7 @@ public class ReferenceServiceImpl implements ReferenceService { private final QueryFactory queryFactory; private final XmlHandlingService xmlHandlingService; - public final RemoteFetcherService remoteFetcherService; + public final ExternalFetcherService externalFetcherService; public ReferenceServiceImpl( EntityManager entityManager, AuthorizationService authorizationService, @@ -75,7 +75,7 @@ public class ReferenceServiceImpl implements ReferenceService { ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory, - XmlHandlingService xmlHandlingService, RemoteFetcherService remoteFetcherService) { + XmlHandlingService xmlHandlingService, ExternalFetcherService externalFetcherService) { this.entityManager = entityManager; this.authorizationService = authorizationService; this.deleterFactory = deleterFactory; @@ -84,7 +84,7 @@ public class ReferenceServiceImpl implements ReferenceService { this.messageSource = messageSource; this.queryFactory = queryFactory; this.xmlHandlingService = xmlHandlingService; - this.remoteFetcherService = remoteFetcherService; + this.externalFetcherService = externalFetcherService; } @Override @@ -246,7 +246,7 @@ public class ReferenceServiceImpl implements ReferenceService { ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition()); if (referenceTypeDefinition == null || this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) return new ExternalDataResult(); - ExternalDataResult results = this.remoteFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).collect(Collectors.toList()), externalReferenceCriteria, key); + ExternalDataResult results = this.externalFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).collect(Collectors.toList()), externalReferenceCriteria, key); for (Map result: results.getResults()) { result.put("referenceType", referenceType.getName()); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java index 4503725cb..7d5d0fae2 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java @@ -14,6 +14,7 @@ import eu.eudat.model.ReferenceType; import eu.eudat.model.builder.ReferenceTypeBuilder; import eu.eudat.model.deleter.ReferenceTypeDeleter; import eu.eudat.model.persist.ReferenceTypePersist; +import eu.eudat.model.persist.externalfetcher.*; import eu.eudat.model.persist.referencetypedefinition.*; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; @@ -115,7 +116,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { } if (!this.conventionService.isListNullOrEmpty(persist.getSources())){ data.setSources(new ArrayList<>()); - for (ReferenceTypeSourceBaseConfigurationPersist sourceBaseConfigPersist: persist.getSources()) { + for (ExternalFetcherBaseSourceConfigurationPersist sourceBaseConfigPersist: persist.getSources()) { data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist)); } } @@ -135,7 +136,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { return data; } - private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ReferenceTypeSourceBaseConfigurationPersist persist){ + private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ExternalFetcherBaseSourceConfigurationPersist persist){ if (persist == null) return new ExternalFetcherApiSourceConfigurationEntity(); ExternalFetcherBaseSourceConfigurationEntity data; @@ -143,22 +144,22 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { if (ReferenceTypeSourceType.API.equals(persist.getType())) { ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity(); - apiEntity.setUrl(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getUrl()); - if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults() != null ) { - apiEntity.setResults(this.buildResultsConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults())); + apiEntity.setUrl(((ExternalFetcherApiSourceConfigurationPersist) persist).getUrl()); + if (((ExternalFetcherApiSourceConfigurationPersist) persist).getResults() != null ) { + apiEntity.setResults(this.buildResultsConfigEntity(((ExternalFetcherApiSourceConfigurationPersist) persist).getResults())); } - apiEntity.setPaginationPath(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getPaginationPath()); - apiEntity.setContentType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getContentType()); - apiEntity.setFirstPage(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFirstPage()); - apiEntity.setHttpMethod(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getHttpMethod()); - apiEntity.setRequestBody(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getRequestBody()); - apiEntity.setFilterType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFilterType()); - if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth() != null) { - apiEntity.setAuth(this.buildAuthConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth())); + apiEntity.setPaginationPath(((ExternalFetcherApiSourceConfigurationPersist) persist).getPaginationPath()); + apiEntity.setContentType(((ExternalFetcherApiSourceConfigurationPersist) persist).getContentType()); + apiEntity.setFirstPage(((ExternalFetcherApiSourceConfigurationPersist) persist).getFirstPage()); + apiEntity.setHttpMethod(((ExternalFetcherApiSourceConfigurationPersist) persist).getHttpMethod()); + apiEntity.setRequestBody(((ExternalFetcherApiSourceConfigurationPersist) persist).getRequestBody()); + apiEntity.setFilterType(((ExternalFetcherApiSourceConfigurationPersist) persist).getFilterType()); + if (((ExternalFetcherApiSourceConfigurationPersist) persist).getAuth() != null) { + apiEntity.setAuth(this.buildAuthConfigEntity(((ExternalFetcherApiSourceConfigurationPersist) persist).getAuth())); } - if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries())){ + if (!this.conventionService.isListNullOrEmpty(((ExternalFetcherApiSourceConfigurationPersist) persist).getQueries())){ apiEntity.setQueries(new ArrayList<>()); - for (QueryConfigPersist queryConfigPersist: ((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries()) { + for (QueryConfigPersist queryConfigPersist: ((ExternalFetcherApiSourceConfigurationPersist) persist).getQueries()) { apiEntity.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist)); } } @@ -167,9 +168,9 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { }else { ExternalFetcherStaticOptionSourceConfigurationEntity staticEntity = new ExternalFetcherStaticOptionSourceConfigurationEntity(); - if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions())){ + if (!this.conventionService.isListNullOrEmpty(((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions())){ staticEntity.setOptions(new ArrayList<>()); - for (ReferenceTypeStaticOptionPersist optionPersist: ((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions()) { + for (StaticOptionPersist optionPersist: ((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions()) { staticEntity.getOptions().add(this.buildStaticOptionEntity(optionPersist)); } } @@ -255,7 +256,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { return data; } - private @NotNull StaticOptionEntity buildStaticOptionEntity(ReferenceTypeStaticOptionPersist persist){ + private @NotNull StaticOptionEntity buildStaticOptionEntity(StaticOptionPersist persist){ StaticOptionEntity data = new StaticOptionEntity(); if (persist == null) return data; diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherService.java b/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherService.java deleted file mode 100644 index 033fe084b..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/service/remotefetcher/RemoteFetcherService.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.eudat.service.remotefetcher; - -import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; -import eu.eudat.service.remotefetcher.models.ExternalDataResult; - -import java.util.List; - -public interface RemoteFetcherService { - ExternalDataResult getExternalData(List sources, ExternalReferenceCriteria externalReferenceCriteria, String key); - Integer countExternalData(List sources, ExternalReferenceCriteria externalReferenceCriteria, String key); -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ValidationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ValidationManager.java index 6adef39df..4cfdf3af5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ValidationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ValidationManager.java @@ -5,7 +5,7 @@ import gr.cite.tools.exception.MyNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; @Component public class ValidationManager { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/ExternalValidationService.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/ExternalValidationService.java index 89933a101..ae3ea7872 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/ExternalValidationService.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/ExternalValidationService.java @@ -1,7 +1,7 @@ package eu.eudat.logic.services; import eu.eudat.commons.scope.user.UserScope; -import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; +import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria; import gr.cite.tools.exception.MyNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;