Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Efstratios Giannopoulos 2024-02-23 18:55:51 +02:00
commit e0deaef950
91 changed files with 877 additions and 303 deletions

View File

@ -1,7 +1,7 @@
package eu.eudat.commons.types.externalfetcher; package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; 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; import jakarta.xml.bind.annotation.XmlElement;
public class AuthenticationConfigurationEntity implements AuthenticationConfiguration { public class AuthenticationConfigurationEntity implements AuthenticationConfiguration {

View File

@ -2,7 +2,7 @@ package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; 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.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.commons.types.externalfetcher; package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeSourceType; 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.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher; 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.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher; 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 jakarta.xml.bind.annotation.XmlElement;
import java.util.UUID; import java.util.UUID;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher; 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.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher; 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; import jakarta.xml.bind.annotation.XmlElement;
public class ResultFieldsMappingConfigurationEntity implements ResultFieldsMappingConfiguration { public class ResultFieldsMappingConfigurationEntity implements ResultFieldsMappingConfiguration {

View File

@ -1,7 +1,6 @@
package eu.eudat.commons.types.externalfetcher; package eu.eudat.commons.types.externalfetcher;
import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity; import eu.eudat.service.externalfetcher.config.entities.ResultsConfiguration;
import eu.eudat.service.remotefetcher.config.entities.ResultsConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.commons.types.externalfetcher; 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; import jakarta.xml.bind.annotation.XmlElement;
public class StaticOptionEntity implements StaticOption { public class StaticOptionEntity implements StaticOption {

View File

@ -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<PrefillingSourceDefinitionField> 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<PrefillingSourceDefinitionField> getFields() {
return fields;
}
public void setFields(List<PrefillingSourceDefinitionField> fields) {
this.fields = fields;
}
}

View File

@ -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<PrefillingSourceDefinitionFieldEntity> 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<PrefillingSourceDefinitionFieldEntity> getFields() {
return fields;
}
public void setFields(List<PrefillingSourceDefinitionFieldEntity> fields) {
this.fields = fields;
}
}

View File

@ -1,6 +1,8 @@
package eu.eudat.commons.types.prefillingsource; package eu.eudat.commons.types.prefillingsource;
public class PrefillingSourceDefinitionField { import jakarta.xml.bind.annotation.XmlElement;
public class PrefillingSourceDefinitionFieldEntity {
private String code; private String code;
private String systemFieldTarget; private String systemFieldTarget;
private String semanticTarget; private String semanticTarget;
@ -11,6 +13,7 @@ public class PrefillingSourceDefinitionField {
return code; return code;
} }
@XmlElement(name = "code")
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
@ -19,6 +22,7 @@ public class PrefillingSourceDefinitionField {
return systemFieldTarget; return systemFieldTarget;
} }
@XmlElement(name = "systemFieldTarget")
public void setSystemFieldTarget(String systemFieldTarget) { public void setSystemFieldTarget(String systemFieldTarget) {
this.systemFieldTarget = systemFieldTarget; this.systemFieldTarget = systemFieldTarget;
} }
@ -27,6 +31,7 @@ public class PrefillingSourceDefinitionField {
return semanticTarget; return semanticTarget;
} }
@XmlElement(name = "semanticTarget")
public void setSemanticTarget(String semanticTarget) { public void setSemanticTarget(String semanticTarget) {
this.semanticTarget = semanticTarget; this.semanticTarget = semanticTarget;
} }
@ -35,6 +40,7 @@ public class PrefillingSourceDefinitionField {
return trimRegex; return trimRegex;
} }
@XmlElement(name = "trimRegex")
public void setTrimRegex(String trimRegex) { public void setTrimRegex(String trimRegex) {
this.trimRegex = trimRegex; this.trimRegex = trimRegex;
} }
@ -43,6 +49,7 @@ public class PrefillingSourceDefinitionField {
return fixedValue; return fixedValue;
} }
@XmlElement(name = "fixedValue")
public void setFixedValue(String fixedValue) { public void setFixedValue(String fixedValue) {
this.fixedValue = fixedValue; this.fixedValue = fixedValue;
} }

View File

@ -1,7 +1,7 @@
package eu.eudat.model; package eu.eudat.model;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition; import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -14,7 +14,7 @@ public class PrefillingSource {
private String label; private String label;
public static final String _label = "label"; public static final String _label = "label";
private String definition; private PrefillingSourceDefinition definition;
public static final String _definition = "definition"; public static final String _definition = "definition";
private IsActive isActive; private IsActive isActive;
@ -45,11 +45,11 @@ public class PrefillingSource {
this.label = label; this.label = label;
} }
public String getDefinition() { public PrefillingSourceDefinition getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(PrefillingSourceDefinition definition) {
this.definition = definition; this.definition = definition;
} }

View File

@ -1,17 +1,11 @@
package eu.eudat.model.builder; package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.ContactInfoType; import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.types.user.AdditionalInfoEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserEntity; import eu.eudat.data.UserEntity;
import eu.eudat.model.*; import eu.eudat.model.*;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
import eu.eudat.query.TenantUserQuery;
import eu.eudat.query.UserContactInfoQuery; 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.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;

View File

@ -2,9 +2,11 @@ package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.model.PrefillingSource; import eu.eudat.model.PrefillingSource;
import eu.eudat.model.builder.prefillingsourcedefinition.PrefillingSourceDefinitionBuilder;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
@ -57,8 +59,10 @@ public class PrefillingSourceBuilder extends BaseBuilder<PrefillingSource, Prefi
PrefillingSource m = new PrefillingSource(); PrefillingSource m = new PrefillingSource();
if (fields.hasField(this.asIndexer(PrefillingSource._id))) m.setId(d.getId()); if (fields.hasField(this.asIndexer(PrefillingSource._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PrefillingSource._label))) m.setLabel(d.getLabel()); if (fields.hasField(this.asIndexer(PrefillingSource._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(PrefillingSource._definition))) m.setDefinition(d.getDefinition()); if (!definitionFields.isEmpty() && d.getDefinition() != null){
if (fields.hasField(this.asIndexer(PrefillingSource._createdAt))) m.setCreatedAt(d.getCreatedAt()); PrefillingSourceDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(PrefillingSourceDefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(PrefillingSourceDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
} if (fields.hasField(this.asIndexer(PrefillingSource._createdAt))) m.setCreatedAt(d.getCreatedAt());
if (fields.hasField(this.asIndexer(PrefillingSource._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); if (fields.hasField(this.asIndexer(PrefillingSource._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(PrefillingSource._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(PrefillingSource._isActive))) m.setIsActive(d.getIsActive());
if (fields.hasField(this.asIndexer(PrefillingSource._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); if (fields.hasField(this.asIndexer(PrefillingSource._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));

View File

@ -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.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.AuthenticationConfigurationEntity; import eu.eudat.commons.types.externalfetcher.AuthenticationConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.AuthenticationConfiguration; import eu.eudat.model.externalfetcher.AuthenticationConfiguration;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;

View File

@ -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.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity; import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceExternalApiConfiguration; import eu.eudat.model.externalfetcher.ExternalFetcherApiSourceConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -20,44 +20,44 @@ import java.util.*;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceExternalApiConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceExternalApiConfiguration, ExternalFetcherApiSourceConfigurationEntity> { public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherApiSourceConfiguration, ExternalFetcherApiSourceConfigurationEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@Autowired @Autowired
public ReferenceTypeSourceExternalApiConfigurationBuilder( public ExternalFetcherApiSourceConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) { 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.builderFactory = builderFactory;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
} }
@Override @Override
protected ReferenceTypeSourceExternalApiConfiguration getInstance() { protected ExternalFetcherApiSourceConfiguration getInstance() {
return new ReferenceTypeSourceExternalApiConfiguration(); return new ExternalFetcherApiSourceConfiguration();
} }
@Override @Override
protected ReferenceTypeSourceExternalApiConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ReferenceTypeSourceExternalApiConfiguration m) { protected ExternalFetcherApiSourceConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ExternalFetcherApiSourceConfiguration m) {
FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._results)); FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._results));
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._auth)); FieldSet authFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._auth));
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._queries)); FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._queries));
if(!authorizationService.authorize(Permission.EditReferenceType)) return m; 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) { if (!resultsFields.isEmpty() && d.getResults() != null) {
m.setResults(this.builderFactory.builder(ResultsConfigurationBuilder.class).authorize(this.authorize).build(resultsFields, d.getResults())); 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(ExternalFetcherApiSourceConfiguration._type))) m.setType(d.getType());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._contentType))) m.setContentType(d.getContentType()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._contentType))) m.setContentType(d.getContentType());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._firstPage))) m.setFirstPage(d.getFirstPage()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._firstPage))) m.setFirstPage(d.getFirstPage());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._requestBody))) m.setRequestBody(d.getRequestBody()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._filterType))) m.setFilterType(d.getFilterType()); if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._filterType))) m.setFilterType(d.getFilterType());
if (!authFields.isEmpty() && d.getAuth() != null) { if (!authFields.isEmpty() && d.getAuth() != null) {
m.setAuth(this.builderFactory.builder(AuthenticationConfigurationBuilder.class).authorize(this.authorize).build(authFields, d.getAuth())); m.setAuth(this.builderFactory.builder(AuthenticationConfigurationBuilder.class).authorize(this.authorize).build(authFields, d.getAuth()));
} }

