diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataFieldsUrlConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataFieldsUrlConfigurationEntity.java deleted file mode 100644 index d7c12dd5c..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataFieldsUrlConfigurationEntity.java +++ /dev/null @@ -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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataUrlConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataUrlConfigurationEntity.java deleted file mode 100644 index f6b06300e..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/DataUrlConfigurationEntity.java +++ /dev/null @@ -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 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 getMergedFields() { -// return mergedFields; -// } -// -// @XmlElementWrapper(name = "merge-fields") -// @XmlElement(name = "field") -// public void setMergedFields(List mergedFields) { -// this.mergedFields = mergedFields; -// } -// -// public String getMergedFieldName() { -// return mergedFieldName; -// } -// -// @XmlElement(name = "merge-field-name") -// public void setMergedFieldName(String mergedFieldName) { -// this.mergedFieldName = mergedFieldName; -// } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeDefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeDefinitionEntity.java index a30ba57f9..8e2993f10 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeDefinitionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeDefinitionEntity.java @@ -11,9 +11,9 @@ public class ReferenceTypeDefinitionEntity { @XmlElement(name = "field") private List fields; - @XmlElementWrapper(name = "urls") - @XmlElement(name = "urlConfig") - private List urlConfig; + @XmlElementWrapper(name = "externalApiConfigs") + @XmlElement(name = "externalApiConfig") + private List externalApiConfig; public List getFields() { return fields; @@ -23,11 +23,11 @@ public class ReferenceTypeDefinitionEntity { this.fields = fields; } - public List getUrlConfig() { - return urlConfig; + public List getExternalApiConfig() { + return externalApiConfig; } - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; + public void setExternalApiConfig(List externalApiConfig) { + this.externalApiConfig = externalApiConfig; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeUrlConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeExternalApiConfigurationEntity.java similarity index 77% rename from dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeUrlConfigurationEntity.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeExternalApiConfigurationEntity.java index 3269cd42a..e97c3411f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeUrlConfigurationEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ReferenceTypeExternalApiConfigurationEntity.java @@ -3,21 +3,19 @@ package eu.eudat.commons.types.referencetype; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; -import jakarta.xml.bind.annotation.XmlRootElement; import java.util.List; -public class ReferenceTypeUrlConfigurationEntity { +public class ReferenceTypeExternalApiConfigurationEntity { private String key; private String label; private Integer ordinal; private String url; - private DataUrlConfigurationEntity data; + private ResultsConfigurationEntity results; private String type; private String paginationPath; private String contentType; - private String funderQuery; - private String firstpage; + private String firstPage; private String requestType = "GET"; private String requestBody = ""; private String filterType = "remote"; @@ -57,18 +55,18 @@ public class ReferenceTypeUrlConfigurationEntity { this.ordinal = ordinal; } - public DataUrlConfigurationEntity getData() { - return data; + public ResultsConfigurationEntity getResults() { + return results; } - @XmlElement(name = "data") - public void setData(DataUrlConfigurationEntity data) { - this.data = data; + @XmlElement(name = "results") + public void setResults(ResultsConfigurationEntity results) { + this.results = results; } public String getPaginationPath() { return paginationPath; } - @XmlElement(name = "paginationpath") + @XmlElement(name = "paginationPath") public void setPaginationPath(String paginationPath) { this.paginationPath = paginationPath; } @@ -84,25 +82,17 @@ public class ReferenceTypeUrlConfigurationEntity { public String getContentType() { return contentType; } - @XmlElement(name = "contenttype") + @XmlElement(name = "contentType") public void setContentType(String contentType) { this.contentType = contentType; } - public String getFunderQuery() { - return funderQuery; - } - @XmlElement(name = "funderQuery") - public void setFunderQuery(String funderQuery) { - this.funderQuery = funderQuery; - } - - public String getFirstpage() { - return firstpage; + public String getFirstPage() { + return firstPage; } @XmlElement(name = "firstPage") - public void setFirstpage(String firstpage) { - this.firstpage = firstpage; + public void setFirstPage(String firstPage) { + this.firstPage = firstPage; } public String getRequestType() { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultFieldsMappingConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultFieldsMappingConfigurationEntity.java new file mode 100644 index 000000000..28ecf655f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultFieldsMappingConfigurationEntity.java @@ -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; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultsConfigurationEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultsConfigurationEntity.java new file mode 100644 index 000000000..84eec895b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/referencetype/ResultsConfigurationEntity.java @@ -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 fieldsMapping; + + public String getResultsArrayPath() { + return resultsArrayPath; + } + + @XmlElement(name = "resultsArrayPath") + public void setResultsArrayPath(String resultsArrayPath) { + this.resultsArrayPath = resultsArrayPath; + } + + public List getFieldsMapping() { + return fieldsMapping; + } + + @XmlElementWrapper + @XmlElement(name = "field") + public void setFieldsMapping(List fieldsMapping) { + this.fieldsMapping = fieldsMapping; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceTypeBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceTypeBuilder.java index 9e18408cc..9379bad25 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceTypeBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/ReferenceTypeBuilder.java @@ -70,6 +70,7 @@ public class ReferenceTypeBuilder extends BaseBuilder { - - private final BuilderFactory builderFactory; - private EnumSet 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 values) { - this.authorize = values; - return this; - } - - @Override - public List build(FieldSet fields, List data) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); - this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || data == null || fields.isEmpty()) - return new ArrayList<>(); - - List models = new ArrayList<>(); - for (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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java index 9a60d203f..2d9fb5b62 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeDefinitionBuilder.java @@ -45,13 +45,13 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder(); 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 models = new ArrayList<>(); for (ReferenceTypeDefinitionEntity d : data) { 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.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); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeExternalApiConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeExternalApiConfigurationBuilder.java new file mode 100644 index 000000000..a7ee48e02 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeExternalApiConfigurationBuilder.java @@ -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 { + + private final BuilderFactory builderFactory; + private EnumSet 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 values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._results)); + FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._auth)); + FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeExternalApiConfiguration._queries)); + + List 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; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeUrlConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeUrlConfigurationBuilder.java deleted file mode 100644 index 433d70b47..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ReferenceTypeUrlConfigurationBuilder.java +++ /dev/null @@ -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 { - - private final BuilderFactory builderFactory; - private EnumSet 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 values) { - this.authorize = values; - return this; - } - - @Override - public List build(FieldSet fields, List data) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); - this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || data == null || fields.isEmpty()) - return new ArrayList<>(); - - FieldSet dataFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._data)); - FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._auth)); - FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._queries)); - - List 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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java new file mode 100644 index 000000000..15b90d2f5 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultFieldsMappingConfigurationBuilder.java @@ -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 { + + private final BuilderFactory builderFactory; + private EnumSet 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 values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + for (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; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/DataUrlConfigurationBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java similarity index 59% rename from dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/DataUrlConfigurationBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java index 94cc06c7c..82d85c927 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/DataUrlConfigurationBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/referencetypedefinition/ResultsConfigurationBuilder.java @@ -1,10 +1,10 @@ package eu.eudat.model.builder.referencetypedefinition; 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.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.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; @@ -20,38 +20,38 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class DataUrlConfigurationBuilder extends BaseBuilder { +public class ResultsConfigurationBuilder extends BaseBuilder { private final BuilderFactory builderFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired - public DataUrlConfigurationBuilder( + public ResultsConfigurationBuilder( ConventionService conventionService, BuilderFactory builderFactory) { - super(conventionService, new LoggerService(LoggerFactory.getLogger(DataUrlConfigurationBuilder.class))); + super(conventionService, new LoggerService(LoggerFactory.getLogger(ResultsConfigurationBuilder.class))); this.builderFactory = builderFactory; } - public DataUrlConfigurationBuilder authorize(EnumSet values) { + public ResultsConfigurationBuilder authorize(EnumSet values) { this.authorize = values; return this; } @Override - public List build(FieldSet fields, List data) throws MyApplicationException { + public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); if (fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); - FieldSet fieldsUrlConfigFields = fields.extractPrefixed(this.asPrefix(DataUrlConfiguration._fieldsUrlConfiguration)); + FieldSet fieldsMappingFields = fields.extractPrefixed(this.asPrefix(ResultsConfiguration._fieldsMapping)); - List models = new ArrayList<>(); - for (DataUrlConfigurationEntity d : data) { - DataUrlConfiguration m = new DataUrlConfiguration(); - if (fields.hasField(this.asIndexer(DataUrlConfiguration._path))) m.setPath(d.getPath()); - if (!fieldsUrlConfigFields.isEmpty() && d.getFieldsUrlConfiguration() != null) { - m.setFieldsUrlConfiguration(this.builderFactory.builder(DataFieldsUrlConfigurationBuilder.class).authorize(this.authorize).build(fieldsUrlConfigFields, d.getFieldsUrlConfiguration())); + List models = new ArrayList<>(); + for (ResultsConfigurationEntity d : data) { + ResultsConfiguration m = new ResultsConfiguration(); + if (fields.hasField(this.asIndexer(ResultsConfiguration._resultsArrayPath))) m.setResultsArrayPath(d.getResultsArrayPath()); + if (!fieldsMappingFields.isEmpty() && d.getFieldsMapping() != null) { + m.setFieldsMapping(this.builderFactory.builder(ResultFieldsMappingConfigurationBuilder.class).authorize(this.authorize).build(fieldsMappingFields, d.getFieldsMapping())); } models.add(m); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeDefinitionCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeDefinitionCensor.java index 07580330b..c9bc73a9c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeDefinitionCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeDefinitionCensor.java @@ -42,8 +42,8 @@ public class ReferenceTypeDefinitionCensor extends BaseCensor { FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._fields)); this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId); - FieldSet urlConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._urlConfig)); - this.censorFactory.censor(ReferenceTypeUrlConfigurationCensor.class).censor(urlConfigFields, userId); + FieldSet externalApiConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._externalApiConfig)); + this.censorFactory.censor(ReferenceTypeExternalApiConfigurationCensor.class).censor(externalApiConfigFields, userId); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeUrlConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeExternalApiConfigurationCensor.java similarity index 66% rename from dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeUrlConfigurationCensor.java rename to dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeExternalApiConfigurationCensor.java index 855374875..3134ae286 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeUrlConfigurationCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ReferenceTypeExternalApiConfigurationCensor.java @@ -3,8 +3,7 @@ package eu.eudat.model.censorship.referencetype; import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; import eu.eudat.model.censorship.BaseCensor; -import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition; -import eu.eudat.model.referencetypedefinition.ReferenceTypeUrlConfiguration; +import eu.eudat.model.referencetypedefinition.ReferenceTypeExternalApiConfiguration; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -19,15 +18,15 @@ import java.util.UUID; @Component @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 CensorFactory censorFactory; - public ReferenceTypeUrlConfigurationCensor(ConventionService conventionService, - AuthorizationService authService, CensorFactory censorFactory) { + public ReferenceTypeExternalApiConfigurationCensor(ConventionService conventionService, + AuthorizationService authService, CensorFactory censorFactory) { super(conventionService); this.authService = authService; this.censorFactory = censorFactory; @@ -40,13 +39,13 @@ public class ReferenceTypeUrlConfigurationCensor extends BaseCensor { this.authService.authorizeForce(Permission.BrowseReferenceType); - FieldSet dataFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._data)); - this.censorFactory.censor(DataUrlConfigurationCensor.class).censor(dataFields, userId); + FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._results)); + 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); - FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._queries)); + FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._queries)); this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataFieldsUrlConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultFieldsMappingConfigurationCensor.java similarity index 78% rename from dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataFieldsUrlConfigurationCensor.java rename to dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultFieldsMappingConfigurationCensor.java index e167be5be..b751b8707 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataFieldsUrlConfigurationCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultFieldsMappingConfigurationCensor.java @@ -16,14 +16,14 @@ import java.util.UUID; @Component @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; - public DataFieldsUrlConfigurationCensor(ConventionService conventionService, - AuthorizationService authService) { + public ResultFieldsMappingConfigurationCensor(ConventionService conventionService, + AuthorizationService authService) { super(conventionService); this.authService = authService; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataUrlConfigurationCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultsConfigurationCensor.java similarity index 74% rename from dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataUrlConfigurationCensor.java rename to dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultsConfigurationCensor.java index bfdaf2b81..e8b4764e7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/DataUrlConfigurationCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/referencetype/ResultsConfigurationCensor.java @@ -3,7 +3,7 @@ package eu.eudat.model.censorship.referencetype; import eu.eudat.authorization.Permission; import eu.eudat.convention.ConventionService; 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.tools.data.censor.CensorFactory; import gr.cite.tools.fieldset.FieldSet; @@ -18,14 +18,14 @@ import java.util.UUID; @Component @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 CensorFactory censorFactory; - public DataUrlConfigurationCensor(ConventionService conventionService, + public ResultsConfigurationCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) { super(conventionService); this.authService = authService; @@ -38,8 +38,8 @@ public class DataUrlConfigurationCensor extends BaseCensor { return; this.authService.authorizeForce(Permission.BrowseReferenceType); - FieldSet fieldsUrlFields = fields.extractPrefixed(this.asIndexerPrefix(DataUrlConfiguration._fieldsUrlConfiguration)); - this.censorFactory.censor(DataFieldsUrlConfigurationCensor.class).censor(fieldsUrlFields, userId); + FieldSet fieldsMappingFields = fields.extractPrefixed(this.asIndexerPrefix(ResultsConfiguration._fieldsMapping)); + this.censorFactory.censor(ResultFieldsMappingConfigurationCensor.class).censor(fieldsMappingFields, userId); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/ReferenceTypePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/ReferenceTypePersist.java index 58ea31ba5..080d876e8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/ReferenceTypePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/ReferenceTypePersist.java @@ -29,6 +29,8 @@ public class ReferenceTypePersist { @Valid private ReferenceTypeDefinitionPersist definition; + private String hash; + public UUID getId() { return id; } @@ -60,4 +62,12 @@ public class ReferenceTypePersist { public void setDefinition(ReferenceTypeDefinitionPersist definition) { this.definition = definition; } + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java index 66418d90b..8e07dc822 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/AuthenticationConfigurationPersist.java @@ -5,16 +5,16 @@ import jakarta.validation.constraints.NotNull; public class AuthenticationConfigurationPersist { @NotNull(message = "{validation.empty}") - private String authUrl; + private String authUrl = null; private String authMethod = "GET"; @NotNull(message = "{validation.empty}") - private String authTokenPath; + private String authTokenPath = null; @NotNull(message = "{validation.empty}") - private String authRequestBody; + private String authRequestBody = null; @NotNull(message = "{validation.empty}") - private String type; + private String type = null; public String getAuthUrl() { return authUrl; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataFieldsUrlConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataFieldsUrlConfigurationPersist.java deleted file mode 100644 index 79f06e2ce..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataFieldsUrlConfigurationPersist.java +++ /dev/null @@ -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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataUrlConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataUrlConfigurationPersist.java deleted file mode 100644 index aeb377cb9..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/DataUrlConfigurationPersist.java +++ /dev/null @@ -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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java index 4d7f87998..e70497d93 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeDefinitionPersist.java @@ -1,6 +1,5 @@ package eu.eudat.model.persist.referencetypedefinition; -import eu.eudat.model.persist.dmpblueprintdefinition.SectionPersist; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; @@ -14,7 +13,7 @@ public class ReferenceTypeDefinitionPersist { @NotNull(message = "{validation.empty}") @Valid - private List urlConfig = null; + private List externalApiConfig = null; public List getFields() { return fields; @@ -24,11 +23,11 @@ public class ReferenceTypeDefinitionPersist { this.fields = fields; } - public List getUrlConfig() { - return urlConfig; + public List getExternalApiConfig() { + return externalApiConfig; } - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; + public void setExternalApiConfig(List externalApiConfig) { + this.externalApiConfig = externalApiConfig; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeUrlConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeExternalApiConfigurationPersist.java similarity index 77% rename from dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeUrlConfigurationPersist.java rename to dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeExternalApiConfigurationPersist.java index e241392c0..60947f85d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeUrlConfigurationPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ReferenceTypeExternalApiConfigurationPersist.java @@ -6,44 +6,41 @@ import jakarta.validation.constraints.NotNull; import java.util.List; -public class ReferenceTypeUrlConfigurationPersist { +public class ReferenceTypeExternalApiConfigurationPersist { @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") - private String key; + private String key = null; @NotNull(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}") @NotEmpty(message = "{validation.empty}") - private Integer ordinal; - - @NotNull(message = "{validation.empty}") - @NotEmpty(message = "{validation.empty}") - private String url; + private String url = null; @Valid - private DataUrlConfigurationPersist data; + private ResultsConfigurationPersist results; @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") - private String type; + private String type = null; @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") - private String paginationPath; + private String paginationPath = null; @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") - private String contentType; - - private String funderQuery; + private String contentType = null; @NotNull(message = "{validation.empty}") @NotEmpty(message = "{validation.empty}") - private String firstpage; + private String firstPage = null; private String requestType = "GET"; private String requestBody = ""; @@ -87,12 +84,12 @@ public class ReferenceTypeUrlConfigurationPersist { this.url = url; } - public DataUrlConfigurationPersist getData() { - return data; + public ResultsConfigurationPersist getResults() { + return results; } - public void setData(DataUrlConfigurationPersist data) { - this.data = data; + public void setResults(ResultsConfigurationPersist results) { + this.results = results; } public String getType() { @@ -119,20 +116,13 @@ public class ReferenceTypeUrlConfigurationPersist { this.contentType = contentType; } - public String getFunderQuery() { - return funderQuery; + + public String getFirstPage() { + return firstPage; } - public void setFunderQuery(String funderQuery) { - this.funderQuery = funderQuery; - } - - public String getFirstpage() { - return firstpage; - } - - public void setFirstpage(String firstpage) { - this.firstpage = firstpage; + public void setFirstPage(String firstPage) { + this.firstPage = firstPage; } public String getRequestType() { diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java new file mode 100644 index 000000000..7616066bb --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultFieldsMappingConfigurationPersist.java @@ -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; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java new file mode 100644 index 000000000..bd35e4051 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/referencetypedefinition/ResultsConfigurationPersist.java @@ -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 fieldsMapping; + + public String getResultsArrayPath() { + return resultsArrayPath; + } + + public void setResultsArrayPath(String resultsArrayPath) { + this.resultsArrayPath = resultsArrayPath; + } + + public List getFieldsMapping() { + return fieldsMapping; + } + + public void setFieldsMapping(List fieldsMapping) { + this.fieldsMapping = fieldsMapping; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataFieldsUrlConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataFieldsUrlConfiguration.java deleted file mode 100644 index d9a48003e..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataFieldsUrlConfiguration.java +++ /dev/null @@ -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; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataUrlConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataUrlConfiguration.java deleted file mode 100644 index 10411ac10..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/DataUrlConfiguration.java +++ /dev/null @@ -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 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 getMergedFields() { -// return mergedFields; -// } -// -// public void setMergedFields(List mergedFields) { -// this.mergedFields = mergedFields; -// } -// -// public String getMergedFieldName() { -// return mergedFieldName; -// } -// -// public void setMergedFieldName(String mergedFieldName) { -// this.mergedFieldName = mergedFieldName; -// } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java index 30363a8a3..67e837625 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeDefinition.java @@ -7,8 +7,8 @@ public class ReferenceTypeDefinition { public final static String _fields = "fields"; private List fields; - public final static String _urlConfig = "urlConfig"; - private List urlConfig; + public final static String _externalApiConfig = "externalApiConfig"; + private List externalApiConfig; public List getFields() { return fields; @@ -18,11 +18,11 @@ public class ReferenceTypeDefinition { this.fields = fields; } - public List getUrlConfig() { - return urlConfig; + public List getExternalApiConfig() { + return externalApiConfig; } - public void setUrlConfig(List urlConfig) { - this.urlConfig = urlConfig; + public void setExternalApiConfig(List externalApiConfig) { + this.externalApiConfig = externalApiConfig; } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeUrlConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeExternalApiConfiguration.java similarity index 85% rename from dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeUrlConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeExternalApiConfiguration.java index d3857e15c..fed65fd8f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeUrlConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ReferenceTypeExternalApiConfiguration.java @@ -3,7 +3,7 @@ package eu.eudat.model.referencetypedefinition; import java.util.List; -public class ReferenceTypeUrlConfiguration { +public class ReferenceTypeExternalApiConfiguration { public final static String _key = "key"; private String key; @@ -18,8 +18,8 @@ public class ReferenceTypeUrlConfiguration { private String url; - public final static String _data = "data"; - private DataUrlConfiguration data; + public final static String _results = "results"; + private ResultsConfiguration results; public final static String _type = "type"; private String type; @@ -30,9 +30,6 @@ public class ReferenceTypeUrlConfiguration { public final static String _contentType = "contentType"; private String contentType; - public final static String _funderQuery = "funderQuery"; - private String funderQuery; - public final static String _firstPage = "firstPage"; private String firstPage; @@ -83,12 +80,12 @@ public class ReferenceTypeUrlConfiguration { this.url = url; } - public DataUrlConfiguration getData() { - return data; + public ResultsConfiguration getResults() { + return results; } - public void setData(DataUrlConfiguration data) { - this.data = data; + public void setResults(ResultsConfiguration results) { + this.results = results; } public String getType() { @@ -115,13 +112,6 @@ public class ReferenceTypeUrlConfiguration { this.contentType = contentType; } - public String getFunderQuery() { - return funderQuery; - } - - public void setFunderQuery(String funderQuery) { - this.funderQuery = funderQuery; - } public String getFirstPage() { return firstPage; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java new file mode 100644 index 000000000..181fe92e5 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultFieldsMappingConfiguration.java @@ -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; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java new file mode 100644 index 000000000..3d52b7d8a --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/referencetypedefinition/ResultsConfiguration.java @@ -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 fieldsMapping; + + public String getResultsArrayPath() { + return resultsArrayPath; + } + + public void setResultsArrayPath(String resultsArrayPath) { + this.resultsArrayPath = resultsArrayPath; + } + + public List getFieldsMapping() { + return fieldsMapping; + } + + public void setFieldsMapping(List fieldsMapping) { + this.fieldsMapping = fieldsMapping; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java index 086f88020..f52602259 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/referencetype/ReferenceTypeServiceImpl.java @@ -111,10 +111,10 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { data.getFields().add(this.buildFieldEntity(fieldPersist)); } } - if (!this.conventionService.isListNullOrEmpty(persist.getUrlConfig())){ - data.setUrlConfig(new ArrayList<>()); - for (ReferenceTypeUrlConfigurationPersist urlConfigPersist: persist.getUrlConfig()) { - data.getUrlConfig().add(this.buildUrlConfigEntity(urlConfigPersist)); + if (!this.conventionService.isListNullOrEmpty(persist.getExternalApiConfig())){ + data.setExternalApiConfig(new ArrayList<>()); + for (ReferenceTypeExternalApiConfigurationPersist externalApiConfigPersist: persist.getExternalApiConfig()) { + data.getExternalApiConfig().add(this.buildExternalApiConfigEntity(externalApiConfigPersist)); } } @@ -131,20 +131,19 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { return data; } - private @NotNull ReferenceTypeUrlConfigurationEntity buildUrlConfigEntity(ReferenceTypeUrlConfigurationPersist persist){ - ReferenceTypeUrlConfigurationEntity data = new ReferenceTypeUrlConfigurationEntity(); + private @NotNull ReferenceTypeExternalApiConfigurationEntity buildExternalApiConfigEntity(ReferenceTypeExternalApiConfigurationPersist persist){ + ReferenceTypeExternalApiConfigurationEntity data = new ReferenceTypeExternalApiConfigurationEntity(); if (persist == null) return data; data.setKey(persist.getKey()); data.setLabel(persist.getLabel()); data.setOrdinal(persist.getOrdinal()); 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.setPaginationPath(persist.getPaginationPath()); data.setContentType(persist.getContentType()); - data.setFunderQuery(persist.getFunderQuery()); - data.setFirstpage(persist.getFirstpage()); + data.setFirstPage(persist.getFirstPage()); data.setRequestType(persist.getRequestType()); data.setRequestBody(persist.getRequestBody()); data.setFilterType(persist.getFilterType()); @@ -159,31 +158,28 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService { return data; } - private @NotNull DataUrlConfigurationEntity buildDataUrlConfigEntity(DataUrlConfigurationPersist persist){ - DataUrlConfigurationEntity data = new DataUrlConfigurationEntity(); + private @NotNull ResultsConfigurationEntity buildResultsConfigEntity(ResultsConfigurationPersist persist){ + ResultsConfigurationEntity data = new ResultsConfigurationEntity(); if (persist == null) return data; - data.setPath(persist.getPath()); - if (persist.getFieldsUrlConfiguration() != null ) data.setFieldsUrlConfiguration(this.buildDataFieldsUrlConfigEntity(persist.getFieldsUrlConfiguration())); + 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 DataFieldsUrlConfigurationEntity buildDataFieldsUrlConfigEntity(DataFieldsUrlConfigurationPersist persist){ - DataFieldsUrlConfigurationEntity data = new DataFieldsUrlConfigurationEntity(); + private @NotNull ResultFieldsMappingConfigurationEntity buildResultFieldsMappingConfigEntity(ResultFieldsMappingConfigurationPersist persist){ + ResultFieldsMappingConfigurationEntity data = new ResultFieldsMappingConfigurationEntity(); if (persist == null) return data; - data.setId(persist.getId()); - data.setName(persist.getName()); - 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()); + data.setCode(persist.getCode()); + data.setResponsePath(persist.getResponsePath()); return data; } diff --git a/dmp-frontend/src/app/core/model/reference-type/reference-type.ts b/dmp-frontend/src/app/core/model/reference-type/reference-type.ts index 5872dae7b..7a23408ee 100644 --- a/dmp-frontend/src/app/core/model/reference-type/reference-type.ts +++ b/dmp-frontend/src/app/core/model/reference-type/reference-type.ts @@ -1,15 +1,12 @@ import { IsActive } from "@app/core/common/enum/is-active.enum"; 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"; -export interface ReferenceType { - id: Guid; +export interface ReferenceType extends BaseEntity{ name: string; code: string; definition: ReferenceTypeDefinition; - isActive: IsActive; - createdAt: Date; - updatedAt: Date; } export interface ReferenceTypeDefinition{ @@ -68,8 +65,7 @@ export interface QueryConfig{ // Persist -export interface ReferenceTypePersist { - id?: Guid; +export interface ReferenceTypePersist extends BaseEntityPersist{ name: string; code: string; definition: ReferenceTypeDefinitionPersist; diff --git a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts index e4ff9be97..b7977580a 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts @@ -146,11 +146,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor void): void { const formData = this.formService.getValue(this.formGroup.value) as ReferenceTypePersist; console.log(formData); - // this.referenceTypeService.persist(formData) - // .pipe(takeUntil(this._destroyed)).subscribe( - // complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), - // error => this.onCallbackError(error) - // ); + this.referenceTypeService.persist(formData) + .pipe(takeUntil(this._destroyed)).subscribe( + complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), + error => this.onCallbackError(error) + ); } formSubmit(): void { diff --git a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.model.ts b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.model.ts index 46a67d689..17d6c60a3 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.model.ts @@ -20,10 +20,13 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen public fromModel(item: ReferenceType): ReferenceTypeEditorModel { if (item) { - super.fromModel(item); + this.id = item.id; this.name = item.name; this.code = item.code; 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; } @@ -115,7 +118,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); 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; return baseContext; diff --git a/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.html b/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.html index 0c2430644..26530010e 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.html @@ -94,7 +94,7 @@ more_horiz -