fix reference type persist and editor
This commit is contained in:
parent
9cff8fb762
commit
e9ae5126f8
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.commons.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||
import jakarta.xml.bind.annotation.XmlEnumValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public enum ReferenceTypeExternalApiHTTPMethodType implements DatabaseEnum<Short> {
|
||||
@XmlEnumValue(value = "0")
|
||||
GET((short) 0),
|
||||
@XmlEnumValue(value = "1")
|
||||
POST((short) 1);
|
||||
private final Short value;
|
||||
|
||||
ReferenceTypeExternalApiHTTPMethodType(Short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final Map<Short, ReferenceTypeExternalApiHTTPMethodType> map = EnumUtils.getEnumValueMap(ReferenceTypeExternalApiHTTPMethodType.class);
|
||||
|
||||
public static ReferenceTypeExternalApiHTTPMethodType of(Short i) {
|
||||
return map.get(i);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.eudat.commons.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||
import jakarta.xml.bind.annotation.XmlEnumValue;
|
||||
import jakarta.xml.bind.annotation.XmlValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public enum ReferenceTypeSourceType implements DatabaseEnum<Short> {
|
||||
@XmlEnumValue(value = "0")
|
||||
API((short) 0),
|
||||
@XmlEnumValue(value = "1")
|
||||
STATIC((short) 1);
|
||||
private final Short value;
|
||||
|
||||
public static class Names {
|
||||
public static final String API = "api";
|
||||
public static final String STATIC = "static";
|
||||
}
|
||||
|
||||
ReferenceTypeSourceType(Short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final Map<Short, ReferenceTypeSourceType> map = EnumUtils.getEnumValueMap(ReferenceTypeSourceType.class);
|
||||
|
||||
public static ReferenceTypeSourceType of(Short i) {
|
||||
return map.get(i);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class AuthenticationConfigurationEntity {
|
||||
|
||||
private String authUrl;
|
||||
private String authMethod = "GET";
|
||||
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||
private String authTokenPath;
|
||||
private String authRequestBody;
|
||||
private String type;
|
||||
|
@ -19,12 +20,12 @@ public class AuthenticationConfigurationEntity {
|
|||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrlMethod")
|
||||
public void setAuthMethod(String authMethod) {
|
||||
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class AuthenticationConfigurationEntity {
|
|||
return authTokenPath;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authTokenJpath")
|
||||
@XmlElement(name = "authTokenPath")
|
||||
public void setAuthTokenPath(String authTokenPath) {
|
||||
this.authTokenPath = authTokenPath;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import eu.eudat.commons.enums.FieldType;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*;
|
||||
import jakarta.xml.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -11,9 +14,12 @@ public class ReferenceTypeDefinitionEntity {
|
|||
@XmlElement(name = "field")
|
||||
private List<ReferenceTypeFieldEntity> fields;
|
||||
|
||||
@XmlElementWrapper(name = "externalApiConfigs")
|
||||
@XmlElement(name = "externalApiConfig")
|
||||
private List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig;
|
||||
@XmlElementWrapper(name = "sources")
|
||||
@XmlElements({
|
||||
@XmlElement(name = ReferenceTypeSourceType.Names.API, type = ReferenceTypeSourceExternalApiConfigurationEntity.class),
|
||||
@XmlElement(name = ReferenceTypeSourceType.Names.STATIC, type = ReferenceTypeSourceStaticOptionConfigurationEntity.class),
|
||||
})
|
||||
private List<ReferenceTypeSourceBaseConfigurationEntity> sources;
|
||||
|
||||
public List<ReferenceTypeFieldEntity> getFields() {
|
||||
return fields;
|
||||
|
@ -23,11 +29,11 @@ public class ReferenceTypeDefinitionEntity {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeExternalApiConfigurationEntity> getExternalApiConfig() {
|
||||
return externalApiConfig;
|
||||
public List<ReferenceTypeSourceBaseConfigurationEntity> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig) {
|
||||
this.externalApiConfig = externalApiConfig;
|
||||
public void setSources(List<ReferenceTypeSourceBaseConfigurationEntity> sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ public class ReferenceTypeFieldEntity {
|
|||
|
||||
@XmlAttribute(name = "code")
|
||||
private String code;
|
||||
|
||||
@XmlAttribute(name = "label")
|
||||
private String label;
|
||||
|
||||
@XmlAttribute(name = "description")
|
||||
private String description;
|
||||
@XmlAttribute(name = "dataType")
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
@ -24,6 +30,21 @@ public class ReferenceTypeFieldEntity {
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ReferenceFieldDataType getDataType() {
|
||||
return dataType;
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public abstract class ReferenceTypeSourceBaseConfigurationEntity {
|
||||
|
||||
private String key;
|
||||
|
||||
private String label;
|
||||
|
||||
private Integer ordinal;
|
||||
private ReferenceTypeSourceType type;
|
||||
|
||||
|
||||
public ReferenceTypeSourceType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@XmlElement(name = "key")
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@XmlElement(name = "label")
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ordinal")
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "type")
|
||||
public void setType(ReferenceTypeSourceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -1,44 +1,25 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import java.util.List;
|
||||
public class ReferenceTypeExternalApiConfigurationEntity {
|
||||
public class ReferenceTypeSourceExternalApiConfigurationEntity extends ReferenceTypeSourceBaseConfigurationEntity {
|
||||
|
||||
private String key;
|
||||
private String label;
|
||||
private Integer ordinal;
|
||||
private String url;
|
||||
private ResultsConfigurationEntity results;
|
||||
private String type;
|
||||
private String paginationPath;
|
||||
private String contentType;
|
||||
private String firstPage;
|
||||
private String requestType = "GET";
|
||||
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||
private String requestBody = "";
|
||||
private String filterType = "remote";
|
||||
private AuthenticationConfigurationEntity auth;
|
||||
|
||||
private List<QueryConfigEntity> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
@XmlElement(name = "key")
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
@XmlElement(name = "label")
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
@ -47,14 +28,6 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
@XmlElement(name = "ordinal")
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public ResultsConfigurationEntity getResults() {
|
||||
return results;
|
||||
}
|
||||
|
@ -71,13 +44,6 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
|||
this.paginationPath = paginationPath;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
@XmlElement(name = "type")
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
|
@ -95,12 +61,12 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
|||
this.firstPage = firstPage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
@XmlElement(name = "request")
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType != null ? requestType : "GET";
|
||||
@XmlElement(name = "requestHttpMethod")
|
||||
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||
this.httpMethod = httpMethod != null ? httpMethod : ReferenceTypeExternalApiHTTPMethodType.GET;
|
||||
}
|
||||
public String getRequestBody() {
|
||||
return requestBody;
|
|
@ -0,0 +1,21 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceStaticOptionConfigurationEntity extends ReferenceTypeSourceBaseConfigurationEntity {
|
||||
|
||||
List<ReferenceTypeStaticOptionEntity> options;
|
||||
|
||||
public List<ReferenceTypeStaticOptionEntity> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "option")
|
||||
public void setOptions(List<ReferenceTypeStaticOptionEntity> options) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class ReferenceTypeStaticOptionEntity {
|
||||
|
||||
private String code;
|
||||
|
||||
private String value;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@XmlElement(name = "code")
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@XmlElement(name = "value")
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceExternalApiConfigurationEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceStaticOptionConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
|
@ -45,13 +49,20 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
|
|||
return new ArrayList<>();
|
||||
|
||||
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields));
|
||||
FieldSet externalApiConfigFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._externalApiConfig));
|
||||
FieldSet sourcesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._sources));
|
||||
|
||||
List<ReferenceTypeDefinition> 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.setExternalApiConfig(this.builderFactory.builder(ReferenceTypeExternalApiConfigurationBuilder.class).authorize(this.authorize).build(externalApiConfigFields, d.getExternalApiConfig()));
|
||||
if (!sourcesFields.isEmpty() && d.getSources() != null) {
|
||||
List<ReferenceTypeSourceExternalApiConfigurationEntity> externalApiConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ReferenceTypeSourceExternalApiConfigurationEntity)x).toList();
|
||||
List<ReferenceTypeSourceStaticOptionConfigurationEntity> staticOptionConfigEntities = d.getSources().stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ReferenceTypeSourceStaticOptionConfigurationEntity)x).toList();
|
||||
m.setSources(new ArrayList<>());
|
||||
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceExternalApiConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, externalApiConfigEntities));
|
||||
m.getSources().addAll(this.builderFactory.builder(ReferenceTypeSourceStaticOptionConfigurationBuilder.class).authorize(this.authorize).build(sourcesFields, staticOptionConfigEntities));
|
||||
m.getSources().sort(Comparator.comparing(ReferenceTypeSourceBaseConfiguration::getOrdinal));
|
||||
}
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -48,6 +48,8 @@ public class ReferenceTypeFieldBuilder extends BaseBuilder<ReferenceTypeField, R
|
|||
for (ReferenceTypeFieldEntity d : data) {
|
||||
ReferenceTypeField m = new ReferenceTypeField();
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._label))) m.setLabel(d.getLabel());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._description))) m.setDescription(d.getDescription());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._dataType))) m.setDataType(d.getDataType());
|
||||
|
||||
models.add(m);
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceBaseConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||
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.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 abstract class ReferenceTypeSourceBaseConfigurationBuilder<Model extends ReferenceTypeSourceBaseConfiguration, Entity extends ReferenceTypeSourceBaseConfigurationEntity> extends BaseBuilder<Model, Entity> {
|
||||
|
||||
protected EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceBaseConfigurationBuilder(
|
||||
ConventionService conventionService,
|
||||
LoggerService logger) {
|
||||
super(conventionService, logger);
|
||||
}
|
||||
|
||||
public ReferenceTypeSourceBaseConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract Model getInstance();
|
||||
|
||||
protected abstract Model buildChild(FieldSet fields, Entity data, Model model);
|
||||
@Override
|
||||
public List<Model> build(FieldSet fields, List<Entity> 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<Model> models = new ArrayList<>();
|
||||
for (Entity d : data) {
|
||||
Model m = this.getInstance();
|
||||
if (fields.hasField(this.asIndexer(Model._key))) m.setKey(d.getKey());
|
||||
if (fields.hasField(this.asIndexer(Model._label))) m.setLabel(d.getLabel());
|
||||
if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||
if (fields.hasField(this.asIndexer(Model._type))) m.setType(d.getType());
|
||||
this.buildChild(fields, d, m);
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceExternalApiConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceExternalApiConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
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 ReferenceTypeSourceExternalApiConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceExternalApiConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceExternalApiConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceExternalApiConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceExternalApiConfiguration getInstance() {
|
||||
return new ReferenceTypeSourceExternalApiConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceExternalApiConfiguration buildChild(FieldSet fields, ReferenceTypeSourceExternalApiConfigurationEntity d, ReferenceTypeSourceExternalApiConfiguration m) {
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._results));
|
||||
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._auth));
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceExternalApiConfiguration._queries));
|
||||
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._url))) m.setUrl(d.getUrl());
|
||||
if (!resultsFields.isEmpty() && d.getResults() != null) {
|
||||
m.setResults(this.builderFactory.builder(ResultsConfigurationBuilder.class).authorize(this.authorize).build(resultsFields, d.getResults()));
|
||||
}
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._type))) m.setType(d.getType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._contentType))) m.setContentType(d.getContentType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._firstPage))) m.setFirstPage(d.getFirstPage());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._httpMethod))) m.setHttpMethod(d.getHttpMethod());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeSourceExternalApiConfiguration._filterType))) m.setFilterType(d.getFilterType());
|
||||
if (!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()));
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeSourceStaticOptionConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceStaticOptionConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
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.EnumSet;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeSourceStaticOptionConfigurationBuilder extends ReferenceTypeSourceBaseConfigurationBuilder<ReferenceTypeSourceStaticOptionConfiguration, ReferenceTypeSourceStaticOptionConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeSourceStaticOptionConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceStaticOptionConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceStaticOptionConfiguration getInstance() {
|
||||
return new ReferenceTypeSourceStaticOptionConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeSourceStaticOptionConfiguration buildChild(FieldSet fields, ReferenceTypeSourceStaticOptionConfigurationEntity d, ReferenceTypeSourceStaticOptionConfiguration m) {
|
||||
FieldSet optionsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeSourceStaticOptionConfiguration._options));
|
||||
|
||||
if (!optionsFields.isEmpty() && d.getOptions() != null) {
|
||||
m.setOptions(this.builderFactory.builder(ReferenceTypeStaticOptionBuilder.class).authorize(this.authorize).build(optionsFields, d.getOptions()));
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeStaticOptionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeStaticOption;
|
||||
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 ReferenceTypeStaticOptionBuilder extends BaseBuilder<ReferenceTypeStaticOption, ReferenceTypeStaticOptionEntity> {
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeStaticOptionBuilder(ConventionService conventionService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeStaticOptionBuilder.class)));
|
||||
}
|
||||
|
||||
public ReferenceTypeStaticOptionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReferenceTypeStaticOption> build(FieldSet fields, List<ReferenceTypeStaticOptionEntity> data) throws MyApplicationException {
|
||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
List<ReferenceTypeStaticOption> models = new ArrayList<>();
|
||||
for (ReferenceTypeStaticOptionEntity d : data) {
|
||||
ReferenceTypeStaticOption m = new ReferenceTypeStaticOption();
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeStaticOption._value))) m.setValue(d.getValue());
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package eu.eudat.model.censorship.referencetype;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
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.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class AuthenticationConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AuthenticationConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
public AuthenticationConfigurationCensor(ConventionService conventionService,
|
||||
AuthorizationService authService) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
|
||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package eu.eudat.model.censorship.referencetype;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
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.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class QueryConfigCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(QueryConfigCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
public QueryConfigCensor(ConventionService conventionService,
|
||||
AuthorizationService authService) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
|
||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
||||
}
|
||||
|
||||
}
|
|
@ -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 externalApiConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._externalApiConfig));
|
||||
this.censorFactory.censor(ReferenceTypeExternalApiConfigurationCensor.class).censor(externalApiConfigFields, userId);
|
||||
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._sources));
|
||||
this.censorFactory.censor(ReferenceTypeSourceBaseConfigurationCensor.class).censor(sourcesFields, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
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.ReferenceTypeExternalApiConfiguration;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
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.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeExternalApiConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeExternalApiConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public ReferenceTypeExternalApiConfigurationCensor(ConventionService conventionService,
|
||||
AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
|
||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
||||
|
||||
FieldSet resultsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._results));
|
||||
this.censorFactory.censor(ResultsConfigurationCensor.class).censor(resultsFields, userId);
|
||||
|
||||
FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._auth));
|
||||
this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId);
|
||||
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeExternalApiConfiguration._queries));
|
||||
this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,13 +16,13 @@ import java.util.UUID;
|
|||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ResultFieldsMappingConfigurationCensor extends BaseCensor {
|
||||
public class ReferenceTypeSourceBaseConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ResultFieldsMappingConfigurationCensor.class));
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeSourceBaseConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
public ResultFieldsMappingConfigurationCensor(ConventionService conventionService,
|
||||
public ReferenceTypeSourceBaseConfigurationCensor(ConventionService conventionService,
|
||||
AuthorizationService authService) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
|
@ -1,45 +0,0 @@
|
|||
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.ResultsConfiguration;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
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.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ResultsConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ResultsConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public ResultsConfigurationCensor(ConventionService conventionService,
|
||||
AuthorizationService authService, CensorFactory censorFactory) {
|
||||
super(conventionService);
|
||||
this.authService = authService;
|
||||
this.censorFactory = censorFactory;
|
||||
}
|
||||
|
||||
public void censor(FieldSet fields, UUID userId) {
|
||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||
if (fields == null || fields.isEmpty())
|
||||
return;
|
||||
|
||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
||||
FieldSet fieldsMappingFields = fields.extractPrefixed(this.asIndexerPrefix(ResultsConfiguration._fieldsMapping));
|
||||
this.censorFactory.censor(ResultFieldsMappingConfigurationCensor.class).censor(fieldsMappingFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ public class ReferenceTypePersist {
|
|||
@Size(max = 100, message = "{validation.largerthanmax}")
|
||||
private String code;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private ReferenceTypeDefinitionPersist definition;
|
||||
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.commons.validation.ValidEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class AuthenticationConfigurationPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authUrl = null;
|
||||
private String authUrl;
|
||||
|
||||
private String authMethod = "GET";
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authTokenPath = null;
|
||||
private String authTokenPath ;
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authRequestBody = null;
|
||||
private String authRequestBody;
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String type = null;
|
||||
private String type;
|
||||
|
||||
public String getAuthUrl() {
|
||||
return authUrl;
|
||||
|
@ -24,11 +27,11 @@ public class AuthenticationConfigurationPersist {
|
|||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,12 @@ import java.util.List;
|
|||
|
||||
public class ReferenceTypeDefinitionPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private List<ReferenceTypeFieldPersist> fields = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig = null;
|
||||
private List<ReferenceTypeSourceBaseConfigurationPersist> sources = null;
|
||||
|
||||
public List<ReferenceTypeFieldPersist> getFields() {
|
||||
return fields;
|
||||
|
@ -23,11 +22,11 @@ public class ReferenceTypeDefinitionPersist {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeExternalApiConfigurationPersist> getExternalApiConfig() {
|
||||
return externalApiConfig;
|
||||
public List<ReferenceTypeSourceBaseConfigurationPersist> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig) {
|
||||
this.externalApiConfig = externalApiConfig;
|
||||
public void setSources(List<ReferenceTypeSourceBaseConfigurationPersist> sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,13 @@ public class ReferenceTypeFieldPersist {
|
|||
@NotEmpty(message = "{validation.empty}")
|
||||
private String code = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String label = null;
|
||||
|
||||
|
||||
private String description;
|
||||
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
@ -23,6 +30,22 @@ public class ReferenceTypeFieldPersist {
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ReferenceFieldDataType getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.validation.ValidEnum;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = "type",
|
||||
visible = true)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = ReferenceTypeSourceExternalApiConfigurationPersist.class, name = "0"),
|
||||
@JsonSubTypes.Type(value = ReferenceTypeSourceStaticOptionConfigurationPersist.class, name = "1")
|
||||
})
|
||||
public abstract class ReferenceTypeSourceBaseConfigurationPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String key = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String label = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private Integer ordinal = null;
|
||||
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private ReferenceTypeSourceType type;
|
||||
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public ReferenceTypeSourceType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ReferenceTypeSourceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -1,48 +1,37 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.validation.ValidEnum;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeExternalApiConfigurationPersist {
|
||||
public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist{
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String key = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String label = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private Integer ordinal = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String url = null;
|
||||
private String url;
|
||||
|
||||
@Valid
|
||||
private ResultsConfigurationPersist results;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String type = null;
|
||||
private String paginationPath;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String paginationPath = null;
|
||||
private String contentType;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String contentType = null;
|
||||
private String firstPage;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String firstPage = null;
|
||||
|
||||
private String requestType = "GET";
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||
private String requestBody = "";
|
||||
private String filterType = "remote";
|
||||
|
||||
|
@ -52,30 +41,6 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
|||
@Valid
|
||||
private List<QueryConfigPersist> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
@ -92,13 +57,6 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
|||
this.results = results;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPaginationPath() {
|
||||
return paginationPath;
|
||||
|
@ -125,12 +83,12 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
|||
this.firstPage = firstPage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType;
|
||||
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
|
@ -0,0 +1,20 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceStaticOptionConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist{
|
||||
|
||||
@Valid
|
||||
List<ReferenceTypeStaticOptionPersist> options;
|
||||
|
||||
public List<ReferenceTypeStaticOptionPersist> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(List<ReferenceTypeStaticOptionPersist> options) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class ReferenceTypeStaticOptionPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String code;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String value;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
|
||||
public class AuthenticationConfiguration {
|
||||
|
||||
|
@ -7,7 +8,7 @@ public class AuthenticationConfiguration {
|
|||
private String authUrl;
|
||||
|
||||
public final static String _authMethod = "authMethod";
|
||||
private String authMethod = "GET";
|
||||
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||
|
||||
public final static String _authTokenPath = "authTokenPath";
|
||||
private String authTokenPath;
|
||||
|
@ -27,12 +28,12 @@ public class AuthenticationConfiguration {
|
|||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ public class ReferenceTypeDefinition {
|
|||
public final static String _fields = "fields";
|
||||
private List<ReferenceTypeField> fields;
|
||||
|
||||
public final static String _externalApiConfig = "externalApiConfig";
|
||||
private List<ReferenceTypeExternalApiConfiguration> externalApiConfig;
|
||||
public final static String _sources = "sources";
|
||||
private List<ReferenceTypeSourceBaseConfiguration> sources;
|
||||
|
||||
public List<ReferenceTypeField> getFields() {
|
||||
return fields;
|
||||
|
@ -18,11 +18,11 @@ public class ReferenceTypeDefinition {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeExternalApiConfiguration> getExternalApiConfig() {
|
||||
return externalApiConfig;
|
||||
public List<ReferenceTypeSourceBaseConfiguration> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfiguration> externalApiConfig) {
|
||||
this.externalApiConfig = externalApiConfig;
|
||||
public void setSources(List<ReferenceTypeSourceBaseConfiguration> sources) {
|
||||
this.sources = sources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,12 @@ public class ReferenceTypeField {
|
|||
public final static String _code = "code";
|
||||
private String code;
|
||||
|
||||
public final static String _label = "label";
|
||||
private String label;
|
||||
|
||||
public final static String _description = "description";
|
||||
private String description;
|
||||
|
||||
public final static String _dataType = "dataType";
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
@ -27,4 +33,19 @@ public class ReferenceTypeField {
|
|||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
|
||||
|
||||
public abstract class ReferenceTypeSourceBaseConfiguration {
|
||||
|
||||
public final static String _key = "key";
|
||||
private String key;
|
||||
|
||||
public final static String _label = "label";
|
||||
private String label;
|
||||
|
||||
public final static String _ordinal = "ordinal";
|
||||
private Integer ordinal;
|
||||
|
||||
public final static String _type = "type";
|
||||
private ReferenceTypeSourceType type;
|
||||
|
||||
public ReferenceTypeSourceType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ReferenceTypeSourceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
|
@ -1,29 +1,18 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeExternalApiConfiguration {
|
||||
|
||||
public final static String _key = "key";
|
||||
private String key;
|
||||
|
||||
public final static String _label = "label";
|
||||
private String label;
|
||||
|
||||
public final static String _ordinal = "ordinal";
|
||||
private Integer ordinal;
|
||||
public class ReferenceTypeSourceExternalApiConfiguration extends ReferenceTypeSourceBaseConfiguration {
|
||||
|
||||
public final static String _url = "url";
|
||||
private String url;
|
||||
|
||||
private String url;
|
||||
|
||||
public final static String _results = "results";
|
||||
private ResultsConfiguration results;
|
||||
|
||||
public final static String _type = "type";
|
||||
private String type;
|
||||
|
||||
public final static String _paginationPath = "paginationPath";
|
||||
private String paginationPath;
|
||||
|
||||
|
@ -33,8 +22,8 @@ public class ReferenceTypeExternalApiConfiguration {
|
|||
public final static String _firstPage = "firstPage";
|
||||
private String firstPage;
|
||||
|
||||
public final static String _requestType = "requestType";
|
||||
private String requestType = "GET";
|
||||
public final static String _httpMethod = "httpMethod";
|
||||
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||
|
||||
public final static String _requestBody = "requestBody";
|
||||
private String requestBody = "";
|
||||
|
@ -48,30 +37,6 @@ public class ReferenceTypeExternalApiConfiguration {
|
|||
public final static String _queries = "queries";
|
||||
private List<QueryConfig> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
@ -88,14 +53,6 @@ public class ReferenceTypeExternalApiConfiguration {
|
|||
this.results = results;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPaginationPath() {
|
||||
return paginationPath;
|
||||
}
|
||||
|
@ -121,12 +78,12 @@ public class ReferenceTypeExternalApiConfiguration {
|
|||
this.firstPage = firstPage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType;
|
||||
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeSourceStaticOptionConfiguration extends ReferenceTypeSourceBaseConfiguration {
|
||||
|
||||
public final static String _options = "options";
|
||||
List<ReferenceTypeStaticOption> options;
|
||||
|
||||
public List<ReferenceTypeStaticOption> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(List<ReferenceTypeStaticOption> options) {
|
||||
this.options = options;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
public class ReferenceTypeStaticOption {
|
||||
|
||||
public final static String _code = "code";
|
||||
private String code;
|
||||
|
||||
public final static String _value = "value";
|
||||
private String value;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package eu.eudat.model.referencetypedefinition;
|
|||
|
||||
public class ResultFieldsMappingConfiguration {
|
||||
|
||||
public final static String _code = "id";
|
||||
public final static String _code = "code";
|
||||
private String code;
|
||||
|
||||
public final static String _responsePath = "responsePath";
|
||||
|
|
|
@ -38,6 +38,8 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
|
||||
private Collection<UUID> excludedIds;
|
||||
|
||||
private Collection<UUID> referenceTypeIds;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
public ReferenceQuery like(String value) {
|
||||
|
@ -120,6 +122,21 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery referenceTypeIds(UUID value) {
|
||||
this.referenceTypeIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery referenceTypeIds(UUID... value) {
|
||||
this.referenceTypeIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery referenceTypeIds(Collection<UUID> values) {
|
||||
this.referenceTypeIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReferenceDefinitionSearchLookup extends Lookup {
|
||||
|
||||
private String like;
|
||||
|
||||
private UUID referenceTypeId;
|
||||
|
||||
private String key;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public UUID getReferenceTypeId() {
|
||||
return referenceTypeId;
|
||||
}
|
||||
|
||||
public void setReferenceTypeId(UUID referenceTypeId) {
|
||||
this.referenceTypeId = referenceTypeId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public ReferenceQuery enrich(QueryFactory queryFactory) {
|
||||
ReferenceQuery query = queryFactory.query(ReferenceQuery.class);
|
||||
if (this.referenceTypeId != null) query.referenceTypeIds(this.referenceTypeId);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.types.referencetype.*;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
|
@ -111,10 +112,10 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||
}
|
||||
}
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getExternalApiConfig())){
|
||||
data.setExternalApiConfig(new ArrayList<>());
|
||||
for (ReferenceTypeExternalApiConfigurationPersist externalApiConfigPersist: persist.getExternalApiConfig()) {
|
||||
data.getExternalApiConfig().add(this.buildExternalApiConfigEntity(externalApiConfigPersist));
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getSources())){
|
||||
data.setSources(new ArrayList<>());
|
||||
for (ReferenceTypeSourceBaseConfigurationPersist sourceBaseConfigPersist: persist.getSources()) {
|
||||
data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,34 +127,59 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
if (persist == null) return data;
|
||||
|
||||
data.setCode(persist.getCode());
|
||||
data.setLabel(persist.getLabel());
|
||||
data.setDescription(persist.getDescription());
|
||||
data.setDataType(persist.getDataType());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ReferenceTypeExternalApiConfigurationEntity buildExternalApiConfigEntity(ReferenceTypeExternalApiConfigurationPersist persist){
|
||||
ReferenceTypeExternalApiConfigurationEntity data = new ReferenceTypeExternalApiConfigurationEntity();
|
||||
if (persist == null) return data;
|
||||
private @NotNull ReferenceTypeSourceBaseConfigurationEntity buildSourceBaseConfigEntity(ReferenceTypeSourceBaseConfigurationPersist persist){
|
||||
if (persist == null) return new ReferenceTypeSourceExternalApiConfigurationEntity();
|
||||
|
||||
ReferenceTypeSourceBaseConfigurationEntity data;
|
||||
|
||||
if (ReferenceTypeSourceType.API.equals(persist.getType())) {
|
||||
ReferenceTypeSourceExternalApiConfigurationEntity apiEntity = new ReferenceTypeSourceExternalApiConfigurationEntity();
|
||||
|
||||
apiEntity.setUrl(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getUrl());
|
||||
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults() != null ) {
|
||||
apiEntity.setResults(this.buildResultsConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getResults()));
|
||||
}
|
||||
apiEntity.setPaginationPath(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getPaginationPath());
|
||||
apiEntity.setContentType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getContentType());
|
||||
apiEntity.setFirstPage(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFirstPage());
|
||||
apiEntity.setHttpMethod(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getHttpMethod());
|
||||
apiEntity.setRequestBody(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getRequestBody());
|
||||
apiEntity.setFilterType(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getFilterType());
|
||||
if (((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth() != null) {
|
||||
apiEntity.setAuth(this.buildAuthConfigEntity(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getAuth()));
|
||||
}
|
||||
if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries())){
|
||||
apiEntity.setQueries(new ArrayList<>());
|
||||
for (QueryConfigPersist queryConfigPersist: ((ReferenceTypeSourceExternalApiConfigurationPersist) persist).getQueries()) {
|
||||
apiEntity.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
|
||||
}
|
||||
}
|
||||
|
||||
data = apiEntity;
|
||||
}else {
|
||||
ReferenceTypeSourceStaticOptionConfigurationEntity staticEntity = new ReferenceTypeSourceStaticOptionConfigurationEntity();
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions())){
|
||||
staticEntity.setOptions(new ArrayList<>());
|
||||
for (ReferenceTypeStaticOptionPersist optionPersist: ((ReferenceTypeSourceStaticOptionConfigurationPersist) persist).getOptions()) {
|
||||
staticEntity.getOptions().add(this.buildStaticOptionEntity(optionPersist));
|
||||
}
|
||||
}
|
||||
|
||||
data = staticEntity;
|
||||
}
|
||||
|
||||
data.setType(persist.getType());
|
||||
data.setKey(persist.getKey());
|
||||
data.setLabel(persist.getLabel());
|
||||
data.setOrdinal(persist.getOrdinal());
|
||||
data.setUrl(persist.getUrl());
|
||||
if (persist.getResults() != null ) data.setResults(this.buildResultsConfigEntity(persist.getResults()));
|
||||
data.setType(persist.getType());
|
||||
data.setPaginationPath(persist.getPaginationPath());
|
||||
data.setContentType(persist.getContentType());
|
||||
data.setFirstPage(persist.getFirstPage());
|
||||
data.setRequestType(persist.getRequestType());
|
||||
data.setRequestBody(persist.getRequestBody());
|
||||
data.setFilterType(persist.getFilterType());
|
||||
if (persist.getAuth() != null) data.setAuth(this.buildAuthConfigEntity(persist.getAuth()));
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getQueries())){
|
||||
data.setQueries(new ArrayList<>());
|
||||
for (QueryConfigPersist queryConfigPersist: persist.getQueries()) {
|
||||
data.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -188,6 +214,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setAuthUrl(persist.getAuthUrl());
|
||||
data.setAuthMethod(persist.getAuthMethod());
|
||||
data.setAuthRequestBody(persist.getAuthRequestBody());
|
||||
data.setType(persist.getType());
|
||||
|
@ -208,6 +235,16 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ReferenceTypeStaticOptionEntity buildStaticOptionEntity(ReferenceTypeStaticOptionPersist persist){
|
||||
ReferenceTypeStaticOptionEntity data = new ReferenceTypeStaticOptionEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setCode(persist.getCode());
|
||||
data.setValue(persist.getValue());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
logger.debug("deleting : {}", id);
|
||||
|
|
|
@ -17,6 +17,7 @@ import eu.eudat.model.persist.ReferencePersist;
|
|||
import eu.eudat.model.result.QueryResult;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||
import eu.eudat.query.lookup.ReferenceLookup;
|
||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
@ -110,6 +111,14 @@ public class ReferenceController extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@PostMapping("search-with-db-definition")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||
|
||||
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Reference get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Reference.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
package eu.eudat.logic.services.references;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.reference.FieldEntity;
|
||||
import eu.eudat.commons.types.referencetype.*;
|
||||
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||
import eu.eudat.logic.proxy.config.FetchStrategy;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.logic.proxy.fetching.entities.Results;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.builder.ReferenceBuilder;
|
||||
|
@ -24,6 +34,8 @@ import eu.eudat.model.persist.ReferencePersist;
|
|||
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
|
@ -43,6 +55,15 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
@ -68,6 +89,8 @@ public class ReferenceService {
|
|||
private final XmlHandlingService xmlHandlingService;
|
||||
private final ReferenceTypeProperties referenceTypeProperties;
|
||||
|
||||
private final WebClient client;
|
||||
|
||||
public ReferenceService(ApiContext apiContext,
|
||||
UserScope userScope,
|
||||
RemoteFetcher remoteFetcher,
|
||||
|
@ -92,6 +115,11 @@ public class ReferenceService {
|
|||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
this.referenceTypeProperties = referenceTypeProperties;
|
||||
this.client = WebClient.builder().codecs(clientCodecConfigurer -> {
|
||||
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
|
||||
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
|
||||
}
|
||||
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||
}
|
||||
|
||||
public Reference persist(ReferencePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException {
|
||||
|
@ -256,4 +284,175 @@ public class ReferenceService {
|
|||
// return list;
|
||||
// }
|
||||
|
||||
public List<Reference> searchReferenceWithDefinition(ReferenceDefinitionSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
|
||||
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).ids(lookup.getReferenceTypeId());
|
||||
List<ReferenceTypeEntity> datas = query.collectAs(lookup.getProject());
|
||||
if (datas.size() != 1 ){
|
||||
return null;
|
||||
}
|
||||
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, datas.get(0).getDefinition());
|
||||
List<Map<String, String>> remoteRepos = this.getAll(definition.getSources());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getAll ( List<ReferenceTypeSourceBaseConfigurationEntity> sources){
|
||||
List<Map<String, String>> results = new LinkedList<>();
|
||||
|
||||
if (sources == null || sources.isEmpty()) {
|
||||
return results;
|
||||
}
|
||||
|
||||
sources.sort(Comparator.comparing(ReferenceTypeSourceBaseConfigurationEntity::getOrdinal));
|
||||
List<ReferenceTypeSourceExternalApiConfigurationEntity> apiSources = sources.stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ReferenceTypeSourceExternalApiConfigurationEntity)x).toList();
|
||||
|
||||
apiSources.forEach(source -> {
|
||||
try {
|
||||
String auth = null;
|
||||
if (source.getAuth()!= null) {
|
||||
//auth = this.getAuthentication(source.getAuth());
|
||||
}
|
||||
results.addAll(getAllResultsFromUrl(source.getUrl(), null, source.getResults(), source.getPaginationPath(), null, source.getLabel(), source.getKey(), source.getContentType(), source.getFirstPage(), source.getRequestBody(), source.getHttpMethod(), source.getFilterType(), source.getQueries(), auth));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private String getAuthentication(AuthenticationConfigurationEntity authenticationConfiguration) {
|
||||
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod().name());
|
||||
Map<String, Object> response = this.client.method(method).uri(authenticationConfiguration.getAuthUrl())
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
|
||||
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
|
||||
})).block();
|
||||
|
||||
|
||||
|
||||
return authenticationConfiguration.getType() + " " + response.get(authenticationConfiguration.getAuthTokenPath());
|
||||
}
|
||||
|
||||
private String parseBodyString(String bodyString) {
|
||||
String finalBodyString = bodyString;
|
||||
if (bodyString.contains("{env:")) {
|
||||
int index = bodyString.indexOf("{env: ");
|
||||
while (index >= 0) {
|
||||
int endIndex = bodyString.indexOf("}", index + 6);
|
||||
String envName = bodyString.substring(index + 6, endIndex);
|
||||
finalBodyString = finalBodyString.replace("{env: " + envName + "}", System.getenv(envName));
|
||||
index = bodyString.indexOf("{env: ", index + 6);
|
||||
}
|
||||
}
|
||||
return finalBodyString;
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getAllResultsFromUrl(String urlPath, FetchStrategy fetchStrategy, final ResultsConfigurationEntity jsonResultsPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, ReferenceTypeExternalApiHTTPMethodType requestType, String filterType, List<QueryConfigEntity> queries, String auth) throws Exception {
|
||||
Set<Integer> pages = new HashSet<>();
|
||||
|
||||
//String replacedPath = replaceCriteriaOnUrl(urlPath, externalUrlCriteria, firstPage, queries);
|
||||
String replacedUrlPath = urlPath;
|
||||
//String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
||||
String replacedUrlBody = requestBody;
|
||||
|
||||
Results results = getResultsFromUrl(replacedUrlPath, jsonResultsPath, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth);
|
||||
if(results != null) {
|
||||
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
||||
results.setResults(results.getResults().stream()
|
||||
.filter(r -> r.get("name").toLowerCase().contains(externalUrlCriteria.getLike().toLowerCase()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
if (fetchStrategy == FetchStrategy.FIRST)
|
||||
return results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
|
||||
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
||||
pages.add(i);
|
||||
|
||||
//Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
||||
Long maxResults = Long.valueOf(1000);
|
||||
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
|
||||
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||
|
||||
Optional<Results> optionalResults = pages.parallelStream()
|
||||
.map(page -> getResultsFromUrl(urlPath + "&page=" + page, jsonResultsPath, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth))
|
||||
.filter(Objects::nonNull)
|
||||
.reduce((result1, result2) -> {
|
||||
result1.getResults().addAll(result2.getResults());
|
||||
return result1;
|
||||
});
|
||||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
||||
remainingResults.getResults().addAll(results.getResults());
|
||||
|
||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
}
|
||||
else {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
protected Results getResultsFromUrl(String urlString, ResultsConfigurationEntity jsonResultsPath, String jsonPaginationPath, String contentType, String requestBody, ReferenceTypeExternalApiHTTPMethodType httpMethod, String auth) {
|
||||
|
||||
try {
|
||||
ResponseEntity<String> response;
|
||||
JsonNode jsonBody = new ObjectMapper().readTree(requestBody);
|
||||
|
||||
response = this.client.method(HttpMethod.valueOf(httpMethod.name())).uri(urlString).headers(httpHeaders -> {
|
||||
if (contentType != null && !contentType.isEmpty()) {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
|
||||
httpHeaders.setContentType(MediaType.valueOf(contentType));
|
||||
}
|
||||
if (auth != null) {
|
||||
httpHeaders.set("Authorization", auth);
|
||||
}
|
||||
}).bodyValue(jsonBody).retrieve().toEntity(String.class).block();
|
||||
if (response.getStatusCode() == HttpStatus.OK) { // success
|
||||
Results results = new Results();
|
||||
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||
results = this.getFromJson(jsonContext, jsonResultsPath);
|
||||
}
|
||||
|
||||
|
||||
if (results.getPagination().size() == 0) {
|
||||
results.getPagination().put("pages", 1);
|
||||
results.getPagination().put("count", results.getResults().size());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error(exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Results getFromJson(DocumentContext jsonContext, ResultsConfigurationEntity jsonResultsPath) {
|
||||
return new Results(parseData(jsonContext, jsonResultsPath),
|
||||
new HashMap<>(1, 1));
|
||||
}
|
||||
|
||||
|
||||
private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity jsonResultsPath) {
|
||||
List <Map<String, String>> rawData = jsonContext.read(jsonResultsPath.getResultsArrayPath());
|
||||
List<Map<String, String>> parsedData = new ArrayList<>();
|
||||
rawData.forEach(stringObjectMap -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
jsonResultsPath.getFieldsMapping().forEach(field ->{
|
||||
String pathValue = field.getResponsePath();
|
||||
if (stringObjectMap.containsKey(pathValue)){
|
||||
map.put(field.getCode(), stringObjectMap.get(pathValue));
|
||||
parsedData.add(map);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
return parsedData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export enum ReferenceTypeExternalApiHTTPMethodType {
|
||||
GET = 0,
|
||||
POST = 1
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export enum ReferenceTypeSourceType {
|
||||
API = 0,
|
||||
STATIC = 1
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
||||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
||||
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
||||
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export interface ReferenceType extends BaseEntity{
|
||||
name: string;
|
||||
|
@ -11,26 +11,31 @@ export interface ReferenceType extends BaseEntity{
|
|||
|
||||
export interface ReferenceTypeDefinition{
|
||||
fields: ReferenceTypeField[];
|
||||
externalApiConfig: ReferenceTypeExternalApiConfiguration[];
|
||||
sources: ReferenceTypeSourceBaseConfiguration[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeField {
|
||||
code: string;
|
||||
label: string;
|
||||
description: string;
|
||||
dataType: ReferenceFieldDataType;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeExternalApiConfiguration {
|
||||
export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceStaticOptionConfiguration{
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfiguration{
|
||||
url: string;
|
||||
results: ResultsConfiguration;
|
||||
type: string;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
//funderQuery?: string;
|
||||
firstPage: string;
|
||||
requestType?: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfiguration;
|
||||
|
@ -50,7 +55,7 @@ export interface ResultFieldsMappingConfiguration{
|
|||
|
||||
export interface AuthenticationConfiguration{
|
||||
authUrl: string;
|
||||
authMethod: string;
|
||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
|
@ -63,6 +68,16 @@ export interface QueryConfig{
|
|||
ordinal: number;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfiguration{
|
||||
options: ReferenceTypeStaticOption[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeStaticOption{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
|
||||
// Persist
|
||||
|
||||
export interface ReferenceTypePersist extends BaseEntityPersist{
|
||||
|
@ -72,28 +87,33 @@ export interface ReferenceTypePersist extends BaseEntityPersist{
|
|||
}
|
||||
|
||||
export interface ReferenceTypeDefinitionPersist{
|
||||
fields: ReferenceTypeFieldPersist[];
|
||||
externalApiConfig: ReferenceTypeExternalApiConfigurationPersist[];
|
||||
fields?: ReferenceTypeFieldPersist[];
|
||||
sources: ReferenceTypeSourceBaseConfigurationPersist[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeFieldPersist {
|
||||
code: string;
|
||||
label: string;
|
||||
description: string;
|
||||
dataType: ReferenceFieldDataType;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeExternalApiConfigurationPersist {
|
||||
export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTypeSourceExternalApiConfigurationPersist, ReferenceTypeSourceStaticOptionConfigurationPersist{
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
||||
url: string;
|
||||
results: ResultsConfigurationPersist;
|
||||
type: string;
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
// toDo move to a general query
|
||||
//funderQuery?: string;
|
||||
firstPage: string;
|
||||
requestType?: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationPersist;
|
||||
|
@ -114,7 +134,7 @@ export interface ResultFieldsMappingConfigurationPersist{
|
|||
|
||||
export interface AuthenticationConfigurationPersist{
|
||||
authUrl: string;
|
||||
authMethod: string;
|
||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
authTokenPath: string;
|
||||
authRequestBody: string;
|
||||
type: string;
|
||||
|
@ -126,3 +146,12 @@ export interface QueryConfigPersist{
|
|||
value: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
|
||||
options: ReferenceTypeStaticOptionPersist[];
|
||||
}
|
||||
|
||||
export interface ReferenceTypeStaticOptionPersist{
|
||||
code: string;
|
||||
value: string;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Lookup } from "@common/model/lookup";
|
||||
import { ReferenceType } from "../common/enum/reference-type";
|
||||
import { Guid } from "@common/types/guid";
|
||||
|
||||
export class ReferenceSearchLookup extends Lookup{
|
||||
like: string;
|
||||
|
@ -10,3 +11,14 @@ export class ReferenceSearchLookup extends Lookup{
|
|||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class ReferenceSearchDefinitionLookup extends Lookup{
|
||||
like: string;
|
||||
referenceTypeId: Guid;
|
||||
key: string;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import { nameof } from 'ts-simple-nameof';
|
|||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
|
||||
import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
|
||||
@Injectable()
|
||||
export class ReferenceService {
|
||||
|
@ -38,6 +38,11 @@ export class ReferenceService {
|
|||
return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
searchWithDefinition(q: ReferenceSearchDefinitionLookup): Observable<Reference[]> {
|
||||
const url = `${this.apiBase}/search-with-db-definition`;
|
||||
return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
getSingle(id: Guid, reqFields: string[] = []): Observable<Reference> {
|
||||
const url = `${this.apiBase}/${id}`;
|
||||
const options = { params: { f: reqFields } };
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
<div class="col-auto d-flex">
|
||||
<mat-card-title>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
|
||||
</div>
|
||||
<!-- <div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></div> -->
|
||||
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove field" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
|
||||
|
@ -92,6 +91,22 @@
|
|||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="label" [formControl]="field.get('label')" required>
|
||||
<mat-error *ngIf="field.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Description</mat-label>
|
||||
<input matInput type="text" name="description" [formControl]="field.get('description')">
|
||||
<mat-error *ngIf="field.get('description').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
|
@ -104,7 +119,7 @@
|
|||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
|
||||
<mat-select name="dataType" [formControl]="field.get('dataType')">
|
||||
<mat-option *ngFor="let dataType of visiblesDataTypes" [value] = "dataType.type">
|
||||
<mat-option *ngFor="let dataType of visibleDataTypes" [value] = "dataType.type">
|
||||
{{dataType.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
@ -124,167 +139,180 @@
|
|||
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-header>
|
||||
<mat-card-title *ngIf="isNew">Reference Type External API Configuration</mat-card-title>
|
||||
<button mat-button class="action-btn" type="button" (click)="addExternalApiConfig()" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CONFIG' | translate}}</button>
|
||||
<mat-card-title *ngIf="isNew">Reference Type Source</mat-card-title>
|
||||
<mat-card-header>
|
||||
<button mat-button class="action-btn" type="button" (click)="addSource()" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-CONFIG' | translate}}</button>
|
||||
</mat-card-header>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<form (ngSubmit)="formSubmit()" [formGroup]="formGroup" *ngIf="formGroup">
|
||||
<!-- External Api Config Info -->
|
||||
<div class="col-12" cdkDropList (cdkDropListDropped)="dropExternalApiConfig($event)">
|
||||
<div *ngFor="let externalApiConfig of formGroup.get('definition').get('externalApiConfig').controls; let externalApiConfigIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div *ngFor="let source of formGroup.get('definition').get('sources').controls; let sourceIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<mat-card-content>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<mat-card-title>{{'REFERENCE-TYPE-EDITOR.FIELDS.EXTERNAL-API-CONFIGURATION' | translate}} {{externalApiConfigIndex + 1}}</mat-card-title>
|
||||
<mat-card-title>{{'REFERENCE-TYPE-EDITOR.FIELDS.SOURCE-CONFIGURATION' | translate}} {{sourceIndex + 1}}</mat-card-title>
|
||||
</div>
|
||||
<!-- <div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></div> -->
|
||||
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove External API Configiguration" (click)="removeExternalApiConfig(externalApiConfigIndex)" [disabled]="formGroup.disabled">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove Source Configiguration" (click)="removeSource(sourceIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row" >
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||
<input matInput type="text" name="key" [formControl]="externalApiConfig.get('key')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('key').hasError('required')">
|
||||
<input matInput type="text" name="key" [formControl]="source.get('key')" required>
|
||||
<mat-error *ngIf="source.get('key').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="label" [formControl]="externalApiConfig.get('label')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('label').hasError('required')">
|
||||
<input matInput type="text" name="label" [formControl]="source.get('label')" required>
|
||||
<mat-error *ngIf="source.get('label').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="ordinal" [formControl]="externalApiConfig.get('ordinal')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('ordinal').hasError('required')">
|
||||
<input matInput type="text" name="ordinal" [formControl]="source.get('ordinal')" required>
|
||||
<mat-error *ngIf="source.get('ordinal').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Source Type</mat-label>
|
||||
<mat-select name="type" [formControl]="source.get('type')" required>
|
||||
<mat-option *ngFor="let vis of visibleSourceTypes" [value] = "vis.type">
|
||||
{{vis.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="source.get('type').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="row" *ngIf="source.get('type').value == 0">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="ordinal" [formControl]="externalApiConfig.get('url')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('url').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Type</mat-label>
|
||||
<input matInput type="text" name="type" [formControl]="externalApiConfig.get('type')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('type').hasError('required')">
|
||||
<input matInput type="text" name="ordinal" [formControl]="source.get('url')">
|
||||
<mat-error *ngIf="source.get('url').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.PAGINATION-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="paginationPath" [formControl]="externalApiConfig.get('paginationPath')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('paginationPath').hasError('required')">
|
||||
<input matInput type="text" name="paginationPath" [formControl]="source.get('paginationPath')">
|
||||
<mat-error *ngIf="source.get('paginationPath').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Content Type</mat-label>
|
||||
<input matInput type="text" name="contentType" [formControl]="externalApiConfig.get('contentType')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('contentType').hasError('required')">
|
||||
<input matInput type="text" name="contentType" [formControl]="source.get('contentType')">
|
||||
<mat-error *ngIf="source.get('contentType').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>First Page</mat-label>
|
||||
<input matInput type="text" name="firstPage" [formControl]="externalApiConfig.get('firstPage')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('firstPage').hasError('required')">
|
||||
<input matInput type="text" name="firstPage" [formControl]="source.get('firstPage')">
|
||||
<mat-error *ngIf="source.get('firstPage').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Request Type</mat-label>
|
||||
<mat-select name="requestType" [formControl]="externalApiConfig.get('requestType')" required>
|
||||
<mat-option *ngFor="let request of requestTypes" [value] = "request">
|
||||
{{request}}
|
||||
<mat-label>HTTP Method</mat-label>
|
||||
<mat-select name="httpMethod" [formControl]="source.get('httpMethod')">
|
||||
<mat-option *ngFor="let vis of visibleHTTPMethodTypes" [value] = "vis.type">
|
||||
{{vis.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="externalApiConfig.get('requestType').hasError('required')">
|
||||
<mat-error *ngIf="source.get('httpMethod').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field *ngIf="externalApiConfig.get('requestType').value == 'POST'" class="w-100">
|
||||
<mat-form-field *ngIf="source.get('httpMethod').value == 1" class="w-100">
|
||||
<mat-label>Request Body</mat-label>
|
||||
<input matInput type="text" name="requestBody" [formControl]="externalApiConfig.get('requestBody')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('requestBody').hasError('required')">
|
||||
<input matInput type="text" name="requestBody" [formControl]="source.get('requestBody')">
|
||||
<mat-error *ngIf="source.get('requestBody').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Filter Type</mat-label>
|
||||
<input matInput type="text" name="filterType" [formControl]="externalApiConfig.get('filterType')">
|
||||
<mat-error *ngIf="externalApiConfig.get('filterType').hasError('required')">
|
||||
<input matInput type="text" name="filterType" [formControl]="source.get('filterType')">
|
||||
<mat-error *ngIf="source.get('filterType').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<!-- Results info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}
|
||||
<button mat-button type="button" (click)="addFieldMapping(externalApiConfigIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-FIELD' | translate}}</button>
|
||||
</h3>
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.RESULTS' | translate}}</h3>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Results Path</mat-label>
|
||||
<input matInput type="text" name="resultsArrayPath" [formControl]="externalApiConfig.get('results').get('resultsArrayPath')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('results').get('resultsArrayPath').hasError('required')">
|
||||
<input matInput type="text" name="resultsArrayPath" [formControl]="source.get('results').get('resultsArrayPath')">
|
||||
<mat-error *ngIf="source.get('results').get('resultsArrayPath').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- fields mapping -->
|
||||
<div class="col-12" cdkDropList (cdkDropListDropped)="dropFieldsMapping($event)">
|
||||
<div *ngFor="let field of externalApiConfig.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<div *ngFor="let field of source.get('results').get('fieldsMapping').controls; let fieldMappingIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD-MAPPING' | translate}} {{fieldMappingIndex + 1}}</h4>
|
||||
</div>
|
||||
<!-- <div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></div> -->
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove field" (click)="removeFieldMapping(fieldMappingIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
<div class="row" *ngIf="fieldMappingIndex < systemFieldsMapping.length">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="code" [formControl]="field.get('code')" required>
|
||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="field.get('code')"[ngModel]="systemFieldsMapping[fieldMappingIndex]">
|
||||
<mat-error *ngIf="field.get('code').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Response Path</mat-label>
|
||||
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')" required>
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
|
||||
<mat-error *ngIf="field.get('responsePath').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" *ngIf="fieldMappingIndex >= systemFieldsMapping.length">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="field.get('code')" [ngModel]="formGroup.get('definition').get('fields').value[fieldMappingIndex - systemFieldsMapping.length].code">
|
||||
<mat-error *ngIf="field.get('code').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
|
||||
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
|
||||
<mat-error *ngIf="field.get('responsePath').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
@ -299,59 +327,61 @@
|
|||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="authUrl" [formControl]="externalApiConfig.get('auth').get('authUrl')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('auth').get('authUrl').hasError('required')">
|
||||
<input matInput type="text" name="authUrl" [formControl]="source.get('auth').get('authUrl')">
|
||||
<mat-error *ngIf="source.get('auth').get('authUrl').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Method</mat-label>
|
||||
<input matInput type="text" name="authMethod" [formControl]="externalApiConfig.get('auth').get('authMethod')">
|
||||
<mat-error *ngIf="externalApiConfig.get('auth').get('authMethod').hasError('required')">
|
||||
<mat-select name="httpMethod" [formControl]="source.get('auth').get('authMethod')">
|
||||
<mat-option *ngFor="let vis of visibleHTTPMethodTypes" [value] = "vis.type">
|
||||
{{vis.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="source.get('auth').get('authMethod').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Token Path</mat-label>
|
||||
<input matInput type="text" name="authTokenPath" [formControl]="externalApiConfig.get('auth').get('authTokenPath')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('auth').get('authTokenPath').hasError('required')">
|
||||
<input matInput type="text" name="authTokenPath" [formControl]="source.get('auth').get('authTokenPath')">
|
||||
<mat-error *ngIf="source.get('auth').get('authTokenPath').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Request Body</mat-label>
|
||||
<input matInput type="text" name="authRequestBody" [formControl]="externalApiConfig.get('auth').get('authRequestBody')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('auth').get('authRequestBody').hasError('required')">
|
||||
<input matInput type="text" name="authRequestBody" [formControl]="source.get('auth').get('authRequestBody')">
|
||||
<mat-error *ngIf="source.get('auth').get('authRequestBody').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Type</mat-label>
|
||||
<input matInput type="text" name="type" [formControl]="externalApiConfig.get('auth').get('type')" required>
|
||||
<mat-error *ngIf="externalApiConfig.get('auth').get('type').hasError('required')">
|
||||
<input matInput type="text" name="type" [formControl]="source.get('auth').get('type')">
|
||||
<mat-error *ngIf="source.get('auth').get('type').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<!-- Queries info -->
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
||||
<button mat-button type="button" (click)="addQuery(externalApiConfigIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
<button mat-button type="button" (click)="addQuery(sourceIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
||||
</h3>
|
||||
<div class="col-12" cdkDropList (cdkDropListDropped)="dropQueries($event)">
|
||||
<div *ngFor="let query of externalApiConfig.get('queries').controls; let queryIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div *ngFor="let query of source.get('queries').controls; let queryIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERY' | translate}} {{queryIndex + 1}}</h4>
|
||||
</div>
|
||||
<!-- <div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></div> -->
|
||||
<div class="col-auto d-flex">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove query" (click)="removeQuery(queryIndex)" [disabled]="formGroup.disabled">
|
||||
<button mat-icon-button class="action-list-icon" matTooltip="remove query" (click)="removeQuery(queryIndex, fieldMappingIndex)" [disabled]="formGroup.disabled">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -384,7 +414,7 @@
|
|||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>Ordinal</mat-label>
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="query.get('ordinal')" required>
|
||||
<mat-error *ngIf="query.get('ordinal').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
|
@ -394,6 +424,65 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Options -->
|
||||
<div class="row" *ngIf="source.get('type').value == 1">
|
||||
<div class="col-12">
|
||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTIONS' | translate}}</h3>
|
||||
<div *ngFor="let option of source.get('options').controls; let optionsIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
<mat-card-header>
|
||||
<div class="row mb-3 d-flex align-items-center">
|
||||
<div class="col-auto d-flex">
|
||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.OPTION' | translate}} {{optionsIndex + 1}}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div class="row" *ngIf="optionsIndex < systemFieldsMapping.length">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="option.get('code')"[ngModel]="systemFieldsMapping[optionsIndex]">
|
||||
<mat-error *ngIf="option.get('code').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="option.get('value')">
|
||||
<mat-error *ngIf="option.get('value').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" *ngIf="optionsIndex >= systemFieldsMapping.length">
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="option.get('code')" [ngModel]="formGroup.get('definition').get('fields').value[optionsIndex - systemFieldsMapping.length].code">
|
||||
<mat-error *ngIf="option.get('code').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
||||
<input matInput type="text" name="value" [formControl]="option.get('value')">
|
||||
<mat-error *ngIf="option.get('value').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
|
|
@ -11,7 +11,7 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
|||
import { DatePipe } from '@angular/common';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { ReferenceType, ReferenceTypePersist } from '@app/core/model/reference-type/reference-type';
|
||||
import { ReferenceType, ReferenceTypePersist, ResultFieldsMappingConfiguration } from '@app/core/model/reference-type/reference-type';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||
|
@ -25,15 +25,27 @@ import { TranslateService } from '@ngx-translate/core';
|
|||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
||||
import { ReferenceTypeEditorService } from './reference-type-editor.service';
|
||||
import { QueryConfigEditorModel, ReferenceTypeEditorModel, ReferenceTypeExternalApiConfigurationEditorModel, ReferenceTypeFieldEditorModel, ResultFieldsMappingConfigurationEditorModel } from './reference-type-editor.model';
|
||||
import { QueryConfigEditorModel, ReferenceTypeEditorModel, ReferenceTypeFieldEditorModel, ReferenceTypeSourceBaseConfigurationEditorModel, ReferenceTypeStaticOptionEditorModel, ResultFieldsMappingConfigurationEditorModel } from './reference-type-editor.model';
|
||||
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
||||
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
||||
|
||||
|
||||
export interface visiblesDataType {
|
||||
export interface visibleDataType {
|
||||
name: string;
|
||||
type: ReferenceFieldDataType;
|
||||
}
|
||||
|
||||
export interface visibleSourceType {
|
||||
name: string;
|
||||
type: ReferenceTypeSourceType;
|
||||
}
|
||||
|
||||
export interface visibleHTTPMethodType {
|
||||
name: string;
|
||||
type: ReferenceTypeExternalApiHTTPMethodType;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-reference-type-editor-component',
|
||||
templateUrl: 'reference-type-editor.component.html',
|
||||
|
@ -86,15 +98,26 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
|
||||
}
|
||||
|
||||
visiblesDataTypes: visiblesDataType[] = [
|
||||
visibleDataTypes: visibleDataType[] = [
|
||||
{name: "Text", type: ReferenceFieldDataType.Text},
|
||||
{name: "Date", type: ReferenceFieldDataType.Date},
|
||||
]
|
||||
|
||||
requestTypes: string[] = ["GET", "POST"]
|
||||
visibleSourceTypes: visibleSourceType[] = [
|
||||
{name: "API", type: ReferenceTypeSourceType.API},
|
||||
{name: "Static", type: ReferenceTypeSourceType.STATIC},
|
||||
]
|
||||
|
||||
visibleHTTPMethodTypes: visibleHTTPMethodType[] = [
|
||||
{name: "GET", type: ReferenceTypeExternalApiHTTPMethodType.GET},
|
||||
{name: "POST", type: ReferenceTypeExternalApiHTTPMethodType.POST},
|
||||
]
|
||||
|
||||
systemFieldsMapping: string[] = ['reference_id', 'label', 'description'];
|
||||
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
//this.addSource();
|
||||
}
|
||||
|
||||
getItem(itemId: Guid, successFunction: (item: ReferenceType) => void) {
|
||||
|
@ -119,7 +142,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
buildForm() {
|
||||
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditReferenceType));
|
||||
console.log(this.formGroup.get('definition').value);
|
||||
this.referenceTypeEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||
}
|
||||
|
||||
|
@ -197,6 +219,21 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
addField(): void {
|
||||
const field: ReferenceTypeFieldEditorModel = new ReferenceTypeFieldEditorModel();
|
||||
(this.formGroup.get('definition').get('fields') as FormArray).push(field.buildForm());
|
||||
|
||||
// const fieldIndex = (this.formGroup.get('definition').get('fields') as FormArray).length - 1;
|
||||
// if(((this.formGroup.get('definition').get('fields') as FormArray).at(fieldIndex) as FormArray).get('code').valid){
|
||||
|
||||
// }
|
||||
|
||||
// const sourceSize = (this.formGroup.get('definition').get('sources') as FormArray).length;
|
||||
|
||||
// if(sourceSize && sourceSize > 0){
|
||||
// for(let i =0; i < sourceSize; i++){
|
||||
// this.addFieldMapping(i);
|
||||
// this.addOption(i);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
removeField(fieldIndex: number): void {
|
||||
|
@ -211,26 +248,26 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// externalApiConfig
|
||||
//
|
||||
//
|
||||
addExternalApiConfig(): void {
|
||||
const externalApiConfig: ReferenceTypeExternalApiConfigurationEditorModel = new ReferenceTypeExternalApiConfigurationEditorModel();
|
||||
(this.formGroup.get('definition').get('externalApiConfig') as FormArray).push(externalApiConfig.buildForm());
|
||||
this.addFieldMapping(0);
|
||||
addSource(): void{
|
||||
const source: ReferenceTypeSourceBaseConfigurationEditorModel = new ReferenceTypeSourceBaseConfigurationEditorModel();
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).push(source.buildForm());
|
||||
const sourceIndex = (this.formGroup.get('definition').get('sources') as FormArray).length - 1;
|
||||
this.systemFieldsMapping.forEach(x => {
|
||||
this.addFieldMapping(sourceIndex);
|
||||
this.addOption(sourceIndex);
|
||||
});
|
||||
|
||||
const fieldsSize = (this.formGroup.get('definition').get('fields') as FormArray).length;
|
||||
if(fieldsSize && fieldsSize > 0){
|
||||
for(let i =0; i < fieldsSize; i++){
|
||||
this.addFieldMapping(sourceIndex);
|
||||
this.addOption(sourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeExternalApiConfig(externalApiConfigIndex: number): void {
|
||||
(this.formGroup.get('definition').get('externalApiConfig') as FormArray).removeAt(externalApiConfigIndex);
|
||||
}
|
||||
|
||||
dropExternalApiConfig(event: CdkDragDrop<string[]>) {
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('externalApiConfig') as FormArray);
|
||||
|
||||
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
||||
fieldssFormArray.updateValueAndValidity();
|
||||
removeSource(sourceIndex: number): void {
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).removeAt(sourceIndex);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -238,18 +275,18 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
// resultFieldsMapping
|
||||
//
|
||||
//
|
||||
addFieldMapping(externalApiConfigIndex: number): void {
|
||||
addFieldMapping(sourceIndex: number): void {
|
||||
const fieldMapping: ResultFieldsMappingConfigurationEditorModel = new ResultFieldsMappingConfigurationEditorModel();
|
||||
((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex).get('results').get('fieldsMapping') as FormArray).push(fieldMapping.buildForm());
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).push(fieldMapping.buildForm());
|
||||
}
|
||||
|
||||
removeFieldMapping(externalApiConfigIndex: number, fieldMappingIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex) as FormArray);
|
||||
removeFieldMapping(sourceIndex: number, fieldMappingIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex) as FormArray);
|
||||
(formArray.get('results').get('fieldsMapping') as FormArray).removeAt(fieldMappingIndex);
|
||||
}
|
||||
|
||||
dropFieldsMapping(event: CdkDragDrop<string[]>) {
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('externalApiConfig').get('fieldsMapping') as FormArray);
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('sources').get('fieldsMapping') as FormArray);
|
||||
|
||||
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
||||
fieldssFormArray.updateValueAndValidity();
|
||||
|
@ -261,20 +298,28 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
// queries
|
||||
//
|
||||
//
|
||||
addQuery(externalApiConfigIndex: number): void {
|
||||
addQuery(sourceIndex: number): void {
|
||||
const query: QueryConfigEditorModel = new QueryConfigEditorModel();
|
||||
((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex).get('queries') as FormArray).push(query.buildForm());
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray).push(query.buildForm());
|
||||
}
|
||||
|
||||
removeQuery(externalApiConfigIndex: number, fieldMappingIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex).get('queries') as FormArray);
|
||||
removeQuery(sourceIndex: number, fieldMappingIndex: number): void {
|
||||
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
|
||||
formArray.removeAt(fieldMappingIndex);
|
||||
}
|
||||
|
||||
dropQueries(event: CdkDragDrop<string[]>) {
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('externalApiConfig').get('queries') as FormArray);
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('sources').get('queries') as FormArray);
|
||||
|
||||
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
||||
fieldssFormArray.updateValueAndValidity();
|
||||
}
|
||||
|
||||
// Options
|
||||
|
||||
addOption(sourceIndex: number): void {
|
||||
const options: ReferenceTypeStaticOptionEditorModel = new ReferenceTypeStaticOptionEditorModel();
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).push(options.buildForm());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypePersist, ReferenceTypeFieldPersist,ReferenceTypeField, AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryConfigPersist, QueryConfig, ReferenceTypeExternalApiConfigurationPersist, ResultsConfigurationPersist, ResultFieldsMappingConfigurationPersist, ReferenceTypeExternalApiConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration } from "@app/core/model/reference-type/reference-type";
|
||||
import { ReferenceTypeExternalApiHTTPMethodType } from "@app/core/common/enum/reference-type-external-api-http-method-type";
|
||||
import { ReferenceTypeSourceType } from "@app/core/common/enum/reference-type-source-type";
|
||||
import { ReferenceType, ReferenceTypeDefinition, ReferenceTypeDefinitionPersist, ReferenceTypePersist, ReferenceTypeFieldPersist,ReferenceTypeField, AuthenticationConfiguration, AuthenticationConfigurationPersist, QueryConfigPersist, QueryConfig, ResultsConfigurationPersist, ResultFieldsMappingConfigurationPersist, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeSourceBaseConfigurationPersist, ReferenceTypeSourceBaseConfiguration, ReferenceTypeStaticOptionPersist, ReferenceTypeStaticOption } from "@app/core/model/reference-type/reference-type";
|
||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
||||
|
@ -58,7 +60,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
|
||||
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
|
||||
fields: ReferenceTypeFieldEditorModel[] = [];
|
||||
externalApiConfig: ReferenceTypeExternalApiConfigurationEditorModel[] = [];
|
||||
sources: ReferenceTypeSourceBaseConfigurationEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -69,7 +71,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
|
||||
if (item) {
|
||||
if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel().fromModel(x))); }
|
||||
if(item.externalApiConfig) { item.externalApiConfig.map(x => this.externalApiConfig.push(new ReferenceTypeExternalApiConfigurationEditorModel().fromModel(x))); }
|
||||
if (item.sources) { item.sources.map(x => this.sources.push(new ReferenceTypeSourceBaseConfigurationEditorModel().fromModel(x))); }
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -97,13 +99,13 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
}), context.getValidation('fields')
|
||||
)
|
||||
),
|
||||
externalApiConfig: this.formBuilder.array(
|
||||
(this.externalApiConfig ?? []).map(
|
||||
(item, index) => new ReferenceTypeExternalApiConfigurationEditorModel(
|
||||
sources: this.formBuilder.array(
|
||||
(this.sources ?? []).map(
|
||||
(item, index) => new ReferenceTypeSourceBaseConfigurationEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `externalApiConfig[${index}].`
|
||||
}), context.getValidation('externalApiConfig')
|
||||
rootPath: `sources[${index}].`
|
||||
}), context.getValidation('sources')
|
||||
)
|
||||
)
|
||||
});
|
||||
|
@ -117,8 +119,8 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
|
||||
baseValidationArray.push({ key: 'externalApiConfig', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}externalApiConfig`)] });
|
||||
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
|
||||
baseValidationArray.push({ key: 'sources', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}sources`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -128,6 +130,8 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
|||
|
||||
export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist {
|
||||
code: string;
|
||||
label: string;
|
||||
description: string;
|
||||
dataType: ReferenceFieldDataType;
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
@ -139,6 +143,8 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
|||
public fromModel(item: ReferenceTypeField): ReferenceTypeFieldEditorModel {
|
||||
if (item) {
|
||||
this.code = item.code;
|
||||
this.label = item.label;
|
||||
this.description = item.description;
|
||||
this.dataType = item.dataType;
|
||||
}
|
||||
return this;
|
||||
|
@ -159,6 +165,8 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
|||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
||||
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
|
||||
});
|
||||
}
|
||||
|
@ -172,6 +180,8 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
|||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||
baseValidationArray.push({ key: 'dataType', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
|
@ -180,21 +190,24 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
|||
|
||||
}
|
||||
|
||||
export class ReferenceTypeExternalApiConfigurationEditorModel implements ReferenceTypeExternalApiConfigurationPersist {
|
||||
public key: string;
|
||||
public label: string;
|
||||
public ordinal: number;
|
||||
public url: string;
|
||||
public results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel();
|
||||
public type: string;
|
||||
public paginationPath: string;
|
||||
public contentType: string;
|
||||
public firstPage: string;
|
||||
public requestType?: string;
|
||||
public requestBody?: string;
|
||||
public filterType?: string;
|
||||
public auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
||||
public queries?: QueryConfigEditorModel[] = [];
|
||||
export class ReferenceTypeSourceBaseConfigurationEditorModel implements ReferenceTypeSourceBaseConfigurationPersist {
|
||||
type: ReferenceTypeSourceType;
|
||||
key: string;
|
||||
label: string;
|
||||
ordinal: number;
|
||||
|
||||
url: string;
|
||||
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel();
|
||||
paginationPath: string;
|
||||
contentType: string;
|
||||
firstPage: string;
|
||||
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
requestBody?: string;
|
||||
filterType?: string;
|
||||
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
||||
queries?: QueryConfigEditorModel[] = [];
|
||||
|
||||
options : ReferenceTypeStaticOptionEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
|
@ -202,22 +215,26 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
|||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ReferenceTypeExternalApiConfiguration): ReferenceTypeExternalApiConfigurationEditorModel {
|
||||
public fromModel(item: ReferenceTypeSourceBaseConfiguration): ReferenceTypeSourceBaseConfigurationEditorModel {
|
||||
if (item) {
|
||||
this.type = item.type;
|
||||
this.key = item.key;
|
||||
this.label = item.label;
|
||||
this.ordinal = item.ordinal;
|
||||
this.url = item.url;
|
||||
this.results = new ResultsConfigurationEditorModel().fromModel(item.results);
|
||||
this.type = item.type;
|
||||
this.paginationPath = item.paginationPath;
|
||||
this.contentType = item.contentType;
|
||||
this.firstPage = item.firstPage;
|
||||
this.requestType = item.requestType;
|
||||
this.requestBody = item.requestBody;
|
||||
this.filterType = item.filterType;
|
||||
this.auth = new AuthenticationConfigurationEditorModel().fromModel(item.auth);
|
||||
|
||||
if (item.url) this.url = item.url;
|
||||
if (item.results) this.results = new ResultsConfigurationEditorModel().fromModel(item.results);
|
||||
if (item.paginationPath) this.paginationPath = item.paginationPath;
|
||||
if (item.contentType) this.contentType = item.contentType;
|
||||
if (item.firstPage) this.firstPage = item.firstPage;
|
||||
if (item.httpMethod) this.httpMethod = item.httpMethod;
|
||||
if (item.requestBody) this.requestBody = item.requestBody;
|
||||
if (item.filterType) this.filterType = item.filterType;
|
||||
if (item.auth) this.auth = new AuthenticationConfigurationEditorModel().fromModel(item.auth);
|
||||
if(item.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel().fromModel(x))); }
|
||||
|
||||
if(item.options) { item.options.map(x => this.options.push(new ReferenceTypeStaticOptionEditorModel().fromModel(x))); }
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -228,26 +245,27 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
|||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ReferenceTypeExternalApiConfigurationEditorModel.createValidationContext({
|
||||
context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return this.formBuilder.group({
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||
|
||||
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
|
||||
results: this.results.buildForm({
|
||||
rootPath: `results.`
|
||||
rootPath: `results.`,
|
||||
//context: context.getValidation('results')
|
||||
}),
|
||||
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
|
||||
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
|
||||
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').validators],
|
||||
requestType: [{ value: this.requestType, disabled: disabled }, context.getValidation('requestType').validators],
|
||||
httpMethod: [{ value: this.httpMethod, disabled: disabled }, context.getValidation('httpMethod').validators],
|
||||
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
||||
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
||||
auth: this.auth.buildForm({
|
||||
|
@ -261,7 +279,18 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
|||
rootPath: `queries[${index}].`
|
||||
}), context.getValidation('queries')
|
||||
)
|
||||
),
|
||||
|
||||
options: this.formBuilder.array(
|
||||
(this.options ?? []).map(
|
||||
(item, index) => new ReferenceTypeStaticOptionEditorModel(
|
||||
this.validationErrorModel
|
||||
).fromModel(item).buildForm({
|
||||
rootPath: `options[${index}].`
|
||||
}), context.getValidation('options')
|
||||
)
|
||||
)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -273,19 +302,23 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
baseValidationArray.push({ key: 'key', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required,Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||
baseValidationArray.push({ key: 'url', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
baseValidationArray.push({ key: 'paginationPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
||||
baseValidationArray.push({ key: 'contentType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
|
||||
baseValidationArray.push({ key: 'firstPage', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
|
||||
baseValidationArray.push({ key: 'requestType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestType`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'url', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}url`)] });
|
||||
baseValidationArray.push({ key: 'paginationPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
||||
baseValidationArray.push({ key: 'contentType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
|
||||
baseValidationArray.push({ key: 'firstPage', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
|
||||
baseValidationArray.push({ key: 'httpMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}httpMethod`)] });
|
||||
baseValidationArray.push({ key: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
|
||||
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
|
||||
baseValidationArray.push({ key: 'results', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}results`)] });
|
||||
baseValidationArray.push({ key: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
|
||||
|
||||
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
|
@ -343,8 +376,8 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'resultsArrayPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
||||
baseValidationArray.push({ key: 'fieldsMapping', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
||||
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
||||
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -382,7 +415,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
|||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
code: [{ value: "code", disabled: disabled }, context.getValidation('code').validators],
|
||||
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
|
||||
});
|
||||
}
|
||||
|
@ -395,8 +428,8 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'responsePath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -405,7 +438,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
|||
|
||||
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
||||
public authUrl: string;
|
||||
public authMethod: string;
|
||||
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||
public authTokenPath: string;
|
||||
public authRequestBody: string;
|
||||
public type: string;
|
||||
|
@ -456,11 +489,11 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
|||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'authUrl', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
||||
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
||||
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
||||
baseValidationArray.push({ key: 'authTokenPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||
baseValidationArray.push({ key: 'authRequestBody', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
||||
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
@ -526,3 +559,56 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
|||
return baseContext;
|
||||
}
|
||||
}
|
||||
|
||||
export class ReferenceTypeStaticOptionEditorModel implements ReferenceTypeStaticOptionPersist {
|
||||
public code: string;
|
||||
public value: string;
|
||||
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
||||
constructor(
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||
) { }
|
||||
|
||||
fromModel(item: ReferenceTypeStaticOption): ReferenceTypeStaticOptionEditorModel {
|
||||
this.code = item.code;
|
||||
this.value = item.value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(params?: {
|
||||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = ReferenceTypeStaticOptionEditorModel.createValidationContext({
|
||||
validationErrorModel: this.validationErrorModel,
|
||||
rootPath
|
||||
});
|
||||
}
|
||||
|
||||
return this.formBuilder.group({
|
||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||
});
|
||||
}
|
||||
|
||||
static createValidationContext(params: {
|
||||
rootPath?: string,
|
||||
validationErrorModel: ValidationErrorModel
|
||||
}): ValidationContext {
|
||||
const { rootPath = '', validationErrorModel } = params;
|
||||
|
||||
const baseContext: ValidationContext = new ValidationContext();
|
||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||
baseValidationArray.push({ key: 'value', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeExternalApiConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration } from '@app/core/model/reference-type/reference-type';
|
||||
import { AuthenticationConfiguration, QueryConfig, ReferenceType, ReferenceTypeDefinition, ReferenceTypeField, ReferenceTypeSourceBaseConfiguration, ResultsConfiguration, ResultFieldsMappingConfiguration, ReferenceTypeStaticOption } from '@app/core/model/reference-type/reference-type';
|
||||
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
||||
|
@ -23,36 +23,41 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
|||
nameof<ReferenceType>(x => x.code),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.description)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.fields), nameof<ReferenceTypeField>(x => x.dataType)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.key)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.label)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.ordinal)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.url)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.resultsArrayPath)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.results), nameof<ResultsConfiguration>(x => x.fieldsMapping), nameof<ResultFieldsMappingConfiguration>(x => x.responsePath)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.requestType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.filterType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.paginationPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.contentType)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.firstPage)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.httpMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authRequestBody)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.type)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.condition)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.ordinal)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.condition)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.separator)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.value)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.queries),nameof<QueryConfig>(x => x.ordinal)].join('.'),
|
||||
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.code)].join('.'),
|
||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.options),nameof<ReferenceTypeStaticOption>(x => x.value)].join('.'),
|
||||
|
||||
nameof<ReferenceType>(x => x.createdAt),
|
||||
nameof<ReferenceType>(x => x.updatedAt),
|
||||
|
|
|
@ -56,8 +56,9 @@ import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties
|
|||
import { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
||||
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
||||
import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
|
||||
import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
import { ReferenceSearchDefinitionLookup, ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
import { Reference } from '@app/core/model/reference/reference';
|
||||
import { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver';
|
||||
|
||||
interface Visible {
|
||||
value: boolean;
|
||||
|
@ -1039,11 +1040,21 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
// Researchers
|
||||
filterResearchers(value: string): Observable<Reference[]> {
|
||||
//return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = value;
|
||||
// const lookup = new ReferenceSearchLookup();
|
||||
// lookup.like = value;
|
||||
// lookup.key = '';
|
||||
// lookup.type = ReferenceType.Researcher;
|
||||
// return this.referenceService.search(lookup);
|
||||
const lookup = new ReferenceSearchDefinitionLookup();
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Researcher;
|
||||
return this.referenceService.search(lookup);
|
||||
//from reference type db hardcoded
|
||||
lookup.referenceTypeId = Guid.parse('c8400d41-28f1-477a-8fa1-3351876fca4f');
|
||||
const fields = [
|
||||
...ReferenceTypeEditorResolver.lookupFields()
|
||||
];
|
||||
lookup.project.fields = fields;
|
||||
|
||||
return this.referenceService.searchWithDefinition(lookup);
|
||||
}
|
||||
|
||||
addResearcher(event: MouseEvent) {
|
||||
|
|
|
@ -1109,14 +1109,18 @@
|
|||
"REFERENCE-TYPE-EDITOR": {
|
||||
"NEW": "New Reference Type",
|
||||
"FIELDS": {
|
||||
"EXTERNAL-API-CONFIGURATION": "External API Configuration",
|
||||
"SOURCE-CONFIGURATION": "Source Configuration",
|
||||
"RESULTS": "Results",
|
||||
"FIELD-MAPPING": "Field Mapping",
|
||||
"AUTHENTICATION": "Authentication",
|
||||
"QUERIES": "Queries",
|
||||
"QUERY": "Query",
|
||||
"OPTIONS": "Options",
|
||||
"OPTION": "Option",
|
||||
"NAME": "Name",
|
||||
"CODE": "Code",
|
||||
"VALUE": "Value",
|
||||
"RESPONSE-PATH": "Response Path",
|
||||
"FIELD": "Field",
|
||||
"DATA-TYPE": "Data Type",
|
||||
"KEY": "Key",
|
||||
|
|
Loading…
Reference in New Issue