View File

@ -1,4 +1,4 @@
package eu.eudat.model.builder.referencetypedefinition; package eu.eudat.model.builder.externalfetcher;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherBaseSourceConfigurationEntity; 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.ReferenceType;
import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.builder.ReferenceTypeBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
import eu.eudat.query.ReferenceTypeQuery; import eu.eudat.query.ReferenceTypeQuery;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -25,14 +25,14 @@ import java.util.stream.Collectors;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends ReferenceTypeSourceBaseConfiguration, Entity extends ExternalFetcherBaseSourceConfigurationEntity> extends BaseBuilder<Model, Entity> { public abstract class ExternalFetcherBaseSourceConfigurationBuilder<Model extends ExternalFetcherBaseSourceConfiguration, Entity extends ExternalFetcherBaseSourceConfigurationEntity> extends BaseBuilder<Model, Entity> {
protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
protected final BuilderFactory builderFactory; protected final BuilderFactory builderFactory;
protected final QueryFactory queryFactory; protected final QueryFactory queryFactory;
@Autowired @Autowired
public ReferenceTypeSourceBaseConfigurationBuilder( public ExternalFetcherBaseSourceConfigurationBuilder(
ConventionService conventionService, ConventionService conventionService,
LoggerService logger, BuilderFactory builderFactory, QueryFactory queryFactory) { LoggerService logger, BuilderFactory builderFactory, QueryFactory queryFactory) {
super(conventionService, logger); super(conventionService, logger);
@ -40,7 +40,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
} }
public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) { public ExternalFetcherBaseSourceConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values; this.authorize = values;
return this; return this;
} }

