create referenceType entity
This commit is contained in:
parent
df5ae4a278
commit
88bf760165
|
@ -57,4 +57,9 @@ public class AuditableAction {
|
|||
public static final EventId SupportiveMaterial_Persist = new EventId(9002, "SupportiveMaterial_Persist");
|
||||
public static final EventId SupportiveMaterial_Delete = new EventId(9003, "SupportiveMaterial_Delete");
|
||||
|
||||
public static final EventId ReferenceType_Query = new EventId(10000, "ReferenceType_Query");
|
||||
public static final EventId ReferenceType_Lookup = new EventId(10001, "ReferenceType_Lookup");
|
||||
public static final EventId ReferenceType_Persist = new EventId(10002, "ReferenceType_Persist");
|
||||
public static final EventId ReferenceType_Delete = new EventId(10003, "ReferenceType_Delete");
|
||||
|
||||
}
|
||||
|
|
|
@ -101,5 +101,10 @@ public final class Permission {
|
|||
public static String EditSupportiveMaterial= "EditSupportiveMaterial";
|
||||
public static String DeleteSupportiveMaterial = "DeleteSupportiveMaterial";
|
||||
|
||||
//ReferenceType
|
||||
public static String BrowseReferenceType = "BrowseReferenceType";
|
||||
public static String EditReferenceType= "EditReferenceType";
|
||||
public static String DeleteReferenceType = "DeleteReferenceType";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class AuthenticationConfigurationEntity {
|
||||
|
||||
private String authUrl;
|
||||
private String authMethod = "GET";
|
||||
private String authTokenPath;
|
||||
private String authRequestBody;
|
||||
private String type;
|
||||
|
||||
public String getAuthUrl() {
|
||||
return authUrl;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrl")
|
||||
public void setAuthUrl(String authUrl) {
|
||||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrlMethod")
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
public String getAuthTokenPath() {
|
||||
return authTokenPath;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authTokenJpath")
|
||||
public void setAuthTokenPath(String authTokenPath) {
|
||||
this.authTokenPath = authTokenPath;
|
||||
}
|
||||
|
||||
public String getAuthRequestBody() {
|
||||
return authRequestBody;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authUrlBody")
|
||||
public void setAuthRequestBody(String authRequestBody) {
|
||||
this.authRequestBody = authRequestBody;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@XmlElement(name = "authType")
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class DataFieldsUrlConfigurationEntity {
|
||||
private String id;
|
||||
private String name;
|
||||
private String pid;
|
||||
private String pidTypeField;
|
||||
private String uri;
|
||||
private String description;
|
||||
private String source;
|
||||
private String count;
|
||||
// private String path;
|
||||
// private String host;
|
||||
private String types;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@XmlElement(name = "id")
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@XmlElement(name = "name")
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
@XmlElement(name = "pid")
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getPidTypeField() {
|
||||
return pidTypeField;
|
||||
}
|
||||
|
||||
@XmlElement(name = "pidTypeField")
|
||||
public void setPidTypeField(String pidTypeField) {
|
||||
this.pidTypeField = pidTypeField;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
@XmlElement(name = "uri")
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@XmlElement(name = "description")
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@XmlElement(name = "source")
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@XmlElement(name = "count")
|
||||
public void setCount(String count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
// public String getPath() {
|
||||
// return path;
|
||||
// }
|
||||
// @XmlElement(name = "path")
|
||||
// public void setPath(String path) {
|
||||
// this.path = path;
|
||||
// }
|
||||
//
|
||||
// public String getHost() {
|
||||
// return host;
|
||||
// }
|
||||
// @XmlElement(name = "host")
|
||||
// public void setHost(String host) {
|
||||
// this.host = host;
|
||||
// }
|
||||
|
||||
@XmlElement(name = "types")
|
||||
public String getTypes() {
|
||||
return types;
|
||||
}
|
||||
public void setTypes(String types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
@XmlElement(name = "firstName")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@XmlElement(name = "lastName")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataUrlConfigurationEntity {
|
||||
private String path;
|
||||
private DataFieldsUrlConfigurationEntity fieldsUrlConfiguration;
|
||||
// private String parseClass;
|
||||
// private String parseField;
|
||||
// private List<String> mergedFields;
|
||||
// private String mergedFieldName;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@XmlElement(name = "path")
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public DataFieldsUrlConfigurationEntity getFieldsUrlConfiguration() {
|
||||
return fieldsUrlConfiguration;
|
||||
}
|
||||
|
||||
@XmlElement(name = "fields")
|
||||
public void setFieldsUrlConfiguration(DataFieldsUrlConfigurationEntity fieldsUrlConfiguration) {
|
||||
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
|
||||
}
|
||||
|
||||
// public String getParseClass() {
|
||||
// return parseClass;
|
||||
// }
|
||||
//
|
||||
// @XmlElement(name = "parse-class")
|
||||
// public void setParseClass(String parseClass) {
|
||||
// this.parseClass = parseClass;
|
||||
// }
|
||||
//
|
||||
// public String getParseField() {
|
||||
// return parseField;
|
||||
// }
|
||||
//
|
||||
// @XmlElement(name = "parse-field")
|
||||
// public void setParseField(String parseField) {
|
||||
// this.parseField = parseField;
|
||||
// }
|
||||
//
|
||||
// public List<String> getMergedFields() {
|
||||
// return mergedFields;
|
||||
// }
|
||||
//
|
||||
// @XmlElementWrapper(name = "merge-fields")
|
||||
// @XmlElement(name = "field")
|
||||
// public void setMergedFields(List<String> mergedFields) {
|
||||
// this.mergedFields = mergedFields;
|
||||
// }
|
||||
//
|
||||
// public String getMergedFieldName() {
|
||||
// return mergedFieldName;
|
||||
// }
|
||||
//
|
||||
// @XmlElement(name = "merge-field-name")
|
||||
// public void setMergedFieldName(String mergedFieldName) {
|
||||
// this.mergedFieldName = mergedFieldName;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class QueryConfigEntity {
|
||||
|
||||
private String condition;
|
||||
private String separator;
|
||||
private String value;
|
||||
private Integer ordinal;
|
||||
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
@XmlElement(name = "condition")
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
@XmlElement(name = "separator")
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@XmlElement(name = "value")
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ordinal")
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import jakarta.xml.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "definition")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ReferenceTypeDefinitionEntity {
|
||||
@XmlElementWrapper(name = "fields")
|
||||
@XmlElement(name = "field")
|
||||
private List<ReferenceTypeFieldEntity> fields;
|
||||
|
||||
@XmlElementWrapper(name = "urls")
|
||||
@XmlElement(name = "urlConfig")
|
||||
private List<ReferenceTypeUrlConfigurationEntity> urlConfig;
|
||||
|
||||
public List<ReferenceTypeFieldEntity> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<ReferenceTypeFieldEntity> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeUrlConfigurationEntity> getUrlConfig() {
|
||||
return urlConfig;
|
||||
}
|
||||
|
||||
public void setUrlConfig(List<ReferenceTypeUrlConfigurationEntity> urlConfig) {
|
||||
this.urlConfig = urlConfig;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "field")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ReferenceTypeFieldEntity {
|
||||
|
||||
@XmlAttribute(name = "code")
|
||||
private String code;
|
||||
@XmlAttribute(name = "dataType")
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
public ReferenceFieldDataType getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(ReferenceFieldDataType dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package eu.eudat.commons.types.referencetype;
|
||||
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import jakarta.xml.bind.annotation.XmlElementWrapper;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import java.util.List;
|
||||
public class ReferenceTypeUrlConfigurationEntity {
|
||||
|
||||
private String key;
|
||||
private String label;
|
||||
private Integer ordinal;
|
||||
private String url;
|
||||
private DataUrlConfigurationEntity data;
|
||||
private String type;
|
||||
private String paginationPath;
|
||||
private String contentType;
|
||||
private String funderQuery;
|
||||
private String firstpage;
|
||||
private String requestType = "GET";
|
||||
private String requestBody = "";
|
||||
private String filterType = "remote";
|
||||
private AuthenticationConfigurationEntity auth;
|
||||
|
||||
private List<QueryConfigEntity> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
@XmlElement(name = "key")
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
@XmlElement(name = "label")
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
@XmlElement(name = "url")
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
@XmlElement(name = "ordinal")
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public DataUrlConfigurationEntity getData() {
|
||||
return data;
|
||||
}
|
||||
@XmlElement(name = "data")
|
||||
public void setData(DataUrlConfigurationEntity data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getPaginationPath() {
|
||||
return paginationPath;
|
||||
}
|
||||
@XmlElement(name = "paginationpath")
|
||||
public void setPaginationPath(String paginationPath) {
|
||||
this.paginationPath = paginationPath;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
@XmlElement(name = "type")
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
@XmlElement(name = "contenttype")
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getFunderQuery() {
|
||||
return funderQuery;
|
||||
}
|
||||
@XmlElement(name = "funderQuery")
|
||||
public void setFunderQuery(String funderQuery) {
|
||||
this.funderQuery = funderQuery;
|
||||
}
|
||||
|
||||
public String getFirstpage() {
|
||||
return firstpage;
|
||||
}
|
||||
@XmlElement(name = "firstPage")
|
||||
public void setFirstpage(String firstpage) {
|
||||
this.firstpage = firstpage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
@XmlElement(name = "request")
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType != null ? requestType : "GET";
|
||||
}
|
||||
public String getRequestBody() {
|
||||
return requestBody;
|
||||
}
|
||||
@XmlElement(name = "requestBody")
|
||||
public void setRequestBody(String requestBody) {
|
||||
this.requestBody = requestBody != null ? requestBody : "";
|
||||
}
|
||||
public String getFilterType() {
|
||||
return filterType;
|
||||
}
|
||||
@XmlElement(name = "filterType")
|
||||
public void setFilterType(String filterType) {
|
||||
this.filterType = filterType;
|
||||
}
|
||||
|
||||
public List<QueryConfigEntity> getQueries() {
|
||||
return queries;
|
||||
}
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name = "query")
|
||||
public void setQueries(List<QueryConfigEntity> queries) {
|
||||
this.queries = queries;
|
||||
}
|
||||
|
||||
public AuthenticationConfigurationEntity getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
@XmlElement(name="authentication")
|
||||
public void setAuth(AuthenticationConfigurationEntity auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ReferenceType\"")
|
||||
public class ReferenceTypeEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
@Column(name = "name", length = 250, nullable = false)
|
||||
private String name;
|
||||
public static final String _name = "name";
|
||||
|
||||
@Column(name = "code", length = 100, nullable = false)
|
||||
private String code;
|
||||
public static final String _code = "code";
|
||||
|
||||
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
||||
@Column(name = "definition", columnDefinition = "xml")
|
||||
private String definition;
|
||||
public static final String _definition = "definition";
|
||||
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReferenceType {
|
||||
|
||||
private UUID id;
|
||||
public static final String _id = "id";
|
||||
|
||||
private String name;
|
||||
public static final String _name = "name";
|
||||
|
||||
private String code;
|
||||
public static final String _code = "code";
|
||||
|
||||
private ReferenceTypeDefinition definition;
|
||||
public static final String _definition = "definition";
|
||||
|
||||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
private Instant createdAt;
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ReferenceTypeDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(ReferenceTypeDefinition definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package eu.eudat.model.builder;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.referencedefinition.DefinitionBuilder;
|
||||
import eu.eudat.model.builder.referencetypedefinition.ReferenceTypeDefinitionBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
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 ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTypeEntity>{
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeBuilder(
|
||||
ConventionService conventionService,
|
||||
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public ReferenceTypeBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReferenceType> build(FieldSet fields, List<ReferenceTypeEntity> 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 definitionFields = fields.extractPrefixed(this.asPrefix(ReferenceType._definition));
|
||||
|
||||
List<ReferenceType> models = new ArrayList<>();
|
||||
for (ReferenceTypeEntity d : data) {
|
||||
ReferenceType m = new ReferenceType();
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._id))) m.setId(d.getId());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._name))) m.setName(d.getName());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._isActive))) m.setIsActive(d.getIsActive());
|
||||
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
||||
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition());
|
||||
m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
||||
}
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.AuthenticationConfigurationEntity;
|
||||
import eu.eudat.commons.types.referencetype.QueryConfigEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.AuthenticationConfiguration;
|
||||
import eu.eudat.model.referencetypedefinition.QueryConfig;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class AuthenticationConfigurationBuilder extends BaseBuilder<AuthenticationConfiguration, AuthenticationConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public AuthenticationConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(AuthenticationConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public AuthenticationConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthenticationConfiguration> build(FieldSet fields, List<AuthenticationConfigurationEntity> 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<AuthenticationConfiguration> models = new ArrayList<>();
|
||||
for (AuthenticationConfigurationEntity d : data) {
|
||||
AuthenticationConfiguration m = new AuthenticationConfiguration();
|
||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authUrl))) m.setAuthUrl(d.getAuthUrl());
|
||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authMethod))) m.setAuthMethod(d.getAuthMethod());
|
||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authTokenPath))) m.setAuthTokenPath(d.getAuthTokenPath());
|
||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authRequestBody))) m.setAuthRequestBody(d.getAuthRequestBody());
|
||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._type))) m.setType(d.getType());
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.DataFieldsUrlConfigurationEntity;
|
||||
import eu.eudat.commons.types.referencetype.QueryConfigEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.DataFieldsUrlConfiguration;
|
||||
import eu.eudat.model.referencetypedefinition.QueryConfig;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class DataFieldsUrlConfigurationBuilder extends BaseBuilder<DataFieldsUrlConfiguration, DataFieldsUrlConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public DataFieldsUrlConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DataFieldsUrlConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public DataFieldsUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataFieldsUrlConfiguration> build(FieldSet fields, List<DataFieldsUrlConfigurationEntity> data) throws MyApplicationException {
|
||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
List<DataFieldsUrlConfiguration> models = new ArrayList<>();
|
||||
for (DataFieldsUrlConfigurationEntity d : data) {
|
||||
DataFieldsUrlConfiguration m = new DataFieldsUrlConfiguration();
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._id))) m.setId(d.getId());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._name))) m.setName(d.getName());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._pid))) m.setPid(d.getPid());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._pidTypeField))) m.setPidTypeField(d.getPidTypeField());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._uri))) m.setUri(d.getUri());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._description))) m.setDescription(d.getDescription());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._source))) m.setSource(d.getSource());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._count))) m.setCount(d.getCount());
|
||||
// if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._path))) m.setPath(d.getPath());
|
||||
// if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._host))) m.setHost(d.getHost());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._types))) m.setTypes(d.getTypes());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._firstName))) m.setFirstName(d.getFirstName());
|
||||
if (fields.hasField(this.asIndexer(DataFieldsUrlConfiguration._lastName))) m.setLastName(d.getLastName());
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.DataUrlConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.DataUrlConfiguration;
|
||||
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 DataUrlConfigurationBuilder extends BaseBuilder<DataUrlConfiguration, DataUrlConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public DataUrlConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DataUrlConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public DataUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataUrlConfiguration> build(FieldSet fields, List<DataUrlConfigurationEntity> data) throws MyApplicationException {
|
||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
FieldSet fieldsUrlConfigFields = fields.extractPrefixed(this.asPrefix(DataUrlConfiguration._fieldsUrlConfiguration));
|
||||
|
||||
List<DataUrlConfiguration> models = new ArrayList<>();
|
||||
for (DataUrlConfigurationEntity d : data) {
|
||||
DataUrlConfiguration m = new DataUrlConfiguration();
|
||||
if (fields.hasField(this.asIndexer(DataUrlConfiguration._path))) m.setPath(d.getPath());
|
||||
if (!fieldsUrlConfigFields.isEmpty() && d.getFieldsUrlConfiguration() != null) {
|
||||
m.setFieldsUrlConfiguration(this.builderFactory.builder(DataFieldsUrlConfigurationBuilder.class).authorize(this.authorize).build(fieldsUrlConfigFields, d.getFieldsUrlConfiguration()));
|
||||
}
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.QueryConfigEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.QueryConfig;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class QueryConfigBuilder extends BaseBuilder<QueryConfig, QueryConfigEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public QueryConfigBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(QueryConfigBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public QueryConfigBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QueryConfig> build(FieldSet fields, List<QueryConfigEntity> 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<QueryConfig> models = new ArrayList<>();
|
||||
for (QueryConfigEntity d : data) {
|
||||
QueryConfig m = new QueryConfig();
|
||||
if (fields.hasField(this.asIndexer(QueryConfig._condition))) m.setCondition(d.getCondition());
|
||||
if (fields.hasField(this.asIndexer(QueryConfig._separator))) m.setSeparator(d.getSeparator());
|
||||
if (fields.hasField(this.asIndexer(QueryConfig._value))) m.setValue(d.getValue());
|
||||
if (fields.hasField(this.asIndexer(QueryConfig._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
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 ReferenceTypeDefinitionBuilder extends BaseBuilder<ReferenceTypeDefinition, ReferenceTypeDefinitionEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeDefinitionBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeDefinitionBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public ReferenceTypeDefinitionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReferenceTypeDefinition> build(FieldSet fields, List<ReferenceTypeDefinitionEntity> 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 fieldsFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._fields));
|
||||
FieldSet urlConfigFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeDefinition._urlConfig));
|
||||
|
||||
List<ReferenceTypeDefinition> models = new ArrayList<>();
|
||||
for (ReferenceTypeDefinitionEntity d : data) {
|
||||
ReferenceTypeDefinition m = new ReferenceTypeDefinition();
|
||||
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceTypeFieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
|
||||
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setUrlConfig(this.builderFactory.builder(ReferenceTypeUrlConfigurationBuilder.class).authorize(this.authorize).build(urlConfigFields, d.getUrlConfig()));
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeFieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeField;
|
||||
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 ReferenceTypeFieldBuilder extends BaseBuilder<ReferenceTypeField, ReferenceTypeFieldEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeFieldBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeFieldBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public ReferenceTypeFieldBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReferenceTypeField> build(FieldSet fields, List<ReferenceTypeFieldEntity> 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<ReferenceTypeField> models = new ArrayList<>();
|
||||
for (ReferenceTypeFieldEntity d : data) {
|
||||
ReferenceTypeField m = new ReferenceTypeField();
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._code))) m.setCode(d.getCode());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeField._dataType))) m.setDataType(d.getDataType());
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package eu.eudat.model.builder.referencetypedefinition;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeUrlConfigurationEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeUrlConfiguration;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.DataLogEntry;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeUrlConfigurationBuilder extends BaseBuilder<ReferenceTypeUrlConfiguration, ReferenceTypeUrlConfigurationEntity> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeUrlConfigurationBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeUrlConfigurationBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
public ReferenceTypeUrlConfigurationBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReferenceTypeUrlConfiguration> build(FieldSet fields, List<ReferenceTypeUrlConfigurationEntity> data) throws MyApplicationException {
|
||||
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||
if (fields == null || data == null || fields.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
FieldSet dataFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._data));
|
||||
FieldSet authFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._auth));
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asPrefix(ReferenceTypeUrlConfiguration._queries));
|
||||
|
||||
List<ReferenceTypeUrlConfiguration> models = new ArrayList<>();
|
||||
for (ReferenceTypeUrlConfigurationEntity d : data) {
|
||||
ReferenceTypeUrlConfiguration m = new ReferenceTypeUrlConfiguration();
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._key))) m.setKey(d.getKey());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._label))) m.setLabel(d.getLabel());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._url))) m.setUrl(d.getUrl());
|
||||
if (!dataFields.isEmpty() && d.getData() != null) {
|
||||
m.setData(this.builderFactory.builder(DataUrlConfigurationBuilder.class).authorize(this.authorize).build(dataFields, d.getData()));
|
||||
}
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._type))) m.setType(d.getType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._paginationPath))) m.setPaginationPath(d.getPaginationPath());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._contentType))) m.setContentType(d.getContentType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._funderQuery))) m.setFunderQuery(d.getFunderQuery());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._firstPage))) m.setFirstPage(d.getFirstpage());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._requestType))) m.setRequestType(d.getRequestType());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._requestBody))) m.setRequestBody(d.getRequestBody());
|
||||
if (fields.hasField(this.asIndexer(ReferenceTypeUrlConfiguration._filterType))) m.setFilterType(d.getFilterType());
|
||||
if (!authFields.isEmpty() && d.getAuth() != null) {
|
||||
m.setAuth(this.builderFactory.builder(AuthenticationConfigurationBuilder.class).authorize(this.authorize).build(authFields, d.getAuth()));
|
||||
}
|
||||
if (!queriesFields.isEmpty() && d.getQueries() != null) {
|
||||
m.setQueries(this.builderFactory.builder(QueryConfigBuilder.class).authorize(this.authorize).build(queriesFields, d.getQueries()));
|
||||
}
|
||||
|
||||
models.add(m);
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package eu.eudat.model.censorship;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.censorship.referencetype.ReferenceTypeDefinitionCensor;
|
||||
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 ReferenceTypeCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public ReferenceTypeCensor(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 definitionFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceType._definition));
|
||||
this.censorFactory.censor(ReferenceTypeDefinitionCensor.class).censor(definitionFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
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 DataFieldsUrlConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DataFieldsUrlConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
public DataFieldsUrlConfigurationCensor(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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package eu.eudat.model.censorship.referencetype;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.referencetypedefinition.DataUrlConfiguration;
|
||||
import 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 DataUrlConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DataUrlConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public DataUrlConfigurationCensor(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 fieldsUrlFields = fields.extractPrefixed(this.asIndexerPrefix(DataUrlConfiguration._fieldsUrlConfiguration));
|
||||
this.censorFactory.censor(DataFieldsUrlConfigurationCensor.class).censor(fieldsUrlFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.model.censorship.referencetype;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import 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 ReferenceTypeDefinitionCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeDefinitionCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public ReferenceTypeDefinitionCensor(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 fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._fields));
|
||||
this.censorFactory.censor(ReferenceTypeFieldCensor.class).censor(fieldsFields, userId);
|
||||
|
||||
FieldSet urlConfigFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeDefinition._urlConfig));
|
||||
this.censorFactory.censor(ReferenceTypeUrlConfigurationCensor.class).censor(urlConfigFields, userId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
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 ReferenceTypeFieldCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeFieldCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
|
||||
public ReferenceTypeFieldCensor(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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.eudat.model.censorship.referencetype;
|
||||
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.censorship.BaseCensor;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeUrlConfiguration;
|
||||
import 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 ReferenceTypeUrlConfigurationCensor extends BaseCensor {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeUrlConfigurationCensor.class));
|
||||
|
||||
protected final AuthorizationService authService;
|
||||
protected final CensorFactory censorFactory;
|
||||
|
||||
public ReferenceTypeUrlConfigurationCensor(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 dataFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._data));
|
||||
this.censorFactory.censor(DataUrlConfigurationCensor.class).censor(dataFields, userId);
|
||||
|
||||
FieldSet authFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._auth));
|
||||
this.censorFactory.censor(AuthenticationConfigurationCensor.class).censor(authFields, userId);
|
||||
|
||||
FieldSet queriesFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceTypeUrlConfiguration._queries));
|
||||
this.censorFactory.censor(QueryConfigCensor.class).censor(queriesFields, userId);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package eu.eudat.model.deleter;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import gr.cite.tools.data.deleter.Deleter;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.persistence.EntityManager;
|
||||
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 javax.management.InvalidApplicationException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeDeleter implements Deleter {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeDeleter.class));
|
||||
private final EntityManager entityManager;
|
||||
|
||||
protected final QueryFactory queryFactory;
|
||||
|
||||
protected final DeleterFactory deleterFactory;
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeDeleter(
|
||||
EntityManager entityManager,
|
||||
QueryFactory queryFactory,
|
||||
DeleterFactory deleterFactory
|
||||
) {
|
||||
this.entityManager = entityManager;
|
||||
this.queryFactory = queryFactory;
|
||||
this.deleterFactory = deleterFactory;
|
||||
}
|
||||
|
||||
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||
List<ReferenceTypeEntity> data = this.queryFactory.query(ReferenceTypeQuery.class).ids(ids).collect();
|
||||
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
this.deleteAndSave(data);
|
||||
}
|
||||
|
||||
public void deleteAndSave(List<ReferenceTypeEntity> data) throws InvalidApplicationException {
|
||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
this.delete(data);
|
||||
logger.trace("saving changes");
|
||||
this.entityManager.flush();
|
||||
logger.trace("changes saved");
|
||||
}
|
||||
|
||||
public void delete(List<ReferenceTypeEntity> data) throws InvalidApplicationException {
|
||||
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
if (data == null || data.isEmpty())
|
||||
return;
|
||||
|
||||
Instant now = Instant.now();
|
||||
|
||||
for (ReferenceTypeEntity item : data) {
|
||||
logger.trace("deleting item {}", item.getId());
|
||||
item.setIsActive(IsActive.Inactive);
|
||||
item.setUpdatedAt(now);
|
||||
logger.trace("updating item");
|
||||
this.entityManager.merge(item);
|
||||
logger.trace("updated item");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package eu.eudat.model.persist;
|
||||
|
||||
import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
|
||||
import eu.eudat.commons.validation.ValidId;
|
||||
import eu.eudat.model.persist.referencetypedefinition.ReferenceTypeDefinitionPersist;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
|
||||
public class ReferenceTypePersist {
|
||||
|
||||
@ValidId(message = "{validation.invalidid}")
|
||||
private UUID id;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
@Size(max = 250, message = "{validation.largerthanmax}")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
@Size(max = 100, message = "{validation.largerthanmax}")
|
||||
private String code;
|
||||
|
||||
@Valid
|
||||
private ReferenceTypeDefinitionPersist definition;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ReferenceTypeDefinitionPersist getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(ReferenceTypeDefinitionPersist definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class AuthenticationConfigurationPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authUrl;
|
||||
|
||||
private String authMethod = "GET";
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authTokenPath;
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String authRequestBody;
|
||||
@NotNull(message = "{validation.empty}")
|
||||
private String type;
|
||||
|
||||
public String getAuthUrl() {
|
||||
return authUrl;
|
||||
}
|
||||
|
||||
public void setAuthUrl(String authUrl) {
|
||||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
public String getAuthTokenPath() {
|
||||
return authTokenPath;
|
||||
}
|
||||
|
||||
public void setAuthTokenPath(String authTokenPath) {
|
||||
this.authTokenPath = authTokenPath;
|
||||
}
|
||||
|
||||
public String getAuthRequestBody() {
|
||||
return authRequestBody;
|
||||
}
|
||||
|
||||
public void setAuthRequestBody(String authRequestBody) {
|
||||
this.authRequestBody = authRequestBody;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
public class DataFieldsUrlConfigurationPersist {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String pid;
|
||||
private String pidTypeField;
|
||||
private String uri;
|
||||
private String description;
|
||||
private String source;
|
||||
private String count;
|
||||
private String types;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getPidTypeField() {
|
||||
return pidTypeField;
|
||||
}
|
||||
|
||||
public void setPidTypeField(String pidTypeField) {
|
||||
this.pidTypeField = pidTypeField;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(String count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(String types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class DataUrlConfigurationPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String path;
|
||||
|
||||
@Valid
|
||||
private DataFieldsUrlConfigurationPersist fieldsUrlConfiguration;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public DataFieldsUrlConfigurationPersist getFieldsUrlConfiguration() {
|
||||
return fieldsUrlConfiguration;
|
||||
}
|
||||
|
||||
public void setFieldsUrlConfiguration(DataFieldsUrlConfigurationPersist fieldsUrlConfiguration) {
|
||||
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
public class QueryConfigPersist {
|
||||
|
||||
private String condition;
|
||||
private String separator;
|
||||
private String value;
|
||||
private Integer ordinal;
|
||||
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
@XmlElement(name = "condition")
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
@XmlElement(name = "separator")
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@XmlElement(name = "value")
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ordinal")
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import eu.eudat.model.persist.dmpblueprintdefinition.SectionPersist;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeDefinitionPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private List<ReferenceTypeFieldPersist> fields = null;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private List<ReferenceTypeUrlConfigurationPersist> urlConfig = null;
|
||||
|
||||
public List<ReferenceTypeFieldPersist> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<ReferenceTypeFieldPersist> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeUrlConfigurationPersist> getUrlConfig() {
|
||||
return urlConfig;
|
||||
}
|
||||
|
||||
public void setUrlConfig(List<ReferenceTypeUrlConfigurationPersist> urlConfig) {
|
||||
this.urlConfig = urlConfig;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.validation.ValidEnum;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class ReferenceTypeFieldPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String code = null;
|
||||
|
||||
@ValidEnum(message = "{validation.empty}")
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ReferenceFieldDataType getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(ReferenceFieldDataType dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package eu.eudat.model.persist.referencetypedefinition;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeUrlConfigurationPersist {
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String key;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String label;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private Integer ordinal;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String url;
|
||||
|
||||
@Valid
|
||||
private DataUrlConfigurationPersist data;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String type;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String paginationPath;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String contentType;
|
||||
|
||||
private String funderQuery;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@NotEmpty(message = "{validation.empty}")
|
||||
private String firstpage;
|
||||
|
||||
private String requestType = "GET";
|
||||
private String requestBody = "";
|
||||
private String filterType = "remote";
|
||||
|
||||
@Valid
|
||||
private AuthenticationConfigurationPersist auth;
|
||||
|
||||
@Valid
|
||||
private List<QueryConfigPersist> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public DataUrlConfigurationPersist getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataUrlConfigurationPersist data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPaginationPath() {
|
||||
return paginationPath;
|
||||
}
|
||||
|
||||
public void setPaginationPath(String paginationPath) {
|
||||
this.paginationPath = paginationPath;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getFunderQuery() {
|
||||
return funderQuery;
|
||||
}
|
||||
|
||||
public void setFunderQuery(String funderQuery) {
|
||||
this.funderQuery = funderQuery;
|
||||
}
|
||||
|
||||
public String getFirstpage() {
|
||||
return firstpage;
|
||||
}
|
||||
|
||||
public void setFirstpage(String firstpage) {
|
||||
this.firstpage = firstpage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public void setRequestBody(String requestBody) {
|
||||
this.requestBody = requestBody;
|
||||
}
|
||||
|
||||
public String getFilterType() {
|
||||
return filterType;
|
||||
}
|
||||
|
||||
public void setFilterType(String filterType) {
|
||||
this.filterType = filterType;
|
||||
}
|
||||
|
||||
public AuthenticationConfigurationPersist getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setAuth(AuthenticationConfigurationPersist auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public List<QueryConfigPersist> getQueries() {
|
||||
return queries;
|
||||
}
|
||||
|
||||
public void setQueries(List<QueryConfigPersist> queries) {
|
||||
this.queries = queries;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
public class AuthenticationConfiguration {
|
||||
|
||||
public final static String _authUrl = "authUrl";
|
||||
private String authUrl;
|
||||
|
||||
public final static String _authMethod = "authMethod";
|
||||
private String authMethod = "GET";
|
||||
|
||||
public final static String _authTokenPath = "authTokenPath";
|
||||
private String authTokenPath;
|
||||
|
||||
public final static String _authRequestBody = "authRequestBody";
|
||||
private String authRequestBody;
|
||||
|
||||
public final static String _type = "type";
|
||||
private String type;
|
||||
|
||||
public String getAuthUrl() {
|
||||
return authUrl;
|
||||
}
|
||||
|
||||
|
||||
public void setAuthUrl(String authUrl) {
|
||||
this.authUrl = authUrl;
|
||||
}
|
||||
|
||||
public String getAuthMethod() {
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
|
||||
public void setAuthMethod(String authMethod) {
|
||||
this.authMethod = authMethod;
|
||||
}
|
||||
|
||||
public String getAuthTokenPath() {
|
||||
return authTokenPath;
|
||||
}
|
||||
|
||||
|
||||
public void setAuthTokenPath(String authTokenPath) {
|
||||
this.authTokenPath = authTokenPath;
|
||||
}
|
||||
|
||||
public String getAuthRequestBody() {
|
||||
return authRequestBody;
|
||||
}
|
||||
|
||||
|
||||
public void setAuthRequestBody(String authRequestBody) {
|
||||
this.authRequestBody = authRequestBody;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
public class DataFieldsUrlConfiguration {
|
||||
|
||||
public final static String _id = "id";
|
||||
private String id;
|
||||
|
||||
public final static String _name = "name";
|
||||
private String name;
|
||||
|
||||
public final static String _pid = "pid";
|
||||
private String pid;
|
||||
|
||||
public final static String _pidTypeField = "pidTypeField";
|
||||
private String pidTypeField;
|
||||
|
||||
public final static String _uri = "uri";
|
||||
private String uri;
|
||||
|
||||
public final static String _description= "description";
|
||||
private String description;
|
||||
|
||||
public final static String _source = "source";
|
||||
private String source;
|
||||
|
||||
public final static String _count = "count";
|
||||
private String count;
|
||||
|
||||
// public final static String _path = "path";
|
||||
// private String path;
|
||||
//
|
||||
// public final static String _host = "host";
|
||||
// private String host;
|
||||
|
||||
public final static String _types = "types";
|
||||
private String types;
|
||||
|
||||
public final static String _firstName = "firstName";
|
||||
private String firstName;
|
||||
|
||||
public final static String _lastName = "lastName";
|
||||
private String lastName;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getPidTypeField() {
|
||||
return pidTypeField;
|
||||
}
|
||||
|
||||
public void setPidTypeField(String pidTypeField) {
|
||||
this.pidTypeField = pidTypeField;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(String count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
// public String getPath() {
|
||||
// return path;
|
||||
// }
|
||||
//
|
||||
// public void setPath(String path) {
|
||||
// this.path = path;
|
||||
// }
|
||||
//
|
||||
// public String getHost() {
|
||||
// return host;
|
||||
// }
|
||||
//
|
||||
// public void setHost(String host) {
|
||||
// this.host = host;
|
||||
// }
|
||||
|
||||
public String getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(String types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataUrlConfiguration {
|
||||
|
||||
public final static String _path = "path";
|
||||
private String path;
|
||||
|
||||
public final static String _fieldsUrlConfiguration = "fieldsUrlConfiguration";
|
||||
private DataFieldsUrlConfiguration fieldsUrlConfiguration;
|
||||
|
||||
// public final static String _parseClass = "parseClass";
|
||||
// private String parseClass;
|
||||
//
|
||||
// public final static String _parseField = "parseField";
|
||||
// private String parseField;
|
||||
//
|
||||
// public final static String _mergedFields = "mergedFields";
|
||||
// private List<String> mergedFields;
|
||||
//
|
||||
// public final static String _mergedFieldName = "mergedFieldName";
|
||||
// private String mergedFieldName;
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public DataFieldsUrlConfiguration getFieldsUrlConfiguration() {
|
||||
return fieldsUrlConfiguration;
|
||||
}
|
||||
|
||||
public void setFieldsUrlConfiguration(DataFieldsUrlConfiguration fieldsUrlConfiguration) {
|
||||
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
|
||||
}
|
||||
|
||||
// public String getParseClass() {
|
||||
// return parseClass;
|
||||
// }
|
||||
//
|
||||
// public void setParseClass(String parseClass) {
|
||||
// this.parseClass = parseClass;
|
||||
// }
|
||||
//
|
||||
// public String getParseField() {
|
||||
// return parseField;
|
||||
// }
|
||||
//
|
||||
// public void setParseField(String parseField) {
|
||||
// this.parseField = parseField;
|
||||
// }
|
||||
//
|
||||
// public List<String> getMergedFields() {
|
||||
// return mergedFields;
|
||||
// }
|
||||
//
|
||||
// public void setMergedFields(List<String> mergedFields) {
|
||||
// this.mergedFields = mergedFields;
|
||||
// }
|
||||
//
|
||||
// public String getMergedFieldName() {
|
||||
// return mergedFieldName;
|
||||
// }
|
||||
//
|
||||
// public void setMergedFieldName(String mergedFieldName) {
|
||||
// this.mergedFieldName = mergedFieldName;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
public class QueryConfig {
|
||||
|
||||
public final static String _condition = "condition";
|
||||
private String condition;
|
||||
|
||||
public final static String _separator = "separator";
|
||||
private String separator;
|
||||
|
||||
public final static String _value = "value";
|
||||
private String value;
|
||||
|
||||
public final static String _ordinal = "ordinal";
|
||||
private Integer ordinal;
|
||||
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeDefinition {
|
||||
|
||||
public final static String _fields = "fields";
|
||||
private List<ReferenceTypeField> fields;
|
||||
|
||||
public final static String _urlConfig = "urlConfig";
|
||||
private List<ReferenceTypeUrlConfiguration> urlConfig;
|
||||
|
||||
public List<ReferenceTypeField> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<ReferenceTypeField> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<ReferenceTypeUrlConfiguration> getUrlConfig() {
|
||||
return urlConfig;
|
||||
}
|
||||
|
||||
public void setUrlConfig(List<ReferenceTypeUrlConfiguration> urlConfig) {
|
||||
this.urlConfig = urlConfig;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
|
||||
public class ReferenceTypeField {
|
||||
|
||||
public final static String _code = "code";
|
||||
private String code;
|
||||
|
||||
public final static String _dataType = "dataType";
|
||||
private ReferenceFieldDataType dataType;
|
||||
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ReferenceFieldDataType getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(ReferenceFieldDataType dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package eu.eudat.model.referencetypedefinition;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReferenceTypeUrlConfiguration {
|
||||
|
||||
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";
|
||||
private String url;
|
||||
|
||||
|
||||
public final static String _data = "data";
|
||||
private DataUrlConfiguration data;
|
||||
|
||||
public final static String _type = "type";
|
||||
private String type;
|
||||
|
||||
public final static String _paginationPath = "paginationPath";
|
||||
private String paginationPath;
|
||||
|
||||
public final static String _contentType = "contentType";
|
||||
private String contentType;
|
||||
|
||||
public final static String _funderQuery = "funderQuery";
|
||||
private String funderQuery;
|
||||
|
||||
public final static String _firstPage = "firstPage";
|
||||
private String firstPage;
|
||||
|
||||
public final static String _requestType = "requestType";
|
||||
private String requestType = "GET";
|
||||
|
||||
public final static String _requestBody = "requestBody";
|
||||
private String requestBody = "";
|
||||
|
||||
public final static String _filterType = "filterType";
|
||||
private String filterType = "remote";
|
||||
|
||||
public final static String _auth = "auth";
|
||||
private AuthenticationConfiguration auth;
|
||||
|
||||
public final static String _queries = "queries";
|
||||
private List<QueryConfig> queries;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public DataUrlConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(DataUrlConfiguration data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPaginationPath() {
|
||||
return paginationPath;
|
||||
}
|
||||
|
||||
public void setPaginationPath(String paginationPath) {
|
||||
this.paginationPath = paginationPath;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getFunderQuery() {
|
||||
return funderQuery;
|
||||
}
|
||||
|
||||
public void setFunderQuery(String funderQuery) {
|
||||
this.funderQuery = funderQuery;
|
||||
}
|
||||
|
||||
public String getFirstPage() {
|
||||
return firstPage;
|
||||
}
|
||||
|
||||
public void setFirstPage(String firstPage) {
|
||||
this.firstPage = firstPage;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public void setRequestBody(String requestBody) {
|
||||
this.requestBody = requestBody;
|
||||
}
|
||||
|
||||
public String getFilterType() {
|
||||
return filterType;
|
||||
}
|
||||
|
||||
public void setFilterType(String filterType) {
|
||||
this.filterType = filterType;
|
||||
}
|
||||
|
||||
public AuthenticationConfiguration getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setAuth(AuthenticationConfiguration auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public List<QueryConfig> getQueries() {
|
||||
return queries;
|
||||
}
|
||||
|
||||
public void setQueries(List<QueryConfig> queries) {
|
||||
this.queries = queries;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
|
||||
|
||||
private String like;
|
||||
|
||||
private Collection<UUID> ids;
|
||||
|
||||
private Collection<IsActive> isActives;
|
||||
|
||||
private Collection<String> codes;
|
||||
|
||||
private Collection<UUID> excludedIds;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
public ReferenceTypeQuery like(String value) {
|
||||
this.like = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery ids(Collection<UUID> values) {
|
||||
this.ids = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery isActive(IsActive value) {
|
||||
this.isActives = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery isActive(IsActive... value) {
|
||||
this.isActives = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery isActive(Collection<IsActive> values) {
|
||||
this.isActives = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery codes(String value) {
|
||||
this.codes = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery codes(String... value) {
|
||||
this.codes = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery codes(Collection<String> values) {
|
||||
this.codes = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery excludedIds(Collection<UUID> values) {
|
||||
this.excludedIds = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery excludedIds(UUID value) {
|
||||
this.excludedIds = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery excludedIds(UUID... value) {
|
||||
this.excludedIds = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReferenceTypeQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final UserScope userScope;
|
||||
|
||||
private final AuthorizationService authService;
|
||||
|
||||
public ReferenceTypeQuery(
|
||||
UserScope userScope,
|
||||
AuthorizationService authService
|
||||
) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ReferenceTypeEntity> entityClass() {
|
||||
return ReferenceTypeEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.codes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceTypeEntity._id));
|
||||
for (UUID item : this.ids)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._code), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._name), this.like)
|
||||
));
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceTypeEntity._isActive));
|
||||
for (IsActive item : this.isActives)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.codes != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._type));
|
||||
for (String item : this.codes)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.excludedIds != null) {
|
||||
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id));
|
||||
for (UUID item : this.excludedIds)
|
||||
notInClause.value(item);
|
||||
predicates.add(notInClause.not());
|
||||
}
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReferenceTypeEntity convert(Tuple tuple, Set<String> columns) {
|
||||
ReferenceTypeEntity item = new ReferenceTypeEntity();
|
||||
item.setId(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._id, UUID.class));
|
||||
item.setName(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._name, String.class));
|
||||
item.setCode(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._code, String.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._isActive, IsActive.class));
|
||||
item.setDefinition(QueryBase.convertSafe(tuple, columns, ReferenceTypeEntity._definition, String.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(ReferenceType._id)) return ReferenceTypeEntity._id;
|
||||
else if (item.match(ReferenceType._name)) return ReferenceTypeEntity._name;
|
||||
else if (item.match(ReferenceType._code)) return ReferenceTypeEntity._code;
|
||||
else if (item.match(ReferenceType._createdAt)) return ReferenceTypeEntity._createdAt;
|
||||
else if (item.match(ReferenceType._updatedAt)) return ReferenceTypeEntity._updatedAt;
|
||||
else if (item.match(ReferenceType._isActive)) return ReferenceTypeEntity._isActive;
|
||||
else if (item.match(ReferenceType._definition)) return ReferenceTypeEntity._definition;
|
||||
else return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReferenceTypeLookup extends Lookup {
|
||||
|
||||
private String like;
|
||||
|
||||
private List<IsActive> isActive;
|
||||
|
||||
private List<UUID> ids;
|
||||
|
||||
private List<String> codes;
|
||||
|
||||
private List<UUID> excludedIds;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public List<IsActive> getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(List<IsActive> isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<String> getCodes() {
|
||||
return codes;
|
||||
}
|
||||
|
||||
public void setCodes(List<String> codes) {
|
||||
this.codes = codes;
|
||||
}
|
||||
|
||||
public List<UUID> getExcludedIds() {
|
||||
return excludedIds;
|
||||
}
|
||||
|
||||
public void setExcludedIds(List<UUID> excludeIds) {
|
||||
this.excludedIds = excludeIds;
|
||||
}
|
||||
|
||||
|
||||
public ReferenceTypeQuery enrich(QueryFactory queryFactory) {
|
||||
ReferenceTypeQuery query = queryFactory.query(ReferenceTypeQuery.class);
|
||||
if (this.like != null) query.like(this.like);
|
||||
if (this.isActive != null) query.isActive(this.isActive);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.codes != null) query.codes(this.codes);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
|
||||
this.enrichCommon(query);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package eu.eudat.service.referencetype;
|
||||
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.persist.ReferenceTypePersist;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ReferenceTypeService {
|
||||
|
||||
ReferenceType persist(ReferenceTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException;
|
||||
|
||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package eu.eudat.service.referencetype;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeFieldEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.SupportiveMaterial;
|
||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.builder.SupportiveMaterialBuilder;
|
||||
import eu.eudat.model.deleter.ReferenceTypeDeleter;
|
||||
import eu.eudat.model.deleter.SupportiveMaterialDeleter;
|
||||
import eu.eudat.model.persist.ReferenceTypePersist;
|
||||
import eu.eudat.model.persist.referencetypedefinition.ReferenceTypeDefinitionPersist;
|
||||
import eu.eudat.model.persist.referencetypedefinition.ReferenceTypeFieldPersist;
|
||||
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Service
|
||||
public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintServiceImpl.class));
|
||||
private final EntityManager entityManager;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final DeleterFactory deleterFactory;
|
||||
private final BuilderFactory builderFactory;
|
||||
private final ConventionService conventionService;
|
||||
private final MessageSource messageSource;
|
||||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
|
||||
|
||||
public ReferenceTypeServiceImpl(
|
||||
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
|
||||
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory,
|
||||
XmlHandlingService xmlHandlingService) {
|
||||
this.entityManager = entityManager;
|
||||
this.authorizationService = authorizationService;
|
||||
this.deleterFactory = deleterFactory;
|
||||
this.builderFactory = builderFactory;
|
||||
this.conventionService = conventionService;
|
||||
this.messageSource = messageSource;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
|
||||
public ReferenceType persist(ReferenceTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{
|
||||
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.EditSupportiveMaterial);
|
||||
|
||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||
|
||||
ReferenceTypeEntity data;
|
||||
if (isUpdate) {
|
||||
data = this.entityManager.find(ReferenceTypeEntity.class, model.getId());
|
||||
if (data == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
} else {
|
||||
|
||||
data = new ReferenceTypeEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setCreatedAt(Instant.now());
|
||||
}
|
||||
|
||||
data.setName(model.getName());
|
||||
data.setCode(model.getCode());
|
||||
data.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(model.getDefinition())));
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
||||
if (isUpdate) this.entityManager.merge(data);
|
||||
else this.entityManager.persist(data);
|
||||
|
||||
this.entityManager.flush();
|
||||
|
||||
return this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, ReferenceType._id), data);
|
||||
}
|
||||
|
||||
private @NotNull ReferenceTypeDefinitionEntity buildDefinitionEntity(ReferenceTypeDefinitionPersist persist){
|
||||
ReferenceTypeDefinitionEntity data = new ReferenceTypeDefinitionEntity();
|
||||
if (persist == null) return data;
|
||||
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
|
||||
data.setFields(new ArrayList<>());
|
||||
for (ReferenceTypeFieldPersist fieldPersist: persist.getFields()) {
|
||||
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private @NotNull ReferenceTypeFieldEntity buildFieldEntity(ReferenceTypeFieldPersist persist){
|
||||
ReferenceTypeFieldEntity data = new ReferenceTypeFieldEntity();
|
||||
if (persist == null) return data;
|
||||
|
||||
data.setCode(persist.getCode());
|
||||
data.setDataType(persist.getDataType());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
logger.debug("deleting : {}", id);
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.DeleteSupportiveMaterial);
|
||||
|
||||
this.deleterFactory.deleter(ReferenceTypeDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package eu.eudat.controllers.v2;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import eu.eudat.audit.AuditableAction;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.controllers.BaseController;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.censorship.ReferenceTypeCensor;
|
||||
import eu.eudat.model.persist.ReferenceTypePersist;
|
||||
import eu.eudat.model.result.QueryResult;
|
||||
import eu.eudat.query.ReferenceTypeQuery;
|
||||
import eu.eudat.query.lookup.ReferenceTypeLookup;
|
||||
import eu.eudat.service.referencetype.ReferenceTypeService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.censor.CensorFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import gr.cite.tools.validation.MyValidate;
|
||||
import jakarta.transaction.Transactional;
|
||||
import jakarta.xml.bind.JAXBException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = {"api/reference-type"})
|
||||
public class ReferenceTypeController extends BaseController {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeController.class));
|
||||
private final BuilderFactory builderFactory;
|
||||
private final AuditService auditService;
|
||||
private final CensorFactory censorFactory;
|
||||
private final QueryFactory queryFactory;
|
||||
private final MessageSource messageSource;
|
||||
private final AuthorizationService authorizationService;
|
||||
private final ReferenceTypeService referenceTypeService;
|
||||
|
||||
@Autowired
|
||||
public ReferenceTypeController(
|
||||
ApiContext apiContext,
|
||||
BuilderFactory builderFactory,
|
||||
AuditService auditService,
|
||||
CensorFactory censorFactory,
|
||||
QueryFactory queryFactory,
|
||||
MessageSource messageSource, AuthorizationService authorizationService, ReferenceTypeService referenceTypeService) {
|
||||
super(apiContext);
|
||||
this.builderFactory = builderFactory;
|
||||
this.auditService = auditService;
|
||||
this.censorFactory = censorFactory;
|
||||
this.queryFactory = queryFactory;
|
||||
this.messageSource = messageSource;
|
||||
this.authorizationService = authorizationService;
|
||||
this.referenceTypeService = referenceTypeService;
|
||||
}
|
||||
|
||||
@PostMapping("query")
|
||||
public QueryResult<ReferenceType> query(@RequestBody ReferenceTypeLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||
logger.debug("querying {}", ReferenceType.class.getSimpleName());
|
||||
|
||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(lookup.getProject(), null);
|
||||
|
||||
ReferenceTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission);
|
||||
List<ReferenceTypeEntity> datas = query.collectAs(lookup.getProject());
|
||||
List<ReferenceType> models = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(lookup.getProject(), datas);
|
||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||
|
||||
this.auditService.track(AuditableAction.ReferenceType_Query, "lookup", lookup);
|
||||
|
||||
return new QueryResult(models, count);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public ReferenceType get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||
|
||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||
|
||||
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id);
|
||||
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||
if (model == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
this.auditService.track(AuditableAction.ReferenceType_Lookup, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@PostMapping("persist")
|
||||
@Transactional
|
||||
public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting" + ReferenceType.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||
|
||||
ReferenceType persisted = this.referenceTypeService.persist(model, fieldSet);
|
||||
|
||||
this.auditService.track(AuditableAction.ReferenceType_Persist, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||
return persisted;
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@Transactional
|
||||
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("id", id));
|
||||
|
||||
this.referenceTypeService.deleteAndSave(id);
|
||||
|
||||
this.auditService.track(AuditableAction.ReferenceType_Delete, "id", id);
|
||||
}
|
||||
|
||||
}
|
|
@ -159,7 +159,7 @@ public class ReferenceService {
|
|||
|
||||
data.setCode(persist.getCode());
|
||||
data.setDataType(persist.getDataType());
|
||||
data.setCode(persist.getCode());
|
||||
data.setValue(persist.getValue());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -342,6 +342,27 @@ permissions:
|
|||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
|
||||
# ReferenceType Permissions
|
||||
BrowseReferenceType:
|
||||
roles:
|
||||
- Admin
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
EditReferenceType:
|
||||
roles:
|
||||
- Admin
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
DeleteReferenceType:
|
||||
roles:
|
||||
- Admin
|
||||
claims: [ ]
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: fals
|
||||
|
||||
|
||||
# DmpDescriptionTemplate Permissions
|
||||
BrowseDmpDescriptionTemplate:
|
||||
|
|
Loading…
Reference in New Issue