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;
|
package eu.eudat.commons.types.referencetype;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
public class AuthenticationConfigurationEntity {
|
public class AuthenticationConfigurationEntity {
|
||||||
|
|
||||||
private String authUrl;
|
private String authUrl;
|
||||||
private String authMethod = "GET";
|
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||||
private String authTokenPath;
|
private String authTokenPath;
|
||||||
private String authRequestBody;
|
private String authRequestBody;
|
||||||
private String type;
|
private String type;
|
||||||
|
@ -19,12 +20,12 @@ public class AuthenticationConfigurationEntity {
|
||||||
this.authUrl = authUrl;
|
this.authUrl = authUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthMethod() {
|
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||||
return authMethod;
|
return authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "authUrlMethod")
|
@XmlElement(name = "authUrlMethod")
|
||||||
public void setAuthMethod(String authMethod) {
|
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||||
this.authMethod = authMethod;
|
this.authMethod = authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ public class AuthenticationConfigurationEntity {
|
||||||
return authTokenPath;
|
return authTokenPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "authTokenJpath")
|
@XmlElement(name = "authTokenPath")
|
||||||
public void setAuthTokenPath(String authTokenPath) {
|
public void setAuthTokenPath(String authTokenPath) {
|
||||||
this.authTokenPath = authTokenPath;
|
this.authTokenPath = authTokenPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package eu.eudat.commons.types.referencetype;
|
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 jakarta.xml.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,9 +14,12 @@ public class ReferenceTypeDefinitionEntity {
|
||||||
@XmlElement(name = "field")
|
@XmlElement(name = "field")
|
||||||
private List<ReferenceTypeFieldEntity> fields;
|
private List<ReferenceTypeFieldEntity> fields;
|
||||||
|
|
||||||
@XmlElementWrapper(name = "externalApiConfigs")
|
@XmlElementWrapper(name = "sources")
|
||||||
@XmlElement(name = "externalApiConfig")
|
@XmlElements({
|
||||||
private List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig;
|
@XmlElement(name = ReferenceTypeSourceType.Names.API, type = ReferenceTypeSourceExternalApiConfigurationEntity.class),
|
||||||
|
@XmlElement(name = ReferenceTypeSourceType.Names.STATIC, type = ReferenceTypeSourceStaticOptionConfigurationEntity.class),
|
||||||
|
})
|
||||||
|
private List<ReferenceTypeSourceBaseConfigurationEntity> sources;
|
||||||
|
|
||||||
public List<ReferenceTypeFieldEntity> getFields() {
|
public List<ReferenceTypeFieldEntity> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
|
@ -23,11 +29,11 @@ public class ReferenceTypeDefinitionEntity {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceTypeExternalApiConfigurationEntity> getExternalApiConfig() {
|
public List<ReferenceTypeSourceBaseConfigurationEntity> getSources() {
|
||||||
return externalApiConfig;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationEntity> externalApiConfig) {
|
public void setSources(List<ReferenceTypeSourceBaseConfigurationEntity> sources) {
|
||||||
this.externalApiConfig = externalApiConfig;
|
this.sources = sources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,12 @@ public class ReferenceTypeFieldEntity {
|
||||||
|
|
||||||
@XmlAttribute(name = "code")
|
@XmlAttribute(name = "code")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "label")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "description")
|
||||||
|
private String description;
|
||||||
@XmlAttribute(name = "dataType")
|
@XmlAttribute(name = "dataType")
|
||||||
private ReferenceFieldDataType dataType;
|
private ReferenceFieldDataType dataType;
|
||||||
|
|
||||||
|
@ -24,6 +30,21 @@ public class ReferenceTypeFieldEntity {
|
||||||
this.code = code;
|
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() {
|
public ReferenceFieldDataType getDataType() {
|
||||||
return dataType;
|
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;
|
package eu.eudat.commons.types.referencetype;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
|
||||||
import java.util.List;
|
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 String url;
|
||||||
private ResultsConfigurationEntity results;
|
private ResultsConfigurationEntity results;
|
||||||
private String type;
|
|
||||||
private String paginationPath;
|
private String paginationPath;
|
||||||
private String contentType;
|
private String contentType;
|
||||||
private String firstPage;
|
private String firstPage;
|
||||||
private String requestType = "GET";
|
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||||
private String requestBody = "";
|
private String requestBody = "";
|
||||||
private String filterType = "remote";
|
private String filterType = "remote";
|
||||||
private AuthenticationConfigurationEntity auth;
|
private AuthenticationConfigurationEntity auth;
|
||||||
|
|
||||||
private List<QueryConfigEntity> queries;
|
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() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -47,14 +28,6 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getOrdinal() {
|
|
||||||
return ordinal;
|
|
||||||
}
|
|
||||||
@XmlElement(name = "ordinal")
|
|
||||||
public void setOrdinal(Integer ordinal) {
|
|
||||||
this.ordinal = ordinal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResultsConfigurationEntity getResults() {
|
public ResultsConfigurationEntity getResults() {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -71,13 +44,6 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
||||||
this.paginationPath = paginationPath;
|
this.paginationPath = paginationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
@XmlElement(name = "type")
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return contentType;
|
return contentType;
|
||||||
|
@ -95,12 +61,12 @@ public class ReferenceTypeExternalApiConfigurationEntity {
|
||||||
this.firstPage = firstPage;
|
this.firstPage = firstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestType() {
|
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||||
return requestType;
|
return httpMethod;
|
||||||
}
|
}
|
||||||
@XmlElement(name = "request")
|
@XmlElement(name = "requestHttpMethod")
|
||||||
public void setRequestType(String requestType) {
|
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||||
this.requestType = requestType != null ? requestType : "GET";
|
this.httpMethod = httpMethod != null ? httpMethod : ReferenceTypeExternalApiHTTPMethodType.GET;
|
||||||
}
|
}
|
||||||
public String getRequestBody() {
|
public String getRequestBody() {
|
||||||
return requestBody;
|
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;
|
package eu.eudat.model.builder.referencetypedefinition;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
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.convention.ConventionService;
|
||||||
import eu.eudat.model.builder.BaseBuilder;
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||||
|
import eu.eudat.model.referencetypedefinition.ReferenceTypeSourceBaseConfiguration;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
@ -45,13 +49,20 @@ public class ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDef
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields));
|
FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields));
|
||||||
FieldSet externalApiConfigFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._externalApiConfig));
|
FieldSet sourcesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._sources));
|
||||||
|
|
||||||
List<ReferenceTypeDefinition> models = new ArrayList<>();
|
List<ReferenceTypeDefinition> models = new ArrayList<>();
|
||||||
for (ReferenceTypeDefinitionEntity d : data) {
|
for (ReferenceTypeDefinitionEntity d : data) {
|
||||||
ReferenceTypeDefinition m = new ReferenceTypeDefinition();
|
ReferenceTypeDefinition m = new ReferenceTypeDefinition();
|
||||||
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
|
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
|
||||||
if (!fieldsFields.isEmpty() && d.getFields() != null) m.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);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
|
@ -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) {
|
for (ReferenceTypeFieldEntity d : data) {
|
||||||
ReferenceTypeField m = new ReferenceTypeField();
|
ReferenceTypeField m = new ReferenceTypeField();
|
||||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._code))) m.setCode(d.getCode());
|
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());
|
if (fields.hasField(this.asIndexer(ReferenceTypeField._dataType))) m.setDataType(d.getDataType());
|
||||||
|
|
||||||
models.add(m);
|
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));
|
FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._fields));
|
||||||
this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId);
|
this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId);
|
||||||
|
|
||||||
FieldSet externalApiConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._externalApiConfig));
|
FieldSet sourcesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._sources));
|
||||||
this.censorFactory.censor(ReferenceTypeExternalApiConfigurationCensor.class).censor(externalApiConfigFields, userId);
|
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,14 +16,14 @@ import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@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;
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
public ResultFieldsMappingConfigurationCensor(ConventionService conventionService,
|
public ReferenceTypeSourceBaseConfigurationCensor(ConventionService conventionService,
|
||||||
AuthorizationService authService) {
|
AuthorizationService authService) {
|
||||||
super(conventionService);
|
super(conventionService);
|
||||||
this.authService = authService;
|
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}")
|
@Size(max = 100, message = "{validation.largerthanmax}")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
@Valid
|
@Valid
|
||||||
private ReferenceTypeDefinitionPersist definition;
|
private ReferenceTypeDefinitionPersist definition;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
package eu.eudat.model.persist.referencetypedefinition;
|
package eu.eudat.model.persist.referencetypedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
|
import eu.eudat.commons.validation.ValidEnum;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class AuthenticationConfigurationPersist {
|
public class AuthenticationConfigurationPersist {
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@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}")
|
@NotNull(message = "{validation.empty}")
|
||||||
private String authTokenPath = null;
|
private String authTokenPath ;
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
private String authRequestBody = null;
|
private String authRequestBody;
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
private String type = null;
|
private String type;
|
||||||
|
|
||||||
public String getAuthUrl() {
|
public String getAuthUrl() {
|
||||||
return authUrl;
|
return authUrl;
|
||||||
|
@ -24,11 +27,11 @@ public class AuthenticationConfigurationPersist {
|
||||||
this.authUrl = authUrl;
|
this.authUrl = authUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthMethod() {
|
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||||
return authMethod;
|
return authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthMethod(String authMethod) {
|
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||||
this.authMethod = authMethod;
|
this.authMethod = authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,12 @@ import java.util.List;
|
||||||
|
|
||||||
public class ReferenceTypeDefinitionPersist {
|
public class ReferenceTypeDefinitionPersist {
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
|
||||||
@Valid
|
@Valid
|
||||||
private List<ReferenceTypeFieldPersist> fields = null;
|
private List<ReferenceTypeFieldPersist> fields = null;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
@Valid
|
@Valid
|
||||||
private List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig = null;
|
private List<ReferenceTypeSourceBaseConfigurationPersist> sources = null;
|
||||||
|
|
||||||
public List<ReferenceTypeFieldPersist> getFields() {
|
public List<ReferenceTypeFieldPersist> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
|
@ -23,11 +22,11 @@ public class ReferenceTypeDefinitionPersist {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceTypeExternalApiConfigurationPersist> getExternalApiConfig() {
|
public List<ReferenceTypeSourceBaseConfigurationPersist> getSources() {
|
||||||
return externalApiConfig;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfigurationPersist> externalApiConfig) {
|
public void setSources(List<ReferenceTypeSourceBaseConfigurationPersist> sources) {
|
||||||
this.externalApiConfig = externalApiConfig;
|
this.sources = sources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,13 @@ public class ReferenceTypeFieldPersist {
|
||||||
@NotEmpty(message = "{validation.empty}")
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String code = null;
|
private String code = null;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
private String label = null;
|
||||||
|
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
@ValidEnum(message = "{validation.empty}")
|
@ValidEnum(message = "{validation.empty}")
|
||||||
private ReferenceFieldDataType dataType;
|
private ReferenceFieldDataType dataType;
|
||||||
|
|
||||||
|
@ -23,6 +30,22 @@ public class ReferenceTypeFieldPersist {
|
||||||
this.code = code;
|
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() {
|
public ReferenceFieldDataType getDataType() {
|
||||||
return dataType;
|
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;
|
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.Valid;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReferenceTypeExternalApiConfigurationPersist {
|
public class ReferenceTypeSourceExternalApiConfigurationPersist extends ReferenceTypeSourceBaseConfigurationPersist{
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
@NotEmpty(message = "{validation.empty}")
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String key = null;
|
private String url;
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@Valid
|
@Valid
|
||||||
private ResultsConfigurationPersist results;
|
private ResultsConfigurationPersist results;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
@NotEmpty(message = "{validation.empty}")
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String type = null;
|
private String paginationPath;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
@NotEmpty(message = "{validation.empty}")
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String paginationPath = null;
|
private String contentType;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
@NotEmpty(message = "{validation.empty}")
|
@NotEmpty(message = "{validation.empty}")
|
||||||
private String contentType = null;
|
private String firstPage;
|
||||||
|
|
||||||
@NotNull(message = "{validation.empty}")
|
@ValidEnum(message = "{validation.empty}")
|
||||||
@NotEmpty(message = "{validation.empty}")
|
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||||
private String firstPage = null;
|
|
||||||
|
|
||||||
private String requestType = "GET";
|
|
||||||
private String requestBody = "";
|
private String requestBody = "";
|
||||||
private String filterType = "remote";
|
private String filterType = "remote";
|
||||||
|
|
||||||
|
@ -52,30 +41,6 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
||||||
@Valid
|
@Valid
|
||||||
private List<QueryConfigPersist> queries;
|
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() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -92,13 +57,6 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPaginationPath() {
|
public String getPaginationPath() {
|
||||||
return paginationPath;
|
return paginationPath;
|
||||||
|
@ -125,12 +83,12 @@ public class ReferenceTypeExternalApiConfigurationPersist {
|
||||||
this.firstPage = firstPage;
|
this.firstPage = firstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestType() {
|
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||||
return requestType;
|
return httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequestType(String requestType) {
|
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||||
this.requestType = requestType;
|
this.httpMethod = httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestBody() {
|
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;
|
package eu.eudat.model.referencetypedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
|
|
||||||
public class AuthenticationConfiguration {
|
public class AuthenticationConfiguration {
|
||||||
|
|
||||||
|
@ -7,7 +8,7 @@ public class AuthenticationConfiguration {
|
||||||
private String authUrl;
|
private String authUrl;
|
||||||
|
|
||||||
public final static String _authMethod = "authMethod";
|
public final static String _authMethod = "authMethod";
|
||||||
private String authMethod = "GET";
|
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||||
|
|
||||||
public final static String _authTokenPath = "authTokenPath";
|
public final static String _authTokenPath = "authTokenPath";
|
||||||
private String authTokenPath;
|
private String authTokenPath;
|
||||||
|
@ -27,12 +28,12 @@ public class AuthenticationConfiguration {
|
||||||
this.authUrl = authUrl;
|
this.authUrl = authUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthMethod() {
|
public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
|
||||||
return authMethod;
|
return authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setAuthMethod(String authMethod) {
|
public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
|
||||||
this.authMethod = authMethod;
|
this.authMethod = authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ public class ReferenceTypeDefinition {
|
||||||
public final static String _fields = "fields";
|
public final static String _fields = "fields";
|
||||||
private List<ReferenceTypeField> fields;
|
private List<ReferenceTypeField> fields;
|
||||||
|
|
||||||
public final static String _externalApiConfig = "externalApiConfig";
|
public final static String _sources = "sources";
|
||||||
private List<ReferenceTypeExternalApiConfiguration> externalApiConfig;
|
private List<ReferenceTypeSourceBaseConfiguration> sources;
|
||||||
|
|
||||||
public List<ReferenceTypeField> getFields() {
|
public List<ReferenceTypeField> getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
|
@ -18,11 +18,11 @@ public class ReferenceTypeDefinition {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReferenceTypeExternalApiConfiguration> getExternalApiConfig() {
|
public List<ReferenceTypeSourceBaseConfiguration> getSources() {
|
||||||
return externalApiConfig;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalApiConfig(List<ReferenceTypeExternalApiConfiguration> externalApiConfig) {
|
public void setSources(List<ReferenceTypeSourceBaseConfiguration> sources) {
|
||||||
this.externalApiConfig = externalApiConfig;
|
this.sources = sources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,12 @@ public class ReferenceTypeField {
|
||||||
public final static String _code = "code";
|
public final static String _code = "code";
|
||||||
private String 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";
|
public final static String _dataType = "dataType";
|
||||||
private ReferenceFieldDataType dataType;
|
private ReferenceFieldDataType dataType;
|
||||||
|
|
||||||
|
@ -27,4 +33,19 @@ public class ReferenceTypeField {
|
||||||
this.dataType = dataType;
|
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;
|
package eu.eudat.model.referencetypedefinition;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReferenceTypeExternalApiConfiguration {
|
public class ReferenceTypeSourceExternalApiConfiguration extends 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 _url = "url";
|
public final static String _url = "url";
|
||||||
private String url;
|
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
public final static String _results = "results";
|
public final static String _results = "results";
|
||||||
private ResultsConfiguration results;
|
private ResultsConfiguration results;
|
||||||
|
|
||||||
public final static String _type = "type";
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
public final static String _paginationPath = "paginationPath";
|
public final static String _paginationPath = "paginationPath";
|
||||||
private String paginationPath;
|
private String paginationPath;
|
||||||
|
|
||||||
|
@ -33,8 +22,8 @@ public class ReferenceTypeExternalApiConfiguration {
|
||||||
public final static String _firstPage = "firstPage";
|
public final static String _firstPage = "firstPage";
|
||||||
private String firstPage;
|
private String firstPage;
|
||||||
|
|
||||||
public final static String _requestType = "requestType";
|
public final static String _httpMethod = "httpMethod";
|
||||||
private String requestType = "GET";
|
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
|
||||||
|
|
||||||
public final static String _requestBody = "requestBody";
|
public final static String _requestBody = "requestBody";
|
||||||
private String requestBody = "";
|
private String requestBody = "";
|
||||||
|
@ -48,30 +37,6 @@ public class ReferenceTypeExternalApiConfiguration {
|
||||||
public final static String _queries = "queries";
|
public final static String _queries = "queries";
|
||||||
private List<QueryConfig> 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() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -88,14 +53,6 @@ public class ReferenceTypeExternalApiConfiguration {
|
||||||
this.results = results;
|
this.results = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPaginationPath() {
|
public String getPaginationPath() {
|
||||||
return paginationPath;
|
return paginationPath;
|
||||||
}
|
}
|
||||||
|
@ -121,12 +78,12 @@ public class ReferenceTypeExternalApiConfiguration {
|
||||||
this.firstPage = firstPage;
|
this.firstPage = firstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestType() {
|
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
|
||||||
return requestType;
|
return httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequestType(String requestType) {
|
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
|
||||||
this.requestType = requestType;
|
this.httpMethod = httpMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestBody() {
|
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 class ResultFieldsMappingConfiguration {
|
||||||
|
|
||||||
public final static String _code = "id";
|
public final static String _code = "code";
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
public final static String _responsePath = "responsePath";
|
public final static String _responsePath = "responsePath";
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
|
|
||||||
private Collection<UUID> excludedIds;
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<UUID> referenceTypeIds;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
public ReferenceQuery like(String value) {
|
public ReferenceQuery like(String value) {
|
||||||
|
@ -120,6 +122,21 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
return this;
|
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) {
|
public ReferenceQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
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.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||||
import eu.eudat.commons.types.referencetype.*;
|
import eu.eudat.commons.types.referencetype.*;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceTypeEntity;
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
|
@ -111,10 +112,10 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.conventionService.isListNullOrEmpty(persist.getExternalApiConfig())){
|
if (!this.conventionService.isListNullOrEmpty(persist.getSources())){
|
||||||
data.setExternalApiConfig(new ArrayList<>());
|
data.setSources(new ArrayList<>());
|
||||||
for (ReferenceTypeExternalApiConfigurationPersist externalApiConfigPersist: persist.getExternalApiConfig()) {
|
for (ReferenceTypeSourceBaseConfigurationPersist sourceBaseConfigPersist: persist.getSources()) {
|
||||||
data.getExternalApiConfig().add(this.buildExternalApiConfigEntity(externalApiConfigPersist));
|
data.getSources().add(this.buildSourceBaseConfigEntity(sourceBaseConfigPersist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,34 +127,59 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
data.setCode(persist.getCode());
|
data.setCode(persist.getCode());
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setDescription(persist.getDescription());
|
||||||
data.setDataType(persist.getDataType());
|
data.setDataType(persist.getDataType());
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull ReferenceTypeExternalApiConfigurationEntity buildExternalApiConfigEntity(ReferenceTypeExternalApiConfigurationPersist persist){
|
private @NotNull ReferenceTypeSourceBaseConfigurationEntity buildSourceBaseConfigEntity(ReferenceTypeSourceBaseConfigurationPersist persist){
|
||||||
ReferenceTypeExternalApiConfigurationEntity data = new ReferenceTypeExternalApiConfigurationEntity();
|
if (persist == null) return new ReferenceTypeSourceExternalApiConfigurationEntity();
|
||||||
if (persist == null) return data;
|
|
||||||
|
|
||||||
|
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.setKey(persist.getKey());
|
||||||
data.setLabel(persist.getLabel());
|
data.setLabel(persist.getLabel());
|
||||||
data.setOrdinal(persist.getOrdinal());
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -188,6 +214,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setAuthUrl(persist.getAuthUrl());
|
||||||
data.setAuthMethod(persist.getAuthMethod());
|
data.setAuthMethod(persist.getAuthMethod());
|
||||||
data.setAuthRequestBody(persist.getAuthRequestBody());
|
data.setAuthRequestBody(persist.getAuthRequestBody());
|
||||||
data.setType(persist.getType());
|
data.setType(persist.getType());
|
||||||
|
@ -208,6 +235,16 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
return data;
|
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 {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug("deleting : {}", id);
|
logger.debug("deleting : {}", id);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import eu.eudat.model.persist.ReferencePersist;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||||
import eu.eudat.query.lookup.ReferenceLookup;
|
import eu.eudat.query.lookup.ReferenceLookup;
|
||||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
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));
|
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}")
|
@GetMapping("{id}")
|
||||||
public Reference get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
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));
|
logger.debug(new MapLogEntry("retrieving" + Reference.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||||
|
|
|
@ -1,20 +1,30 @@
|
||||||
package eu.eudat.logic.services.references;
|
package eu.eudat.logic.services.references;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
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.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
|
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.reference.FieldEntity;
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
|
import eu.eudat.commons.types.referencetype.*;
|
||||||
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
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.HugeResultSet;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||||
|
import eu.eudat.logic.proxy.fetching.entities.Results;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
import eu.eudat.model.builder.ReferenceBuilder;
|
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.DefinitionPersist;
|
||||||
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import eu.eudat.query.ReferenceTypeQuery;
|
||||||
|
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
|
||||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
@ -43,6 +55,15 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
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.management.InvalidApplicationException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
@ -68,6 +89,8 @@ public class ReferenceService {
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private final ReferenceTypeProperties referenceTypeProperties;
|
private final ReferenceTypeProperties referenceTypeProperties;
|
||||||
|
|
||||||
|
private final WebClient client;
|
||||||
|
|
||||||
public ReferenceService(ApiContext apiContext,
|
public ReferenceService(ApiContext apiContext,
|
||||||
UserScope userScope,
|
UserScope userScope,
|
||||||
RemoteFetcher remoteFetcher,
|
RemoteFetcher remoteFetcher,
|
||||||
|
@ -92,6 +115,11 @@ public class ReferenceService {
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.referenceTypeProperties = referenceTypeProperties;
|
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 {
|
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;
|
// 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 { 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 { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||||
import { Guid } from "@common/types/guid";
|
|
||||||
|
|
||||||
export interface ReferenceType extends BaseEntity{
|
export interface ReferenceType extends BaseEntity{
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -11,26 +11,31 @@ export interface ReferenceType extends BaseEntity{
|
||||||
|
|
||||||
export interface ReferenceTypeDefinition{
|
export interface ReferenceTypeDefinition{
|
||||||
fields: ReferenceTypeField[];
|
fields: ReferenceTypeField[];
|
||||||
externalApiConfig: ReferenceTypeExternalApiConfiguration[];
|
sources: ReferenceTypeSourceBaseConfiguration[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferenceTypeField {
|
export interface ReferenceTypeField {
|
||||||
code: string;
|
code: string;
|
||||||
|
label: string;
|
||||||
|
description: string;
|
||||||
dataType: ReferenceFieldDataType;
|
dataType: ReferenceFieldDataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferenceTypeExternalApiConfiguration {
|
export interface ReferenceTypeSourceBaseConfiguration extends ReferenceTypeSourceExternalApiConfiguration, ReferenceTypeSourceStaticOptionConfiguration{
|
||||||
|
type: ReferenceTypeSourceType;
|
||||||
key: string;
|
key: string;
|
||||||
label: string;
|
label: string;
|
||||||
ordinal: number;
|
ordinal: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeSourceExternalApiConfiguration{
|
||||||
url: string;
|
url: string;
|
||||||
results: ResultsConfiguration;
|
results: ResultsConfiguration;
|
||||||
type: string;
|
|
||||||
paginationPath: string;
|
paginationPath: string;
|
||||||
contentType: string;
|
contentType: string;
|
||||||
//funderQuery?: string;
|
//funderQuery?: string;
|
||||||
firstPage: string;
|
firstPage: string;
|
||||||
requestType?: string;
|
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
requestBody?: string;
|
requestBody?: string;
|
||||||
filterType?: string;
|
filterType?: string;
|
||||||
auth: AuthenticationConfiguration;
|
auth: AuthenticationConfiguration;
|
||||||
|
@ -50,7 +55,7 @@ export interface ResultFieldsMappingConfiguration{
|
||||||
|
|
||||||
export interface AuthenticationConfiguration{
|
export interface AuthenticationConfiguration{
|
||||||
authUrl: string;
|
authUrl: string;
|
||||||
authMethod: string;
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
authTokenPath: string;
|
authTokenPath: string;
|
||||||
authRequestBody: string;
|
authRequestBody: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -63,6 +68,16 @@ export interface QueryConfig{
|
||||||
ordinal: number;
|
ordinal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeSourceStaticOptionConfiguration{
|
||||||
|
options: ReferenceTypeStaticOption[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeStaticOption{
|
||||||
|
code: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Persist
|
// Persist
|
||||||
|
|
||||||
export interface ReferenceTypePersist extends BaseEntityPersist{
|
export interface ReferenceTypePersist extends BaseEntityPersist{
|
||||||
|
@ -72,28 +87,33 @@ export interface ReferenceTypePersist extends BaseEntityPersist{
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferenceTypeDefinitionPersist{
|
export interface ReferenceTypeDefinitionPersist{
|
||||||
fields: ReferenceTypeFieldPersist[];
|
fields?: ReferenceTypeFieldPersist[];
|
||||||
externalApiConfig: ReferenceTypeExternalApiConfigurationPersist[];
|
sources: ReferenceTypeSourceBaseConfigurationPersist[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferenceTypeFieldPersist {
|
export interface ReferenceTypeFieldPersist {
|
||||||
code: string;
|
code: string;
|
||||||
|
label: string;
|
||||||
|
description: string;
|
||||||
dataType: ReferenceFieldDataType;
|
dataType: ReferenceFieldDataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferenceTypeExternalApiConfigurationPersist {
|
export interface ReferenceTypeSourceBaseConfigurationPersist extends ReferenceTypeSourceExternalApiConfigurationPersist, ReferenceTypeSourceStaticOptionConfigurationPersist{
|
||||||
|
type: ReferenceTypeSourceType;
|
||||||
key: string;
|
key: string;
|
||||||
label: string;
|
label: string;
|
||||||
ordinal: number;
|
ordinal: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeSourceExternalApiConfigurationPersist{
|
||||||
url: string;
|
url: string;
|
||||||
results: ResultsConfigurationPersist;
|
results: ResultsConfigurationPersist;
|
||||||
type: string;
|
|
||||||
paginationPath: string;
|
paginationPath: string;
|
||||||
contentType: string;
|
contentType: string;
|
||||||
// toDo move to a general query
|
// toDo move to a general query
|
||||||
//funderQuery?: string;
|
//funderQuery?: string;
|
||||||
firstPage: string;
|
firstPage: string;
|
||||||
requestType?: string;
|
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
requestBody?: string;
|
requestBody?: string;
|
||||||
filterType?: string;
|
filterType?: string;
|
||||||
auth: AuthenticationConfigurationPersist;
|
auth: AuthenticationConfigurationPersist;
|
||||||
|
@ -114,7 +134,7 @@ export interface ResultFieldsMappingConfigurationPersist{
|
||||||
|
|
||||||
export interface AuthenticationConfigurationPersist{
|
export interface AuthenticationConfigurationPersist{
|
||||||
authUrl: string;
|
authUrl: string;
|
||||||
authMethod: string;
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
authTokenPath: string;
|
authTokenPath: string;
|
||||||
authRequestBody: string;
|
authRequestBody: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -125,4 +145,13 @@ export interface QueryConfigPersist{
|
||||||
separator: string;
|
separator: string;
|
||||||
value: string;
|
value: string;
|
||||||
ordinal: number;
|
ordinal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeSourceStaticOptionConfigurationPersist {
|
||||||
|
options: ReferenceTypeStaticOptionPersist[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReferenceTypeStaticOptionPersist{
|
||||||
|
code: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
import { Lookup } from "@common/model/lookup";
|
import { Lookup } from "@common/model/lookup";
|
||||||
import { ReferenceType } from "../common/enum/reference-type";
|
import { ReferenceType } from "../common/enum/reference-type";
|
||||||
|
import { Guid } from "@common/types/guid";
|
||||||
|
|
||||||
export class ReferenceSearchLookup extends Lookup{
|
export class ReferenceSearchLookup extends Lookup{
|
||||||
like: string;
|
like: string;
|
||||||
type: ReferenceType;
|
type: ReferenceType;
|
||||||
key: string;
|
key: string;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class ReferenceSearchDefinitionLookup extends Lookup{
|
||||||
|
like: string;
|
||||||
|
referenceTypeId: Guid;
|
||||||
|
key: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { nameof } from 'ts-simple-nameof';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||||
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
|
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()
|
@Injectable()
|
||||||
export class ReferenceService {
|
export class ReferenceService {
|
||||||
|
@ -38,6 +38,11 @@ export class ReferenceService {
|
||||||
return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
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> {
|
getSingle(id: Guid, reqFields: string[] = []): Observable<Reference> {
|
||||||
const url = `${this.apiBase}/${id}`;
|
const url = `${this.apiBase}/${id}`;
|
||||||
const options = { params: { f: reqFields } };
|
const options = { params: { f: reqFields } };
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
<div class="col-auto d-flex">
|
<div class="col-auto d-flex">
|
||||||
<mat-card-title>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
|
<mat-card-title>{{'REFERENCE-TYPE-EDITOR.FIELDS.FIELD' | translate}} {{fieldIndex + 1}}</mat-card-title>
|
||||||
</div>
|
</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">
|
<div class="col-auto d-flex">
|
||||||
<button mat-icon-button class="action-list-icon" matTooltip="remove field" (click)="removeField(fieldIndex)" [disabled]="formGroup.disabled">
|
<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-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div class="row">
|
<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">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
|
@ -104,7 +119,7 @@
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
|
||||||
<mat-select name="dataType" [formControl]="field.get('dataType')">
|
<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}}
|
{{dataType.name}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
@ -121,286 +136,360 @@
|
||||||
</form>
|
</form>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
<mat-card appearance="outlined">
|
<mat-card appearance="outlined">
|
||||||
<mat-card-header>
|
<mat-card-header>
|
||||||
<mat-card-title *ngIf="isNew">Reference Type External API Configuration</mat-card-title>
|
<mat-card-title *ngIf="isNew">Reference Type Source</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-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-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<form (ngSubmit)="formSubmit()" [formGroup]="formGroup" *ngIf="formGroup">
|
<form (ngSubmit)="formSubmit()" [formGroup]="formGroup" *ngIf="formGroup">
|
||||||
<!-- External Api Config Info -->
|
<!-- External Api Config Info -->
|
||||||
<div class="col-12" cdkDropList (cdkDropListDropped)="dropExternalApiConfig($event)">
|
<div class="col-12">
|
||||||
<div *ngFor="let externalApiConfig of formGroup.get('definition').get('externalApiConfig').controls; let externalApiConfigIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
<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">
|
<div class="col-12">
|
||||||
<mat-card-header>
|
<mat-card-content>
|
||||||
<div class="row mb-3 d-flex align-items-center">
|
<div class="row mb-3 d-flex align-items-center">
|
||||||
<div class="col-auto d-flex">
|
<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>
|
||||||
<!-- <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">
|
<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>
|
<mat-icon>delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-header>
|
<div class="row" >
|
||||||
<mat-card-content>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="key" [formControl]="externalApiConfig.get('key')" required>
|
<input matInput type="text" name="key" [formControl]="source.get('key')" required>
|
||||||
<mat-error *ngIf="externalApiConfig.get('key').hasError('required')">
|
<mat-error *ngIf="source.get('key').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.LABEL' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="label" [formControl]="externalApiConfig.get('label')" required>
|
<input matInput type="text" name="label" [formControl]="source.get('label')" required>
|
||||||
<mat-error *ngIf="externalApiConfig.get('label').hasError('required')">
|
<mat-error *ngIf="source.get('label').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.ORDINAL' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="ordinal" [formControl]="externalApiConfig.get('ordinal')" required>
|
<input matInput type="text" name="ordinal" [formControl]="source.get('ordinal')" required>
|
||||||
<mat-error *ngIf="externalApiConfig.get('ordinal').hasError('required')">
|
<mat-error *ngIf="source.get('ordinal').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
<mat-label>Source Type</mat-label>
|
||||||
<input matInput type="text" name="ordinal" [formControl]="externalApiConfig.get('url')" required>
|
<mat-select name="type" [formControl]="source.get('type')" required>
|
||||||
<mat-error *ngIf="externalApiConfig.get('url').hasError('required')">
|
<mat-option *ngFor="let vis of visibleSourceTypes" [value] = "vis.type">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{vis.name}}
|
||||||
</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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="externalApiConfig.get('requestType').hasError('required')">
|
<mat-error *ngIf="source.get('type').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-label>Request Body</mat-label>
|
|
||||||
<input matInput type="text" name="requestBody" [formControl]="externalApiConfig.get('requestBody')" required>
|
|
||||||
<mat-error *ngIf="externalApiConfig.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')">
|
|
||||||
{{'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>
|
|
||||||
<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')">
|
|
||||||
{{'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">
|
|
||||||
<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="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>
|
|
||||||
<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-error *ngIf="field.get('responsePath').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Auth info -->
|
|
||||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}</h3>
|
|
||||||
<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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'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')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Queries info -->
|
<div class="row" *ngIf="source.get('type').value == 0">
|
||||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
<div class="col-6">
|
||||||
<button mat-button type="button" (click)="addQuery(externalApiConfigIndex)" [disabled]="formGroup.disabled">{{'REFERENCE-TYPE-EDITOR.ACTIONS.ADD-QUERY' | translate}}</button>
|
<mat-form-field class="w-100">
|
||||||
</h3>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||||
<div class="col-12" cdkDropList (cdkDropListDropped)="dropQueries($event)">
|
<input matInput type="text" name="ordinal" [formControl]="source.get('url')">
|
||||||
<div *ngFor="let query of externalApiConfig.get('queries').controls; let queryIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
<mat-error *ngIf="source.get('url').hasError('required')">
|
||||||
<div class="col-12">
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-card-header>
|
</mat-form-field>
|
||||||
<div class="row mb-3 d-flex align-items-center">
|
</div>
|
||||||
<div class="col-auto d-flex">
|
<div class="col-6">
|
||||||
<h4 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERY' | translate}} {{queryIndex + 1}}</h4>
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.PAGINATION-PATH' | translate}}</mat-label>
|
||||||
|
<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]="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]="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>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="source.get('httpMethod').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<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]="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]="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}}</h3>
|
||||||
|
<div class="col-6">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>Results Path</mat-label>
|
||||||
|
<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">
|
||||||
|
<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>
|
</div>
|
||||||
<!-- <div class="col-auto d-flex"><mat-icon cdkDragHandle style="cursor: move; color: #129d99;">drag_indicator</mat-icon></div> -->
|
</mat-card-header>
|
||||||
<div class="col-auto d-flex">
|
<mat-card-content>
|
||||||
<button mat-icon-button class="action-list-icon" matTooltip="remove query" (click)="removeQuery(queryIndex)" [disabled]="formGroup.disabled">
|
<div class="row" *ngIf="fieldMappingIndex < systemFieldsMapping.length">
|
||||||
<mat-icon>delete</mat-icon>
|
<div class="col-6">
|
||||||
</button>
|
<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]="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>{{'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>
|
||||||
</div>
|
<div class="row" *ngIf="fieldMappingIndex >= systemFieldsMapping.length">
|
||||||
</mat-card-header>
|
<div class="col-6">
|
||||||
<mat-card-content>
|
<mat-form-field class="w-100">
|
||||||
<div class="col-6">
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
<mat-form-field class="w-100">
|
<input matInput type="text" [readonly]="true" name="code" [formControl]="field.get('code')" [ngModel]="formGroup.get('definition').get('fields').value[fieldMappingIndex - systemFieldsMapping.length].code">
|
||||||
<mat-label>Condition</mat-label>
|
<mat-error *ngIf="field.get('code').hasError('required')">
|
||||||
<input matInput type="text" name="condition" [formControl]="query.get('condition')" required>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-error *ngIf="query.get('condition').hasError('required')">
|
</mat-form-field>
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</div>
|
||||||
</mat-form-field>
|
<div class="col-6">
|
||||||
</div>
|
<mat-form-field class="w-100">
|
||||||
<div class="col-6">
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
|
||||||
<mat-form-field class="w-100">
|
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
|
||||||
<mat-label>Separator</mat-label>
|
<mat-error *ngIf="field.get('responsePath').hasError('required')">
|
||||||
<input matInput type="text" name="separator" [formControl]="query.get('separator')" required>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-error *ngIf="query.get('separator').hasError('required')">
|
</mat-form-field>
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</div>
|
||||||
</mat-form-field>
|
</div>
|
||||||
</div>
|
</mat-card-content>
|
||||||
<div class="col-6">
|
</div>
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>Value</mat-label>
|
|
||||||
<input matInput type="text" name="value" [formControl]="query.get('value')" required>
|
|
||||||
<mat-error *ngIf="query.get('value').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>Ordinal</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>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Auth info -->
|
||||||
|
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}</h3>
|
||||||
|
<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]="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>
|
||||||
|
<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]="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]="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]="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(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 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">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<div class="col-6">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>Condition</mat-label>
|
||||||
|
<input matInput type="text" name="condition" [formControl]="query.get('condition')" required>
|
||||||
|
<mat-error *ngIf="query.get('condition').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>Separator</mat-label>
|
||||||
|
<input matInput type="text" name="separator" [formControl]="query.get('separator')" required>
|
||||||
|
<mat-error *ngIf="query.get('separator').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<mat-form-field class="w-100">
|
||||||
|
<mat-label>Value</mat-label>
|
||||||
|
<input matInput type="text" name="value" [formControl]="query.get('value')" required>
|
||||||
|
<mat-error *ngIf="query.get('value').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="value" [formControl]="query.get('ordinal')" required>
|
||||||
|
<mat-error *ngIf="query.get('ordinal').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
|
</form>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
import { AppPermission } from '@app/core/common/enum/permission.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 { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.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 { map, takeUntil } from 'rxjs/operators';
|
||||||
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
import { ReferenceTypeEditorResolver } from './reference-type-editor.resolver';
|
||||||
import { ReferenceTypeEditorService } from './reference-type-editor.service';
|
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 { 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;
|
name: string;
|
||||||
type: ReferenceFieldDataType;
|
type: ReferenceFieldDataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface visibleSourceType {
|
||||||
|
name: string;
|
||||||
|
type: ReferenceTypeSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface visibleHTTPMethodType {
|
||||||
|
name: string;
|
||||||
|
type: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-reference-type-editor-component',
|
selector: 'app-reference-type-editor-component',
|
||||||
templateUrl: 'reference-type-editor.component.html',
|
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);
|
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
visiblesDataTypes: visiblesDataType[] = [
|
visibleDataTypes: visibleDataType[] = [
|
||||||
{name: "Text", type: ReferenceFieldDataType.Text},
|
{name: "Text", type: ReferenceFieldDataType.Text},
|
||||||
{name: "Date", type: ReferenceFieldDataType.Date},
|
{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 {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
//this.addSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem(itemId: Guid, successFunction: (item: ReferenceType) => void) {
|
getItem(itemId: Guid, successFunction: (item: ReferenceType) => void) {
|
||||||
|
@ -118,8 +141,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForm() {
|
buildForm() {
|
||||||
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditReferenceType));
|
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);
|
this.referenceTypeEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +219,21 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
addField(): void {
|
addField(): void {
|
||||||
const field: ReferenceTypeFieldEditorModel = new ReferenceTypeFieldEditorModel();
|
const field: ReferenceTypeFieldEditorModel = new ReferenceTypeFieldEditorModel();
|
||||||
(this.formGroup.get('definition').get('fields') as FormArray).push(field.buildForm());
|
(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 {
|
removeField(fieldIndex: number): void {
|
||||||
|
@ -211,26 +248,26 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
addSource(): void{
|
||||||
//
|
const source: ReferenceTypeSourceBaseConfigurationEditorModel = new ReferenceTypeSourceBaseConfigurationEditorModel();
|
||||||
// externalApiConfig
|
(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 => {
|
||||||
addExternalApiConfig(): void {
|
this.addFieldMapping(sourceIndex);
|
||||||
const externalApiConfig: ReferenceTypeExternalApiConfigurationEditorModel = new ReferenceTypeExternalApiConfigurationEditorModel();
|
this.addOption(sourceIndex);
|
||||||
(this.formGroup.get('definition').get('externalApiConfig') as FormArray).push(externalApiConfig.buildForm());
|
});
|
||||||
this.addFieldMapping(0);
|
|
||||||
|
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 {
|
removeSource(sourceIndex: number): void {
|
||||||
(this.formGroup.get('definition').get('externalApiConfig') as FormArray).removeAt(externalApiConfigIndex);
|
(this.formGroup.get('definition').get('sources') as FormArray).removeAt(sourceIndex);
|
||||||
}
|
|
||||||
|
|
||||||
dropExternalApiConfig(event: CdkDragDrop<string[]>) {
|
|
||||||
const fieldssFormArray = (this.formGroup.get('definition').get('externalApiConfig') as FormArray);
|
|
||||||
|
|
||||||
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
|
||||||
fieldssFormArray.updateValueAndValidity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -238,18 +275,18 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
// resultFieldsMapping
|
// resultFieldsMapping
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
addFieldMapping(externalApiConfigIndex: number): void {
|
addFieldMapping(sourceIndex: number): void {
|
||||||
const fieldMapping: ResultFieldsMappingConfigurationEditorModel = new ResultFieldsMappingConfigurationEditorModel();
|
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 {
|
removeFieldMapping(sourceIndex: number, fieldMappingIndex: number): void {
|
||||||
const formArray = ((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex) as FormArray);
|
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex) as FormArray);
|
||||||
(formArray.get('results').get('fieldsMapping') as FormArray).removeAt(fieldMappingIndex);
|
(formArray.get('results').get('fieldsMapping') as FormArray).removeAt(fieldMappingIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
dropFieldsMapping(event: CdkDragDrop<string[]>) {
|
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);
|
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
||||||
fieldssFormArray.updateValueAndValidity();
|
fieldssFormArray.updateValueAndValidity();
|
||||||
|
@ -261,20 +298,28 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
// queries
|
// queries
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
addQuery(externalApiConfigIndex: number): void {
|
addQuery(sourceIndex: number): void {
|
||||||
const query: QueryConfigEditorModel = new QueryConfigEditorModel();
|
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 {
|
removeQuery(sourceIndex: number, fieldMappingIndex: number): void {
|
||||||
const formArray = ((this.formGroup.get('definition').get('externalApiConfig') as FormArray).at(externalApiConfigIndex).get('queries') as FormArray);
|
const formArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('queries') as FormArray);
|
||||||
formArray.removeAt(fieldMappingIndex);
|
formArray.removeAt(fieldMappingIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
dropQueries(event: CdkDragDrop<string[]>) {
|
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);
|
moveItemInArray(fieldssFormArray.controls, event.previousIndex, event.currentIndex);
|
||||||
fieldssFormArray.updateValueAndValidity();
|
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 { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||||
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
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 { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||||
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
|
||||||
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
|
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 {
|
export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefinitionPersist {
|
||||||
fields: ReferenceTypeFieldEditorModel[] = [];
|
fields: ReferenceTypeFieldEditorModel[] = [];
|
||||||
externalApiConfig: ReferenceTypeExternalApiConfigurationEditorModel[] = [];
|
sources: ReferenceTypeSourceBaseConfigurationEditorModel[] = [];
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
||||||
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
|
public fromModel(item: ReferenceTypeDefinition): ReferenceTypeDefinitionEditorModel {
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item.fields) { item.fields.map(x => this.fields.push(new ReferenceTypeFieldEditorModel().fromModel(x))); }
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -97,13 +99,13 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
||||||
}), context.getValidation('fields')
|
}), context.getValidation('fields')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
externalApiConfig: this.formBuilder.array(
|
sources: this.formBuilder.array(
|
||||||
(this.externalApiConfig ?? []).map(
|
(this.sources ?? []).map(
|
||||||
(item, index) => new ReferenceTypeExternalApiConfigurationEditorModel(
|
(item, index) => new ReferenceTypeSourceBaseConfigurationEditorModel(
|
||||||
this.validationErrorModel
|
this.validationErrorModel
|
||||||
).fromModel(item).buildForm({
|
).fromModel(item).buildForm({
|
||||||
rootPath: `externalApiConfig[${index}].`
|
rootPath: `sources[${index}].`
|
||||||
}), context.getValidation('externalApiConfig')
|
}), context.getValidation('sources')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -117,8 +119,8 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
||||||
|
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'fields', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
|
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
|
||||||
baseValidationArray.push({ key: 'externalApiConfig', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}externalApiConfig`)] });
|
baseValidationArray.push({ key: 'sources', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}sources`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -128,6 +130,8 @@ export class ReferenceTypeDefinitionEditorModel implements ReferenceTypeDefiniti
|
||||||
|
|
||||||
export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist {
|
export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist {
|
||||||
code: string;
|
code: string;
|
||||||
|
label: string;
|
||||||
|
description: string;
|
||||||
dataType: ReferenceFieldDataType;
|
dataType: ReferenceFieldDataType;
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
@ -139,6 +143,8 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
||||||
public fromModel(item: ReferenceTypeField): ReferenceTypeFieldEditorModel {
|
public fromModel(item: ReferenceTypeField): ReferenceTypeFieldEditorModel {
|
||||||
if (item) {
|
if (item) {
|
||||||
this.code = item.code;
|
this.code = item.code;
|
||||||
|
this.label = item.label;
|
||||||
|
this.description = item.description;
|
||||||
this.dataType = item.dataType;
|
this.dataType = item.dataType;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -159,6 +165,8 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
||||||
|
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
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],
|
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 baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
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`)] });
|
baseValidationArray.push({ key: 'dataType', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
|
@ -180,44 +190,51 @@ export class ReferenceTypeFieldEditorModel implements ReferenceTypeFieldPersist
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReferenceTypeExternalApiConfigurationEditorModel implements ReferenceTypeExternalApiConfigurationPersist {
|
export class ReferenceTypeSourceBaseConfigurationEditorModel implements ReferenceTypeSourceBaseConfigurationPersist {
|
||||||
public key: string;
|
type: ReferenceTypeSourceType;
|
||||||
public label: string;
|
key: string;
|
||||||
public ordinal: number;
|
label: string;
|
||||||
public url: string;
|
ordinal: number;
|
||||||
public results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel();
|
|
||||||
public type: string;
|
url: string;
|
||||||
public paginationPath: string;
|
results: ResultsConfigurationEditorModel = new ResultsConfigurationEditorModel();
|
||||||
public contentType: string;
|
paginationPath: string;
|
||||||
public firstPage: string;
|
contentType: string;
|
||||||
public requestType?: string;
|
firstPage: string;
|
||||||
public requestBody?: string;
|
httpMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
public filterType?: string;
|
requestBody?: string;
|
||||||
public auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
filterType?: string;
|
||||||
public queries?: QueryConfigEditorModel[] = [];
|
auth: AuthenticationConfigurationEditorModel = new AuthenticationConfigurationEditorModel();
|
||||||
|
queries?: QueryConfigEditorModel[] = [];
|
||||||
|
|
||||||
|
options : ReferenceTypeStaticOptionEditorModel[] = [];
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
fromModel(item: ReferenceTypeExternalApiConfiguration): ReferenceTypeExternalApiConfigurationEditorModel {
|
public fromModel(item: ReferenceTypeSourceBaseConfiguration): ReferenceTypeSourceBaseConfigurationEditorModel {
|
||||||
this.key = item.key;
|
if (item) {
|
||||||
this.label = item.label;
|
this.type = item.type;
|
||||||
this.ordinal = item.ordinal;
|
this.key = item.key;
|
||||||
this.url = item.url;
|
this.label = item.label;
|
||||||
this.results = new ResultsConfigurationEditorModel().fromModel(item.results);
|
this.ordinal = item.ordinal;
|
||||||
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.queries) { item.queries.map(x => this.queries.push(new QueryConfigEditorModel().fromModel(x))); }
|
|
||||||
|
|
||||||
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,30 +245,31 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
||||||
}): UntypedFormGroup {
|
}): UntypedFormGroup {
|
||||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = ReferenceTypeExternalApiConfigurationEditorModel.createValidationContext({
|
context = ReferenceTypeSourceBaseConfigurationEditorModel.createValidationContext({
|
||||||
validationErrorModel: this.validationErrorModel,
|
validationErrorModel: this.validationErrorModel,
|
||||||
rootPath
|
rootPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
|
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
|
||||||
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
|
||||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||||
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
|
||||||
|
|
||||||
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
|
url: [{ value: this.url, disabled: disabled }, context.getValidation('url').validators],
|
||||||
results: this.results.buildForm({
|
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],
|
paginationPath: [{ value: this.paginationPath, disabled: disabled }, context.getValidation('paginationPath').validators],
|
||||||
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
|
contentType: [{ value: this.contentType, disabled: disabled }, context.getValidation('contentType').validators],
|
||||||
firstPage: [{ value: this.firstPage, disabled: disabled }, context.getValidation('firstPage').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],
|
requestBody: [{ value: this.requestBody, disabled: disabled }, context.getValidation('requestBody').validators],
|
||||||
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
filterType: [{ value: this.filterType, disabled: disabled }, context.getValidation('filterType').validators],
|
||||||
auth: this.auth.buildForm({
|
auth: this.auth.buildForm({
|
||||||
rootPath: `auth.`
|
rootPath: `auth.`
|
||||||
}),
|
}),
|
||||||
queries: this.formBuilder.array(
|
queries: this.formBuilder.array(
|
||||||
(this.queries ?? []).map(
|
(this.queries ?? []).map(
|
||||||
|
@ -261,7 +279,18 @@ export class ReferenceTypeExternalApiConfigurationEditorModel implements Referen
|
||||||
rootPath: `queries[${index}].`
|
rootPath: `queries[${index}].`
|
||||||
}), context.getValidation('queries')
|
}), 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 baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
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: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||||
baseValidationArray.push({ key: 'paginationPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}paginationPath`)] });
|
baseValidationArray.push({ key: 'key', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
|
||||||
baseValidationArray.push({ key: 'contentType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}contentType`)] });
|
baseValidationArray.push({ key: 'label', validators: [Validators.required,BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
baseValidationArray.push({ key: 'firstPage', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}firstPage`)] });
|
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required,Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||||
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: 'requestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}requestBody`)] });
|
||||||
baseValidationArray.push({ key: 'filterType', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}filterType`)] });
|
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: 'queries', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}queries`)] });
|
||||||
|
|
||||||
|
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}options`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
}
|
}
|
||||||
|
@ -343,8 +376,8 @@ export class ResultsConfigurationEditorModel implements ResultsConfigurationPers
|
||||||
|
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'resultsArrayPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
baseValidationArray.push({ key: 'resultsArrayPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}resultsArrayPath`)] });
|
||||||
baseValidationArray.push({ key: 'fieldsMapping', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
baseValidationArray.push({ key: 'fieldsMapping', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldsMapping`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -382,7 +415,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.formBuilder.group({
|
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],
|
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 baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
baseValidationArray.push({ key: 'code', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}code`)] });
|
||||||
baseValidationArray.push({ key: 'responsePath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
baseValidationArray.push({ key: 'responsePath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}responsePath`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -405,7 +438,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
||||||
|
|
||||||
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
||||||
public authUrl: string;
|
public authUrl: string;
|
||||||
public authMethod: string;
|
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
public authTokenPath: string;
|
public authTokenPath: string;
|
||||||
public authRequestBody: string;
|
public authRequestBody: string;
|
||||||
public type: string;
|
public type: string;
|
||||||
|
@ -456,11 +489,11 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
||||||
|
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: '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: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
||||||
baseValidationArray.push({ key: 'authTokenPath', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||||
baseValidationArray.push({ key: 'authRequestBody', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
baseValidationArray.push({ key: 'authRequestBody', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authRequestBody`)] });
|
||||||
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
baseValidationArray.push({ key: 'type', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
@ -522,6 +555,59 @@ export class QueryConfigEditorModel implements QueryConfigPersist {
|
||||||
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
|
||||||
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, Validators.pattern("^[0-9]*$"), BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
|
||||||
|
|
||||||
|
baseContext.validation = baseValidationArray;
|
||||||
|
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;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
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 { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
|
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.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.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.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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.type)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.key)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.label)].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.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.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.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.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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.paginationPath)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.contentType)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.firstPage)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.httpMethod)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].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.externalApiConfig), nameof<ReferenceTypeExternalApiConfiguration>(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.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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.sources), nameof<ReferenceTypeSourceBaseConfiguration>(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.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.createdAt),
|
||||||
nameof<ReferenceType>(x => x.updatedAt),
|
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 { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
||||||
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
||||||
import { ProjectFormModel } from '../editor/grant-tab/project-form-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 { Reference } from '@app/core/model/reference/reference';
|
||||||
|
import { ReferenceTypeEditorResolver } from '@app/ui/admin/reference-type/editor/reference-type-editor.resolver';
|
||||||
|
|
||||||
interface Visible {
|
interface Visible {
|
||||||
value: boolean;
|
value: boolean;
|
||||||
|
@ -1039,11 +1040,21 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
||||||
// Researchers
|
// Researchers
|
||||||
filterResearchers(value: string): Observable<Reference[]> {
|
filterResearchers(value: string): Observable<Reference[]> {
|
||||||
//return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
//return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
||||||
const lookup = new ReferenceSearchLookup();
|
// const lookup = new ReferenceSearchLookup();
|
||||||
lookup.like = value;
|
// lookup.like = value;
|
||||||
|
// lookup.key = '';
|
||||||
|
// lookup.type = ReferenceType.Researcher;
|
||||||
|
// return this.referenceService.search(lookup);
|
||||||
|
const lookup = new ReferenceSearchDefinitionLookup();
|
||||||
lookup.key = '';
|
lookup.key = '';
|
||||||
lookup.type = ReferenceType.Researcher;
|
//from reference type db hardcoded
|
||||||
return this.referenceService.search(lookup);
|
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) {
|
addResearcher(event: MouseEvent) {
|
||||||
|
|
|
@ -1109,14 +1109,18 @@
|
||||||
"REFERENCE-TYPE-EDITOR": {
|
"REFERENCE-TYPE-EDITOR": {
|
||||||
"NEW": "New Reference Type",
|
"NEW": "New Reference Type",
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
"EXTERNAL-API-CONFIGURATION": "External API Configuration",
|
"SOURCE-CONFIGURATION": "Source Configuration",
|
||||||
"RESULTS": "Results",
|
"RESULTS": "Results",
|
||||||
"FIELD-MAPPING": "Field Mapping",
|
"FIELD-MAPPING": "Field Mapping",
|
||||||
"AUTHENTICATION": "Authentication",
|
"AUTHENTICATION": "Authentication",
|
||||||
"QUERIES": "Queries",
|
"QUERIES": "Queries",
|
||||||
"QUERY": "Query",
|
"QUERY": "Query",
|
||||||
|
"OPTIONS": "Options",
|
||||||
|
"OPTION": "Option",
|
||||||
"NAME": "Name",
|
"NAME": "Name",
|
||||||
"CODE": "Code",
|
"CODE": "Code",
|
||||||
|
"VALUE": "Value",
|
||||||
|
"RESPONSE-PATH": "Response Path",
|
||||||
"FIELD": "Field",
|
"FIELD": "Field",
|
||||||
"DATA-TYPE": "Data Type",
|
"DATA-TYPE": "Data Type",
|
||||||
"KEY": "Key",
|
"KEY": "Key",
|
||||||
|
|
Loading…
Reference in New Issue