View File

@ -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.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity; import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
import eu.eudat.convention.ConventionService; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
@ -20,34 +20,34 @@ import java.util.EnumSet;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeSourceStaticOptionConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceStaticOptionConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> { public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherStaticOptionSourceConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@Autowired @Autowired
public ReferenceTypeSourceStaticOptionConfigurationBuilder( public ExternalFetcherStaticOptionSourceConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) { 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.builderFactory = builderFactory;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
} }
@Override @Override
protected ReferenceTypeSourceStaticOptionConfiguration getInstance() { protected ExternalFetcherStaticOptionSourceConfiguration getInstance() {
return new ReferenceTypeSourceStaticOptionConfiguration(); return new ExternalFetcherStaticOptionSourceConfiguration();
} }
@Override @Override
protected ReferenceTypeSourceStaticOptionConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ReferenceTypeSourceStaticOptionConfiguration m) { protected ExternalFetcherStaticOptionSourceConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ExternalFetcherStaticOptionSourceConfiguration m) {
FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceStaticOptionConfiguration._options)); FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherStaticOptionSourceConfiguration._options));
if(!authorizationService.authorize(Permission.EditReferenceType)) return m; if(!authorizationService.authorize(Permission.EditReferenceType)) return m;
if (!optionsFields.isEmpty() && d.getOptions() != null) { 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; return m;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.builder.referencetypedefinition; package eu.eudat.model.builder.externalfetcher;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.QueryCaseConfigEntity; 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.ReferenceType;
import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.builder.ReferenceTypeBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder;
import eu.eudat.model.referencetypedefinition.QueryCaseConfig; import eu.eudat.model.externalfetcher.QueryCaseConfig;
import eu.eudat.query.ReferenceTypeQuery; import eu.eudat.query.ReferenceTypeQuery;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;

View File

@ -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.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.QueryConfigEntity; import eu.eudat.commons.types.externalfetcher.QueryConfigEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; 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.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -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.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity; import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; 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.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -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.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.ResultsConfigurationEntity; import eu.eudat.commons.types.externalfetcher.ResultsConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; 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.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -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.AuthorizationFlags;
import eu.eudat.commons.types.externalfetcher.StaticOptionEntity; import eu.eudat.commons.types.externalfetcher.StaticOptionEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; 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.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.DataLogEntry;
@ -19,32 +19,32 @@ import java.util.*;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeStaticOptionBuilder extends BaseBuilder<ReferenceTypeStaticOption, StaticOptionEntity> { public class StaticOptionBuilder extends BaseBuilder<StaticOption, StaticOptionEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public ReferenceTypeStaticOptionBuilder(ConventionService conventionService) { public StaticOptionBuilder(ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeStaticOptionBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(StaticOptionBuilder.class)));
} }
public ReferenceTypeStaticOptionBuilder authorize(EnumSet<AuthorizationFlags> values) { public StaticOptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values; this.authorize = values;
return this; return this;
} }
@Override @Override
public List<ReferenceTypeStaticOption> build(FieldSet fields, List<StaticOptionEntity> data) throws MyApplicationException { public List<StaticOption> build(FieldSet fields, List<StaticOptionEntity> 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.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)); this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty()) if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>(); return new ArrayList<>();
List<ReferenceTypeStaticOption> models = new ArrayList<>(); List<StaticOption> models = new ArrayList<>();
for (StaticOptionEntity d : data) { for (StaticOptionEntity d : data) {
ReferenceTypeStaticOption m = new ReferenceTypeStaticOption(); StaticOption m = new StaticOption();
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._code))) m.setCode(d.getCode()); if (fields.hasField(this.asIndexer(StaticOption._code))) m.setCode(d.getCode());
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._value))) m.setValue(d.getValue()); if (fields.hasField(this.asIndexer(StaticOption._value))) m.setValue(d.getValue());
models.add(m); models.add(m);
} }

View File

@ -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<PrefillingSourceDefinition, PrefillingSourceDefinitionEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PrefillingSourceDefinition> build(FieldSet fields, List<PrefillingSourceDefinitionEntity> 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<PrefillingSourceDefinition> 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;
}
}

View File

@ -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<PrefillingSourceDefinitionField, PrefillingSourceDefinitionFieldEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<PrefillingSourceDefinitionField> build(FieldSet fields, List<PrefillingSourceDefinitionFieldEntity> 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<PrefillingSourceDefinitionField> 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;
}
}

View File

@ -7,8 +7,10 @@ import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurat
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity; import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; 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.ReferenceTypeDefinition;
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration; import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -59,9 +61,9 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
List<ExternalFetcherApiSourceConfigurationEntity> externalApiConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList(); List<ExternalFetcherApiSourceConfigurationEntity> externalApiConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ExternalFetcherApiSourceConfigurationEntity)x).toList();
List<ExternalFetcherStaticOptionSourceConfigurationEntity> staticOptionConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ExternalFetcherStaticOptionSourceConfigurationEntity)x).toList(); List<ExternalFetcherStaticOptionSourceConfigurationEntity> staticOptionConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ExternalFetcherStaticOptionSourceConfigurationEntity)x).toList();
m.setSources(new ArrayList<>()); m.setSources(new ArrayList<>());
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceExternalApiConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities)); m.getSources().addAll(this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities));
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceStaticOptionConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities)); m.getSources().addAll(this.builderFactory.builder(ExternalFetcherStaticOptionSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities));
m.getSources().sort(Comparator.comparing(ReferenceTypeSourceBaseConfiguration::getOrdinal)); m.getSources().sort(Comparator.comparing(ExternalFetcherBaseSourceConfiguration::getOrdinal));
} }
models.add(m); models.add(m);
} }

