rename reference type definition fields and fix listing

This commit is contained in:
amentis 2023-11-09 18:25:35 +02:00
parent 33672e5ce8
commit 3ecb1ed982
38 changed files with 472 additions and 888 deletions

View File

@ -1,131 +0,0 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
public class DataFieldsUrlConfigurationEntity {
private String id;
private String name;
private String pid;
private String pidTypeField;
private String uri;
private String description;
private String source;
private String count;
// private String path;
// private String host;
private String types;
private String firstName;
private String lastName;
public String getId() {
return id;
}
@XmlElement(name = "id")
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
@XmlElement(name = "name")
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
@XmlElement(name = "pid")
public void setPid(String pid) {
this.pid = pid;
}
public String getPidTypeField() {
return pidTypeField;
}
@XmlElement(name = "pidTypeField")
public void setPidTypeField(String pidTypeField) {
this.pidTypeField = pidTypeField;
}
public String getUri() {
return uri;
}
@XmlElement(name = "uri")
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
@XmlElement(name = "description")
public void setDescription(String description) {
this.description = description;
}
public String getSource() {
return source;
}
@XmlElement(name = "source")
public void setSource(String source) {
this.source = source;
}
public String getCount() {
return count;
}
@XmlElement(name = "count")
public void setCount(String count) {
this.count = count;
}
// public String getPath() {
// return path;
// }
// @XmlElement(name = "path")
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHost() {
// return host;
// }
// @XmlElement(name = "host")
// public void setHost(String host) {
// this.host = host;
// }
@XmlElement(name = "types")
public String getTypes() {
return types;
}
public void setTypes(String types) {
this.types = types;
}
@XmlElement(name = "firstName")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@XmlElement(name = "lastName")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

View File

@ -1,70 +0,0 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class DataUrlConfigurationEntity {
private String path;
private DataFieldsUrlConfigurationEntity fieldsUrlConfiguration;
// private String parseClass;
// private String parseField;
// private List<String> mergedFields;
// private String mergedFieldName;
public String getPath() {
return path;
}
@XmlElement(name = "path")
public void setPath(String path) {
this.path = path;
}
public DataFieldsUrlConfigurationEntity getFieldsUrlConfiguration() {
return fieldsUrlConfiguration;
}
@XmlElement(name = "fields")
public void setFieldsUrlConfiguration(DataFieldsUrlConfigurationEntity fieldsUrlConfiguration) {
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
}
// public String getParseClass() {
// return parseClass;
// }
//
// @XmlElement(name = "parse-class")
// public void setParseClass(String parseClass) {
// this.parseClass = parseClass;
// }
//
// public String getParseField() {
// return parseField;
// }
//
// @XmlElement(name = "parse-field")
// public void setParseField(String parseField) {
// this.parseField = parseField;
// }
//
// public List<String> getMergedFields() {
// return mergedFields;
// }
//
// @XmlElementWrapper(name = "merge-fields")
// @XmlElement(name = "field")
// public void setMergedFields(List<String> mergedFields) {
// this.mergedFields = mergedFields;
// }
//
// public String getMergedFieldName() {
// return mergedFieldName;
// }
//
// @XmlElement(name = "merge-field-name")
// public void setMergedFieldName(String mergedFieldName) {
// this.mergedFieldName = mergedFieldName;
// }
}

View File

@ -11,9 +11,9 @@ public class ReferenceTypeDefinitionEntity {
@XmlElement(name = "field") @XmlElement(name = "field")
private List<ReferenceTypeFieldEntity> fields; private List<ReferenceTypeFieldEntity> fields;
@XmlElementWrapper(name = "urls") @XmlElementWrapper(name = "externalApiConfigs")
@XmlElement(name = "urlConfig") @XmlElement(name = "externalApiConfig")
private List<ReferenceTypeUrlConfigurationEntity> urlConfig; private List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig;
public List<ReferenceTypeFieldEntity> getFields() { public List<ReferenceTypeFieldEntity> getFields() {
return fields; return fields;
@ -23,11 +23,11 @@ public class ReferenceTypeDefinitionEntity {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeUrlConfigurationEntity> getUrlConfig() { public List<ReferenceTypeExternalApiConfigurationEntity> getExternalApiConfig() {
return urlConfig; return externalApiConfig;
} }
public void setUrlConfig(List<ReferenceTypeUrlConfigurationEntity> urlConfig) { public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig) {
this.urlConfig = urlConfig; this.externalApiConfig = externalApiConfig;
} }
} }

View File

@ -3,21 +3,19 @@ package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.List; import java.util.List;
public class ReferenceTypeUrlConfigurationEntity { public class ReferenceTypeExternalApiConfigurationEntity {
private String key; private String key;
private String label; private String label;
private Integer ordinal; private Integer ordinal;
private String url; private String url;
private DataUrlConfigurationEntity data; private ResultsConfigurationEntity results;
private String type; private String type;
private String paginationPath; private String paginationPath;
private String contentType; private String contentType;
private String funderQuery; private String firstPage;
private String firstpage;
private String requestType = "GET"; private String requestType = "GET";
private String requestBody = ""; private String requestBody = "";
private String filterType = "remote"; private String filterType = "remote";
@ -57,18 +55,18 @@ public class ReferenceTypeUrlConfigurationEntity {
this.ordinal = ordinal; this.ordinal = ordinal;
} }
public DataUrlConfigurationEntity getData() { public ResultsConfigurationEntity getResults() {
return data; return results;
} }
@XmlElement(name = "data") @XmlElement(name = "results")
public void setData(DataUrlConfigurationEntity data) { public void setResults(ResultsConfigurationEntity results) {
this.data = data; this.results = results;
} }
public String getPaginationPath() { public String getPaginationPath() {
return paginationPath; return paginationPath;
} }
@XmlElement(name = "paginationpath") @XmlElement(name = "paginationPath")
public void setPaginationPath(String paginationPath) { public void setPaginationPath(String paginationPath) {
this.paginationPath = paginationPath; this.paginationPath = paginationPath;
} }
@ -84,25 +82,17 @@ public class ReferenceTypeUrlConfigurationEntity {
public String getContentType() { public String getContentType() {
return contentType; return contentType;
} }
@XmlElement(name = "contenttype") @XmlElement(name = "contentType")
public void setContentType(String contentType) { public void setContentType(String contentType) {
this.contentType = contentType; this.contentType = contentType;
} }
public String getFunderQuery() { public String getFirstPage() {
return funderQuery; return firstPage;
}
@XmlElement(name = "funderQuery")
public void setFunderQuery(String funderQuery) {
this.funderQuery = funderQuery;
}
public String getFirstpage() {
return firstpage;
} }
@XmlElement(name = "firstPage") @XmlElement(name = "firstPage")
public void setFirstpage(String firstpage) { public void setFirstPage(String firstPage) {
this.firstpage = firstpage; this.firstPage = firstPage;
} }
public String getRequestType() { public String getRequestType() {

View File

@ -0,0 +1,27 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
public class ResultFieldsMappingConfigurationEntity {
private String code;
private String responsePath;
public String getCode() {
return code;
}
@XmlElement(name = "code")
public void setCode(String code) {
this.code = code;
}
public String getResponsePath() {
return responsePath;
}
@XmlElement(name = "responsePath")
public void setResponsePath(String responsePath) {
this.responsePath = responsePath;
}
}

View File

@ -0,0 +1,31 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class ResultsConfigurationEntity {
private String resultsArrayPath;
private List<ResultFieldsMappingConfigurationEntity> fieldsMapping;
public String getResultsArrayPath() {
return resultsArrayPath;
}
@XmlElement(name = "resultsArrayPath")
public void setResultsArrayPath(String resultsArrayPath) {
this.resultsArrayPath = resultsArrayPath;
}
public List<ResultFieldsMappingConfigurationEntity> getFieldsMapping() {
return fieldsMapping;
}
@XmlElementWrapper
@XmlElement(name = "field")
public void setFieldsMapping(List<ResultFieldsMappingConfigurationEntity> fieldsMapping) {
this.fieldsMapping = fieldsMapping;
}
}

View File

@ -70,6 +70,7 @@ public class ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTy
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition()); ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition());
m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
} }
models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models; return models;

View File

@ -1,71 +0,0 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.DataFieldsUrlConfigurationEntity;
import eu.eudat.commons.types.referencetype.QueryConfigEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.DataFieldsUrlConfiguration;
import eu.eudat.model.referencetypedefinition.QueryConfig;
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 DataFieldsUrlConfigurationBuilder extends BaseBuilder<DataFieldsUrlConfiguration, DataFieldsUrlConfigurationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public DataFieldsUrlConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DataFieldsUrlConfigurationBuilder.class)));
this.builderFactory = builderFactory;
}
public DataFieldsUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<DataFieldsUrlConfiguration> build(FieldSet fields, List<DataFieldsUrlConfigurationEntity> 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<DataFieldsUrlConfiguration> models = new ArrayList<>();
for (DataFieldsUrlConfigurationEntity d : data) {
DataFieldsUrlConfiguration m = new DataFieldsUrlConfiguration();
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._name))) m.setName(d.getName());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._pid))) m.setPid(d.getPid());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._pidTypeField))) m.setPidTypeField(d.getPidTypeField());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._uri))) m.setUri(d.getUri());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._source))) m.setSource(d.getSource());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._count))) m.setCount(d.getCount());
// if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._path))) m.setPath(d.getPath());
// if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._host))) m.setHost(d.getHost());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._types))) m.setTypes(d.getTypes());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._firstName))) m.setFirstName(d.getFirstName());
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._lastName))) m.setLastName(d.getLastName());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -45,13 +45,13 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
return new ArrayList<>(); return new ArrayList<>();
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields)); FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields));
FieldSet urlConfigFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._urlConfig)); FieldSet externalApiConfigFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._externalApiConfig));
List<ReferenceTypeDefinition> models = new ArrayList<>(); List<ReferenceTypeDefinition> models = new ArrayList<>();
for (ReferenceTypeDefinitionEntity d : data) { for (ReferenceTypeDefinitionEntity d : data) {
ReferenceTypeDefinition m = new ReferenceTypeDefinition(); ReferenceTypeDefinition m = new ReferenceTypeDefinition();
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields())); if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setUrlConfig(this.builderFactory.builder(ReferenceTypeUrlConfigurationBuilder.class).authorize(this.authorize).build(urlConfigFields, d.getUrlConfig())); if (!fieldsFields.isEmpty() && d.getFields() != null) m.setExternalApiConfig(this.builderFactory.builder(ReferenceTypeExternalApiConfigurationBuilder.class).authorize(this.authorize).build(externalApiConfigFields, d.getExternalApiConfig()));
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -0,0 +1,80 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.ReferenceTypeExternalApiConfigurationEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeExternalApiConfiguration;
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 ReferenceTypeExternalApiConfigurationBuilder extends BaseBuilder<ReferenceTypeExternalApiConfiguration, ReferenceTypeExternalApiConfigurationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public ReferenceTypeExternalApiConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeExternalApiConfigurationBuilder.class)));
this.builderFactory = builderFactory;
}
public ReferenceTypeExternalApiConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<ReferenceTypeExternalApiConfiguration> build(FieldSet fields, List<ReferenceTypeExternalApiConfigurationEntity> 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 resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._results));
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._auth));
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._queries));
List<ReferenceTypeExternalApiConfiguration> models = new ArrayList<>();
for (ReferenceTypeExternalApiConfigurationEntity d : data) {
ReferenceTypeExternalApiConfiguration m = new ReferenceTypeExternalApiConfiguration();
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._key))) m.setKey(d.getKey());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._ordinal))) m.setOrdinal(d.getOrdinal());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._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(ReferenceTypeExternalApiConfiguration._type))) m.setType(d.getType());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._contentType))) m.setContentType(d.getContentType());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._firstPage))) m.setFirstPage(d.getFirstPage());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._requestType))) m.setRequestType(d.getRequestType());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
if (fields.hasField(this.asIndexer(ReferenceTypeExternalApiConfiguration._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()));
}
if (!queriesFields.isEmpty() && d.getQueries() != null) {
m.setQueries(this.builderFactory.builder(QueryConfigBuilder.class).authorize(this.authorize).build(queriesFields, d.getQueries()));
}
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -1,81 +0,0 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.ReferenceTypeUrlConfigurationEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ReferenceTypeUrlConfiguration;
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 ReferenceTypeUrlConfigurationBuilder extends BaseBuilder<ReferenceTypeUrlConfiguration, ReferenceTypeUrlConfigurationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public ReferenceTypeUrlConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeUrlConfigurationBuilder.class)));
this.builderFactory = builderFactory;
}
public ReferenceTypeUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<ReferenceTypeUrlConfiguration> build(FieldSet fields, List<ReferenceTypeUrlConfigurationEntity> 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 dataFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._data));
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._auth));
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._queries));
List<ReferenceTypeUrlConfiguration> models = new ArrayList<>();
for (ReferenceTypeUrlConfigurationEntity d : data) {
ReferenceTypeUrlConfiguration m = new ReferenceTypeUrlConfiguration();
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._key))) m.setKey(d.getKey());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._ordinal))) m.setOrdinal(d.getOrdinal());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._url))) m.setUrl(d.getUrl());
if (!dataFields.isEmpty() && d.getData() != null) {
m.setData(this.builderFactory.builder(DataUrlConfigurationBuilder.class).authorize(this.authorize).build(dataFields, d.getData()));
}
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._type))) m.setType(d.getType());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._contentType))) m.setContentType(d.getContentType());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._funderQuery))) m.setFunderQuery(d.getFunderQuery());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._firstPage))) m.setFirstPage(d.getFirstpage());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._requestType))) m.setRequestType(d.getRequestType());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._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()));
}
if (!queriesFields.isEmpty() && d.getQueries() != null) {
m.setQueries(this.builderFactory.builder(QueryConfigBuilder.class).authorize(this.authorize).build(queriesFields, d.getQueries()));
}
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,58 @@
package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.ResultFieldsMappingConfigurationEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.ResultFieldsMappingConfiguration;
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 ResultFieldsMappingConfigurationBuilder extends BaseBuilder<ResultFieldsMappingConfiguration, ResultFieldsMappingConfigurationEntity> {
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public ResultFieldsMappingConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(ResultFieldsMappingConfigurationBuilder.class)));
this.builderFactory = builderFactory;
}
public ResultFieldsMappingConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<ResultFieldsMappingConfiguration> build(FieldSet fields, List<ResultFieldsMappingConfigurationEntity> 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<ResultFieldsMappingConfiguration> models = new ArrayList<>();
for (ResultFieldsMappingConfigurationEntity d : data) {
ResultFieldsMappingConfiguration m = new ResultFieldsMappingConfiguration();
if (fields.hasField(this.asIndexer(ResultFieldsMappingConfiguration._code))) m.setCode(d.getCode());
if (fields.hasField(this.asIndexer(ResultFieldsMappingConfiguration._responsePath))) m.setResponsePath(d.getResponsePath());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -1,10 +1,10 @@
package eu.eudat.model.builder.referencetypedefinition; package eu.eudat.model.builder.referencetypedefinition;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.types.referencetype.DataUrlConfigurationEntity; import eu.eudat.commons.types.referencetype.ResultsConfigurationEntity;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.builder.BaseBuilder; import eu.eudat.model.builder.BaseBuilder;
import eu.eudat.model.referencetypedefinition.DataUrlConfiguration; import eu.eudat.model.referencetypedefinition.ResultsConfiguration;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -20,38 +20,38 @@ import java.util.*;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DataUrlConfigurationBuilder extends BaseBuilder<DataUrlConfiguration, DataUrlConfigurationEntity> { public class ResultsConfigurationBuilder extends BaseBuilder<ResultsConfiguration, ResultsConfigurationEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public DataUrlConfigurationBuilder( public ResultsConfigurationBuilder(
ConventionService conventionService, BuilderFactory builderFactory) { ConventionService conventionService, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DataUrlConfigurationBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(ResultsConfigurationBuilder.class)));
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
} }
public DataUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) { public ResultsConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values; this.authorize = values;
return this; return this;
} }
@Override @Override
public List<DataUrlConfiguration> build(FieldSet fields, List<DataUrlConfigurationEntity> data) throws MyApplicationException { public List<ResultsConfiguration> build(FieldSet fields, List<ResultsConfigurationEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields)); this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty()) if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>(); return new ArrayList<>();
FieldSet fieldsUrlConfigFields = fields.extractPrefixed(this.asPrefix(DataUrlConfiguration._fieldsUrlConfiguration)); FieldSet fieldsMappingFields = fields.extractPrefixed(this.asPrefix(ResultsConfiguration._fieldsMapping));
List<DataUrlConfiguration> models = new ArrayList<>(); List<ResultsConfiguration> models = new ArrayList<>();
for (DataUrlConfigurationEntity d : data) { for (ResultsConfigurationEntity d : data) {
DataUrlConfiguration m = new DataUrlConfiguration(); ResultsConfiguration m = new ResultsConfiguration();
if (fields.hasField(this.asIndexer(DataUrlConfiguration._path))) m.setPath(d.getPath()); if (fields.hasField(this.asIndexer(ResultsConfiguration._resultsArrayPath))) m.setResultsArrayPath(d.getResultsArrayPath());
if (!fieldsUrlConfigFields.isEmpty() && d.getFieldsUrlConfiguration() != null) { if (!fieldsMappingFields.isEmpty() && d.getFieldsMapping() != null) {
m.setFieldsUrlConfiguration(this.builderFactory.builder(DataFieldsUrlConfigurationBuilder.class).authorize(this.authorize).build(fieldsUrlConfigFields, d.getFieldsUrlConfiguration())); m.setFieldsMapping(this.builderFactory.builder(ResultFieldsMappingConfigurationBuilder.class).authorize(this.authorize).build(fieldsMappingFields, d.getFieldsMapping()));
} }
models.add(m); models.add(m);

View File

@ -42,8 +42,8 @@ public class ReferenceTypeDefinitionCensor extends BaseCensor {
FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._fields)); FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._fields));
this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId); this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId);
FieldSet urlConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._urlConfig)); FieldSet externalApiConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._externalApiConfig));
this.censorFactory.censor(ReferenceTypeUrlConfigurationCensor.class).censor(urlConfigFields, userId); this.censorFactory.censor(ReferenceTypeExternalApiConfigurationCensor.class).censor(externalApiConfigFields, userId);
} }
} }

