Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
e0deaef950
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.service.remotefetcher.config.entities.AuthenticationConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.AuthenticationConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class AuthenticationConfigurationEntity implements AuthenticationConfiguration {
|
||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.commons.types.externalfetcher;
|
|||
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.service.remotefetcher.config.entities.SourceExternalApiConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.SourceExternalApiConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.SourceStaticOptionConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.SourceStaticOptionConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.QueryCaseConfig;
|
||||
import eu.eudat.service.externalfetcher.config.entities.QueryCaseConfig;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.QueryConfig;
|
||||
import eu.eudat.service.externalfetcher.config.entities.QueryConfig;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.ResultFieldsMappingConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.ResultFieldsMappingConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class ResultFieldsMappingConfigurationEntity implements ResultFieldsMappingConfiguration {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity;
|
||||
import eu.eudat.service.remotefetcher.config.entities.ResultsConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.entities.ResultsConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.commons.types.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.StaticOption;
|
||||
import eu.eudat.service.externalfetcher.config.entities.StaticOption;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class StaticOptionEntity implements StaticOption {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package eu.eudat.commons.types.prefillingsource;
|
||||
|
||||
public class PrefillingSourceDefinitionField {
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class PrefillingSourceDefinitionFieldEntity {
|
||||
private String code;
|
||||
private String systemFieldTarget;
|
||||
private String semanticTarget;
|
||||
|
@ -11,6 +13,7 @@ public class PrefillingSourceDefinitionField {
|
|||
return code;
|
||||
}
|
||||
|
||||
@XmlElement(name = "code")
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
@ -19,6 +22,7 @@ public class PrefillingSourceDefinitionField {
|
|||
return systemFieldTarget;
|
||||
}
|
||||
|
||||
@XmlElement(name = "systemFieldTarget")
|
||||
public void setSystemFieldTarget(String systemFieldTarget) {
|
||||
this.systemFieldTarget = systemFieldTarget;
|
||||
}
|
||||
|
@ -27,6 +31,7 @@ public class PrefillingSourceDefinitionField {
|
|||
return semanticTarget;
|
||||
}
|
||||
|
||||
@XmlElement(name = "semanticTarget")
|
||||
public void setSemanticTarget(String semanticTarget) {
|
||||
this.semanticTarget = semanticTarget;
|
||||
}
|
||||
|
@ -35,6 +40,7 @@ public class PrefillingSourceDefinitionField {
|
|||
return trimRegex;
|
||||
}
|
||||
|
||||
@XmlElement(name = "trimRegex")
|
||||
public void setTrimRegex(String trimRegex) {
|
||||
this.trimRegex = trimRegex;
|
||||
}
|
||||
|
@ -43,6 +49,7 @@ public class PrefillingSourceDefinitionField {
|
|||
return fixedValue;
|
||||
}
|
||||
|
||||
@XmlElement(name = "fixedValue")
|
||||
public void setFixedValue(String fixedValue) {
|
||||
this.fixedValue = fixedValue;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import eu.eudat.model.prefillingsourcedefinition.PrefillingSourceDefinition;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
@ -14,7 +14,7 @@ public class PrefillingSource {
|
|||
private String label;
|
||||
public static final String _label = "label";
|
||||
|
||||
private String definition;
|
||||
private PrefillingSourceDefinition definition;
|
||||
public static final String _definition = "definition";
|
||||
|
||||
private IsActive isActive;
|
||||
|
@ -45,11 +45,11 @@ public class PrefillingSource {
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
public PrefillingSourceDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
public void setDefinition(PrefillingSourceDefinition definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
package eu.eudat.model.builder;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.JsonHandlingService;
|
||||
import eu.eudat.commons.enums.ContactInfoType;
|
||||
import eu.eudat.commons.types.user.AdditionalInfoEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.UserEntity;
|
||||
import eu.eudat.model.*;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||
import eu.eudat.query.TenantUserQuery;
|
||||
import eu.eudat.query.UserContactInfoQuery;
|
||||
import eu.eudat.query.UserCredentialQuery;
|
||||
import eu.eudat.query.UserRoleQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
|
|
|
@ -2,9 +2,11 @@ package eu.eudat.model.builder;
|
|||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.PrefillingSourceEntity;
|
||||
import eu.eudat.model.PrefillingSource;
|
||||
import eu.eudat.model.builder.prefillingsourcedefinition.PrefillingSourceDefinitionBuilder;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
|
@ -57,8 +59,10 @@ public class PrefillingSourceBuilder extends BaseBuilder<PrefillingSource, Prefi
|
|||
PrefillingSource m = new PrefillingSource();
|
||||
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._definition))) m.setDefinition(d.getDefinition());
|
||||
if (fields.hasField(this.asIndexer(PrefillingSource._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
||||
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._isActive))) m.setIsActive(d.getIsActive());
|
||||
if (fields.hasField(this.asIndexer(PrefillingSource._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.AuthenticationConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
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.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurationEntity;
|
||||
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.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -20,44 +20,44 @@ import java.util.*;
|
|||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeSourceExternalApiConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceExternalApiConfiguration, ExternalFetcherApiSourceConfigurationEntity> {
|
||||
public class ExternalFetcherApiSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherApiSourceConfiguration, ExternalFetcherApiSourceConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
private final AuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceExternalApiConfigurationBuilder(
|
||||
public ExternalFetcherApiSourceConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)), builderFactory, queryFactory);
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ExternalFetcherApiSourceConfigurationBuilder.class)), builderFactory, queryFactory);
|
||||
this.builderFactory = builderFactory;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceExternalApiConfiguration getInstance() {
|
||||
return new ReferenceTypeSourceExternalApiConfiguration();
|
||||
protected ExternalFetcherApiSourceConfiguration getInstance() {
|
||||
return new ExternalFetcherApiSourceConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceExternalApiConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ReferenceTypeSourceExternalApiConfiguration m) {
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._results));
|
||||
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._auth));
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._queries));
|
||||
protected ExternalFetcherApiSourceConfiguration buildChild(FieldSet fields, ExternalFetcherApiSourceConfigurationEntity d, ExternalFetcherApiSourceConfiguration m) {
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._results));
|
||||
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._auth));
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherApiSourceConfiguration._queries));
|
||||
if(!authorizationService.authorize(Permission.EditReferenceType)) return m;
|
||||
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._url))) m.setUrl(d.getUrl());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._url))) m.setUrl(d.getUrl());
|
||||
if (!resultsFields.isEmpty() && d.getResults() != null) {
|
||||
m.setResults(this.builderFactory.builder(ResultsConfigurationBuilder.class).authorize(this.authorize).build(resultsFields, d.getResults()));
|
||||
}
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._type))) m.setType(d.getType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._contentType))) m.setContentType(d.getContentType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._firstPage))) m.setFirstPage(d.getFirstPage());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._filterType))) m.setFilterType(d.getFilterType());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._type))) m.setType(d.getType());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._contentType))) m.setContentType(d.getContentType());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._firstPage))) m.setFirstPage(d.getFirstPage());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
|
||||
if (fields.hasField(this.asIndexer(ExternalFetcherApiSourceConfiguration._filterType))) m.setFilterType(d.getFilterType());
|
||||
if (!authFields.isEmpty() && d.getAuth() != null) {
|
||||
m.setAuth(this.builderFactory.builder(AuthenticationConfigurationBuilder.class).authorize(this.authorize).build(authFields, d.getAuth()));
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.ExternalFetcherBaseSourceConfigurationEntity;
|
||||
|
@ -6,7 +6,7 @@ import eu.eudat.convention.ConventionService;
|
|||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -25,14 +25,14 @@ import java.util.stream.Collectors;
|
|||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public abstract class ReferenceTypeSourceBaseConfigurationBuilder<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 final BuilderFactory builderFactory;
|
||||
protected final QueryFactory queryFactory;
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceBaseConfigurationBuilder(
|
||||
public ExternalFetcherBaseSourceConfigurationBuilder(
|
||||
ConventionService conventionService,
|
||||
LoggerService logger, BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||
super(conventionService, logger);
|
||||
|
@ -40,7 +40,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends
|
|||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
||||
public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
public ExternalFetcherBaseSourceConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceStaticOptionConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
@ -20,34 +20,34 @@ import java.util.EnumSet;
|
|||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeSourceStaticOptionConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceStaticOptionConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> {
|
||||
public class ExternalFetcherStaticOptionSourceConfigurationBuilder extends ExternalFetcherBaseSourceConfigurationBuilder<ExternalFetcherStaticOptionSourceConfiguration, ExternalFetcherStaticOptionSourceConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
private final AuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceStaticOptionConfigurationBuilder(
|
||||
public ExternalFetcherStaticOptionSourceConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory, AuthorizationService authorizationService, QueryFactory queryFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceStaticOptionConfigurationBuilder.class)), builderFactory, queryFactory);
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ExternalFetcherStaticOptionSourceConfigurationBuilder.class)), builderFactory, queryFactory);
|
||||
this.builderFactory = builderFactory;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceStaticOptionConfiguration getInstance() {
|
||||
return new ReferenceTypeSourceStaticOptionConfiguration();
|
||||
protected ExternalFetcherStaticOptionSourceConfiguration getInstance() {
|
||||
return new ExternalFetcherStaticOptionSourceConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceStaticOptionConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ReferenceTypeSourceStaticOptionConfiguration m) {
|
||||
FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceStaticOptionConfiguration._options));
|
||||
protected ExternalFetcherStaticOptionSourceConfiguration buildChild(FieldSet fields, ExternalFetcherStaticOptionSourceConfigurationEntity d, ExternalFetcherStaticOptionSourceConfiguration m) {
|
||||
FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ExternalFetcherStaticOptionSourceConfiguration._options));
|
||||
|
||||
if(!authorizationService.authorize(Permission.EditReferenceType)) return m;
|
||||
|
||||
if (!optionsFields.isEmpty() && d.getOptions() != null) {
|
||||
m.setOptions(this.builderFactory.builder(ReferenceTypeStaticOptionBuilder.class).authorize(this.authorize).build(optionsFields, d.getOptions()));
|
||||
m.setOptions(this.builderFactory.builder(StaticOptionBuilder.class).authorize(this.authorize).build(optionsFields, d.getOptions()));
|
||||
}
|
||||
|
||||
return m;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.QueryCaseConfigEntity;
|
||||
|
@ -6,7 +6,7 @@ import eu.eudat.convention.ConventionService;
|
|||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.QueryCaseConfig;
|
||||
import eu.eudat.model.externalfetcher.QueryCaseConfig;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.QueryConfigEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.QueryConfig;
|
||||
import eu.eudat.model.externalfetcher.QueryConfig;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.ResultFieldsMappingConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ResultFieldsMappingConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ResultFieldsMappingConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.ResultsConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ResultsConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ResultsConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
package eu.eudat.model.builder.externalfetcher;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.externalfetcher.StaticOptionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeStaticOption;
|
||||
import eu.eudat.model.externalfetcher.StaticOption;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
|
@ -19,32 +19,32 @@ import java.util.*;
|
|||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeStaticOptionBuilder extends BaseBuilder<ReferenceTypeStaticOption, StaticOptionEntity> {
|
||||
public class StaticOptionBuilder extends BaseBuilder<StaticOption, StaticOptionEntity> {
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeStaticOptionBuilder(ConventionService conventionService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeStaticOptionBuilder.class)));
|
||||
public StaticOptionBuilder(ConventionService conventionService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(StaticOptionBuilder.class)));
|
||||
}
|
||||
|
||||
public ReferenceTypeStaticOptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
public StaticOptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@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.trace(new DataLogEntry("requested fields", fields));
|
||||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
List<ReferenceTypeStaticOption> models = new ArrayList<>();
|
||||
List<StaticOption> models = new ArrayList<>();
|
||||
for (StaticOptionEntity d : data) {
|
||||
ReferenceTypeStaticOption m = new ReferenceTypeStaticOption();
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._value))) m.setValue(d.getValue());
|
||||
StaticOption m = new StaticOption();
|
||||
if (fields.hasField(this.asIndexer(StaticOption._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(StaticOption._value))) m.setValue(d.getValue());
|
||||
|
||||
models.add(m);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -7,8 +7,10 @@ import eu.eudat.commons.types.externalfetcher.ExternalFetcherApiSourceConfigurat
|
|||
import eu.eudat.commons.types.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.builder.externalfetcher.ExternalFetcherApiSourceConfigurationBuilder;
|
||||
import eu.eudat.model.builder.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
@ -59,9 +61,9 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
|
|||
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();
|
||||
m.setSources(new ArrayList<>());
|
||||
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceExternalApiConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities));
|
||||
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceStaticOptionConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities));
|
||||
m.getSources().sort(Comparator.comparing(ReferenceTypeSourceBaseConfiguration::getOrdinal));
|
||||
m.getSources().addAll(this.builderFactory.builder(ExternalFetcherApiSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities));
|
||||
m.getSources().addAll(this.builderFactory.builder(ExternalFetcherStaticOptionSourceConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities));
|
||||
m.getSources().sort(Comparator.comparing(ExternalFetcherBaseSourceConfiguration::getOrdinal));
|
||||
}
|
||||
models.add(m);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.authorization.Permission;
|
|||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.censorship.ReferenceTypeCensor;
|
||||
import eu.eudat.model.referencetypedefinition.QueryCaseConfig;
|
||||
import eu.eudat.model.externalfetcher.QueryCaseConfig;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.referencetypedefinition.QueryConfig;
|
||||
import eu.eudat.model.externalfetcher.QueryConfig;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
|
|
@ -4,7 +4,9 @@ import eu.eudat.authorization.Permission;
|
|||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.censorship.ReferenceTypeCensor;
|
||||
import eu.eudat.model.referencetypedefinition.*;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherApiSourceConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherStaticOptionSourceConfiguration;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
@ -39,19 +41,19 @@ public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor {
|
|||
return;
|
||||
|
||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
||||
FieldSet referenceTypeDependencyFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceBaseConfiguration._referenceTypeDependencies));
|
||||
FieldSet referenceTypeDependencyFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherBaseSourceConfiguration._referenceTypeDependencies));
|
||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(referenceTypeDependencyFields, userId);
|
||||
|
||||
FieldSet optionsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceStaticOptionConfiguration._options));
|
||||
FieldSet optionsFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherStaticOptionSourceConfiguration._options));
|
||||
this.censorFactory.censor(ReferenceTypeStaticOptionCensor.class).censor(optionsFields, userId);
|
||||
|
||||
FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._auth));
|
||||
FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._auth));
|
||||
this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId);
|
||||
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._results));
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._results));
|
||||
this.censorFactory.censor(ResultsConfigurationCensor.class).censor(resultsFields, userId);
|
||||
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeSourceExternalApiConfiguration._queries));
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ExternalFetcherApiSourceConfiguration._queries));
|
||||
this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetypedefinition;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.referencetypedefinition.ResultsConfiguration;
|
||||
import eu.eudat.model.externalfetcher.ResultsConfiguration;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceExternalApiConfiguration extends ReferenceTypeSourceBaseConfiguration {
|
||||
public class ExternalFetcherApiSourceConfiguration extends ExternalFetcherBaseSourceConfiguration {
|
||||
|
||||
public final static String _url = "url";
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
|
@ -6,7 +6,7 @@ import eu.eudat.model.ReferenceType;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class ReferenceTypeSourceBaseConfiguration {
|
||||
public abstract class ExternalFetcherBaseSourceConfiguration {
|
||||
|
||||
public final static String _key = "key";
|
||||
private String key;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
|
||||
import eu.eudat.model.ReferenceType;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
|
||||
public class ResultFieldsMappingConfiguration {
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
|
||||
import java.util.List;
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
package eu.eudat.model.externalfetcher;
|
||||
|
||||
public class ReferenceTypeStaticOption {
|
||||
public class StaticOption {
|
||||
|
||||
public final static String _code = "code";
|
||||
private String code;
|
|
@ -3,6 +3,7 @@ package eu.eudat.model.persist;
|
|||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionPersist;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -23,7 +24,7 @@ public class PrefillingSourcePersist {
|
|||
|
||||
public static final String _label = "label";
|
||||
|
||||
private String definition;
|
||||
private PrefillingSourceDefinitionPersist definition;
|
||||
|
||||
public static final String _definition = "definition";
|
||||
|
||||
|
@ -47,11 +48,11 @@ public class PrefillingSourcePersist {
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
public PrefillingSourceDefinitionPersist getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
public void setDefinition(PrefillingSourceDefinitionPersist definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,15 @@ public class PrefillingSourcePersist {
|
|||
.failOn(PrefillingSourcePersist._hash).failWith(messageSource.getMessage("Validation_OverPosting", new Object[]{}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getLabel()))
|
||||
.failOn(PrefillingSourcePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._label}, LocaleContextHolder.getLocale()))
|
||||
.failOn(PrefillingSourcePersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._label}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getDefinition()))
|
||||
.failOn(PrefillingSourcePersist._definition).failWith(messageSource.getMessage("Validation_Required", new Object[]{PrefillingSourcePersist._definition}, LocaleContextHolder.getLocale())),
|
||||
this.refSpec()
|
||||
.iff(() -> !this.isNull(item.getDefinition()))
|
||||
.on(PrefillingSourcePersist._definition)
|
||||
.over(item.getDefinition())
|
||||
.using(() -> this.validatorFactory.validator(PrefillingSourceDefinitionPersist.PrefillingSourceDefinitionPersistValidator.class))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist {
|
||||
public class ExternalFetcherApiSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist {
|
||||
|
||||
private String url;
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
|
|||
|
||||
@Component(ReferenceTypeSourceExternalApiConfigurationPersistValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceExternalApiConfigurationPersist> {
|
||||
public static class ReferenceTypeSourceExternalApiConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherApiSourceConfigurationPersist> {
|
||||
|
||||
public static final String ValidatorName = "ReferenceTypeSourceExternalApiConfigurationPersistValidator";
|
||||
|
||||
|
@ -143,49 +143,49 @@ public class ReferenceTypeSourceExternalApiConfigurationPersist extends Referenc
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Class<ReferenceTypeSourceExternalApiConfigurationPersist> modelClass() {
|
||||
return ReferenceTypeSourceExternalApiConfigurationPersist.class;
|
||||
protected Class<ExternalFetcherApiSourceConfigurationPersist> modelClass() {
|
||||
return ExternalFetcherApiSourceConfigurationPersist.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Specification> specifications(ReferenceTypeSourceExternalApiConfigurationPersist item) {
|
||||
protected List<Specification> specifications(ExternalFetcherApiSourceConfigurationPersist item) {
|
||||
List<Specification> specifications = getBaseSpecifications(item);
|
||||
specifications.addAll(Arrays.asList(
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getUrl()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._url}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._url).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._url}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getPaginationPath()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._paginationPath}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._paginationPath).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._paginationPath}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getContentType()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._contentType}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._contentType).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._contentType}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getFirstPage()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._firstPage).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._firstPage}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getHttpMethod()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._httpMethod).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._httpMethod}, LocaleContextHolder.getLocale())),
|
||||
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getResults()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._results).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._results}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._results).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._results}, LocaleContextHolder.getLocale())),
|
||||
this.refSpec()
|
||||
.iff(() -> !this.isNull(item.getResults()))
|
||||
.on(ReferenceTypeSourceExternalApiConfigurationPersist._results)
|
||||
.on(ExternalFetcherApiSourceConfigurationPersist._results)
|
||||
.over(item.getResults())
|
||||
.using(() -> this.validatorFactory.validator(ResultsConfigurationPersist.ResultsConfigurationPersistValidator.class)),
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getAuth()))
|
||||
.failOn(ReferenceTypeSourceExternalApiConfigurationPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceExternalApiConfigurationPersist._auth}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherApiSourceConfigurationPersist._auth).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherApiSourceConfigurationPersist._auth}, LocaleContextHolder.getLocale())),
|
||||
this.refSpec()
|
||||
.iff(() -> !this.isNull(item.getAuth()))
|
||||
.on(ReferenceTypeSourceExternalApiConfigurationPersist._auth)
|
||||
.on(ExternalFetcherApiSourceConfigurationPersist._auth)
|
||||
.over(item.getAuth())
|
||||
.using(() -> this.validatorFactory.validator(AuthenticationConfigurationPersist.AuthenticationConfigurationPersistValidator.class)),
|
||||
this.navSpec()
|
||||
.iff(() -> !this.isListNullOrEmpty(item.getQueries()))
|
||||
.on(ReferenceTypeSourceExternalApiConfigurationPersist._queries)
|
||||
.on(ExternalFetcherApiSourceConfigurationPersist._queries)
|
||||
.over(item.getQueries())
|
||||
.using((itm) -> this.validatorFactory.validator(QueryConfigPersist.QueryConfigPersistValidator.class))
|
||||
));
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
@ -22,10 +22,10 @@ import java.util.UUID;
|
|||
property = "type",
|
||||
visible = true)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = ReferenceTypeSourceExternalApiConfigurationPersist.class, name = "0"),
|
||||
@JsonSubTypes.Type(value = ReferenceTypeSourceStaticOptionConfigurationPersist.class, name = "1")
|
||||
@JsonSubTypes.Type(value = ExternalFetcherApiSourceConfigurationPersist.class, name = "0"),
|
||||
@JsonSubTypes.Type(value = ExternalFetcherStaticOptionSourceConfigurationPersist.class, name = "1")
|
||||
})
|
||||
public abstract class ReferenceTypeSourceBaseConfigurationPersist {
|
||||
public abstract class ExternalFetcherBaseSourceConfigurationPersist {
|
||||
|
||||
private String key = null;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
|
|||
this.referenceTypeDependencyIds = referenceTypeDependencyIds;
|
||||
}
|
||||
|
||||
public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator<T extends ReferenceTypeSourceBaseConfigurationPersist> extends BaseValidator<T> {
|
||||
public static abstract class ReferenceTypeSourceBaseConfigurationPersistValidator<T extends ExternalFetcherBaseSourceConfigurationPersist> extends BaseValidator<T> {
|
||||
|
||||
protected final MessageSource messageSource;
|
||||
|
||||
|
@ -104,16 +104,16 @@ public abstract class ReferenceTypeSourceBaseConfigurationPersist {
|
|||
specifications.addAll(Arrays.asList(
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getKey()))
|
||||
.failOn(ReferenceTypeSourceBaseConfigurationPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._key}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherBaseSourceConfigurationPersist._key).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._key}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getLabel()))
|
||||
.failOn(ReferenceTypeSourceBaseConfigurationPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._label}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherBaseSourceConfigurationPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._label}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getOrdinal()))
|
||||
.failOn(ReferenceTypeSourceBaseConfigurationPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._ordinal}, LocaleContextHolder.getLocale())),
|
||||
.failOn(ExternalFetcherBaseSourceConfigurationPersist._ordinal).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._ordinal}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isNull(item.getType()))
|
||||
.failOn(ReferenceTypeSourceBaseConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeSourceBaseConfigurationPersist._type}, LocaleContextHolder.getLocale()))
|
||||
.failOn(ExternalFetcherBaseSourceConfigurationPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalFetcherBaseSourceConfigurationPersist._type}, LocaleContextHolder.getLocale()))
|
||||
));
|
||||
return specifications;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
|
@ -7,28 +7,27 @@ import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist {
|
||||
public class ExternalFetcherStaticOptionSourceConfigurationPersist extends ExternalFetcherBaseSourceConfigurationPersist {
|
||||
|
||||
List<ReferenceTypeStaticOptionPersist> options;
|
||||
List<StaticOptionPersist> options;
|
||||
|
||||
public static final String _options = "options";
|
||||
|
||||
public List<ReferenceTypeStaticOptionPersist> getOptions() {
|
||||
public List<StaticOptionPersist> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(List<ReferenceTypeStaticOptionPersist> options) {
|
||||
public void setOptions(List<StaticOptionPersist> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@Component(ReferenceTypeSourceStaticOptionConfigurationPersistValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ReferenceTypeSourceStaticOptionConfigurationPersist> {
|
||||
public static class ReferenceTypeSourceStaticOptionConfigurationPersistValidator extends ReferenceTypeSourceBaseConfigurationPersistValidator<ExternalFetcherStaticOptionSourceConfigurationPersist> {
|
||||
|
||||
public static final String ValidatorName = "ReferenceTypeSourceStaticOptionConfigurationPersistValidator";
|
||||
|
||||
|
@ -37,19 +36,19 @@ public class ReferenceTypeSourceStaticOptionConfigurationPersist extends Referen
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Class<ReferenceTypeSourceStaticOptionConfigurationPersist> modelClass() {
|
||||
return ReferenceTypeSourceStaticOptionConfigurationPersist.class;
|
||||
protected Class<ExternalFetcherStaticOptionSourceConfigurationPersist> modelClass() {
|
||||
return ExternalFetcherStaticOptionSourceConfigurationPersist.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Specification> specifications(ReferenceTypeSourceStaticOptionConfigurationPersist item) {
|
||||
protected List<Specification> specifications(ExternalFetcherStaticOptionSourceConfigurationPersist item) {
|
||||
List<Specification> specifications = getBaseSpecifications(item);
|
||||
specifications.add(
|
||||
this.navSpec()
|
||||
.iff(() -> !this.isListNullOrEmpty(item.getOptions()))
|
||||
.on(ReferenceTypeSourceStaticOptionConfigurationPersist._options)
|
||||
.on(ExternalFetcherStaticOptionSourceConfigurationPersist._options)
|
||||
.over(item.getOptions())
|
||||
.using((itm) -> this.validatorFactory.validator(ReferenceTypeStaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class))
|
||||
.using((itm) -> this.validatorFactory.validator(StaticOptionPersist.ReferenceTypeStaticOptionPersistValidator.class))
|
||||
);
|
||||
return specifications;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import eu.eudat.convention.ConventionService;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
package eu.eudat.model.persist.externalfetcher;
|
||||
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
|
@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeStaticOptionPersist {
|
||||
public class StaticOptionPersist {
|
||||
|
||||
private String code;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ReferenceTypeStaticOptionPersist {
|
|||
|
||||
@Component(ReferenceTypeStaticOptionPersistValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator<ReferenceTypeStaticOptionPersist> {
|
||||
public static class ReferenceTypeStaticOptionPersistValidator extends BaseValidator<StaticOptionPersist> {
|
||||
|
||||
public static final String ValidatorName = "ReferenceTypeStaticOptionPersistValidator";
|
||||
|
||||
|
@ -53,19 +53,19 @@ public class ReferenceTypeStaticOptionPersist {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Class<ReferenceTypeStaticOptionPersist> modelClass() {
|
||||
return ReferenceTypeStaticOptionPersist.class;
|
||||
protected Class<StaticOptionPersist> modelClass() {
|
||||
return StaticOptionPersist.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Specification> specifications(ReferenceTypeStaticOptionPersist item) {
|
||||
protected List<Specification> specifications(StaticOptionPersist item) {
|
||||
return Arrays.asList(
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getCode()))
|
||||
.failOn(ReferenceTypeStaticOptionPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._code}, LocaleContextHolder.getLocale())),
|
||||
.failOn(StaticOptionPersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{StaticOptionPersist._code}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.must(() -> !this.isEmpty(item.getValue()))
|
||||
.failOn(ReferenceTypeStaticOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{ReferenceTypeStaticOptionPersist._value}, LocaleContextHolder.getLocale()))
|
||||
.failOn(StaticOptionPersist._value).failWith(messageSource.getMessage("Validation_Required", new Object[]{StaticOptionPersist._value}, LocaleContextHolder.getLocale()))
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@ package eu.eudat.model.persist.referencetypedefinition;
|
|||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.validation.BaseValidator;
|
||||
import eu.eudat.model.persist.externalfetcher.ExternalFetcherBaseSourceConfigurationPersist;
|
||||
import eu.eudat.model.persist.externalfetcher.ExternalFetcherApiSourceConfigurationPersist;
|
||||
import eu.eudat.model.persist.externalfetcher.ExternalFetcherStaticOptionSourceConfigurationPersist;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
|
@ -21,7 +24,7 @@ public class ReferenceTypeDefinitionPersist {
|
|||
|
||||
public static final String _fields = "fields";
|
||||
|
||||
private List<ReferenceTypeSourceBaseConfigurationPersist> sources = null;
|
||||
private List<ExternalFetcherBaseSourceConfigurationPersist> sources = null;
|
||||
|
||||
public static final String _sources = "sources";
|
||||
|
||||
|
@ -33,11 +36,11 @@ public class ReferenceTypeDefinitionPersist {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeSourceBaseConfigurationPersist> getSources() {
|
||||
public List<ExternalFetcherBaseSourceConfigurationPersist> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setSources(List<ReferenceTypeSourceBaseConfigurationPersist> sources) {
|
||||
public void setSources(List<ExternalFetcherBaseSourceConfigurationPersist> sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
|
||||
|
@ -77,7 +80,7 @@ public class ReferenceTypeDefinitionPersist {
|
|||
.iff(() -> !this.isListNullOrEmpty(item.getSources()))
|
||||
.on(ReferenceTypeDefinitionPersist._sources)
|
||||
.over(item.getSources())
|
||||
.using((itm) -> ((ReferenceTypeSourceBaseConfigurationPersist) itm).getType() == ReferenceTypeSourceType.STATIC? this.validatorFactory.validator(ReferenceTypeSourceStaticOptionConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class): this.validatorFactory.validator(ReferenceTypeSourceExternalApiConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class))
|
||||
.using((itm) -> ((ExternalFetcherBaseSourceConfigurationPersist) itm).getType() == ReferenceTypeSourceType.STATIC? this.validatorFactory.validator(ExternalFetcherStaticOptionSourceConfigurationPersist.ReferenceTypeSourceStaticOptionConfigurationPersistValidator.class): this.validatorFactory.validator(ExternalFetcherApiSourceConfigurationPersist.ReferenceTypeSourceExternalApiConfigurationPersistValidator.class))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
import eu.eudat.model.externalfetcher.ExternalFetcherBaseSourceConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeDefinition {
|
||||
|
@ -8,7 +10,7 @@ public class ReferenceTypeDefinition {
|
|||
private List<ReferenceTypeField> fields;
|
||||
|
||||
public final static String _sources = "sources";
|
||||
private List<ReferenceTypeSourceBaseConfiguration> sources;
|
||||
private List<ExternalFetcherBaseSourceConfiguration> sources;
|
||||
|
||||
public List<ReferenceTypeField> getFields() {
|
||||
return fields;
|
||||
|
@ -18,11 +20,11 @@ public class ReferenceTypeDefinition {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeSourceBaseConfiguration> getSources() {
|
||||
public List<ExternalFetcherBaseSourceConfiguration> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setSources(List<ReferenceTypeSourceBaseConfiguration> sources) {
|
||||
public void setSources(List<ExternalFetcherBaseSourceConfiguration> sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher;
|
||||
package eu.eudat.service.externalfetcher;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -11,9 +11,9 @@ import eu.eudat.convention.ConventionService;
|
|||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.referencedefinition.Field;
|
||||
import eu.eudat.service.remotefetcher.config.entities.*;
|
||||
import eu.eudat.service.remotefetcher.models.ExternalDataResult;
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.config.entities.*;
|
||||
import eu.eudat.service.externalfetcher.models.ExternalDataResult;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import net.minidev.json.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -31,14 +31,14 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class RemoteFetcherServiceImpl implements RemoteFetcherService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcherServiceImpl.class);
|
||||
public class ExternalFetcherServiceImpl implements ExternalFetcherService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExternalFetcherServiceImpl.class);
|
||||
|
||||
private WebClient webClient;
|
||||
private final ConventionService conventionService;
|
||||
private final JsonHandlingService jsonHandlingService;
|
||||
@Autowired
|
||||
public RemoteFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) {
|
||||
public ExternalFetcherServiceImpl(ConventionService conventionService, JsonHandlingService jsonHandlingService) {
|
||||
this.conventionService = conventionService;
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.service.remotefetcher;
|
||||
package eu.eudat.service.externalfetcher;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.ExternalUrls;
|
||||
import eu.eudat.service.externalfetcher.config.ExternalUrls;
|
||||
import eu.eudat.service.storage.StorageFileService;
|
||||
import jakarta.xml.bind.JAXBContext;
|
||||
import jakarta.xml.bind.Unmarshaller;
|
|
@ -1,9 +1,9 @@
|
|||
package eu.eudat.service.remotefetcher.config;
|
||||
package eu.eudat.service.externalfetcher.config;
|
||||
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.prefilling.PrefillingConfigMapAdapter;
|
||||
import eu.eudat.service.externalfetcher.config.prefilling.PrefillingConfigMapAdapter;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.*;
|
||||
import eu.eudat.service.externalfetcher.config.entities.*;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|
@ -1,11 +1,8 @@
|
|||
package eu.eudat.service.remotefetcher.config;
|
||||
package eu.eudat.service.externalfetcher.config;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
import java.util.List;
|
||||
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
|
||||
|
||||
public class UrlConfiguration implements SourceBaseConfiguration {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
public interface PrefillingMapping {
|
||||
String getTarget();
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.UrlConfiguration;
|
||||
import eu.eudat.service.externalfetcher.config.UrlConfiguration;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
public interface ResultFieldsMappingConfiguration {
|
||||
String getResponsePath();
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.config.entities;
|
||||
package eu.eudat.service.externalfetcher.config.entities;
|
||||
|
||||
public interface StaticOption {
|
||||
String getCode();
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.service.remotefetcher.config.prefilling;
|
||||
package eu.eudat.service.externalfetcher.config.prefilling;
|
||||
|
||||
import eu.eudat.service.remotefetcher.config.entities.PrefillingConfig;
|
||||
import eu.eudat.service.externalfetcher.config.entities.PrefillingConfig;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import jakarta.xml.bind.JAXBContext;
|
|
@ -1,9 +1,8 @@
|
|||
package eu.eudat.service.remotefetcher.criteria;
|
||||
package eu.eudat.service.externalfetcher.criteria;
|
||||
|
||||
import eu.eudat.model.Reference;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExternalReferenceCriteria {
|
||||
private String like;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.models;
|
||||
package eu.eudat.service.externalfetcher.models;
|
||||
|
||||
public class ExternalAutocompleteFieldResult {
|
||||
private String id;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.service.remotefetcher.models;
|
||||
package eu.eudat.service.externalfetcher.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -18,9 +18,9 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
|
|||
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
||||
import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider;
|
||||
import eu.eudat.service.remotefetcher.config.entities.*;
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider;
|
||||
import eu.eudat.service.externalfetcher.config.entities.*;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
|
|
|
@ -7,13 +7,14 @@ import gr.cite.tools.exception.MyForbiddenException;
|
|||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface PrefillingSourceService {
|
||||
|
||||
PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
||||
PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException;
|
||||
|
||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.types.externalfetcher.*;
|
||||
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionEntity;
|
||||
import eu.eudat.commons.types.prefillingsource.PrefillingSourceDefinitionFieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.PrefillingSourceEntity;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
|
@ -11,6 +14,9 @@ import eu.eudat.model.PrefillingSource;
|
|||
import eu.eudat.model.builder.PrefillingSourceBuilder;
|
||||
import eu.eudat.model.deleter.PrefillingSourceDeleter;
|
||||
import eu.eudat.model.persist.PrefillingSourcePersist;
|
||||
import eu.eudat.model.persist.externalfetcher.*;
|
||||
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionFieldPersist;
|
||||
import eu.eudat.model.persist.prefillingsourcedefinition.PrefillingSourceDefinitionPersist;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -23,6 +29,8 @@ import gr.cite.tools.fieldset.FieldSet;
|
|||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
@ -30,6 +38,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -62,7 +71,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
}
|
||||
|
||||
|
||||
public PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException{
|
||||
public PrefillingSource persist(PrefillingSourcePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException {
|
||||
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.EditPrefillingSource);
|
||||
|
@ -84,7 +93,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
}
|
||||
|
||||
data.setLabel(model.getLabel());
|
||||
data.setDefinition(model.getDefinition());
|
||||
data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition())));
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
||||
if (isUpdate) this.entityManager.merge(data);
|
||||
|
@ -95,6 +104,131 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
|||
return this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, PrefillingSource._id), data);
|
||||
}
|
||||
|
||||
private @NotNull PrefillingSourceDefinitionEntity buildDefinitionEntity(PrefillingSourceDefinitionPersist persist) {
|
||||
PrefillingSourceDefinitionEntity data = new PrefillingSourceDefinitionEntity();
|
||||
if (persist == null)
|
||||
return data;
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
|
||||
data.setFields(new ArrayList<>());
|
||||
for (PrefillingSourceDefinitionFieldPersist fieldPersist : persist.getFields()) {
|
||||
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull PrefillingSourceDefinitionFieldEntity buildFieldEntity(PrefillingSourceDefinitionFieldPersist persist) {
|
||||
PrefillingSourceDefinitionFieldEntity data = new PrefillingSourceDefinitionFieldEntity();
|
||||
if (persist == null)
|
||||
return data;
|
||||
|
||||
data.setCode(persist.getCode());
|
||||
data.setSemanticTarget(persist.getSemanticTarget());
|
||||
data.setSystemFieldTarget(persist.getSystemFieldTarget());
|
||||
data.setFixedValue(persist.getFixedValue());
|
||||
data.setTrimRegex(persist.getTrimRegex());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ExternalFetcherApiSourceConfigurationEntity buildExternalFetcherApiConfigEntity(ExternalFetcherApiSourceConfigurationPersist persist) {
|
||||
ExternalFetcherApiSourceConfigurationEntity data = new ExternalFetcherApiSourceConfigurationEntity();
|
||||
if (persist == null)
|
||||
return data;
|
||||
|
||||
data.setUrl(persist.getUrl());
|
||||
if (persist.getResults() != null ) {
|
||||
data.setResults(this.buildResultsConfigEntity(persist.getResults()));
|
||||
}
|
||||
data.setPaginationPath(persist.getPaginationPath());
|
||||
data.setContentType(persist.getContentType());
|
||||
data.setFirstPage(persist.getFirstPage());
|
||||
data.setHttpMethod(persist.getHttpMethod());
|
||||
data.setRequestBody(persist.getRequestBody());
|
||||
data.setFilterType(persist.getFilterType());
|
||||
if (persist.getAuth() != null) {
|
||||
data.setAuth(this.buildAuthConfigEntity(persist.getAuth()));
|
||||
}
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getQueries())){
|
||||
data.setQueries(new ArrayList<>());
|
||||
for (QueryConfigPersist queryConfigPersist: (persist.getQueries())){
|
||||
data.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ResultsConfigurationEntity buildResultsConfigEntity(ResultsConfigurationPersist persist){
|
||||
ResultsConfigurationEntity data = new ResultsConfigurationEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setResultsArrayPath(persist.getResultsArrayPath());
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getFieldsMapping())){
|
||||
data.setFieldsMapping(new ArrayList<>());
|
||||
for (ResultFieldsMappingConfigurationPersist fieldsMappingPersist: persist.getFieldsMapping()) {
|
||||
data.getFieldsMapping().add(this.buildResultFieldsMappingConfigEntity(fieldsMappingPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ResultFieldsMappingConfigurationEntity buildResultFieldsMappingConfigEntity(ResultFieldsMappingConfigurationPersist persist){
|
||||
ResultFieldsMappingConfigurationEntity data = new ResultFieldsMappingConfigurationEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setCode(persist.getCode());
|
||||
data.setResponsePath(persist.getResponsePath());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull AuthenticationConfigurationEntity buildAuthConfigEntity(AuthenticationConfigurationPersist persist){
|
||||
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setEnabled(persist.getEnabled());
|
||||
data.setAuthUrl(persist.getAuthUrl());
|
||||
data.setAuthMethod(persist.getAuthMethod());
|
||||
data.setAuthRequestBody(persist.getAuthRequestBody());
|
||||
data.setType(persist.getType());
|
||||
data.setAuthTokenPath(persist.getAuthTokenPath());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull QueryConfigEntity buildQueryConfigEntity(QueryConfigPersist persist){
|
||||
QueryConfigEntity data = new QueryConfigEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setName(persist.getName());
|
||||
data.setDefaultValue(persist.getDefaultValue());
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getCases())){
|
||||
data.setCases(new ArrayList<>());
|
||||
for (QueryCaseConfigPersist queryCaseConfigPersist: persist.getCases()) {
|
||||
data.getCases().add(this.buildQueryCaseConfigEntity(queryCaseConfigPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull QueryCaseConfigEntity buildQueryCaseConfigEntity(QueryCaseConfigPersist persist){
|
||||
QueryCaseConfigEntity data = new QueryCaseConfigEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setReferenceTypeId(persist.getReferenceTypeId());
|
||||
data.setReferenceTypeSourceKey(persist.getReferenceTypeSourceKey());
|
||||
data.setSeparator(persist.getSeparator());
|
||||
data.setValue(persist.getValue());
|
||||
data.setLikePattern(persist.getLikePattern());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
logger.debug("deleting : {}", id);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.service.reference;
|
||||
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import gr.cite.tools.cache.CacheService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
@ -22,10 +22,10 @@ import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
|||
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||
import eu.eudat.service.remotefetcher.RemoteFetcherService;
|
||||
import eu.eudat.service.remotefetcher.config.entities.SourceBaseConfiguration;
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.remotefetcher.models.ExternalDataResult;
|
||||
import eu.eudat.service.externalfetcher.ExternalFetcherService;
|
||||
import eu.eudat.service.externalfetcher.config.entities.SourceBaseConfiguration;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.models.ExternalDataResult;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
|
@ -66,7 +66,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
|||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
|
||||
public final RemoteFetcherService remoteFetcherService;
|
||||
public final ExternalFetcherService externalFetcherService;
|
||||
public ReferenceServiceImpl(
|
||||
EntityManager entityManager,
|
||||
AuthorizationService authorizationService,
|
||||
|
@ -75,7 +75,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
|||
ConventionService conventionService,
|
||||
MessageSource messageSource,
|
||||
QueryFactory queryFactory,
|
||||
XmlHandlingService xmlHandlingService, RemoteFetcherService remoteFetcherService) {
|
||||
XmlHandlingService xmlHandlingService, ExternalFetcherService externalFetcherService) {
|
||||
this.entityManager = entityManager;
|
||||
this.authorizationService = authorizationService;
|
||||
this.deleterFactory = deleterFactory;
|
||||
|
@ -84,7 +84,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
|||
this.messageSource = messageSource;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
this.remoteFetcherService = remoteFetcherService;
|
||||
this.externalFetcherService = externalFetcherService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -246,7 +246,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
|||
ReferenceTypeDefinitionEntity referenceTypeDefinition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, referenceType.getDefinition());
|
||||
if (referenceTypeDefinition == null || this.conventionService.isListNullOrEmpty(referenceTypeDefinition.getSources())) return new ExternalDataResult();
|
||||
|
||||
ExternalDataResult results = this.remoteFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).collect(Collectors.toList()), externalReferenceCriteria, key);
|
||||
ExternalDataResult results = this.externalFetcherService.getExternalData(referenceTypeDefinition.getSources().stream().map(x -> (SourceBaseConfiguration)x).collect(Collectors.toList()), externalReferenceCriteria, key);
|
||||
for (Map<String, String> result: results.getResults()) {
|
||||
result.put("referenceType", referenceType.getName());
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import eu.eudat.model.ReferenceType;
|
|||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.deleter.ReferenceTypeDeleter;
|
||||
import eu.eudat.model.persist.ReferenceTypePersist;
|
||||
import eu.eudat.model.persist.externalfetcher.*;
|
||||
import eu.eudat.model.persist.referencetypedefinition.*;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
|
@ -115,7 +116,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
}
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getSources())){
|
||||
data.setSources(new ArrayList<>());
|
||||
for (ReferenceTypeSourceBaseConfigurationPersist sourceBaseConfigPersist: persist.getSources()) {
|
||||
for (ExternalFetcherBaseSourceConfigurationPersist sourceBaseConfigPersist: persist.getSources()) {
|
||||
data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist));
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ReferenceTypeSourceBaseConfigurationPersist persist){
|
||||
private @NotNull ExternalFetcherBaseSourceConfigurationEntity buildSourceBaseConfigEntity(ExternalFetcherBaseSourceConfigurationPersist persist){
|
||||
if (persist == null) return new ExternalFetcherApiSourceConfigurationEntity();
|
||||
|
||||
ExternalFetcherBaseSourceConfigurationEntity data;
|
||||
|
@ -143,22 +144,22 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
if (ReferenceTypeSourceType.API.equals(persist.getType())) {
|
||||
ExternalFetcherApiSourceConfigurationEntity apiEntity = new ExternalFetcherApiSourceConfigurationEntity();
|
||||
|
||||
apiEntity.setUrl(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getUrl());
|
||||
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults() != null ) {
|
||||
apiEntity.setResults(this.buildResultsConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults()));
|
||||
apiEntity.setUrl(((ExternalFetcherApiSourceConfigurationPersist) persist).getUrl());
|
||||
if (((ExternalFetcherApiSourceConfigurationPersist) persist).getResults() != null ) {
|
||||
apiEntity.setResults(this.buildResultsConfigEntity(((ExternalFetcherApiSourceConfigurationPersist) persist).getResults()));
|
||||
}
|
||||
apiEntity.setPaginationPath(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getPaginationPath());
|
||||
apiEntity.setContentType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getContentType());
|
||||
apiEntity.setFirstPage(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFirstPage());
|
||||
apiEntity.setHttpMethod(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getHttpMethod());
|
||||
apiEntity.setRequestBody(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getRequestBody());
|
||||
apiEntity.setFilterType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFilterType());
|
||||
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth() != null) {
|
||||
apiEntity.setAuth(this.buildAuthConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth()));
|
||||
apiEntity.setPaginationPath(((ExternalFetcherApiSourceConfigurationPersist) persist).getPaginationPath());
|
||||
apiEntity.setContentType(((ExternalFetcherApiSourceConfigurationPersist) persist).getContentType());
|
||||
apiEntity.setFirstPage(((ExternalFetcherApiSourceConfigurationPersist) persist).getFirstPage());
|
||||
apiEntity.setHttpMethod(((ExternalFetcherApiSourceConfigurationPersist) persist).getHttpMethod());
|
||||
apiEntity.setRequestBody(((ExternalFetcherApiSourceConfigurationPersist) persist).getRequestBody());
|
||||
apiEntity.setFilterType(((ExternalFetcherApiSourceConfigurationPersist) persist).getFilterType());
|
||||
if (((ExternalFetcherApiSourceConfigurationPersist) persist).getAuth() != null) {
|
||||
apiEntity.setAuth(this.buildAuthConfigEntity(((ExternalFetcherApiSourceConfigurationPersist) persist).getAuth()));
|
||||
}
|
||||
if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries())){
|
||||
if (!this.conventionService.isListNullOrEmpty(((ExternalFetcherApiSourceConfigurationPersist) persist).getQueries())){
|
||||
apiEntity.setQueries(new ArrayList<>());
|
||||
for (QueryConfigPersist queryConfigPersist: ((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries()) {
|
||||
for (QueryConfigPersist queryConfigPersist: ((ExternalFetcherApiSourceConfigurationPersist) persist).getQueries()) {
|
||||
apiEntity.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
|
||||
}
|
||||
}
|
||||
|
@ -167,9 +168,9 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
}else {
|
||||
ExternalFetcherStaticOptionSourceConfigurationEntity staticEntity = new ExternalFetcherStaticOptionSourceConfigurationEntity();
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions())){
|
||||
if (!this.conventionService.isListNullOrEmpty(((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions())){
|
||||
staticEntity.setOptions(new ArrayList<>());
|
||||
for (ReferenceTypeStaticOptionPersist optionPersist: ((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions()) {
|
||||
for (StaticOptionPersist optionPersist: ((ExternalFetcherStaticOptionSourceConfigurationPersist) persist).getOptions()) {
|
||||
staticEntity.getOptions().add(this.buildStaticOptionEntity(optionPersist));
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +256,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
return data;
|
||||
}
|
||||
|
||||
private @NotNull StaticOptionEntity buildStaticOptionEntity(ReferenceTypeStaticOptionPersist persist){
|
||||
private @NotNull StaticOptionEntity buildStaticOptionEntity(StaticOptionPersist persist){
|
||||
StaticOptionEntity data = new StaticOptionEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -5,7 +5,7 @@ import gr.cite.tools.exception.MyNotFoundException;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
|
||||
@Component
|
||||
public class ValidationManager {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.logic.services;
|
||||
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
|
||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
Loading…
Reference in New Issue