View File

@ -4,7 +4,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.ReferenceTypeCensor; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -4,7 +4,9 @@ import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.censorship.ReferenceTypeCensor; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -39,19 +41,19 @@ public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor {
return; return;
this.authService.authorizeForce(Permission.BrowseReferenceType); 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); 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); 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); 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); 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); this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId);
} }

View File

@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;

View File

@ -1,10 +1,10 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import java.util.List; import java.util.List;
public class ReferenceTypeSourceExternalApiConfiguration extends ReferenceTypeSourceBaseConfiguration { public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSourceConfiguration {
public final static String _url = "url"; public final static String _url = "url";

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
@ -6,7 +6,7 @@ import eu.eudat.model.ReferenceType;
import java.util.List; import java.util.List;
public abstract class ReferenceTypeSourceBaseConfiguration { public abstract class ExternalFetcherBaseSourceConfiguration {
public final static String _key = "key"; public final static String _key = "key";
private String key; private String key;

View File

@ -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<StaticOption> options;
public List<StaticOption> getOptions() {
return options;
}
public void setOptions(List<StaticOption> options) {
this.options = options;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
public class ResultFieldsMappingConfiguration { public class ResultFieldsMappingConfiguration {

View File

@ -1,4 +1,4 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.externalfetcher;
import java.util.List; import java.util.List;

View File

@ -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"; public final static String _code = "code";
private String code; private String code;

View File

@ -3,6 +3,7 @@ package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionPersist;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -23,7 +24,7 @@ public class PrefillingSourcePersist {
public static final String _label = "label"; public static final String _label = "label";
private String definition; private PrefillingSourceDefinitionPersist definition;
public static final String _definition = "definition"; public static final String _definition = "definition";
@ -47,11 +48,11 @@ public class PrefillingSourcePersist {
this.label = label; this.label = label;
} }
public String getDefinition() { public PrefillingSourceDefinitionPersist getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(PrefillingSourceDefinitionPersist definition) {
this.definition = definition; this.definition = definition;
} }
@ -97,7 +98,15 @@ public class PrefillingSourcePersist {
.failOn(PrefillingSourcePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())), .failOn(PrefillingSourcePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getLabel())) .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))
); );
} }
} }

View File

@ -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.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.commons.validation.BaseValidator; import eu.eudat.commons.validation.BaseValidator;

View File

@ -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.enums.ReferenceTypeExternalApiHTTPMethodType;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist {
private String url; private String url;
@ -134,7 +134,7 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
@Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName) @Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceExternalApiConfigurationPersist> { public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherApiSourceConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator"; public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator";
@ -143,49 +143,49 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
} }
@Override @Override
protected Class<ReferenceTypeSourceExternalApiConfigurationPersist> modelClass() { protected Class<ExternalFetcherApiSourceConfigurationPersist> modelClass() {
return ReferenceTypeSourceExternalApiConfigurationPersist.class; return ExternalFetcherApiSourceConfigurationPersist.class;
} }
@Override @Override
protected List<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) { protected List<Specification> specifications(ExternalFetcherApiSourceConfigurationPersist item) {
List<Specification> specifications = getBaseSpecifications(item); List<Specification> specifications = getBaseSpecifications(item);
specifications.addAll(Arrays.asList( specifications.addAll(Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getUrl())) .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() this.spec()
.must(() -> !this.isEmpty(item.getPaginationPath())) .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() this.spec()
.must(() -> !this.isEmpty(item.getContentType())) .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() this.spec()
.must(() -> !this.isEmpty(item.getFirstPage())) .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() this.spec()
.must(() -> !this.isNull(item.getHttpMethod())) .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() this.spec()
.must(() -> !this.isNull(item.getResults())) .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() this.refSpec()
.iff(() -> !this.isNull(item.getResults())) .iff(() -> !this.isNull(item.getResults()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._results) .on(ExternalFetcherApiSourceConfigurationPersist._results)
.over(item.getResults()) .over(item.getResults())
.using(() -> this.validatorFactory.validator(ResultsConfigurationPersist.ResultsConfigurationPersistValidator.class)), .using(() -> this.validatorFactory.validator(ResultsConfigurationPersist.ResultsConfigurationPersistValidator.class)),
this.spec() this.spec()
.must(() -> !this.isNull(item.getAuth())) .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() this.refSpec()
.iff(() -> !this.isNull(item.getAuth())) .iff(() -> !this.isNull(item.getAuth()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._auth) .on(ExternalFetcherApiSourceConfigurationPersist._auth)
.over(item.getAuth()) .over(item.getAuth())
.using(() -> this.validatorFactory.validator(AuthenticationConfigurationPersist.AuthenticationConfigurationPersistValidator.class)), .using(() -> this.validatorFactory.validator(AuthenticationConfigurationPersist.AuthenticationConfigurationPersistValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getQueries())) .iff(() -> !this.isListNullOrEmpty(item.getQueries()))
.on(ReferenceTypeSourceExternalApiConfigurationPersist._queries) .on(ExternalFetcherApiSourceConfigurationPersist._queries)
.over(item.getQueries()) .over(item.getQueries())
.using((itm) -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class))
)); ));