View File

@ -3,8 +3,7 @@ package eu.eudat.model.censorship.referencetype;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition; import eu.eudat.model.referencetypedefinition.ReferenceTypeExternalApiConfiguration;
import eu.eudat.model.referencetypedefinition.ReferenceTypeUrlConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -19,15 +18,15 @@ import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceTypeUrlConfigurationCensor extends BaseCensor { public class ReferenceTypeExternalApiConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeUrlConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeExternalApiConfigurationCensor.class));
protected final AuthorizationService authService; protected final AuthorizationService authService;
protected final CensorFactory censorFactory; protected final CensorFactory censorFactory;
public ReferenceTypeUrlConfigurationCensor(ConventionService conventionService, public ReferenceTypeExternalApiConfigurationCensor(ConventionService conventionService,
AuthorizationService authService, CensorFactory censorFactory) { AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService); super(conventionService);
this.authService = authService; this.authService = authService;
this.censorFactory = censorFactory; this.censorFactory = censorFactory;
@ -40,13 +39,13 @@ public class ReferenceTypeUrlConfigurationCensor extends BaseCensor {
this.authService.authorizeForce(Permission.BrowseReferenceType); this.authService.authorizeForce(Permission.BrowseReferenceType);
FieldSet dataFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._data)); FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._results));
this.censorFactory.censor(DataUrlConfigurationCensor.class).censor(dataFields, userId); this.censorFactory.censor(ResultsConfigurationCensor.class).censor(resultsFields, userId);
FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._auth)); FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._auth));
this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId); this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId);
FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._queries)); FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._queries));
this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId); this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId);
} }