View File

@ -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.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
@ -22,10 +22,10 @@ import java.util.UUID;
property = "type", property = "type",
visible = true) visible = true)
@JsonSubTypes({ @JsonSubTypes({
@JsonSubTypes.Type(value = ReferenceTypeSourceExternalApiConfigurationPersist.class, name = "0"), @JsonSubTypes.Type(value = ExternalFetcherApiSourceConfigurationPersist.class, name = "0"),
@JsonSubTypes.Type(value = ReferenceTypeSourceStaticOptionConfigurationPersist.class, name = "1") @JsonSubTypes.Type(value = ExternalFetcherStaticOptionSourceConfigurationPersist.class, name = "1")
}) })
public abstract class ReferenceTypeSourceBaseConfigurationPersist { public abstract class ExternalFetcherBaseSourceConfigurationPersist {
private String key = null; private String key = null;
@ -87,7 +87,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
this.referenceTypeDependencyIds = referenceTypeDependencyIds; this.referenceTypeDependencyIds = referenceTypeDependencyIds;
} }
public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator<T extends ReferenceTypeSourceBaseConfigurationPersist> extends BaseValidator<T> { public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator<T extends ExternalFetcherBaseSourceConfigurationPersist> extends BaseValidator<T> {
protected final MessageSource messageSource; protected final MessageSource messageSource;
@ -104,16 +104,16 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
specifications.addAll(Arrays.asList( specifications.addAll(Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getKey())) .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() this.spec()
.must(() -> !this.isEmpty(item.getLabel())) .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() this.spec()
.must(() -> !this.isNull(item.getOrdinal())) .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() this.spec()
.must(() -> !this.isNull(item.getType())) .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; return specifications;
} }

View File

@ -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.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; 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.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist { public class ExternalFetcherStaticOptionSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist {
List<ReferenceTypeStaticOptionPersist> options; List<StaticOptionPersist> options;
public static final String _options = "options"; public static final String _options = "options";
public List<ReferenceTypeStaticOptionPersist> getOptions() { public List<StaticOptionPersist> getOptions() {
return options; return options;
} }
public void setOptions(List<ReferenceTypeStaticOptionPersist> options) { public void setOptions(List<StaticOptionPersist> options) {
this.options = options; this.options = options;
} }
@Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName) @Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceStaticOptionConfigurationPersist> { public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherStaticOptionSourceConfigurationPersist> {
public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator"; public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator";
@ -37,19 +36,19 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen
} }
@Override @Override
protected Class<ReferenceTypeSourceStaticOptionConfigurationPersist> modelClass() { protected Class<ExternalFetcherStaticOptionSourceConfigurationPersist> modelClass() {
return ReferenceTypeSourceStaticOptionConfigurationPersist.class; return ExternalFetcherStaticOptionSourceConfigurationPersist.class;
} }
@Override @Override
protected List<Specification> specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) { protected List<Specification> specifications(ExternalFetcherStaticOptionSourceConfigurationPersist item) {
List<Specification> specifications = getBaseSpecifications(item); List<Specification> specifications = getBaseSpecifications(item);
specifications.add( specifications.add(
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getOptions())) .iff(() -> !this.isListNullOrEmpty(item.getOptions()))
.on(ReferenceTypeSourceStaticOptionConfigurationPersist._options) .on(ExternalFetcherStaticOptionSourceConfigurationPersist._options)
.over(item.getOptions()) .over(item.getOptions())
.using((itm) -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class)) .using((itm) -> this.validatorFactory.validator(StaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class))
); );
return specifications; return specifications;
} }

View File

@ -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.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;

View File

@ -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.commons.validation.BaseValidator;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;

View File

@ -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.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;

View File

@ -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.commons.validation.BaseValidator;
import gr.cite.tools.validation.ValidatorFactory; import gr.cite.tools.validation.ValidatorFactory;

View File

@ -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.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class ReferenceTypeStaticOptionPersist { public class StaticOptionPersist {
private String code; private String code;
@ -41,7 +41,7 @@ public class ReferenceTypeStaticOptionPersist {
@Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName) @Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator<ReferenceTypeStaticOptionPersist> { public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator<StaticOptionPersist> {
public static final String ValidatorName = "ReferenceTypeStaticOptionPersistValidator"; public static final String ValidatorName = "ReferenceTypeStaticOptionPersistValidator";
@ -53,19 +53,19 @@ public class ReferenceTypeStaticOptionPersist {
} }
@Override @Override
protected Class<ReferenceTypeStaticOptionPersist> modelClass() { protected Class<StaticOptionPersist> modelClass() {
return ReferenceTypeStaticOptionPersist.class; return StaticOptionPersist.class;
} }
@Override @Override
protected List<Specification> specifications(ReferenceTypeStaticOptionPersist item) { protected List<Specification> specifications(StaticOptionPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getCode())) .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() this.spec()
.must(() -> !this.isEmpty(item.getValue())) .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()))
); );
} }
} }

View File

@ -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<PrefillingSourceDefinitionFieldPersist> {
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<PrefillingSourceDefinitionFieldPersist> modelClass() {
return PrefillingSourceDefinitionFieldPersist.class;
}
@Override
protected List<Specification> specifications(PrefillingSourceDefinitionFieldPersist item) {
return Arrays.asList();
}
}
}