View File

@ -16,14 +16,14 @@ import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DataFieldsUrlConfigurationCensor extends BaseCensor { public class ResultFieldsMappingConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DataFieldsUrlConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ResultFieldsMappingConfigurationCensor.class));
protected final AuthorizationService authService; protected final AuthorizationService authService;
public DataFieldsUrlConfigurationCensor(ConventionService conventionService, public ResultFieldsMappingConfigurationCensor(ConventionService conventionService,
AuthorizationService authService) { AuthorizationService authService) {
super(conventionService); super(conventionService);
this.authService = authService; this.authService = authService;
} }

View File

@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetype;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.model.censorship.BaseCensor; import eu.eudat.model.censorship.BaseCensor;
import eu.eudat.model.referencetypedefinition.DataUrlConfiguration; import eu.eudat.model.referencetypedefinition.ResultsConfiguration;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
@ -18,14 +18,14 @@ import java.util.UUID;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DataUrlConfigurationCensor extends BaseCensor { public class ResultsConfigurationCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DataUrlConfigurationCensor.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ResultsConfigurationCensor.class));
protected final AuthorizationService authService; protected final AuthorizationService authService;
protected final CensorFactory censorFactory; protected final CensorFactory censorFactory;
public DataUrlConfigurationCensor(ConventionService conventionService, public ResultsConfigurationCensor(ConventionService conventionService,
AuthorizationService authService, CensorFactory censorFactory) { AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService); super(conventionService);
this.authService = authService; this.authService = authService;
@ -38,8 +38,8 @@ public class DataUrlConfigurationCensor extends BaseCensor {
return; return;
this.authService.authorizeForce(Permission.BrowseReferenceType); this.authService.authorizeForce(Permission.BrowseReferenceType);
FieldSet fieldsUrlFields = fields.extractPrefixed(this.asIndexerPrefix(DataUrlConfiguration._fieldsUrlConfiguration)); FieldSet fieldsMappingFields = fields.extractPrefixed(this.asIndexerPrefix(ResultsConfiguration._fieldsMapping));
this.censorFactory.censor(DataFieldsUrlConfigurationCensor.class).censor(fieldsUrlFields, userId); this.censorFactory.censor(ResultFieldsMappingConfigurationCensor.class).censor(fieldsMappingFields, userId);
} }
} }

View File

@ -29,6 +29,8 @@ public class ReferenceTypePersist {
@Valid @Valid
private ReferenceTypeDefinitionPersist definition; private ReferenceTypeDefinitionPersist definition;
private String hash;
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -60,4 +62,12 @@ public class ReferenceTypePersist {
public void setDefinition(ReferenceTypeDefinitionPersist definition) { public void setDefinition(ReferenceTypeDefinitionPersist definition) {
this.definition = definition; this.definition = definition;
} }
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
} }

View File

@ -5,16 +5,16 @@ import jakarta.validation.constraints.NotNull;
public class AuthenticationConfigurationPersist { public class AuthenticationConfigurationPersist {
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String authUrl; private String authUrl = null;
private String authMethod = "GET"; private String authMethod = "GET";
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String authTokenPath; private String authTokenPath = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String authRequestBody; private String authRequestBody = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
private String type; private String type = null;
public String getAuthUrl() { public String getAuthUrl() {
return authUrl; return authUrl;

View File

@ -1,104 +0,0 @@
package eu.eudat.model.persist.referencetypedefinition;
public class DataFieldsUrlConfigurationPersist {
private String id;
private String name;
private String pid;
private String pidTypeField;
private String uri;
private String description;
private String source;
private String count;
private String types;
private String firstName;
private String lastName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getPidTypeField() {
return pidTypeField;
}
public void setPidTypeField(String pidTypeField) {
this.pidTypeField = pidTypeField;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getTypes() {
return types;
}
public void setTypes(String types) {
this.types = types;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
public class DataUrlConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String path;
@Valid
private DataFieldsUrlConfigurationPersist fieldsUrlConfiguration;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public DataFieldsUrlConfigurationPersist getFieldsUrlConfiguration() {
return fieldsUrlConfiguration;
}
public void setFieldsUrlConfiguration(DataFieldsUrlConfigurationPersist fieldsUrlConfiguration) {
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
}
}

View File

@ -1,6 +1,5 @@
package eu.eudat.model.persist.referencetypedefinition; package eu.eudat.model.persist.referencetypedefinition;
import eu.eudat.model.persist.dmpblueprintdefinition.SectionPersist;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@ -14,7 +13,7 @@ public class ReferenceTypeDefinitionPersist {
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@Valid @Valid
private List<ReferenceTypeUrlConfigurationPersist> urlConfig = null; private List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig = null;
public List<ReferenceTypeFieldPersist> getFields() { public List<ReferenceTypeFieldPersist> getFields() {
return fields; return fields;
@ -24,11 +23,11 @@ public class ReferenceTypeDefinitionPersist {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeUrlConfigurationPersist> getUrlConfig() { public List<ReferenceTypeExternalApiConfigurationPersist> getExternalApiConfig() {
return urlConfig; return externalApiConfig;
} }
public void setUrlConfig(List<ReferenceTypeUrlConfigurationPersist> urlConfig) { public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig) {
this.urlConfig = urlConfig; this.externalApiConfig = externalApiConfig;
} }
} }

View File

@ -6,44 +6,41 @@ import jakarta.validation.constraints.NotNull;
import java.util.List; import java.util.List;
public class ReferenceTypeUrlConfigurationPersist { public class ReferenceTypeExternalApiConfigurationPersist {
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String key; private String key = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String label; private String label = null;
@NotNull(message = "{validation.empty}")
private Integer ordinal = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private Integer ordinal; private String url = null;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String url;
@Valid @Valid
private DataUrlConfigurationPersist data; private ResultsConfigurationPersist results;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String type; private String type = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String paginationPath; private String paginationPath = null;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String contentType; private String contentType = null;
private String funderQuery;
@NotNull(message = "{validation.empty}") @NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}")
private String firstpage; private String firstPage = null;
private String requestType = "GET"; private String requestType = "GET";
private String requestBody = ""; private String requestBody = "";
@ -87,12 +84,12 @@ public class ReferenceTypeUrlConfigurationPersist {
this.url = url; this.url = url;
} }
public DataUrlConfigurationPersist getData() { public ResultsConfigurationPersist getResults() {
return data; return results;
} }
public void setData(DataUrlConfigurationPersist data) { public void setResults(ResultsConfigurationPersist results) {
this.data = data; this.results = results;
} }
public String getType() { public String getType() {
@ -119,20 +116,13 @@ public class ReferenceTypeUrlConfigurationPersist {
this.contentType = contentType; this.contentType = contentType;
} }
public String getFunderQuery() {
return funderQuery; public String getFirstPage() {
return firstPage;
} }
public void setFunderQuery(String funderQuery) { public void setFirstPage(String firstPage) {
this.funderQuery = funderQuery; this.firstPage = firstPage;
}
public String getFirstpage() {
return firstpage;
}
public void setFirstpage(String firstpage) {
this.firstpage = firstpage;
} }
public String getRequestType() { public String getRequestType() {

View File

@ -0,0 +1,31 @@
package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
public class ResultFieldsMappingConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String code;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String responsePath;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getResponsePath() {
return responsePath;
}
public void setResponsePath(String responsePath) {
this.responsePath = responsePath;
}
}

View File

@ -0,0 +1,34 @@
package eu.eudat.model.persist.referencetypedefinition;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
public class ResultsConfigurationPersist {
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String resultsArrayPath;
@NotNull(message = "{validation.empty}")
@Valid
private List<ResultFieldsMappingConfigurationPersist> fieldsMapping;
public String getResultsArrayPath() {
return resultsArrayPath;
}
public void setResultsArrayPath(String resultsArrayPath) {
this.resultsArrayPath = resultsArrayPath;
}
public List<ResultFieldsMappingConfigurationPersist> getFieldsMapping() {
return fieldsMapping;
}
public void setFieldsMapping(List<ResultFieldsMappingConfigurationPersist> fieldsMapping) {
this.fieldsMapping = fieldsMapping;
}
}

View File

@ -1,149 +0,0 @@
package eu.eudat.model.referencetypedefinition;
public class DataFieldsUrlConfiguration {
public final static String _id = "id";
private String id;
public final static String _name = "name";
private String name;
public final static String _pid = "pid";
private String pid;
public final static String _pidTypeField = "pidTypeField";
private String pidTypeField;
public final static String _uri = "uri";
private String uri;
public final static String _description= "description";
private String description;
public final static String _source = "source";
private String source;
public final static String _count = "count";
private String count;
// public final static String _path = "path";
// private String path;
//
// public final static String _host = "host";
// private String host;
public final static String _types = "types";
private String types;
public final static String _firstName = "firstName";
private String firstName;
public final static String _lastName = "lastName";
private String lastName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getPidTypeField() {
return pidTypeField;
}
public void setPidTypeField(String pidTypeField) {
this.pidTypeField = pidTypeField;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
public String getTypes() {
return types;
}
public void setTypes(String types) {
this.types = types;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

View File

@ -1,74 +0,0 @@
package eu.eudat.model.referencetypedefinition;
import java.util.List;
public class DataUrlConfiguration {
public final static String _path = "path";
private String path;
public final static String _fieldsUrlConfiguration = "fieldsUrlConfiguration";
private DataFieldsUrlConfiguration fieldsUrlConfiguration;
// public final static String _parseClass = "parseClass";
// private String parseClass;
//
// public final static String _parseField = "parseField";
// private String parseField;
//
// public final static String _mergedFields = "mergedFields";
// private List<String> mergedFields;
//
// public final static String _mergedFieldName = "mergedFieldName";
// private String mergedFieldName;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public DataFieldsUrlConfiguration getFieldsUrlConfiguration() {
return fieldsUrlConfiguration;
}
public void setFieldsUrlConfiguration(DataFieldsUrlConfiguration fieldsUrlConfiguration) {
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
}
// public String getParseClass() {
// return parseClass;
// }
//
// public void setParseClass(String parseClass) {
// this.parseClass = parseClass;
// }
//
// public String getParseField() {
// return parseField;
// }
//
// public void setParseField(String parseField) {
// this.parseField = parseField;
// }
//
// public List<String> getMergedFields() {
// return mergedFields;
// }
//
// public void setMergedFields(List<String> mergedFields) {
// this.mergedFields = mergedFields;
// }
//
// public String getMergedFieldName() {
// return mergedFieldName;
// }
//
// public void setMergedFieldName(String mergedFieldName) {
// this.mergedFieldName = mergedFieldName;
// }
}

View File

@ -7,8 +7,8 @@ public class ReferenceTypeDefinition {
public final static String _fields = "fields"; public final static String _fields = "fields";
private List<ReferenceTypeField> fields; private List<ReferenceTypeField> fields;
public final static String _urlConfig = "urlConfig"; public final static String _externalApiConfig = "externalApiConfig";
private List<ReferenceTypeUrlConfiguration> urlConfig; private List<ReferenceTypeExternalApiConfiguration> externalApiConfig;
public List<ReferenceTypeField> getFields() { public List<ReferenceTypeField> getFields() {
return fields; return fields;
@ -18,11 +18,11 @@ public class ReferenceTypeDefinition {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeUrlConfiguration> getUrlConfig() { public List<ReferenceTypeExternalApiConfiguration> getExternalApiConfig() {
return urlConfig; return externalApiConfig;
} }
public void setUrlConfig(List<ReferenceTypeUrlConfiguration> urlConfig) { public void setExternalApiConfig(List<ReferenceTypeExternalApiConfiguration> externalApiConfig) {
this.urlConfig = urlConfig; this.externalApiConfig = externalApiConfig;
} }
} }

View File

@ -3,7 +3,7 @@ package eu.eudat.model.referencetypedefinition;
import java.util.List; import java.util.List;
public class ReferenceTypeUrlConfiguration { public class ReferenceTypeExternalApiConfiguration {
public final static String _key = "key"; public final static String _key = "key";
private String key; private String key;
@ -18,8 +18,8 @@ public class ReferenceTypeUrlConfiguration {
private String url; private String url;
public final static String _data = "data"; public final static String _results = "results";
private DataUrlConfiguration data; private ResultsConfiguration results;
public final static String _type = "type"; public final static String _type = "type";
private String type; private String type;
@ -30,9 +30,6 @@ public class ReferenceTypeUrlConfiguration {
public final static String _contentType = "contentType"; public final static String _contentType = "contentType";
private String contentType; private String contentType;
public final static String _funderQuery = "funderQuery";
private String funderQuery;
public final static String _firstPage = "firstPage"; public final static String _firstPage = "firstPage";
private String firstPage; private String firstPage;
@ -83,12 +80,12 @@ public class ReferenceTypeUrlConfiguration {
this.url = url; this.url = url;
} }
public DataUrlConfiguration getData() { public ResultsConfiguration getResults() {
return data; return results;
} }
public void setData(DataUrlConfiguration data) { public void setResults(ResultsConfiguration results) {
this.data = data; this.results = results;
} }
public String getType() { public String getType() {
@ -115,13 +112,6 @@ public class ReferenceTypeUrlConfiguration {
this.contentType = contentType; this.contentType = contentType;
} }
public String getFunderQuery() {
return funderQuery;
}
public void setFunderQuery(String funderQuery) {
this.funderQuery = funderQuery;
}
public String getFirstPage() { public String getFirstPage() {
return firstPage; return firstPage;

View File

@ -0,0 +1,29 @@
package eu.eudat.model.referencetypedefinition;
public class ResultFieldsMappingConfiguration {
public final static String _code = "id";
private String code;
public final static String _responsePath = "responsePath";
private String responsePath;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getResponsePath() {
return responsePath;
}
public void setResponsePath(String responsePath) {
this.responsePath = responsePath;
}
}

View File

@ -0,0 +1,29 @@
package eu.eudat.model.referencetypedefinition;
import java.util.List;
public class ResultsConfiguration {
public final static String _resultsArrayPath = "resultsArrayPath";
private String resultsArrayPath;
public final static String _fieldsMapping = "fieldsMapping";
private List<ResultFieldsMappingConfiguration> fieldsMapping;
public String getResultsArrayPath() {
return resultsArrayPath;
}
public void setResultsArrayPath(String resultsArrayPath) {
this.resultsArrayPath = resultsArrayPath;
}
public List<ResultFieldsMappingConfiguration> getFieldsMapping() {
return fieldsMapping;
}
public void setFieldsMapping(List<ResultFieldsMappingConfiguration> fieldsMapping) {
this.fieldsMapping = fieldsMapping;
}
}

View File

@ -111,10 +111,10 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
data.getFields().add(this.buildFieldEntity(fieldPersist)); data.getFields().add(this.buildFieldEntity(fieldPersist));
} }
} }
if (!this.conventionService.isListNullOrEmpty(persist.getUrlConfig())){ if (!this.conventionService.isListNullOrEmpty(persist.getExternalApiConfig())){
data.setUrlConfig(new ArrayList<>()); data.setExternalApiConfig(new ArrayList<>());
for (ReferenceTypeUrlConfigurationPersist urlConfigPersist: persist.getUrlConfig()) { for (ReferenceTypeExternalApiConfigurationPersist externalApiConfigPersist: persist.getExternalApiConfig()) {
data.getUrlConfig().add(this.buildUrlConfigEntity(urlConfigPersist)); data.getExternalApiConfig().add(this.buildExternalApiConfigEntity(externalApiConfigPersist));
} }
} }
@ -131,20 +131,19 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
return data; return data;
} }
private @NotNull ReferenceTypeUrlConfigurationEntity buildUrlConfigEntity(ReferenceTypeUrlConfigurationPersist persist){ private @NotNull ReferenceTypeExternalApiConfigurationEntity buildExternalApiConfigEntity(ReferenceTypeExternalApiConfigurationPersist persist){
ReferenceTypeUrlConfigurationEntity data = new ReferenceTypeUrlConfigurationEntity(); ReferenceTypeExternalApiConfigurationEntity data = new ReferenceTypeExternalApiConfigurationEntity();
if (persist == null) return data; if (persist == null) return data;
data.setKey(persist.getKey()); data.setKey(persist.getKey());
data.setLabel(persist.getLabel()); data.setLabel(persist.getLabel());
data.setOrdinal(persist.getOrdinal()); data.setOrdinal(persist.getOrdinal());
data.setUrl(persist.getUrl()); data.setUrl(persist.getUrl());
if (persist.getData() != null ) data.setData(this.buildDataUrlConfigEntity(persist.getData())); if (persist.getResults() != null ) data.setResults(this.buildResultsConfigEntity(persist.getResults()));
data.setType(persist.getType()); data.setType(persist.getType());
data.setPaginationPath(persist.getPaginationPath()); data.setPaginationPath(persist.getPaginationPath());
data.setContentType(persist.getContentType()); data.setContentType(persist.getContentType());
data.setFunderQuery(persist.getFunderQuery()); data.setFirstPage(persist.getFirstPage());
data.setFirstpage(persist.getFirstpage());
data.setRequestType(persist.getRequestType()); data.setRequestType(persist.getRequestType());
data.setRequestBody(persist.getRequestBody()); data.setRequestBody(persist.getRequestBody());
data.setFilterType(persist.getFilterType()); data.setFilterType(persist.getFilterType());
@ -159,31 +158,28 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
return data; return data;
} }
private @NotNull DataUrlConfigurationEntity buildDataUrlConfigEntity(DataUrlConfigurationPersist persist){ private @NotNull ResultsConfigurationEntity buildResultsConfigEntity(ResultsConfigurationPersist persist){
DataUrlConfigurationEntity data = new DataUrlConfigurationEntity(); ResultsConfigurationEntity data = new ResultsConfigurationEntity();
if (persist == null) return data; if (persist == null) return data;
data.setPath(persist.getPath()); data.setResultsArrayPath(persist.getResultsArrayPath());
if (persist.getFieldsUrlConfiguration() != null ) data.setFieldsUrlConfiguration(this.buildDataFieldsUrlConfigEntity(persist.getFieldsUrlConfiguration()));
if (!this.conventionService.isListNullOrEmpty(persist.getFieldsMapping())){
data.setFieldsMapping(new ArrayList<>());
for (ResultFieldsMappingConfigurationPersist fieldsMappingPersist: persist.getFieldsMapping()) {
data.getFieldsMapping().add(this.buildResultFieldsMappingConfigEntity(fieldsMappingPersist));
}
}
return data; return data;
} }
private @NotNull DataFieldsUrlConfigurationEntity buildDataFieldsUrlConfigEntity(DataFieldsUrlConfigurationPersist persist){ private @NotNull ResultFieldsMappingConfigurationEntity buildResultFieldsMappingConfigEntity(ResultFieldsMappingConfigurationPersist persist){
DataFieldsUrlConfigurationEntity data = new DataFieldsUrlConfigurationEntity(); ResultFieldsMappingConfigurationEntity data = new ResultFieldsMappingConfigurationEntity();
if (persist == null) return data; if (persist == null) return data;
data.setId(persist.getId()); data.setCode(persist.getCode());
data.setName(persist.getName()); data.setResponsePath(persist.getResponsePath());
data.setPid(persist.getPid());
data.setPidTypeField(persist.getPidTypeField());
data.setUri(persist.getUri());
data.setDescription(persist.getDescription());
data.setSource(persist.getSource());
data.setCount(persist.getCount());
data.setTypes(persist.getTypes());
data.setFirstName(persist.getFirstName());
data.setLastName(persist.getLastName());
return data; return data;
} }

View File

@ -1,15 +1,12 @@
import { IsActive } from "@app/core/common/enum/is-active.enum"; import { IsActive } from "@app/core/common/enum/is-active.enum";
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type"; import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { Guid } from "@common/types/guid"; import { Guid } from "@common/types/guid";
export interface ReferenceType { export interface ReferenceType extends BaseEntity{
id: Guid;
name: string; name: string;
code: string; code: string;
definition: ReferenceTypeDefinition; definition: ReferenceTypeDefinition;
isActive: IsActive;
createdAt: Date;
updatedAt: Date;
} }
export interface ReferenceTypeDefinition{ export interface ReferenceTypeDefinition{
@ -68,8 +65,7 @@ export interface QueryConfig{
// Persist // Persist
export interface ReferenceTypePersist { export interface ReferenceTypePersist extends BaseEntityPersist{
id?: Guid;
name: string; name: string;
code: string; code: string;
definition: ReferenceTypeDefinitionPersist; definition: ReferenceTypeDefinitionPersist;

View File

@ -146,11 +146,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
persistEntity(onSuccess?: (response) => void): void { persistEntity(onSuccess?: (response) => void): void {
const formData = this.formService.getValue(this.formGroup.value) as ReferenceTypePersist; const formData = this.formService.getValue(this.formGroup.value) as ReferenceTypePersist;
console.log(formData); console.log(formData);
// this.referenceTypeService.persist(formData) this.referenceTypeService.persist(formData)
// .pipe(takeUntil(this._destroyed)).subscribe( .pipe(takeUntil(this._destroyed)).subscribe(
// complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
// error => this.onCallbackError(error) error => this.onCallbackError(error)
// ); );
} }
formSubmit(): void { formSubmit(): void {

View File

@ -20,10 +20,13 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
public fromModel(item: ReferenceType): ReferenceTypeEditorModel { public fromModel(item: ReferenceType): ReferenceTypeEditorModel {
if (item) { if (item) {
super.fromModel(item); this.id = item.id;
this.name = item.name; this.name = item.name;
this.code = item.code; this.code = item.code;
this.definition = new ReferenceTypeDefinitionEditorModel().fromModel(item.definition); this.definition = new ReferenceTypeDefinitionEditorModel().fromModel(item.definition);
this.hash = item.hash;
if (item.createdAt) { this.createdAt = item.createdAt; }
if (item.updatedAt) { this.updatedAt = item.updatedAt; }
} }
return this; return this;
} }
@ -115,7 +118,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
const baseContext: ValidationContext = new ValidationContext(); const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>(); const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseValidationArray.push({ key: 'externalApiConfig', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}externalApiConfig`)] }); baseValidationArray.push({ key: 'externalApiConfig', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}externalApiConfig`)] });
baseContext.validation = baseValidationArray; baseContext.validation = baseValidationArray;
return baseContext; return baseContext;

View File

@ -94,7 +94,7 @@
<mat-icon>more_horiz</mat-icon> <mat-icon>more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item [routerLink]="['/description-template-type/' + row.id]"> <button mat-menu-item [routerLink]="['/reference-type/' + row.id]">
<mat-icon>edit</mat-icon>{{'REFERENCE-TYPE-LISTING.ACTIONS.EDIT' | translate}} <mat-icon>edit</mat-icon>{{'REFERENCE-TYPE-LISTING.ACTIONS.EDIT' | translate}}
</button> </button>
<button mat-menu-item (click)="deleteType(row.id)"> <button mat-menu-item (click)="deleteType(row.id)">

View File

@ -25,7 +25,7 @@ const routes: Routes = [
permissions: [AppPermission.EditReferenceType] permissions: [AppPermission.EditReferenceType]
}, },
...BreadcrumbService.generateRouteDataConfiguration({ ...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.NEW-DESCRIPTION-TEMPLATE-TYPE' title: 'BREADCRUMBS.NEW-REFERENCE-TYPE'
}) })
} }
}, },
@ -39,7 +39,7 @@ const routes: Routes = [
}, },
data: { data: {
...BreadcrumbService.generateRouteDataConfiguration({ ...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.EDIT-DESCRIPTION-TEMPLATE-TYPE' title: 'BREADCRUMBS.EDIT-REFERENCE-TYPE'
}), }),
authContext: { authContext: {
permissions: [AppPermission.EditReferenceType] permissions: [AppPermission.EditReferenceType]

View File

@ -239,7 +239,9 @@
"NEW-DMP-BLUEPRINT": "New", "NEW-DMP-BLUEPRINT": "New",
"EDIT-DMP-BLUEPRINT": "Edit", "EDIT-DMP-BLUEPRINT": "Edit",
"NEW-DESCRIPTION-TEMPLATES": "New", "NEW-DESCRIPTION-TEMPLATES": "New",
"EDIT-DESCRIPTION-TEMPLATES": "Edit" "EDIT-DESCRIPTION-TEMPLATES": "Edit",
"NEW-REFERENCE-TYPE": "New",
"EDIT-REFERENCE-TYPE": "Edit"
}, },
"COOKIE": { "COOKIE": {
"MESSAGE": "This website uses cookies to enhance the user experience.", "MESSAGE": "This website uses cookies to enhance the user experience.",