View File

@ -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<PrefillingSourceDefinitionFieldPersist> 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<PrefillingSourceDefinitionFieldPersist> getFields() {
return fields;
}
public void setFields(List<PrefillingSourceDefinitionFieldPersist> fields) {
this.fields = fields;
}
@Component(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class PrefillingSourceDefinitionPersistValidator extends BaseValidator<PrefillingSourceDefinitionPersist> {
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<PrefillingSourceDefinitionPersist> modelClass() {
return PrefillingSourceDefinitionPersist.class;
}
@Override
protected List<Specification> 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))
);
}
}
}

View File

@ -2,6 +2,9 @@ package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.validation.BaseValidator; 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.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
@ -21,7 +24,7 @@ public class ReferenceTypeDefinitionPersist {
public static final String _fields = "fields"; public static final String _fields = "fields";
private List<ReferenceTypeSourceBaseConfigurationPersist> sources = null; private List<ExternalFetcherBaseSourceConfigurationPersist> sources = null;
public static final String _sources = "sources"; public static final String _sources = "sources";
@ -33,11 +36,11 @@ public class ReferenceTypeDefinitionPersist {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeSourceBaseConfigurationPersist> getSources() { public List<ExternalFetcherBaseSourceConfigurationPersist> getSources() {
return sources; return sources;
} }
public void setSources(List<ReferenceTypeSourceBaseConfigurationPersist> sources) { public void setSources(List<ExternalFetcherBaseSourceConfigurationPersist> sources) {
this.sources = sources; this.sources = sources;
} }
@ -77,7 +80,7 @@ public class ReferenceTypeDefinitionPersist {
.iff(() -> !this.isListNullOrEmpty(item.getSources())) .iff(() -> !this.isListNullOrEmpty(item.getSources()))
.on(ReferenceTypeDefinitionPersist._sources) .on(ReferenceTypeDefinitionPersist._sources)
.over(item.getSources()) .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))
); );
} }
} }

View File

@ -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<PrefillingSourceDefinitionField> 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<PrefillingSourceDefinitionField> getFields() {
return fields;
}
public void setFields(List<PrefillingSourceDefinitionField> fields) {
this.fields = fields;
}
}

View File

@ -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;
}
}

View File

@ -1,5 +1,7 @@
package eu.eudat.model.referencetypedefinition; package eu.eudat.model.referencetypedefinition;
import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
import java.util.List; import java.util.List;
public class ReferenceTypeDefinition { public class ReferenceTypeDefinition {
@ -8,7 +10,7 @@ public class ReferenceTypeDefinition {
private List<ReferenceTypeField> fields; private List<ReferenceTypeField> fields;
public final static String _sources = "sources"; public final static String _sources = "sources";
private List<ReferenceTypeSourceBaseConfiguration> sources; private List<ExternalFetcherBaseSourceConfiguration> sources;
public List<ReferenceTypeField> getFields() { public List<ReferenceTypeField> getFields() {
return fields; return fields;
@ -18,11 +20,11 @@ public class ReferenceTypeDefinition {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeSourceBaseConfiguration> getSources() { public List<ExternalFetcherBaseSourceConfiguration> getSources() {
return sources; return sources;
} }
public void setSources(List<ReferenceTypeSourceBaseConfiguration> sources) { public void setSources(List<ExternalFetcherBaseSourceConfiguration> sources) {
this.sources = sources; this.sources = sources;
} }
} }

View File

@ -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<ReferenceTypeStaticOption> options;
public List<ReferenceTypeStaticOption> getOptions() {
return options;
}
public void setOptions(List<ReferenceTypeStaticOption> options) {
this.options = options;
}
}

View File

@ -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<SourceBaseConfiguration> sources, ExternalReferenceCriteria externalReferenceCriteria, String key);
Integer countExternalData(List<SourceBaseConfiguration> sources, ExternalReferenceCriteria externalReferenceCriteria, String key);
}

View File

@ -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.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -11,9 +11,9 @@ import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.ReferenceEntity;
import eu.eudat.model.Reference; import eu.eudat.model.Reference;
import eu.eudat.model.referencedefinition.Field; import eu.eudat.model.referencedefinition.Field;
import eu.eudat.service.remotefetcher.config.entities.*; import eu.eudat.service.externalfetcher.config.entities.*;
import eu.eudat.service.remotefetcher.models.ExternalDataResult; import eu.eudat.service.externalfetcher.models.ExternalDataResult;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import net.minidev.json.JSONArray; import net.minidev.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -31,14 +31,14 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class RemoteFetcherServiceImpl implements RemoteFetcherService { public class ExternalFetcherServiceImpl implements ExternalFetcherService {
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcherServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(ExternalFetcherServiceImpl.class);
private WebClient webClient; private WebClient webClient;
private final ConventionService conventionService; private final ConventionService conventionService;
private final JsonHandlingService jsonHandlingService; private final JsonHandlingService jsonHandlingService;
@Autowired @Autowired
public RemoteFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) { public ExternalFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) {
this.conventionService = conventionService; this.conventionService = conventionService;
this.jsonHandlingService = jsonHandlingService; this.jsonHandlingService = jsonHandlingService;
} }

View File

@ -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 eu.eudat.service.storage.StorageFileService;
import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;

View File

@ -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.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

View File

@ -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.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;
import java.util.List;
public class UrlConfiguration implements SourceBaseConfiguration { public class UrlConfiguration implements SourceBaseConfiguration {

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;

View File

@ -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.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import java.util.List; import java.util.List;

View File

@ -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.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;

View File

@ -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.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;

View File

@ -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.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
public interface PrefillingMapping { public interface PrefillingMapping {
String getTarget(); String getTarget();

View File

@ -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 jakarta.xml.bind.annotation.XmlElement;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import java.util.UUID; import java.util.UUID;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
public interface ResultFieldsMappingConfiguration { public interface ResultFieldsMappingConfiguration {
String getResponsePath(); String getResponsePath();

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeSourceType; import eu.eudat.commons.enums.ReferenceTypeSourceType;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType; import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.config.entities; package eu.eudat.service.externalfetcher.config.entities;
public interface StaticOption { public interface StaticOption {
String getCode(); String getCode();

View File

@ -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 org.w3c.dom.Element;
import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;

View File

@ -1,9 +1,8 @@
package eu.eudat.service.remotefetcher.criteria; package eu.eudat.service.externalfetcher.criteria;
import eu.eudat.model.Reference; import eu.eudat.model.Reference;
import java.util.List; import java.util.List;
import java.util.Map;
public class ExternalReferenceCriteria { public class ExternalReferenceCriteria {
private String like; private String like;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.models; package eu.eudat.service.externalfetcher.models;
public class ExternalAutocompleteFieldResult { public class ExternalAutocompleteFieldResult {
private String id; private String id;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.remotefetcher.models; package eu.eudat.service.externalfetcher.models;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -18,9 +18,9 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem; import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
import eu.eudat.model.persist.DescriptionProfilingRequest; import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest; import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider; import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider;
import eu.eudat.service.remotefetcher.config.entities.*; import eu.eudat.service.externalfetcher.config.entities.*;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;

View File

@ -7,13 +7,14 @@ import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.util.UUID; import java.util.UUID;
public interface PrefillingSourceService { 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; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
} }

View File

@ -4,6 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.IsActive; 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.convention.ConventionService;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.errorcode.ErrorThesaurusProperties;
@ -11,6 +14,9 @@ import eu.eudat.model.PrefillingSource;
import eu.eudat.model.builder.PrefillingSourceBuilder; import eu.eudat.model.builder.PrefillingSourceBuilder;
import eu.eudat.model.deleter.PrefillingSourceDeleter; import eu.eudat.model.deleter.PrefillingSourceDeleter;
import eu.eudat.model.persist.PrefillingSourcePersist; 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.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory; 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.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
@ -30,6 +38,7 @@ import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; 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)); logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.EditPrefillingSource); this.authorizationService.authorizeForce(Permission.EditPrefillingSource);
@ -84,7 +93,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
} }
data.setLabel(model.getLabel()); data.setLabel(model.getLabel());
data.setDefinition(model.getDefinition()); data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition())));
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
if (isUpdate) this.entityManager.merge(data); 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); 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 { public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting : {}", id); logger.debug("deleting : {}", id);

View File

@ -1,6 +1,6 @@
package eu.eudat.service.reference; 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 gr.cite.tools.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -22,10 +22,10 @@ import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
import eu.eudat.model.persist.referencedefinition.FieldPersist; import eu.eudat.model.persist.referencedefinition.FieldPersist;
import eu.eudat.query.ReferenceQuery; import eu.eudat.query.ReferenceQuery;
import eu.eudat.query.lookup.ReferenceSearchLookup; import eu.eudat.query.lookup.ReferenceSearchLookup;
import eu.eudat.service.remotefetcher.RemoteFetcherService; import eu.eudat.service.externalfetcher.ExternalFetcherService;
import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration; import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.remotefetcher.models.ExternalDataResult; import eu.eudat.service.externalfetcher.models.ExternalDataResult;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
@ -66,7 +66,7 @@ public class ReferenceServiceImpl implements ReferenceService {
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
public final RemoteFetcherService remoteFetcherService; public final ExternalFetcherService externalFetcherService;
public ReferenceServiceImpl( public ReferenceServiceImpl(
EntityManager entityManager, EntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
@ -75,7 +75,7 @@ public class ReferenceServiceImpl implements ReferenceService {
ConventionService conventionService, ConventionService conventionService,
MessageSource messageSource, MessageSource messageSource,
QueryFactory queryFactory, QueryFactory queryFactory,
XmlHandlingService xmlHandlingService, RemoteFetcherService remoteFetcherService) { XmlHandlingService xmlHandlingService, ExternalFetcherService externalFetcherService) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -84,7 +84,7 @@ public class ReferenceServiceImpl implements ReferenceService {
this.messageSource = messageSource; this.messageSource = messageSource;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.remoteFetcherService = remoteFetcherService; this.externalFetcherService = externalFetcherService;
} }
@Override @Override
@ -246,7 +246,7 @@ public class ReferenceServiceImpl implements ReferenceService {
ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition()); ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition());
if (referenceTypeDefinition == null || this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) return new ExternalDataResult(); 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<String, String> result: results.getResults()) { for (Map<String, String> result: results.getResults()) {
result.put("referenceType", referenceType.getName()); result.put("referenceType", referenceType.getName());
} }

View File

@ -14,6 +14,7 @@ import eu.eudat.model.ReferenceType;
import eu.eudat.model.builder.ReferenceTypeBuilder; import eu.eudat.model.builder.ReferenceTypeBuilder;
import eu.eudat.model.deleter.ReferenceTypeDeleter; import eu.eudat.model.deleter.ReferenceTypeDeleter;
import eu.eudat.model.persist.ReferenceTypePersist; import eu.eudat.model.persist.ReferenceTypePersist;
import eu.eudat.model.persist.externalfetcher.*;
import eu.eudat.model.persist.referencetypedefinition.*; import eu.eudat.model.persist.referencetypedefinition.*;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
@ -115,7 +116,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
} }
if (!this.conventionService.isListNullOrEmpty(persist.getSources())){ if (!this.conventionService.isListNullOrEmpty(persist.getSources())){
data.setSources(new ArrayList<>()); data.setSources(new ArrayList<>());
for (ReferenceTypeSourceBaseConfigurationPersist sourceBaseConfigPersist: persist.getSources()) { for (ExternalFetcherBaseSourceConfigurationPersist sourceBaseConfigPersist: persist.getSources()) {
data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist)); data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist));
} }
} }
@ -135,7 +136,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
return data; return data;
} }
private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ReferenceTypeSourceBaseConfigurationPersist persist){ private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ExternalFetcherBaseSourceConfigurationPersist persist){
if (persist == null) return new ExternalFetcherApiSourceConfigurationEntity(); if (persist == null) return new ExternalFetcherApiSourceConfigurationEntity();
ExternalFetcherBaseSourceConfigurationEntity data; ExternalFetcherBaseSourceConfigurationEntity data;
@ -143,22 +144,22 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
if (ReferenceTypeSourceType.API.equals(persist.getType())) { if (ReferenceTypeSourceType.API.equals(persist.getType())) {
ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity(); ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity();
apiEntity.setUrl(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getUrl()); apiEntity.setUrl(((ExternalFetcherApiSourceConfigurationPersist) persist).getUrl());
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults() != null ) { if (((ExternalFetcherApiSourceConfigurationPersist) persist).getResults() != null ) {
apiEntity.setResults(this.buildResultsConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults())); apiEntity.setResults(this.buildResultsConfigEntity(((ExternalFetcherApiSourceConfigurationPersist) persist).getResults()));
} }
apiEntity.setPaginationPath(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getPaginationPath()); apiEntity.setPaginationPath(((ExternalFetcherApiSourceConfigurationPersist) persist).getPaginationPath());
apiEntity.setContentType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getContentType()); apiEntity.setContentType(((ExternalFetcherApiSourceConfigurationPersist) persist).getContentType());
apiEntity.setFirstPage(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFirstPage()); apiEntity.setFirstPage(((ExternalFetcherApiSourceConfigurationPersist) persist).getFirstPage());
apiEntity.setHttpMethod(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getHttpMethod()); apiEntity.setHttpMethod(((ExternalFetcherApiSourceConfigurationPersist) persist).getHttpMethod());
apiEntity.setRequestBody(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getRequestBody()); apiEntity.setRequestBody(((ExternalFetcherApiSourceConfigurationPersist) persist).getRequestBody());
apiEntity.setFilterType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFilterType()); apiEntity.setFilterType(((ExternalFetcherApiSourceConfigurationPersist) persist).getFilterType());
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth() != null) { if (((ExternalFetcherApiSourceConfigurationPersist) persist).getAuth() != null) {
apiEntity.setAuth(this.buildAuthConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth())); 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<>()); apiEntity.setQueries(new ArrayList<>());
for (QueryConfigPersist queryConfigPersist: ((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries()) { for (QueryConfigPersist queryConfigPersist: ((ExternalFetcherApiSourceConfigurationPersist) persist).getQueries()) {
apiEntity.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist)); apiEntity.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
} }
} }
@ -167,9 +168,9 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
}else { }else {
ExternalFetcherStaticOptionSourceConfigurationEntity staticEntity = new ExternalFetcherStaticOptionSourceConfigurationEntity(); ExternalFetcherStaticOptionSourceConfigurationEntity staticEntity = new ExternalFetcherStaticOptionSourceConfigurationEntity();
if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions())){ if (!this.conventionService.isListNullOrEmpty(((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions())){
staticEntity.setOptions(new ArrayList<>()); staticEntity.setOptions(new ArrayList<>());
for (ReferenceTypeStaticOptionPersist optionPersist: ((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions()) { for (StaticOptionPersist optionPersist: ((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions()) {
staticEntity.getOptions().add(this.buildStaticOptionEntity(optionPersist)); staticEntity.getOptions().add(this.buildStaticOptionEntity(optionPersist));
} }
} }
@ -255,7 +256,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
return data; return data;
} }
private @NotNull StaticOptionEntity buildStaticOptionEntity(ReferenceTypeStaticOptionPersist persist){ private @NotNull StaticOptionEntity buildStaticOptionEntity(StaticOptionPersist persist){
StaticOptionEntity data = new StaticOptionEntity(); StaticOptionEntity data = new StaticOptionEntity();
if (persist == null) return data; if (persist == null) return data;

View File

@ -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<SourceBaseConfiguration> sources, ExternalReferenceCriteria externalReferenceCriteria, String key);
Integer countExternalData(List<SourceBaseConfiguration> sources, ExternalReferenceCriteria externalReferenceCriteria, String key);
}

View File

@ -5,7 +5,7 @@ import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria; import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
@Component @Component
public class ValidationManager { public class ValidationManager {

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.services; package eu.eudat.logic.services;
import eu.eudat.commons.scope.user.UserScope; 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 gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;