Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Diamantis Tziotzios 2023-11-16 15:37:41 +02:00
commit f1d2b9d8d4
1375 changed files with 115466 additions and 5007 deletions

2
.gitignore vendored
View File

@ -50,3 +50,5 @@ bin/
openDMP/dmp-backend/uploads/ openDMP/dmp-backend/uploads/
openDMP/dmp-backend/tmp/ openDMP/dmp-backend/tmp/
storage/ storage/
logs/
dmp-backend/web/src/main/resources/certificates/

View File

@ -15,12 +15,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>dmp-backend</groupId>
<artifactId>queryable</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
@ -39,6 +33,11 @@
<groupId>gr.cite.opendmp</groupId> <groupId>gr.cite.opendmp</groupId>
<artifactId>repositorydepositbase</artifactId> <artifactId>repositorydepositbase</artifactId>
<version>1.0.4</version> <version>1.0.4</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>elastic</artifactId>
<version>2.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.angus</groupId> <groupId>org.eclipse.angus</groupId>
@ -52,8 +51,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>17</source> <source>21</source>
<target>17</target> <target>21</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -31,11 +31,16 @@ public class AuditableAction {
public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup"); public static final EventId Dmp_Lookup = new EventId(5001, "Dmp_Lookup");
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist"); public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete"); public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
public static final EventId Dmp_Clone = new EventId(5004, "Dmp_Clone");
public static final EventId Dmp_PersistNewVersion = new EventId(5005, "Dmp_PersistNewVersion");
public static final EventId Dmp_Assign_Users = new EventId(5006, "Dmp_Assign_Users");
public static final EventId Description_Query = new EventId(6000, "Description_Query"); public static final EventId Description_Query = new EventId(6000, "Description_Query");
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup"); public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
public static final EventId Description_Persist = new EventId(6002, "Description_Persist"); public static final EventId Description_Persist = new EventId(6002, "Description_Persist");
public static final EventId Description_Delete = new EventId(6003, "Description_Delete"); public static final EventId Description_Delete = new EventId(6003, "Description_Delete");
public static final EventId Description_PublicQuery = new EventId(6004, "Description_PublicQuery");
public static final EventId Description_PublicLookup = new EventId(6005, "Description_PublicLookup");
public static final EventId Reference_Query = new EventId(7000, "Reference_Query"); public static final EventId Reference_Query = new EventId(7000, "Reference_Query");
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup"); public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");

View File

@ -3,6 +3,6 @@ package eu.eudat.authorization;
import java.util.EnumSet; import java.util.EnumSet;
public enum AuthorizationFlags { public enum AuthorizationFlags {
None, Permission, Owner; None, Permission, DmpAssociated, Public;
public static final EnumSet<AuthorizationFlags> OwnerOrPermission = EnumSet.of(Owner, Permission); public static final EnumSet<AuthorizationFlags> OwnerOrPermissionOrMemberOrPublic = EnumSet.of(DmpAssociated, Permission, Public);
} }

View File

@ -50,7 +50,11 @@ public final class Permission {
public static String BrowseDmp = "BrowseDmp"; public static String BrowseDmp = "BrowseDmp";
public static String EditDmp = "EditDmp"; public static String EditDmp = "EditDmp";
public static String DeleteDmp = "DeleteDmp"; public static String DeleteDmp = "DeleteDmp";
public static String CloneDmp = "CloneDmp";
public static String CreateNewVersionDmp = "CreateNewVersionDmp"; public static String CreateNewVersionDmp = "CreateNewVersionDmp";
public static String ExportDmp = "ExportDmp";
public static String FinalizeDmp = "FinalizeDmp";
public static String AssignDmpUsers = "AssignDmpUsers";
//DmpBlueprint //DmpBlueprint
public static String BrowseDmpBlueprint = "BrowseDmpBlueprint"; public static String BrowseDmpBlueprint = "BrowseDmpBlueprint";
@ -74,6 +78,12 @@ public final class Permission {
public static String BrowseDescription = "BrowseDescription"; public static String BrowseDescription = "BrowseDescription";
public static String EditDescription = "EditDescription"; public static String EditDescription = "EditDescription";
public static String DeleteDescription = "DeleteDescription"; public static String DeleteDescription = "DeleteDescription";
public static String CloneDescription = "CloneDescription";
//DescriptionTag
public static String BrowseDescriptionTag = "BrowseDescriptionTag";
public static String EditDescriptionTag = "EditDescriptionTag";
public static String DeleteDescriptionTag = "DeleteDescriptionTag";
//DescriptionTemplateType //DescriptionTemplateType
public static String BrowseEntityDoi = "BrowseEntityDoi"; public static String BrowseEntityDoi = "BrowseEntityDoi";

View File

@ -7,7 +7,7 @@ import java.util.Map;
public enum DescriptionStatus implements DatabaseEnum<Short> { public enum DescriptionStatus implements DatabaseEnum<Short> {
Saved((short) 0), Draft((short) 0),
Finalized((short) 1), Finalized((short) 1),
Canceled((short) 2); Canceled((short) 2);

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionTemplateVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Previous ((short) 1);
private final Short value;
DescriptionTemplateVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionTemplateVersionStatus> map = EnumUtils.getEnumValueMap(DescriptionTemplateVersionStatus.class);
public static DescriptionTemplateVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -7,7 +7,7 @@ import java.util.Map;
public enum DmpStatus implements DatabaseEnum<Short> { public enum DmpStatus implements DatabaseEnum<Short> {
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99); Draft((short) 0), Finalized((short) 1);
private final Short value; private final Short value;

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpVersionStatus implements DatabaseEnum<Short> {
Current((short) 0), Previous ((short) 1);
private final Short value;
DmpVersionStatus(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DmpVersionStatus> map = EnumUtils.getEnumValueMap(DmpVersionStatus.class);
public static DmpVersionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,30 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import java.util.Map;
public enum ReferenceTypeExternalApiHTTPMethodType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
GET((short) 0),
@XmlEnumValue(value = "1")
POST((short) 1);
private final Short value;
ReferenceTypeExternalApiHTTPMethodType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ReferenceTypeExternalApiHTTPMethodType> map = EnumUtils.getEnumValueMap(ReferenceTypeExternalApiHTTPMethodType.class);
public static ReferenceTypeExternalApiHTTPMethodType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,36 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import jakarta.xml.bind.annotation.XmlValue;
import java.util.Map;
public enum ReferenceTypeSourceType implements DatabaseEnum<Short> {
@XmlEnumValue(value = "0")
API((short) 0),
@XmlEnumValue(value = "1")
STATIC((short) 1);
private final Short value;
public static class Names {
public static final String API = "api";
public static final String STATIC = "static";
}
ReferenceTypeSourceType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, ReferenceTypeSourceType> map = EnumUtils.getEnumValueMap(ReferenceTypeSourceType.class);
public static ReferenceTypeSourceType of(Short i) {
return map.get(i);
}
}

View File

@ -1,11 +1,12 @@
package eu.eudat.commons.types.referencetype; package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
public class AuthenticationConfigurationEntity { public class AuthenticationConfigurationEntity {
private String authUrl; private String authUrl;
private String authMethod = "GET"; private ReferenceTypeExternalApiHTTPMethodType authMethod;
private String authTokenPath; private String authTokenPath;
private String authRequestBody; private String authRequestBody;
private String type; private String type;
@ -19,12 +20,12 @@ public class AuthenticationConfigurationEntity {
this.authUrl = authUrl; this.authUrl = authUrl;
} }
public String getAuthMethod() { public ReferenceTypeExternalApiHTTPMethodType getAuthMethod() {
return authMethod; return authMethod;
} }
@XmlElement(name = "authUrlMethod") @XmlElement(name = "authUrlMethod")
public void setAuthMethod(String authMethod) { public void setAuthMethod(ReferenceTypeExternalApiHTTPMethodType authMethod) {
this.authMethod = authMethod; this.authMethod = authMethod;
} }
@ -32,7 +33,7 @@ public class AuthenticationConfigurationEntity {
return authTokenPath; return authTokenPath;
} }
@XmlElement(name = "authTokenJpath") @XmlElement(name = "authTokenPath")
public void setAuthTokenPath(String authTokenPath) { public void setAuthTokenPath(String authTokenPath) {
this.authTokenPath = authTokenPath; this.authTokenPath = authTokenPath;
} }

View File

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

View File

@ -1,5 +1,8 @@
package eu.eudat.commons.types.referencetype; package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import eu.eudat.commons.types.descriptiontemplate.importexport.fielddata.*;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
import java.util.List; import java.util.List;
@ -11,9 +14,12 @@ public class ReferenceTypeDefinitionEntity {
@XmlElement(name = "field") @XmlElement(name = "field")
private List<ReferenceTypeFieldEntity> fields; private List<ReferenceTypeFieldEntity> fields;
@XmlElementWrapper(name = "urls") @XmlElementWrapper(name = "sources")
@XmlElement(name = "urlConfig") @XmlElements({
private List<ReferenceTypeUrlConfigurationEntity> urlConfig; @XmlElement(name = ReferenceTypeSourceType.Names.API, type = ReferenceTypeSourceExternalApiConfigurationEntity.class),
@XmlElement(name = ReferenceTypeSourceType.Names.STATIC, type = ReferenceTypeSourceStaticOptionConfigurationEntity.class),
})
private List<ReferenceTypeSourceBaseConfigurationEntity> sources;
public List<ReferenceTypeFieldEntity> getFields() { public List<ReferenceTypeFieldEntity> getFields() {
return fields; return fields;
@ -23,11 +29,11 @@ public class ReferenceTypeDefinitionEntity {
this.fields = fields; this.fields = fields;
} }
public List<ReferenceTypeUrlConfigurationEntity> getUrlConfig() { public List<ReferenceTypeSourceBaseConfigurationEntity> getSources() {
return urlConfig; return sources;
} }
public void setUrlConfig(List<ReferenceTypeUrlConfigurationEntity> urlConfig) { public void setSources(List<ReferenceTypeSourceBaseConfigurationEntity> sources) {
this.urlConfig = urlConfig; this.sources = sources;
} }
} }

View File

@ -12,6 +12,12 @@ public class ReferenceTypeFieldEntity {
@XmlAttribute(name = "code") @XmlAttribute(name = "code")
private String code; private String code;
@XmlAttribute(name = "label")
private String label;
@XmlAttribute(name = "description")
private String description;
@XmlAttribute(name = "dataType") @XmlAttribute(name = "dataType")
private ReferenceFieldDataType dataType; private ReferenceFieldDataType dataType;
@ -24,6 +30,21 @@ public class ReferenceTypeFieldEntity {
this.code = code; this.code = code;
} }
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public ReferenceFieldDataType getDataType() { public ReferenceFieldDataType getDataType() {
return dataType; return dataType;

View File

@ -0,0 +1,51 @@
package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.ReferenceTypeSourceType;
import jakarta.xml.bind.annotation.XmlElement;
public abstract class ReferenceTypeSourceBaseConfigurationEntity {
private String key;
private String label;
private Integer ordinal;
private ReferenceTypeSourceType type;
public ReferenceTypeSourceType getType() {
return type;
}
public String getKey() {
return key;
}
@XmlElement(name = "key")
public void setKey(String key) {
this.key = key;
}
public String getLabel() {
return label;
}
@XmlElement(name = "label")
public void setLabel(String label) {
this.label = label;
}
public Integer getOrdinal() {
return ordinal;
}
@XmlElement(name = "ordinal")
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
@XmlElement(name = "type")
public void setType(ReferenceTypeSourceType type) {
this.type = type;
}
}

View File

@ -0,0 +1,104 @@
package eu.eudat.commons.types.referencetype;
import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class ReferenceTypeSourceExternalApiConfigurationEntity extends ReferenceTypeSourceBaseConfigurationEntity {
private String url;
private ResultsConfigurationEntity results;
private String paginationPath;
private String contentType;
private String firstPage;
private ReferenceTypeExternalApiHTTPMethodType httpMethod;
private String requestBody = "";
private String filterType = "remote";
private AuthenticationConfigurationEntity auth;
private List<QueryConfigEntity> queries;
public String getUrl() {
return url;
}
@XmlElement(name = "url")
public void setUrl(String url) {
this.url = url;
}
public ResultsConfigurationEntity getResults() {
return results;
}
@XmlElement(name = "results")
public void setResults(ResultsConfigurationEntity results) {
this.results = results;
}
public String getPaginationPath() {
return paginationPath;
}
@XmlElement(name = "paginationPath")
public void setPaginationPath(String paginationPath) {
this.paginationPath = paginationPath;
}
public String getContentType() {
return contentType;
}
@XmlElement(name = "contentType")
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getFirstPage() {
return firstPage;
}
@XmlElement(name = "firstPage")
public void setFirstPage(String firstPage) {
this.firstPage = firstPage;
}
public ReferenceTypeExternalApiHTTPMethodType getHttpMethod() {
return httpMethod;
}
@XmlElement(name = "requestHttpMethod")
public void setHttpMethod(ReferenceTypeExternalApiHTTPMethodType httpMethod) {
this.httpMethod = httpMethod != null ? httpMethod : ReferenceTypeExternalApiHTTPMethodType.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;
}
}

View File

@ -0,0 +1,21 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class ReferenceTypeSourceStaticOptionConfigurationEntity extends ReferenceTypeSourceBaseConfigurationEntity {
List<ReferenceTypeStaticOptionEntity> options;
public List<ReferenceTypeStaticOptionEntity> getOptions() {
return options;
}
@XmlElementWrapper
@XmlElement(name = "option")
public void setOptions(List<ReferenceTypeStaticOptionEntity> options) {
this.options = options;
}
}

View File

@ -0,0 +1,28 @@
package eu.eudat.commons.types.referencetype;
import jakarta.xml.bind.annotation.XmlElement;
public class ReferenceTypeStaticOptionEntity {
private String code;
private String value;
public String getCode() {
return code;
}
@XmlElement(name = "code")
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
@XmlElement(name = "value")
public void setValue(String value) {
this.value = value;
}
}

View File

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

View File

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

View File

@ -0,0 +1,20 @@
package eu.eudat.configurations.elastic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(AppElasticProperties.class)
public class AppElasticConfiguration {
private final AppElasticProperties properties;
@Autowired
public AppElasticConfiguration(AppElasticProperties properties) {
this.properties = properties;
}
public AppElasticProperties getProperties() {
return properties;
}
}

View File

@ -0,0 +1,43 @@
package eu.eudat.configurations.elastic;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "app-elastic")
public class AppElasticProperties {
private boolean enabled;
private String dmpIndexName;
private String descriptionIndexName;
private boolean enableIcuAnalysisPlugin;
public String getDmpIndexName() {
return dmpIndexName;
}
public void setDmpIndexName(String dmpIndexName) {
this.dmpIndexName = dmpIndexName;
}
public boolean isEnableIcuAnalysisPlugin() {
return enableIcuAnalysisPlugin;
}
public void setEnableIcuAnalysisPlugin(boolean enableIcuAnalysisPlugin) {
this.enableIcuAnalysisPlugin = enableIcuAnalysisPlugin;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getDescriptionIndexName() {
return descriptionIndexName;
}
public void setDescriptionIndexName(String descriptionIndexName) {
this.descriptionIndexName = descriptionIndexName;
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.configurations.typedefinition;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
/**
* @deprecated hibernate's abstract class is depricated and those type of conversions and checks
* are done by hibernate itself
*/
@Deprecated
public class PostgreSQLEnumType extends org.hibernate.type.EnumType {
public void nullSafeSet(
PreparedStatement st,
Object value,
int index,
SharedSessionContractImplementor session)
throws HibernateException, SQLException {
st.setObject(
index,
value != null ?
((Enum) value).name() :
null,
Types.OTHER
);
}
}

View File

@ -1,118 +0,0 @@
package eu.eudat.configurations.typedefinition;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.UUID;
/**
* Currently not used
*/
public class UUIDType implements UserType<UUID> {
private final int[] sqlTypesSupported = new int[]{Types.NUMERIC};
private final String CAST_EXCEPTION_TEXT = " cannot be cast to a java.util.UUID";
public int[] sqlTypes() {
return sqlTypesSupported;
}
@Override
public int getSqlType() {
return sqlTypesSupported[0];
}
public Class<UUID> returnedClass() {
return UUID.class;
}
public boolean equals(UUID x, UUID y) throws HibernateException {
if (x == null) return y == null;
else return x.equals(y);
}
public int hashCode(UUID x) throws HibernateException {
return x == null ? -1 : x.hashCode();
}
@Override
public UUID nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
assert (position >= 0);
Object value = rs.getObject(position);
if (value == null) return null;
UUID uuid = UUID.fromString(rs.getString(position));
return rs.wasNull() ? null : uuid;
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
assert (names.length == 1);
Object value = rs.getObject(names[0]);
if (value == null) return null;
UUID uuid = UUID.fromString(rs.getString(names[0]));
return rs.wasNull() ? null : uuid;
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
st.setNull(index, Types.NULL);
return;
}
if (!UUID.class.isAssignableFrom(value.getClass()))
throw new HibernateException(value.getClass().toString() + CAST_EXCEPTION_TEXT);
UUID uuid = (UUID) value;
st.setObject(index, uuid, Types.OTHER);
}
public UUID deepCopy(UUID value) throws HibernateException {
if (value == null) return null;
return new UUID(value.getMostSignificantBits(), value.getLeastSignificantBits());
}
public boolean isMutable() {
return false;
}
public Serializable disassemble(UUID value) throws HibernateException {
return value;
}
public UUID assemble(Serializable cached, Object owner) throws HibernateException {
return (UUID) cached;
}
public UUID replace(UUID original, Object target, Object owner) throws HibernateException {
return original;
}
// public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
// throws HibernateException, SQLException
// {
// return nullSafeGet(rs, names, owner);
// }
//
// public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
// throws HibernateException, SQLException
// {
// nullSafeSet(st, value, index);
//
// }
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
return nullSafeGet(rs, names, owner);
}
public void nullSafeSet(PreparedStatement st, UUID value, int index, SharedSessionContractImplementor session)
throws HibernateException, SQLException {
nullSafeSet(st, value, index);
}
}

View File

@ -1,95 +0,0 @@
package eu.eudat.configurations.typedefinition;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
/**
* Store and retrieve a PostgreSQL "xml" column as a Java string.
*/
public class XMLType implements UserType<String> {
private final int[] sqlTypesSupported = new int[]{Types.VARCHAR};
public int[] sqlTypes() {
return sqlTypesSupported;
}
@Override
public int getSqlType() {
return sqlTypesSupported[0];
}
public Class<String> returnedClass() {
return String.class;
}
public boolean equals(String x, String y) throws HibernateException {
if (x == null) {
return y == null;
} else {
return x.equals(y);
}
}
public int hashCode(String x) throws HibernateException {
return x == null ? -1 : x.hashCode();
}
@Override
public String nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException {
assert (i >= 0);
String xmldoc = resultSet.getString(i);
return resultSet.wasNull() ? null : xmldoc;
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
assert (names.length == 1);
String xmldoc = rs.getString(names[0]);
return rs.wasNull() ? null : xmldoc;
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
st.setNull(index, Types.OTHER);
} else {
st.setObject(index, value, Types.OTHER);
}
}
public String deepCopy(String value) throws HibernateException {
return value;
}
public boolean isMutable() {
return false;
}
public Serializable disassemble(String value) throws HibernateException {
return value;
}
public String assemble(Serializable cached, Object owner) throws HibernateException {
return (String) cached;
}
public String replace(String original, String target, Object owner) throws HibernateException {
return original;
}
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
return nullSafeGet(rs, names, owner);
}
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
nullSafeSet(st, value, index);
}
}

View File

@ -7,7 +7,7 @@ import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.ProviderTypeConverter; import eu.eudat.data.converters.enums.ProviderTypeConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -7,7 +7,7 @@ import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.DescriptionStatusConverter; import eu.eudat.data.converters.enums.DescriptionStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
@ -40,7 +40,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
@Column(name = "status", nullable = false) @Column(name = "status", nullable = false)
@Convert(converter = DescriptionStatusConverter.class) @Convert(converter = DescriptionStatusConverter.class)
private DescriptionStatus status; private DescriptionStatus status;
public static final String _status = "status"; public static final String _status = "status";
@Column(name = "description") @Column(name = "description")
@ -77,8 +76,12 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
@Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false) @Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false)
private UUID dmpDescriptionTemplateId; private UUID dmpDescriptionTemplateId;
public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId"; public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId";
@Column(name = "dmp", columnDefinition = "uuid", nullable = false)
private UUID dmpId;
public static final String _dmpId = "dmpId";
public UUID getId() { public UUID getId() {
return id; return id;
@ -168,6 +171,14 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
this.dmpDescriptionTemplateId = dmpDescriptionTemplateId; this.dmpDescriptionTemplateId = dmpDescriptionTemplateId;
} }
public UUID getDmpId() {
return dmpId;
}
public void setDmpId(UUID dmpId) {
this.dmpId = dmpId;
}
@Override @Override
public void update(DescriptionEntity entity) { public void update(DescriptionEntity entity) {
// this.setUri(entity.getUri()); // this.setUri(entity.getUri());

View File

@ -34,13 +34,11 @@ public class DescriptionReferenceEntity {
public static final String _referenceId = "referenceId"; public static final String _referenceId = "referenceId";
@Column(name = "created_at") @Column(name = "created_at")
@Convert(converter = DateToUTCConverter.class)
private Instant createdAt; private Instant createdAt;
public static final String _createdAt = "createdAt"; public static final String _createdAt = "createdAt";
@Column(name = "updated_at") @Column(name = "updated_at")
@Convert(converter = DateToUTCConverter.class)
private Instant updatedAt; private Instant updatedAt;
public static final String _updatedAt = "updatedAt"; public static final String _updatedAt = "updatedAt";

View File

@ -2,15 +2,17 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DescriptionTemplateStatus; import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DescriptionTemplateStatusConverter; import eu.eudat.data.converters.enums.DescriptionTemplateStatusConverter;
import eu.eudat.data.converters.enums.DescriptionTemplateVersionStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.List;
import java.util.UUID;
@Entity @Entity
@ -26,8 +28,7 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
public static final String _label = "label"; public static final String _label = "label";
public static final int _labelLength = 250; public static final int _labelLength = 250;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"definition\"", nullable = false)
@Column(name = "\"definition\"", columnDefinition = "xml", nullable = false)
private String definition; private String definition;
public static final String _definition = "definition"; public static final String _definition = "definition";
@ -61,6 +62,11 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
@Column(name = "\"version\"", nullable = false) @Column(name = "\"version\"", nullable = false)
private Short version; private Short version;
public static final String _version = "version"; public static final String _version = "version";
@Column(name = "version_status", nullable = false)
@Convert(converter = DescriptionTemplateVersionStatusConverter.class)
private DescriptionTemplateVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
@Column(name = "\"language\"", nullable = false) @Column(name = "\"language\"", nullable = false)
private String language; private String language;
@ -149,6 +155,14 @@ public class DescriptionTemplateEntity implements DataEntity<DescriptionTemplate
this.typeId = typeId; this.typeId = typeId;
} }
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
@Override @Override
public void update(DescriptionTemplateEntity entity) { public void update(DescriptionTemplateEntity entity) {
} }

View File

@ -3,22 +3,11 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DmpBlueprintStatus; import eu.eudat.commons.enums.DmpBlueprintStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.DescriptionTemplateTypeStatusConverter;
import eu.eudat.data.converters.enums.DmpBlueprintStatusConverter; import eu.eudat.data.converters.enums.DmpBlueprintStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.DMP;
import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -35,8 +24,7 @@ public class DmpBlueprintEntity {
public static final String _label = "label"; public static final String _label = "label";
public static final int _labelLength = 250; public static final int _labelLength = 250;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"definition\"", nullable = true)
@Column(name = "\"definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
public static final String _definition = "definition"; public static final String _definition = "definition";

View File

@ -2,16 +2,16 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.Column; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.Convert; import jakarta.persistence.*;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity
@Table(name = "\"DmpDescriptionTemplate\"") @Table(name = "\"DmpDescriptionTemplate\"")
public class DmpDescriptionTemplateEntity { public class DmpDescriptionTemplateEntity implements DataEntity<DmpDescriptionTemplateEntity, UUID> {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -106,4 +106,18 @@ public class DmpDescriptionTemplateEntity {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
public void update(DmpDescriptionTemplateEntity entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public DmpDescriptionTemplateEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
} }

View File

@ -2,18 +2,22 @@ package eu.eudat.data;
import eu.eudat.commons.enums.DmpAccessType; import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus; import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
import eu.eudat.data.converters.enums.DmpStatusConverter; import eu.eudat.data.converters.enums.DmpStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Dmp\"") @Table(name = "\"Dmp\"")
public class DmpEntity { public class DmpEntity implements DataEntity<DmpEntity, UUID> {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -31,6 +35,12 @@ public class DmpEntity {
public static final String _version = "version"; public static final String _version = "version";
@Column(name = "version_status", nullable = false)
@Convert(converter = DmpStatusConverter.class)
private DmpVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
@Column(name = "status", nullable = false) @Column(name = "status", nullable = false)
@Convert(converter = DmpStatusConverter.class) @Convert(converter = DmpStatusConverter.class)
private DmpStatus status; private DmpStatus status;
@ -71,7 +81,6 @@ public class DmpEntity {
public static final String _isActive = "isActive"; public static final String _isActive = "isActive";
@Column(name = "finalized_at") @Column(name = "finalized_at")
@Convert(converter = DateToUTCConverter.class)
private Instant finalizedAt; private Instant finalizedAt;
public static final String _finalizedAt = "finalizedAt"; public static final String _finalizedAt = "finalizedAt";
@ -81,8 +90,8 @@ public class DmpEntity {
public static final String _creator = "creator"; public static final String _creator = "creator";
@Enumerated(EnumType.STRING)
@Column(name = "access_type", nullable = false) @Column(name = "access_type", nullable = false)
@Convert(converter = DmpAccessTypeConverter.class)
private DmpAccessType accessType; private DmpAccessType accessType;
public static final String _accessType = "accessType"; public static final String _accessType = "accessType";
@ -98,7 +107,6 @@ public class DmpEntity {
public static final String _language = "language"; public static final String _language = "language";
@Column(name = "public_after") @Column(name = "public_after")
@Convert(converter = DateToUTCConverter.class)
private Instant publicAfter; private Instant publicAfter;
public static final String _publicAfter = "publicAfter"; public static final String _publicAfter = "publicAfter";
@ -230,4 +238,28 @@ public class DmpEntity {
public void setPublicAfter(Instant publicAfter) { public void setPublicAfter(Instant publicAfter) {
this.publicAfter = publicAfter; this.publicAfter = publicAfter;
} }
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
@Override
public void update(DmpEntity entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public DmpEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
} }

View File

@ -4,13 +4,16 @@ import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DmpUserRoleConverter; import eu.eudat.data.converters.enums.DmpUserRoleConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity
@Table(name = "\"DmpUser\"") @Table(name = "\"DmpUser\"")
public class DmpUserEntity { public class DmpUserEntity implements DataEntity {
@Id @Id
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -28,7 +31,7 @@ public class DmpUserEntity {
public static final String _user = "user"; public static final String _user = "user";
@Column(name = "status", nullable = false) @Column(name = "role", nullable = false)
@Convert(converter = DmpUserRoleConverter.class) @Convert(converter = DmpUserRoleConverter.class)
private DmpUserRole role; private DmpUserRole role;
@ -106,4 +109,18 @@ public class DmpUserEntity {
this.isActive = isActive; this.isActive = isActive;
} }
@Override
public void update(Object entity) {
}
@Override
public Object getKeys() {
return null;
}
@Override
public Object buildFromTuple(List tuple, List fields, String base) {
return null;
}
} }

View File

@ -2,14 +2,11 @@ package eu.eudat.data;
import eu.eudat.commons.enums.EntityType; import eu.eudat.commons.enums.EntityType;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.converters.enums.EntityTypeConverter; import eu.eudat.data.converters.enums.EntityTypeConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.old.DMP;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;
import java.util.Date;
import java.util.UUID; import java.util.UUID;
@Entity @Entity

View File

@ -7,7 +7,6 @@ import eu.eudat.data.converters.enums.ReferenceSourceTypeConverter;
import eu.eudat.data.converters.enums.ReferenceTypeConverter; import eu.eudat.data.converters.enums.ReferenceTypeConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -34,8 +33,7 @@ public class ReferenceEntity {
private String description; private String description;
public static final String _description = "description"; public static final String _description = "description";
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "definition")
@Column(name = "definition", columnDefinition = "xml")
private String definition; private String definition;
public static final String _definition = "definition"; public static final String _definition = "definition";

View File

@ -3,7 +3,6 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -25,8 +24,7 @@ public class ReferenceTypeEntity {
private String code; private String code;
public static final String _code = "code"; public static final String _code = "code";
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "definition")
@Column(name = "definition", columnDefinition = "xml")
private String definition; private String definition;
public static final String _definition = "definition"; public static final String _definition = "definition";

View File

@ -1,16 +1,11 @@
package eu.eudat.data; package eu.eudat.data;
import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.DescriptionTemplateStatusConverter;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.queryable.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;

View File

@ -5,7 +5,7 @@ import eu.eudat.commons.enums.UserDescriptionTemplateRole;
import eu.eudat.data.converters.enums.IsActiveConverter; import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.converters.enums.UserDescriptionTemplateRoleConverter; import eu.eudat.data.converters.enums.UserDescriptionTemplateRoleConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.Instant; import java.time.Instant;

View File

@ -0,0 +1,11 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import jakarta.persistence.Converter;
@Converter
public class DescriptionTemplateVersionStatusConverter extends DatabaseEnumConverter<DescriptionTemplateVersionStatus, Short>{
protected DescriptionTemplateVersionStatus of(Short i) {
return DescriptionTemplateVersionStatus.of(i);
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DmpVersionStatus;
import jakarta.persistence.Converter;
@Converter
public class DmpVersionStatusConverter extends DatabaseEnumConverter<DmpVersionStatus, Short> {
@Override
protected DmpVersionStatus of(Short i) {
return DmpVersionStatus.of(i);
}
}

View File

@ -1,8 +1,7 @@
package eu.eudat.data.old; package eu.eudat.data.old;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.List; import java.util.List;
@ -65,7 +64,6 @@ public class Content implements DataEntity<Content, UUID> { //IGNORE ME
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;

View File

@ -2,14 +2,12 @@ package eu.eudat.data.old;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@ -32,8 +30,7 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"")
@Column(name = "\"Definition\"", columnDefinition = "xml")
private String definition; private String definition;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)

View File

@ -1,8 +1,7 @@
package eu.eudat.data.old; package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -15,7 +14,6 @@ public class EmailConfirmation implements DataEntity<EmailConfirmation, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false) @Column(name = "\"ID\"", updatable = false, nullable = false)
private UUID id; private UUID id;

View File

@ -2,12 +2,11 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;

View File

@ -2,7 +2,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;

View File

@ -1,7 +1,6 @@
package eu.eudat.data.old; package eu.eudat.data.old;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -73,12 +72,10 @@ public class Funder implements DataEntity<Funder, UUID> {
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Reference\"", nullable = true)
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference; private String reference;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = true)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)

View File

@ -3,8 +3,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.*; import java.util.*;
@ -13,18 +12,18 @@ import java.util.stream.Collectors;
@Entity @Entity
@Table(name = "\"Grant\"") @Table(name = "\"Grant\"")
@NamedEntityGraphs({ //@NamedEntityGraphs({
@NamedEntityGraph( // @NamedEntityGraph(
name = "grantRecentActivity", // name = "grantRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")}, // attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")}) // subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
), // ),
@NamedEntityGraph( // @NamedEntityGraph(
name = "grantListingItem", // name = "grantListingItem",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")}, // attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")}) // subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
) // )
}) //})
public class Grant implements DataEntity<Grant, UUID> { public class Grant implements DataEntity<Grant, UUID> {
public enum Status { public enum Status {
@ -86,8 +85,8 @@ public class Grant implements DataEntity<Grant, UUID> {
private UUID id; private UUID id;
@OneToMany(mappedBy = "grant") // @OneToMany(mappedBy = "grant")
private Set<DMP> dmps; // private Set<DMP> dmps;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@ -101,7 +100,6 @@ public class Grant implements DataEntity<Grant, UUID> {
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@ -231,12 +229,12 @@ public class Grant implements DataEntity<Grant, UUID> {
this.definition = definition; this.definition = definition;
} }
public Set<DMP> getDmps() { // public Set<DMP> getDmps() {
return dmps; // return dmps;
} // }
public void setDmps(Set<DMP> dmps) { // public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; // this.dmps = dmps;
} // }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
return creationUser; return creationUser;
@ -273,7 +271,7 @@ public class Grant implements DataEntity<Grant, UUID> {
this.abbreviation = entity.getAbbreviation(); this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated(); this.created = entity.getCreated();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.dmps = entity.getDmps(); // this.dmps = entity.getDmps();
this.startdate = entity.getStartdate(); this.startdate = entity.getStartdate();
this.enddate = entity.getEnddate(); this.enddate = entity.getEnddate();
this.modified = new Date(); this.modified = new Date();
@ -291,8 +289,8 @@ public class Grant implements DataEntity<Grant, UUID> {
public Grant buildFromTuple(List<Tuple> tuple, List<String> fields, String base) { public Grant buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + "."; String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "dmps")) // if (fields.contains(currentBase + "dmps"))
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser")) if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this; return this;

View File

@ -1,9 +1,7 @@
package eu.eudat.data.old; package eu.eudat.data.old;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.List; import java.util.List;
@ -16,7 +14,6 @@ public class Invitation implements DataEntity<Invitation, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false) @Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id; private UUID id;
@ -27,9 +24,9 @@ public class Invitation implements DataEntity<Invitation, UUID> {
@JoinColumn(name = "\"CreationUser\"", nullable = false) @JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserInfo user; private UserInfo user;
@OneToOne(fetch = FetchType.EAGER) // @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Dmp\"", nullable = false) // @JoinColumn(name = "\"Dmp\"", nullable = false)
private DMP dmp; // private DMP dmp;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token; private UUID token;
@ -37,8 +34,7 @@ public class Invitation implements DataEntity<Invitation, UUID> {
@Column(name = "\"AcceptedInvitation\"", nullable = false) @Column(name = "\"AcceptedInvitation\"", nullable = false)
private boolean acceptedInvitation; private boolean acceptedInvitation;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Properties\"", nullable = true)
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties; private String properties;
public UUID getId() { public UUID getId() {
@ -65,13 +61,13 @@ public class Invitation implements DataEntity<Invitation, UUID> {
this.user = user; this.user = user;
} }
public DMP getDmp() { // public DMP getDmp() {
return dmp; // return dmp;
} // }
//
public void setDmp(DMP dmp) { // public void setDmp(DMP dmp) {
this.dmp = dmp; // this.dmp = dmp;
} // }
public UUID getToken() { public UUID getToken() {
return token; return token;

View File

@ -2,8 +2,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -16,7 +15,6 @@ public class Lock implements DataEntity<Lock, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;

View File

@ -4,8 +4,7 @@ import eu.eudat.commons.enums.old.notification.ActiveStatus;
import eu.eudat.commons.enums.old.notification.ContactType; import eu.eudat.commons.enums.old.notification.ContactType;
import eu.eudat.commons.enums.old.notification.NotificationType; import eu.eudat.commons.enums.old.notification.NotificationType;
import eu.eudat.commons.enums.old.notification.NotifyState; import eu.eudat.commons.enums.old.notification.NotifyState;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -18,7 +17,6 @@ public class Notification implements DataEntity<Notification, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;

View File

@ -2,9 +2,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@ -14,18 +12,17 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Organisation\"") //@Table(name = "\"Organisation\"")
@NamedEntityGraphs({ //@NamedEntityGraphs({
@NamedEntityGraph( // @NamedEntityGraph(
name = "organisationRecentActivity", // name = "organisationRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps")} // attributeNodes = {@NamedAttributeNode(value = "dmps")}
) // )
}) //})
public class Organisation implements Serializable, DataEntity<Organisation,UUID> { public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ -35,23 +32,21 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Reference\"", nullable = true)
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference; private String reference;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = true)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@OneToMany(fetch = FetchType.LAZY) // @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPOrganisation\"", // @JoinTable(name = "\"DMPOrganisation\"",
joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}, // joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")} // inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
) // )
private Set<DMP> dmps; // private Set<DMP> dmps;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@ -128,12 +123,12 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
this.definition = definition; this.definition = definition;
} }
public Set<DMP> getDmps() { // public Set<DMP> getDmps() {
return dmps; // return dmps;
} // }
public void setDmps(Set<DMP> dmps) { // public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; // this.dmps = dmps;
} // }
@Override @Override
public void update(Organisation entity) { public void update(Organisation entity) {

View File

@ -2,8 +2,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.*; import java.util.*;
@ -71,8 +70,8 @@ public class Project implements DataEntity<Project, UUID> {
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@OneToMany(mappedBy = "project") // @OneToMany(mappedBy = "project")
private Set<DMP> dmps; // private Set<DMP> dmps;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@ -80,14 +79,13 @@ public class Project implements DataEntity<Project, UUID> {
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Reference\"", nullable = true)
private String reference; private String reference;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = true)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Column(name = "\"StartDate\"", nullable = false) @Column(name = "\"StartDate\"", nullable = false)
@ -133,12 +131,12 @@ public class Project implements DataEntity<Project, UUID> {
this.id = id; this.id = id;
} }
public Set<DMP> getDmps() { // public Set<DMP> getDmps() {
return dmps; // return dmps;
} // }
public void setDmps(Set<DMP> dmps) { // public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; // this.dmps = dmps;
} // }
public String getLabel() { public String getLabel() {
return label; return label;
@ -245,7 +243,7 @@ public class Project implements DataEntity<Project, UUID> {
this.abbreviation = entity.getAbbreviation(); this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated(); this.created = entity.getCreated();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.dmps = entity.getDmps(); // this.dmps = entity.getDmps();
this.startdate = entity.getStartdate(); this.startdate = entity.getStartdate();
this.enddate = entity.getEnddate(); this.enddate = entity.getEnddate();
this.modified = new Date(); this.modified = new Date();
@ -260,7 +258,7 @@ public class Project implements DataEntity<Project, UUID> {
project.setAbbreviation(grant.getAbbreviation()); project.setAbbreviation(grant.getAbbreviation());
project.setCreated(new Date()); project.setCreated(new Date());
project.setDefinition(grant.getDefinition()); project.setDefinition(grant.getDefinition());
project.setDmps(grant.getDmps()); // project.setDmps(grant.getDmps());
project.setStartdate(grant.getStartdate()); project.setStartdate(grant.getStartdate());
project.setEnddate(grant.getEnddate()); project.setEnddate(grant.getEnddate());
project.setModified(new Date()); project.setModified(new Date());
@ -281,8 +279,8 @@ public class Project implements DataEntity<Project, UUID> {
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) { public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + "."; String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "dmps")) // if (fields.contains(currentBase + "dmps"))
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet()); // this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser")) if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0); this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this; return this;

View File

@ -4,8 +4,7 @@ package eu.eudat.data.old;
import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -34,8 +33,7 @@ public class Registry implements DataEntity<Registry, UUID> {
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = true)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Transient @Transient

View File

@ -3,8 +3,7 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
@ -18,8 +17,6 @@ import java.util.UUID;
public class Researcher implements DataEntity<Researcher, UUID> { public class Researcher implements DataEntity<Researcher, UUID> {
@Id @Id
/*@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")*/
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ -32,21 +29,19 @@ public class Researcher implements DataEntity<Researcher, UUID> {
@Column(name = "\"PrimaryEmail\"") @Column(name = "\"PrimaryEmail\"")
private String primaryEmail; private String primaryEmail;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = true)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Reference\"", nullable = true)
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference; private String reference;
@OneToMany(fetch = FetchType.LAZY) // @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPResearcher\"", // @JoinTable(name = "\"DMPResearcher\"",
joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}, // joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")} // inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
) // )
private Set<DMP> dMPs; // private Set<DMP> dMPs;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
@ -128,12 +123,12 @@ public class Researcher implements DataEntity<Researcher, UUID> {
this.definition = definition; this.definition = definition;
} }
public Set<DMP> getdMPs() { // public Set<DMP> getdMPs() {
return dMPs; // return dMPs;
} // }
public void setdMPs(Set<DMP> dMPs) { // public void setdMPs(Set<DMP> dMPs) {
this.dMPs = dMPs; // this.dMPs = dMPs;
} // }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
return creationUser; return creationUser;

View File

@ -2,13 +2,11 @@ package eu.eudat.data.old;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -32,8 +30,7 @@ public class Service implements DataEntity<Service, UUID> {
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Column(name = "\"Definition\"", nullable = false)
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition; private String definition;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)

View File

@ -3,9 +3,7 @@ package eu.eudat.data.old;
import eu.eudat.data.CredentialEntity; import eu.eudat.data.CredentialEntity;
import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.*; import java.util.*;
@ -22,7 +20,6 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
public final static String _id = "id"; public final static String _id = "id";
@ -65,17 +62,16 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
public final static String _lastloggedin = "lastloggedin"; public final static String _lastloggedin = "lastloggedin";
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
@Column(name = "additionalinfo", nullable = true) @Column(name = "additionalinfo", nullable = true)
private String additionalinfo; private String additionalinfo;
public final static String _additionalinfo = "additionalinfo"; public final static String _additionalinfo = "additionalinfo";
@OneToMany(fetch = FetchType.LAZY) // @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"", // @JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}, // joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")} // inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
) // )
private Set<DMP> dmps; // private Set<DMP> dmps;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "Id") @JoinColumn(name = "Id")
@ -90,13 +86,13 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
@OneToMany(mappedBy = "userId", fetch = FetchType.LAZY) @OneToMany(mappedBy = "userId", fetch = FetchType.LAZY)
private Set<Notification> notifications = new HashSet<>(); private Set<Notification> notifications = new HashSet<>();
public Set<DMP> getDmps() { // public Set<DMP> getDmps() {
return dmps; // return dmps;
} // }
//
public void setDmps(Set<DMP> dmps) { // public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; // this.dmps = dmps;
} // }
public UUID getId() { public UUID getId() {
return id; return id;

View File

@ -1,8 +1,7 @@
package eu.eudat.data.old; package eu.eudat.data.old;
import eu.eudat.data.old.helpers.EntityBinder; import eu.eudat.data.old.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.data.old.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.List; import java.util.List;
@ -15,7 +14,6 @@ public class UserRole implements DataEntity<UserRole, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;

View File

@ -1,4 +1,4 @@
package eu.eudat.queryable.queryableentity; package eu.eudat.data.old.queryableentity;
import jakarta.persistence.Tuple; import jakarta.persistence.Tuple;
import java.util.List; import java.util.List;

View File

@ -0,0 +1,40 @@
package eu.eudat.elastic;
import eu.eudat.elastic.converter.*;
import gr.cite.tools.elastic.configuration.AbstractElasticConfiguration;
import gr.cite.tools.elastic.configuration.ElasticCertificateProvider;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions;
import java.util.List;
@Configuration
@EnableConfigurationProperties(ElasticProperties.class)
@ConditionalOnProperty(prefix = "elastic", name = "enabled", matchIfMissing = false)
public class ElasticConfiguration extends AbstractElasticConfiguration {
public ElasticConfiguration(ElasticProperties elasticProperties, ElasticCertificateProvider elasticCertificateProvider) {
super(elasticProperties, elasticCertificateProvider);
}
@Bean
@Override
public ElasticsearchCustomConversions elasticsearchCustomConversions() {
return new ElasticsearchCustomConversions(
List.of(
new DmpUserRoleToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(),
new DmpStatusToShortConverter(),
new IsActiveToShortConverter(),
new DescriptionTemplateVersionStatusToShortConverter(),
new DmpVersionStatusToShortConverter(),
new DmpAccessTypeToShortConverter()
));
}
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DescriptionTemplateVersionStatusToShortConverter implements Converter<DescriptionTemplateVersionStatus, Short> {
@Override
public Short convert(DescriptionTemplateVersionStatus source) {
return source.getValue();
}
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpAccessType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DmpAccessTypeToShortConverter implements Converter<DmpAccessType, Short> {
@Override
public Short convert(DmpAccessType source) {
return source.getValue();
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DmpStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DmpStatusToShortConverter implements Converter<DmpStatus, Short> {
@Override
public Short convert(DmpStatus source) {
return source.getValue();
}
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpUserRole;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DmpUserRoleToShortConverter implements Converter<DmpUserRole, Short> {
@Override
public Short convert(DmpUserRole source) {
return source.getValue();
}
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpVersionStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class DmpVersionStatusToShortConverter implements Converter<DmpVersionStatus, Short> {
@Override
public Short convert(DmpVersionStatus source) {
return source.getValue();
}
}

View File

@ -0,0 +1,13 @@
package eu.eudat.elastic.converter;
import eu.eudat.commons.enums.DmpStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;
@WritingConverter
public class IsActiveToShortConverter implements Converter<DmpStatus, Short> {
@Override
public Short convert(DmpStatus source) {
return source.getValue();
}
}

View File

@ -0,0 +1,139 @@
package eu.eudat.elastic.data;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.*;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Document(indexName = "description")
public class DescriptionElasticEntity {
@Id
@Field(value = DescriptionElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = DescriptionElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
@Field(value = DescriptionElasticEntity._description, type = FieldType.Text)
private String description;
public final static String _description = "description";
@Field(value = DescriptionElasticEntity._status, type = FieldType.Short)
private DescriptionStatus status;
public final static String _status = "status";
@Field(value = DescriptionElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt";
@Field(value = DescriptionElasticEntity._createdAt, type = FieldType.Date)
private Date createdAt;
public final static String _createdAt = "createdAt";
@Field(value = DescriptionElasticEntity._tags, type = FieldType.Nested)
private List<NestedTagElasticEntity> tags;
public final static String _tags = "tags";
@Field(value = DescriptionElasticEntity._descriptionTemplate, type = FieldType.Object)
private NestedDescriptionTemplateElasticEntity descriptionTemplate;
public final static String _descriptionTemplate = "descriptionTemplate";
@Field(value = DescriptionElasticEntity._dmp, type = FieldType.Object)
private NestedDmpElasticEntity dmp;
public final static String _dmp = "dmp";
@Field(value = DescriptionElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references;
public final static String _references = "references";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public DescriptionStatus getStatus() {
return status;
}
public void setStatus(DescriptionStatus status) {
this.status = status;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<NestedTagElasticEntity> getTags() {
return tags;
}
public void setTags(List<NestedTagElasticEntity> tags) {
this.tags = tags;
}
public NestedDescriptionTemplateElasticEntity getDescriptionTemplate() {
return descriptionTemplate;
}
public void setDescriptionTemplate(NestedDescriptionTemplateElasticEntity descriptionTemplate) {
this.descriptionTemplate = descriptionTemplate;
}
public NestedDmpElasticEntity getDmp() {
return dmp;
}
public void setDmp(NestedDmpElasticEntity dmp) {
this.dmp = dmp;
}
public List<NestedReferenceElasticEntity> getReferences() {
return references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
this.references = references;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
}

View File

@ -0,0 +1,210 @@
package eu.eudat.elastic.data;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.nested.*;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Document(indexName = "dmp")
public class DmpElasticEntity {
@Id
@Field(value = DmpElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = DmpElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
@Field(value = DmpElasticEntity._description, type = FieldType.Text)
private String description;
public final static String _description = "description";
@Field(value = DmpElasticEntity._version, type = FieldType.Keyword)
private Short version;
public final static String _version = "version";
@Field(value = DmpElasticEntity._status, type = FieldType.Short)
private DmpStatus status;
public final static String _status = "status";
@Field(value = DmpElasticEntity._accessType, type = FieldType.Short)
private DmpAccessType accessType;
public final static String _accessType = "accessType";
@Field(value = DmpElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
@Field(value = DmpElasticEntity._language, type = FieldType.Keyword)
private String language;
public final static String _language = "language";
@Field(value = DmpElasticEntity._blueprintId, type = FieldType.Keyword)
private UUID blueprintId;
public final static String _blueprintId = "blueprintId";
@Field(value = DmpElasticEntity._groupId, type = FieldType.Keyword)
private UUID groupId;
public final static String _groupId = "groupId";
@Field(value = DmpElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt";
@Field(value = DmpElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references;
public final static String _references = "references";
@Field(value = DmpElasticEntity._collaborators, type = FieldType.Nested)
private List<NestedCollaboratorElasticEntity> collaborators;
public final static String _collaborators = "collaborators";
@Field(value = DmpElasticEntity._descriptionTemplates, type = FieldType.Nested)
private List<NestedDescriptionTemplateElasticEntity> descriptionTemplates;
public final static String _descriptionTemplates = "descriptionTemplates";
@Field(value = DmpElasticEntity._descriptions, type = FieldType.Nested)
private List<NestedDescriptionElasticEntity> descriptions;
public final static String _descriptions = "descriptions";
@Field(value = DmpElasticEntity._dois, type = FieldType.Nested)
private List<NestedDoiElasticEntity> dois;
public final static String _dois = "dois";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getVersion() {
return version;
}
public void setVersion(Short version) {
this.version = version;
}
public DmpStatus getStatus() {
return status;
}
public void setStatus(DmpStatus status) {
this.status = status;
}
public DmpAccessType getAccessType() {
return accessType;
}
public void setAccessType(DmpAccessType accessType) {
this.accessType = accessType;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public UUID getBlueprintId() {
return blueprintId;
}
public void setBlueprintId(UUID blueprintId) {
this.blueprintId = blueprintId;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<NestedReferenceElasticEntity> getReferences() {
return references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
this.references = references;
}
public List<NestedCollaboratorElasticEntity> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<NestedCollaboratorElasticEntity> collaborators) {
this.collaborators = collaborators;
}
public List<NestedDescriptionTemplateElasticEntity> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<NestedDescriptionTemplateElasticEntity> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
public List<NestedDescriptionElasticEntity> getDescriptions() {
return descriptions;
}
public void setDescriptions(List<NestedDescriptionElasticEntity> descriptions) {
this.descriptions = descriptions;
}
public List<NestedDoiElasticEntity> getDois() {
return dois;
}
public void setDois(List<NestedDoiElasticEntity> dois) {
this.dois = dois;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -0,0 +1,49 @@
package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DmpUserRole;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.UUID;
public class NestedCollaboratorElasticEntity {
@Id
@Field(value = NestedCollaboratorElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = NestedCollaboratorElasticEntity._name, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String name;
public final static String _name = "name";
@Field(value = NestedCollaboratorElasticEntity._role, type = FieldType.Short)
private DmpUserRole role;
public final static String _role = "role";
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 DmpUserRole getRole() {
return role;
}
public void setRole(DmpUserRole role) {
this.role = role;
}
}

View File

@ -0,0 +1,112 @@
package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DescriptionStatus;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class NestedDescriptionElasticEntity {
@Id
@Field(value = NestedDescriptionElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@Field(value = NestedDescriptionElasticEntity._dmpId, type = FieldType.Keyword)
private UUID dmpId;
public final static String _dmpId = "dmpId";
@MultiField(mainField = @Field(value = NestedDescriptionElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
@Field(value = NestedDescriptionElasticEntity._description, type = FieldType.Text)
private String description;
public final static String _description = "description";
@Field(value = NestedDescriptionElasticEntity._status, type = FieldType.Short)
private DescriptionStatus status;
public final static String _status = "status";
@Field(value = NestedDescriptionElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt";
@Field(value = NestedDescriptionElasticEntity._tags, type = FieldType.Nested)
private List<NestedTagElasticEntity> tags;
public final static String _tags = "tags";
@Field(value = NestedDescriptionElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references;
public final static String _references = "references";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getDmpId() {
return dmpId;
}
public void setDmpId(UUID dmpId) {
this.dmpId = dmpId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public DescriptionStatus getStatus() {
return status;
}
public void setStatus(DescriptionStatus status) {
this.status = status;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<NestedTagElasticEntity> getTags() {
return tags;
}
public void setTags(List<NestedTagElasticEntity> tags) {
this.tags = tags;
}
public List<NestedReferenceElasticEntity> getReferences() {
return references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
this.references = references;
}
}

View File

@ -0,0 +1,53 @@
package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.UUID;
public class NestedDescriptionTemplateElasticEntity {
@Id
@Field(value = NestedDescriptionTemplateElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = NestedDescriptionTemplateElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
@Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short)
private DescriptionTemplateVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -0,0 +1,186 @@
package eu.eudat.elastic.data.nested;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.DmpElasticEntity;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class NestedDmpElasticEntity {
@Id
@Field(value = NestedDmpElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = NestedDmpElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
@Field(value = NestedDmpElasticEntity._description, type = FieldType.Text)
private String description;
public final static String _description = "description";
@Field(value = NestedDmpElasticEntity._version, type = FieldType.Keyword)
private Short version;
public final static String _version = "version";
@Field(value = NestedDmpElasticEntity._versionStatus, type = FieldType.Short)
private DmpVersionStatus versionStatus;
public final static String _versionStatus = "versionStatus";
@Field(value = NestedDmpElasticEntity._status, type = FieldType.Short)
private DmpStatus status;
public final static String _status = "status";
@Field(value = NestedDmpElasticEntity._accessType, type = FieldType.Short)
private DmpAccessType accessType;
public final static String _accessType = "accessType";
@Field(value = NestedDmpElasticEntity._language, type = FieldType.Keyword)
private String language;
public final static String _language = "language";
@Field(value = NestedDmpElasticEntity._blueprintId, type = FieldType.Keyword)
private UUID blueprintId;
public final static String _blueprintId = "blueprintId";
@Field(value = NestedDmpElasticEntity._groupId, type = FieldType.Keyword)
private UUID groupId;
public final static String _groupId = "groupId";
@Field(value = NestedDmpElasticEntity._finalizedAt, type = FieldType.Date)
private Date finalizedAt;
public final static String _finalizedAt = "finalizedAt";
@Field(value = NestedDmpElasticEntity._references, type = FieldType.Nested)
private List<NestedReferenceElasticEntity> references;
public final static String _references = "references";
@Field(value = NestedDmpElasticEntity._collaborators, type = FieldType.Nested)
private List<NestedCollaboratorElasticEntity> collaborators;
public final static String _collaborators = "collaborators";
@Field(value = NestedDmpElasticEntity._dois, type = FieldType.Nested)
private List<NestedDoiElasticEntity> dois;
public final static String _dois = "dois";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getVersion() {
return version;
}
public void setVersion(Short version) {
this.version = version;
}
public DmpStatus getStatus() {
return status;
}
public void setStatus(DmpStatus status) {
this.status = status;
}
public DmpAccessType getAccessType() {
return accessType;
}
public void setAccessType(DmpAccessType accessType) {
this.accessType = accessType;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public UUID getBlueprintId() {
return blueprintId;
}
public void setBlueprintId(UUID blueprintId) {
this.blueprintId = blueprintId;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public List<NestedReferenceElasticEntity> getReferences() {
return references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
this.references = references;
}
public List<NestedCollaboratorElasticEntity> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<NestedCollaboratorElasticEntity> collaborators) {
this.collaborators = collaborators;
}
public List<NestedDoiElasticEntity> getDois() {
return dois;
}
public void setDois(List<NestedDoiElasticEntity> dois) {
this.dois = dois;
}
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
}

View File

@ -0,0 +1,46 @@
package eu.eudat.elastic.data.nested;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.UUID;
public class NestedDoiElasticEntity {
@Id
@Field(value = NestedDoiElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@Field(value = NestedDoiElasticEntity._repositoryId, type = FieldType.Keyword)
private String repositoryId;
public final static String _repositoryId = "repositoryId";
@Field(value = NestedDoiElasticEntity._doi, type = FieldType.Keyword)
private String doi;
public final static String _doi = "doi";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
}

View File

@ -0,0 +1,36 @@
package eu.eudat.elastic.data.nested;
import gr.cite.tools.elastic.ElasticConstants;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import java.util.UUID;
public class NestedReferenceElasticEntity {
@Id
@Field(value = NestedReferenceElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = NestedReferenceElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -0,0 +1,36 @@
package eu.eudat.elastic.data.nested;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import gr.cite.tools.elastic.ElasticConstants;
import java.util.UUID;
public class NestedTagElasticEntity {
@Id
@Field(value = NestedTagElasticEntity._id, type = FieldType.Keyword)
private UUID id;
public final static String _id = "id";
@MultiField(mainField = @Field(value = NestedTagElasticEntity._label, type = FieldType.Text), otherFields = {
@InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)
})
private String label;
public final static String _label = "label";
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -0,0 +1,93 @@
package eu.eudat.elastic.elasticbuilder;
import eu.eudat.convention.ConventionService;
import gr.cite.tools.data.builder.Builder;
import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import java.time.Instant;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public abstract class BaseElasticBuilder<M, D> implements Builder {
protected final LoggerService logger;
protected final ConventionService conventionService;
public BaseElasticBuilder(
ConventionService conventionService,
LoggerService logger
) {
this.conventionService = conventionService;
this.logger = logger;
}
public M build(D data) throws MyApplicationException {
if (data == null) {
M model = null;
return null; //TODO
}
List<M> models = this.build(Arrays.asList(data));
return models.stream().findFirst().orElse(null); //TODO
}
public abstract List<M> build(List<D> datas) throws MyApplicationException;
public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("Building references from query");
List<D> datas = query.collect();
this.logger.debug("collected {} items to build", Optional.ofNullable(datas).map(e -> e.size()).orElse(0));
return this.asForeignKey(datas, keySelector);
}
public <K> Map<K, M> asForeignKey(List<D> datas, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("building references");
List<M> models = this.build(datas);
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(e -> e.size()).orElse(0), Optional.ofNullable(datas).map(e -> e.size()).orElse(0));
Map<K, M> map = models.stream().collect(Collectors.toMap(o -> keySelector.apply(o), o -> o));
return map;
}
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("Building details from query");
List<D> datas = query.collect();
this.logger.debug("collected {} items to build", Optional.ofNullable(datas).map(e -> e.size()).orElse(0));
return this.asMasterKey(datas, keySelector);
}
public <K> Map<K, List<M>> asMasterKey(List<D> datas, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("building details");
List<M> models = this.build(datas);
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(e -> e.size()).orElse(0), Optional.ofNullable(datas).map(e -> e.size()).orElse(0));
Map<K, List<M>> map = new HashMap<>();
for (M model : models) {
K key = keySelector.apply(model);
if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
map.get(key).add(model);
}
return map;
}
public <FK, FM> Map<FK, FM> asEmpty(List<FK> keys, Function<FK, FM> mapper, Function<FM, FK> keySelector) {
this.logger.trace("building static references");
List<FM> models = keys.stream().map(x -> mapper.apply(x)).collect(Collectors.toList());
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(x -> x.size()).orElse(0), Optional.ofNullable(keys).map(x -> x.size()));
Map<FK, FM> map = models.stream().collect(Collectors.toMap(o -> keySelector.apply(o), o -> o));
return map;
}
protected String hashValue(Instant value) throws MyApplicationException {
return this.conventionService.hashValue(value);
}
protected String asPrefix(String name) {
return this.conventionService.asPrefix(name);
}
protected String asIndexer(String... names) {
return this.conventionService.asIndexer(names);
}
}

View File

@ -0,0 +1,149 @@
package eu.eudat.elastic.elasticbuilder;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.DmpDescriptionTemplateEntity;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import eu.eudat.elastic.data.nested.*;
import eu.eudat.elastic.elasticbuilder.nested.NestedDescriptionTemplateElasticBuilder;
import eu.eudat.elastic.elasticbuilder.nested.NestedDmpElasticBuilder;
import eu.eudat.elastic.elasticbuilder.nested.NestedReferenceElasticBuilder;
import eu.eudat.elastic.elasticbuilder.nested.NestedTagElasticBuilder;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.builder.ReferenceBuilder;
import eu.eudat.query.*;
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.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DescriptionElasticBuilder extends BaseElasticBuilder<DescriptionElasticEntity, DescriptionEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
@Autowired
public DescriptionElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionElasticBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
@Override
public List<DescriptionElasticEntity> build(List<DescriptionEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data);
Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data);
Map<UUID, NestedDmpElasticEntity> dmpElasticEntityMap = this.collectDmps(data);
Map<UUID, NestedDescriptionTemplateElasticEntity> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data);
List<DescriptionElasticEntity> models = new ArrayList<>();
for (DescriptionEntity d : data) {
DescriptionElasticEntity m = new DescriptionElasticEntity();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
m.setStatus(d.getStatus());
m.setCreatedAt(Date.from(d.getCreatedAt()));
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (tagElasticEntityMap != null) m.setTags(tagElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpElasticEntityMap != null) m.setDmp(dmpElasticEntityMap.getOrDefault(d.getDmpId(), null));
if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplate(descriptionTemplateElasticEntityMap.getOrDefault(d.getDmpId(), null));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<NestedReferenceElasticEntity>> collectDescriptionReferences(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName());
DescriptionReferenceQuery associationQuery = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DescriptionReferenceEntity> associationEntities = associationQuery.collect();
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DescriptionReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDescriptionId())) itemMap.put(associationEntity.getDescriptionId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null);
if (item != null) itemMap.get(associationEntity.getDescriptionId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedTagElasticEntity>> collectDescriptionTags(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DescriptionTag.class.getSimpleName());
DescriptionTagQuery associationQuery = this.queryFactory.query(DescriptionTagQuery.class).descriptionIds(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DescriptionTagEntity> associationEntities = associationQuery.collect();
TagQuery query = this.queryFactory.query(TagQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()));
Map<UUID, NestedTagElasticEntity> itemMapById = this.builderFactory.builder(NestedTagElasticBuilder.class).asForeignKey(query, NestedTagElasticEntity::getId);
Map<UUID, List<NestedTagElasticEntity>> itemMap = new HashMap<>();
for (DescriptionTagEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDescriptionId())) itemMap.put(associationEntity.getDescriptionId(), new ArrayList<>());
NestedTagElasticEntity item = itemMapById.getOrDefault(associationEntity.getTagId(), null);
if (item != null) itemMap.get(associationEntity.getDescriptionId()).add(item);
}
return itemMap;
}
private Map<UUID, NestedDmpElasticEntity> collectDmps(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", Dmp.class.getSimpleName());
Map<UUID, NestedDmpElasticEntity> itemMap;
DmpQuery q = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(NestedDmpElasticBuilder.class).asForeignKey(q, NestedDmpElasticEntity::getId);
return itemMap;
}
private Map<UUID, NestedDescriptionTemplateElasticEntity> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
DmpDescriptionTemplateQuery associationQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(data.stream().map(DescriptionEntity::getDmpDescriptionTemplateId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DmpDescriptionTemplateEntity> associationEntities = associationQuery.collect();
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMapById = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(query, NestedDescriptionTemplateElasticEntity::getId);
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMap = new HashMap<>();
for (DmpDescriptionTemplateEntity associationEntity : associationEntities){
itemMap.put(associationEntity.getId(), itemMapById.getOrDefault(associationEntity.getDescriptionTemplateId(), null));
}
return itemMap;
}
}

View File

@ -0,0 +1,164 @@
package eu.eudat.elastic.elasticbuilder;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.*;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.*;
import eu.eudat.elastic.elasticbuilder.nested.*;
import eu.eudat.model.DmpReference;
import eu.eudat.query.*;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DmpElasticBuilder extends BaseElasticBuilder<DmpElasticEntity, DmpEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
@Autowired
public DmpElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpElasticBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
@Override
public List<DmpElasticEntity> build(List<DmpEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data);
Map<UUID, List<NestedDescriptionElasticEntity>> dmpElasticEntityMap = this.collectDescriptions(data);
Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data);
Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data);
Map<UUID, List<NestedDescriptionTemplateElasticEntity>> descriptionTemplateElasticEntityMap = this.collectDescriptionTemplates(data);
List<DmpElasticEntity> models = new ArrayList<>();
for (DmpEntity d : data) {
DmpElasticEntity m = new DmpElasticEntity();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
m.setVersion(d.getVersion());
m.setVersionStatus(d.getVersionStatus());
m.setStatus(d.getStatus());
m.setAccessType(d.getAccessType());
m.setLanguage(d.getLanguage());
m.setBlueprintId(d.getBlueprint());
m.setGroupId(d.getGroupId());
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (dmpElasticEntityMap != null) m.setDescriptions(dmpElasticEntityMap.getOrDefault(d.getId(), null));
if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null));
if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null));
if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplates(descriptionTemplateElasticEntityMap.getOrDefault(d.getId(), null));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<NestedReferenceElasticEntity>> collectDmpReferences(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
DmpReferenceQuery associationQuery = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpReferenceEntity> associationEntities = associationQuery.collect();
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DmpReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null);
if (item != null) itemMap.get(associationEntity.getDmpId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedDescriptionTemplateElasticEntity>> collectDescriptionTemplates(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
DmpDescriptionTemplateQuery associationQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DmpDescriptionTemplateEntity> associationEntities = associationQuery.collect();
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpDescriptionTemplateEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList()));
Map<UUID, NestedDescriptionTemplateElasticEntity> itemMapById = this.builderFactory.builder(NestedDescriptionTemplateElasticBuilder.class).asForeignKey(query, NestedDescriptionTemplateElasticEntity::getId);
Map<UUID, List<NestedDescriptionTemplateElasticEntity>> itemMap = new HashMap<>();
for (DmpDescriptionTemplateEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>());
NestedDescriptionTemplateElasticEntity item = itemMapById.getOrDefault(associationEntity.getDescriptionTemplateId(), null);
if (item != null) itemMap.get(associationEntity.getDmpId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedDescriptionElasticEntity>> collectDescriptions(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", DescriptionEntity.class.getSimpleName());
Map<UUID, List<NestedDescriptionElasticEntity>> itemMap;
DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).dmpSubQuery(this.queryFactory.query(DmpQuery.class).ids(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())));
itemMap = this.builderFactory.builder(NestedDescriptionElasticBuilder.class).asMasterKey(q, NestedDescriptionElasticEntity::getDmpId);
return itemMap;
}
private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName());
DmpUserQuery associationQuery = this.queryFactory.query(DmpUserQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpUserEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId);
Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>();
for (DmpUserEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmp(), new ArrayList<>());
NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null);
if (item != null) itemMap.get(associationEntity.getDmp()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName());
EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).entityIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<EntityDoiEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId);
Map<UUID, List<NestedDoiElasticEntity>> itemMap = new HashMap<>();
for (EntityDoiEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getEntityId(), new ArrayList<>());
NestedDoiElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null);
if (item != null) itemMap.get(associationEntity.getEntityId()).add(item);
}
return itemMap;
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.elastic.data.nested.NestedCollaboratorElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
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.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder<NestedCollaboratorElasticEntity, DmpUserEntity> {
@Autowired
public NestedCollaboratorElasticBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedCollaboratorElasticBuilder.class)));
}
@Override
public List<NestedCollaboratorElasticEntity> build(List<DmpUserEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
List<NestedCollaboratorElasticEntity> models = new ArrayList<>();
for (DmpUserEntity d : data) {
NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity();
m.setId(d.getId());
m.setRole(d.getRole());
m.setName(d.getUser().toString()); //TODO: Get UserName
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,110 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity;
import eu.eudat.elastic.data.nested.NestedReferenceElasticEntity;
import eu.eudat.elastic.data.nested.NestedTagElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.DescriptionTag;
import eu.eudat.query.DescriptionReferenceQuery;
import eu.eudat.query.DescriptionTagQuery;
import eu.eudat.query.ReferenceQuery;
import eu.eudat.query.TagQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDescriptionElasticBuilder extends BaseElasticBuilder<NestedDescriptionElasticEntity, DescriptionEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
@Autowired
public NestedDescriptionElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDescriptionElasticBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
@Override
public List<NestedDescriptionElasticEntity> build(List<DescriptionEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDescriptionReferences(data);
Map<UUID, List<NestedTagElasticEntity>> tagElasticEntityMap = this.collectDescriptionTags(data);
List<NestedDescriptionElasticEntity> models = new ArrayList<>();
for (DescriptionEntity d : data) {
NestedDescriptionElasticEntity m = new NestedDescriptionElasticEntity();
m.setId(d.getId());
m.setDmpId(d.getDmpId());
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
m.setStatus(d.getStatus());
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (tagElasticEntityMap != null) m.setTags(tagElasticEntityMap.getOrDefault(d.getId(), null));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<NestedReferenceElasticEntity>> collectDescriptionReferences(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName());
DescriptionReferenceQuery associationQuery = this.queryFactory.query(DescriptionReferenceQuery.class).descriptionIds(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DescriptionReferenceEntity> associationEntities = associationQuery.collect();
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DescriptionReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDescriptionId())) itemMap.put(associationEntity.getDescriptionId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null);
if (item != null) itemMap.get(associationEntity.getDescriptionId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedTagElasticEntity>> collectDescriptionTags(List<DescriptionEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DescriptionTag.class.getSimpleName());
DescriptionTagQuery associationQuery = this.queryFactory.query(DescriptionTagQuery.class).descriptionIds(data.stream().map(DescriptionEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<DescriptionTagEntity> associationEntities = associationQuery.collect();
TagQuery query = this.queryFactory.query(TagQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DescriptionTagEntity::getTagId).distinct().collect(Collectors.toList()));
Map<UUID, NestedTagElasticEntity> itemMapById = this.builderFactory.builder(NestedTagElasticBuilder.class).asForeignKey(query, NestedTagElasticEntity::getId);
Map<UUID, List<NestedTagElasticEntity>> itemMap = new HashMap<>();
for (DescriptionTagEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDescriptionId())) itemMap.put(associationEntity.getDescriptionId(), new ArrayList<>());
NestedTagElasticEntity item = itemMapById.getOrDefault(associationEntity.getTagId(), null);
if (item != null) itemMap.get(associationEntity.getDescriptionId()).add(item);
}
return itemMap;
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
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.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDescriptionTemplateElasticBuilder extends BaseElasticBuilder<NestedDescriptionTemplateElasticEntity, DescriptionTemplateEntity> {
@Autowired
public NestedDescriptionTemplateElasticBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDescriptionTemplateElasticBuilder.class)));
}
@Override
public List<NestedDescriptionTemplateElasticEntity> build(List<DescriptionTemplateEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
List<NestedDescriptionTemplateElasticEntity> models = new ArrayList<>();
for (DescriptionTemplateEntity d : data) {
NestedDescriptionTemplateElasticEntity m = new NestedDescriptionTemplateElasticEntity();
m.setId(d.getId());
m.setVersionStatus(d.getVersionStatus());
m.setLabel(d.getLabel());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,135 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpReferenceEntity;
import eu.eudat.data.DmpUserEntity;
import eu.eudat.data.EntityDoiEntity;
import eu.eudat.elastic.data.nested.*;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import eu.eudat.model.DmpReference;
import eu.eudat.query.DmpReferenceQuery;
import eu.eudat.query.DmpUserQuery;
import eu.eudat.query.EntityDoiQuery;
import eu.eudat.query.ReferenceQuery;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
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.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDmpElasticBuilder extends BaseElasticBuilder<NestedDmpElasticEntity, DmpEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
@Autowired
public NestedDmpElasticBuilder(
ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDmpElasticBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
@Override
public List<NestedDmpElasticEntity> build(List<DmpEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
Map<UUID, List<NestedReferenceElasticEntity>> referenceElasticEntityMap = this.collectDmpReferences(data);
Map<UUID, List<NestedCollaboratorElasticEntity>> collaboratorElasticEntityMap = this.collectCollaborators(data);
Map<UUID, List<NestedDoiElasticEntity>> doiElasticEntityMap = this.collectDois(data);
List<NestedDmpElasticEntity> models = new ArrayList<>();
for (DmpEntity d : data) {
NestedDmpElasticEntity m = new NestedDmpElasticEntity();
m.setId(d.getId());
m.setLabel(d.getLabel());
m.setDescription(d.getDescription());
m.setVersion(d.getVersion());
m.setStatus(d.getStatus());
m.setAccessType(d.getAccessType());
m.setLanguage(d.getLanguage());
m.setBlueprintId(d.getBlueprint());
m.setGroupId(d.getGroupId());
m.setGroupId(d.getGroupId());
m.setVersionStatus(d.getVersionStatus());
m.setFinalizedAt(Date.from(d.getFinalizedAt()));
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (collaboratorElasticEntityMap != null) m.setCollaborators(collaboratorElasticEntityMap.getOrDefault(d.getId(), null));
if (doiElasticEntityMap != null) m.setDois(doiElasticEntityMap.getOrDefault(d.getId(), null));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<NestedReferenceElasticEntity>> collectDmpReferences(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty()) return null;
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
DmpReferenceQuery associationQuery = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpReferenceEntity> associationEntities = associationQuery.collect();
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).isActive(IsActive.Active).ids(associationEntities.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
Map<UUID, NestedReferenceElasticEntity> itemMapById = this.builderFactory.builder(NestedReferenceElasticBuilder.class).asForeignKey(query, NestedReferenceElasticEntity::getId);
Map<UUID, List<NestedReferenceElasticEntity>> itemMap = new HashMap<>();
for (DmpReferenceEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getDmpId())) itemMap.put(associationEntity.getDmpId(), new ArrayList<>());
NestedReferenceElasticEntity item = itemMapById.getOrDefault(associationEntity.getReferenceId(), null);
if (item != null) itemMap.get(associationEntity.getDmpId()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedCollaboratorElasticEntity>> collectCollaborators(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName());
DmpUserQuery associationQuery = this.queryFactory.query(DmpUserQuery.class).dmpIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActives(IsActive.Active);
List<DmpUserEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedCollaboratorElasticEntity> itemMapById = this.builderFactory.builder(NestedCollaboratorElasticBuilder.class).asForeignKey(associationEntities, NestedCollaboratorElasticEntity::getId);
Map<UUID, List<NestedCollaboratorElasticEntity>> itemMap = new HashMap<>();
for (DmpUserEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getDmp(), new ArrayList<>());
NestedCollaboratorElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null);
if (item != null) itemMap.get(associationEntity.getDmp()).add(item);
}
return itemMap;
}
private Map<UUID, List<NestedDoiElasticEntity>> collectDois(List<DmpEntity> data) throws MyApplicationException {
if (data.isEmpty())
return null;
this.logger.debug("checking related - {}", EntityDoiEntity.class.getSimpleName());
EntityDoiQuery associationQuery = this.queryFactory.query(EntityDoiQuery.class).entityIds(data.stream().map(DmpEntity::getId).collect(Collectors.toList())).isActive(IsActive.Active);
List<EntityDoiEntity> associationEntities = associationQuery.collect();
Map<UUID, NestedDoiElasticEntity> itemMapById = this.builderFactory.builder(NestedDoiElasticBuilder.class).asForeignKey(associationEntities, NestedDoiElasticEntity::getId);
Map<UUID, List<NestedDoiElasticEntity>> itemMap = new HashMap<>();
for (EntityDoiEntity associationEntity : associationEntities){
if (!itemMap.containsKey(associationEntity.getId())) itemMap.put(associationEntity.getEntityId(), new ArrayList<>());
NestedDoiElasticEntity item = itemMapById.getOrDefault(associationEntity.getId(), null);
if (item != null) itemMap.get(associationEntity.getEntityId()).add(item);
}
return itemMap;
}
}

View File

@ -0,0 +1,45 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.EntityDoiEntity;
import eu.eudat.elastic.data.nested.NestedDoiElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
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.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDoiElasticBuilder extends BaseElasticBuilder<NestedDoiElasticEntity, EntityDoiEntity> {
@Autowired
public NestedDoiElasticBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedDoiElasticBuilder.class)));
}
@Override
public List<NestedDoiElasticEntity> build(List<EntityDoiEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
List<NestedDoiElasticEntity> models = new ArrayList<>();
for (EntityDoiEntity d : data) {
NestedDoiElasticEntity m = new NestedDoiElasticEntity();
m.setId(d.getId());
m.setDoi(d.getDoi());
m.setRepositoryId(d.getRepositoryId());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.elastic.data.nested.NestedReferenceElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
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 NestedReferenceElasticBuilder extends BaseElasticBuilder<NestedReferenceElasticEntity, ReferenceEntity> {
@Autowired
public NestedReferenceElasticBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedReferenceElasticBuilder.class)));
}
@Override
public List<NestedReferenceElasticEntity> build(List<ReferenceEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
List<NestedReferenceElasticEntity> models = new ArrayList<>();
for (ReferenceEntity d : data) {
NestedReferenceElasticEntity m = new NestedReferenceElasticEntity();
m.setId(d.getId());
m.setLabel(d.getLabel());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.elastic.elasticbuilder.nested;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.TagEntity;
import eu.eudat.elastic.data.nested.NestedTagElasticEntity;
import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
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.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedTagElasticBuilder extends BaseElasticBuilder<NestedTagElasticEntity, TagEntity> {
@Autowired
public NestedTagElasticBuilder(
ConventionService conventionService) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedTagElasticBuilder.class)));
}
@Override
public List<NestedTagElasticEntity> build(List<TagEntity> data) throws MyApplicationException {
if (data == null)
return new ArrayList<>();
List<NestedTagElasticEntity> models = new ArrayList<>();
for (TagEntity d : data) {
NestedTagElasticEntity m = new NestedTagElasticEntity();
m.setId(d.getId());
m.setLabel(d.getLabel());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
}

View File

@ -0,0 +1,293 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.elastic.data.DescriptionElasticEntity;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.NestedDmpElasticEntity;
import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.service.elastic.ElasticService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticFields;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import gr.cite.tools.elastic.query.ElasticQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@Component
//Like in C# make it Transient
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class DescriptionElasticQuery extends ElasticQuery<DescriptionElasticEntity, UUID> {
private Collection<UUID> ids;
private String like;
private InnerObjectDmpElasticQuery dmpSubQuery;
private Instant createdAfter;
private Instant createdBefore;
private Instant finalizedAfter;
private Instant finalizedBefore;
private Collection<UUID> excludedIds;
private Collection<DescriptionStatus> statuses;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public DescriptionElasticQuery like(String value) {
this.like = value;
return this;
}
public DescriptionElasticQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public DescriptionElasticQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public DescriptionElasticQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public DescriptionElasticQuery dmpSubQuery(InnerObjectDmpElasticQuery subQuery) {
this.dmpSubQuery = subQuery;
return this;
}
public DescriptionElasticQuery createdAfter(Instant value) {
this.createdAfter = value;
return this;
}
public DescriptionElasticQuery createdBefore(Instant value) {
this.createdBefore = value;
return this;
}
public DescriptionElasticQuery finalizedAfter(Instant value) {
this.finalizedAfter = value;
return this;
}
public DescriptionElasticQuery finalizedBefore(Instant value) {
this.finalizedBefore = value;
return this;
}
public DescriptionElasticQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public DescriptionElasticQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public DescriptionElasticQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public DescriptionElasticQuery statuses(DescriptionStatus value) {
this.statuses = List.of(value);
return this;
}
public DescriptionElasticQuery statuses(DescriptionStatus... value) {
this.statuses = Arrays.asList(value);
return this;
}
public DescriptionElasticQuery statuses(Collection<DescriptionStatus> values) {
this.statuses = values;
return this;
}
public DescriptionElasticQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
private final QueryFactory queryFactory;
private final AppElasticProperties appElasticProperties;
private final ElasticService elasticService;
private final UserScope userScope;
private final AuthorizationService authService;
@Autowired()
public DescriptionElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticProperties appElasticProperties, ElasticService elasticService, UserScope userScope, AuthorizationService authService) {
super(elasticsearchTemplate, elasticProperties);
this.queryFactory = queryFactory;
this.appElasticProperties = appElasticProperties;
this.elasticService = elasticService;
this.userScope = userScope;
this.authService = authService;
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) ||
this.isEmpty(this.excludedIds) ||
this.isEmpty(this.statuses);
}
@Override
protected Class<DescriptionElasticEntity> entityClass() {
return DescriptionElasticEntity.class;
}
@Override
protected Query applyAuthZ() {
if (this.authorize.contains(AuthorizationFlags.None)) return null;
//if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDescription)) return null;
UUID userId = null;
boolean usePublic = this.authorize.contains(AuthorizationFlags.Public);
if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe();
List<Query> predicates = new ArrayList<>();
if (usePublic ) {
predicates.add(this.and(
this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + DmpElasticEntity._status, this.entityClass()).disableInfer(true), DmpStatus.Finalized.getValue()),
this.equals(new ElasticField(DescriptionElasticEntity._dmp + "." + DmpElasticEntity._accessType, this.entityClass()).disableInfer(true), DmpAccessType.Public.getValue())
));
}
if (userId != null) {
NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DescriptionElasticEntity._dmp + "." + NestedDmpElasticEntity._collaborators);
query.ids(userId);
predicates.add(this.nestedQuery(query).build()._toQuery());
}
if (!predicates.isEmpty()) {
return this.or(predicates)._toQuery();
} else {
return this.equals(this.elasticFieldOf(DescriptionElasticEntity._id), UUID.randomUUID());
}
}
@Override
protected Query applyFilters() {
List<Query> predicates = new ArrayList<>();
if (like != null && !like.isBlank()) {
if (!like.startsWith("*")) like = "*" + like;
if (!like.endsWith("*")) like = like + "*";
ElasticFields elasticFields = this.elasticFieldsOf();
elasticFields.add(DescriptionElasticEntity._label);
elasticFields.add(DescriptionElasticEntity._description);
predicates.add(this.like(elasticFields, List.of(like))._toQuery());
}
if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DescriptionElasticEntity._id), ids)._toQuery());
}
if (excludedIds != null) {
predicates.add(this.not(this.containsUUID(this.elasticFieldOf(DescriptionElasticEntity._id), excludedIds)._toQuery())._toQuery());
}
if (statuses != null) {
predicates.add(this.contains(this.elasticFieldOf(DescriptionElasticEntity._status), statuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[statuses.size()]))._toQuery());
}
if (this.finalizedAfter != null) {
predicates.add(this.dateGreaterThanQuery(this.elasticFieldOf(DescriptionElasticEntity._finalizedAt), this.finalizedAfter)._toQuery());
}
if (this.finalizedBefore != null) {
predicates.add(this.dateLessThanQuery(this.elasticFieldOf(DescriptionElasticEntity._finalizedAt), this.finalizedBefore)._toQuery());
}
if (this.createdAfter != null) {
predicates.add(this.dateGreaterThanQuery(this.elasticFieldOf(DescriptionElasticEntity._createdAt), this.createdAfter)._toQuery());
}
if (this.createdBefore != null) {
predicates.add(this.dateLessThanQuery(this.elasticFieldOf(DescriptionElasticEntity._createdAt), this.createdBefore)._toQuery());
}
if (dmpSubQuery != null) {
predicates.add(dmpSubQuery.innerPath(DescriptionElasticEntity._dmp).applyFilters());
}
if (!predicates.isEmpty()) {
return this.and(predicates);
} else {
return null;
}
}
@Override
public DescriptionElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
DescriptionElasticEntity mocDoc = new DescriptionElasticEntity();
if (columns.contains(DescriptionElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._id), UUID.class));
if (columns.contains(DescriptionElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._label), String.class));
if (columns.contains(DescriptionElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._description), String.class));
if (columns.contains(DescriptionElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._status), DescriptionStatus.class));
if (columns.contains(DescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._finalizedAt), Date.class));
if (columns.contains(DescriptionElasticEntity._createdAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DescriptionElasticEntity._createdAt), Date.class));
mocDoc.setTags(this.convertNested(rawData, columns, this.queryFactory.query(NestedTagElasticQuery.class), DescriptionElasticEntity._tags, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DescriptionElasticEntity._references, null));
mocDoc.setDescriptionTemplate(this.convertInnerObject(rawData, columns, this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class), DescriptionElasticEntity._descriptionTemplate, null));
mocDoc.setDmp(this.convertInnerObject(rawData, columns, this.queryFactory.query(InnerObjectDmpElasticQuery.class), DescriptionElasticEntity._dmp, null));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(DescriptionElasticEntity._id)) return this.elasticFieldOf(DescriptionElasticEntity._id);
else if (item.match(DescriptionElasticEntity._label)) return this.elasticFieldOf(DescriptionElasticEntity._label);
else if (item.match(DescriptionElasticEntity._description)) return this.elasticFieldOf(DescriptionElasticEntity._description);
else if (item.match(DescriptionElasticEntity._status)) return this.elasticFieldOf(DescriptionElasticEntity._status);
else if (item.match(DescriptionElasticEntity._finalizedAt)) return this.elasticFieldOf(DescriptionElasticEntity._finalizedAt);
else if (item.match(DescriptionElasticEntity._createdAt)) return this.elasticFieldOf(DescriptionElasticEntity._createdAt);
else if (item.prefix(DescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DescriptionElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._references));
else if (item.prefix(DescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(DescriptionElasticEntity._tags).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._tags));
else if (item.prefix(DescriptionElasticEntity._descriptionTemplate)) return this.queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class).innerPath(DescriptionElasticEntity._descriptionTemplate).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._description));
else if (item.prefix(DescriptionElasticEntity._dmp)) return this.queryFactory.query(InnerObjectDmpElasticQuery.class).innerPath(DescriptionElasticEntity._dmp).fieldNameOf(this.extractPrefixed(item, DescriptionElasticEntity._dmp));
else return null;
}
@Override
protected String[] getIndex() {
List<String> indexNames = new ArrayList<>();
indexNames.add(this.appElasticProperties.getDescriptionIndexName());
try {
this.elasticService.ensureDescriptionIndex();
} catch (IOException e) {
throw new RuntimeException(e);
}
return indexNames.toArray(new String[indexNames.size()]);
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(DescriptionElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(DescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DescriptionElasticEntity._references);
else if (item.prefix(DescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(DescriptionElasticEntity._tags);
else return null;
}
}

View File

@ -0,0 +1,321 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.configurations.elastic.AppElasticProperties;
import eu.eudat.data.DmpEntity;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.utils.QueryUtilsService;
import eu.eudat.service.elastic.ElasticService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.*;
import jakarta.persistence.criteria.Predicate;
import org.elasticsearch.index.query.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@Component
//Like in C# make it Transient
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
private String like;
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<DmpStatus> statuses;
private Collection<DmpVersionStatus> versionStatuses;
private Collection<DmpAccessType> accessTypes;
private Collection<Integer> versions;
private Collection<UUID> groupIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public DmpElasticQuery like(String value) {
this.like = value;
return this;
}
public DmpElasticQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public DmpElasticQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public DmpElasticQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public DmpElasticQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public DmpElasticQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public DmpElasticQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public DmpElasticQuery versionStatuses(DmpVersionStatus value) {
this.versionStatuses = List.of(value);
return this;
}
public DmpElasticQuery versionStatuses(DmpVersionStatus... value) {
this.versionStatuses = Arrays.asList(value);
return this;
}
public DmpElasticQuery versionStatuses(Collection<DmpVersionStatus> values) {
this.versionStatuses = values;
return this;
}
public DmpElasticQuery accessTypes(DmpAccessType value) {
this.accessTypes = List.of(value);
return this;
}
public DmpElasticQuery accessTypes(DmpAccessType... value) {
this.accessTypes = Arrays.asList(value);
return this;
}
public DmpElasticQuery accessTypes(Collection<DmpAccessType> values) {
this.accessTypes = values;
return this;
}
public DmpElasticQuery statuses(DmpStatus value) {
this.statuses = List.of(value);
return this;
}
public DmpElasticQuery statuses(DmpStatus... value) {
this.statuses = Arrays.asList(value);
return this;
}
public DmpElasticQuery statuses(Collection<DmpStatus> values) {
this.statuses = values;
return this;
}
public DmpElasticQuery versions(Integer value) {
this.versions = List.of(value);
return this;
}
public DmpElasticQuery versions(Integer... value) {
this.versions = Arrays.asList(value);
return this;
}
public DmpElasticQuery versions(Collection<Integer> values) {
this.versions = values;
return this;
}
public DmpElasticQuery groupIds(UUID value) {
this.groupIds = List.of(value);
return this;
}
public DmpElasticQuery groupIds(UUID... value) {
this.groupIds = Arrays.asList(value);
return this;
}
public DmpElasticQuery groupIds(Collection<UUID> values) {
this.groupIds = values;
return this;
}
public DmpElasticQuery authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
private final QueryFactory queryFactory;
private final AppElasticProperties appElasticProperties;
private final ElasticService elasticService;
private final UserScope userScope;
private final AuthorizationService authService;
@Autowired()
public DmpElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory, AppElasticProperties appElasticProperties, ElasticService elasticService, UserScope userScope, AuthorizationService authService) {
super(elasticsearchTemplate, elasticProperties);
this.queryFactory = queryFactory;
this.appElasticProperties = appElasticProperties;
this.elasticService = elasticService;
this.userScope = userScope;
this.authService = authService;
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.versionStatuses) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses);
}
@Override
protected Class<DmpElasticEntity> entityClass() {
return DmpElasticEntity.class;
}
@Override
protected Query applyAuthZ() {
if (this.authorize.contains(AuthorizationFlags.None)) return null;
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmp)) return null;
UUID userId = null;
boolean usePublic = this.authorize.contains(AuthorizationFlags.Public);
if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe();
List<Query> predicates = new ArrayList<>();
if (usePublic) {
predicates.add(this.and(
this.equals(this.elasticFieldOf(DmpElasticEntity._status), DmpStatus.Finalized.getValue()),
this.equals(this.elasticFieldOf(DmpElasticEntity._accessType), DmpAccessType.Public.getValue())
));
}
if (userId != null) {
NestedCollaboratorElasticQuery query = this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators);
query.ids(userId);
predicates.add(this.nestedQuery(query).build()._toQuery());
}
return this.or(predicates)._toQuery();
}
@Override
protected Query applyFilters() {
List<Query> predicates = new ArrayList<>();
if (like != null && !like.isBlank()) {
if (!like.startsWith("*")) like = "*" + like;
if (!like.endsWith("*")) like = like + "*";
ElasticFields elasticFields = this.elasticFieldsOf();
elasticFields.add(DmpElasticEntity._label);
elasticFields.add(DmpElasticEntity._descriptions);
predicates.add(this.like(elasticFields, List.of(like))._toQuery());
}
if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), ids)._toQuery());
}
if (groupIds != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._groupId), groupIds)._toQuery());
}
if (versions != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._version), versions.toArray(new Integer[versions.size()]))._toQuery());
}
if (excludedIds != null) {
predicates.add(this.not(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), excludedIds)._toQuery())._toQuery());
}
if (statuses != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._status), statuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[statuses.size()]))._toQuery());
}
if (versionStatuses != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._versionStatus), versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[versionStatuses.size()]))._toQuery());
}
if (accessTypes != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._accessType), accessTypes.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[accessTypes.size()]))._toQuery());
}
if (!predicates.isEmpty()) {
return this.and(predicates);
} else {
return null;
}
}
@Override
public DmpElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
DmpElasticEntity mocDoc = new DmpElasticEntity();
if (columns.contains(DmpElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._id), UUID.class));
if (columns.contains(DmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._label), String.class));
if (columns.contains(DmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._description), String.class));
if (columns.contains(DmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._status), DmpStatus.class));
if (columns.contains(DmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._versionStatus), DmpVersionStatus.class));
if (columns.contains(DmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._version), Short.class));
if (columns.contains(DmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._groupId), UUID.class));
if (columns.contains(DmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._accessType), DmpAccessType.class));
if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class));
mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null));
mocDoc.setDescriptionTemplates(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class), DmpElasticEntity._descriptionTemplates, null));
mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(DmpElasticEntity._id)) return this.elasticFieldOf(DmpElasticEntity._id);
else if (item.match(DmpElasticEntity._label)) return this.elasticFieldOf(DmpElasticEntity._label);
else if (item.match(DmpElasticEntity._description)) return this.elasticFieldOf(DmpElasticEntity._description);
else if (item.match(DmpElasticEntity._status)) return this.elasticFieldOf(DmpElasticEntity._status);
else if (item.match(DmpElasticEntity._version)) return this.elasticFieldOf(DmpElasticEntity._version);
else if (item.match(DmpElasticEntity._versionStatus)) return this.elasticFieldOf(DmpElasticEntity._versionStatus);
else if (item.match(DmpElasticEntity._groupId)) return this.elasticFieldOf(DmpElasticEntity._groupId);
else if (item.match(DmpElasticEntity._finalizedAt)) return this.elasticFieldOf(DmpElasticEntity._finalizedAt);
else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType);
else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators));
else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references));
else if (item.prefix(DmpElasticEntity._descriptionTemplates)) return this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._descriptionTemplates).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptionTemplates));
else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._descriptions));
else return null;
}
@Override
protected String[] getIndex() {
List<String> indexNames = new ArrayList<>();
indexNames.add(this.appElasticProperties.getDmpIndexName());
try {
this.elasticService.ensureDescriptionIndex();
} catch (IOException e) {
throw new RuntimeException(e);
}
return indexNames.toArray(new String[indexNames.size()]);
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(DmpElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators);
else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references);
else if (item.prefix(DmpElasticEntity._descriptionTemplates)) return this.queryFactory.query(NestedDescriptionTemplateElasticQuery.class).nestedPath(DmpElasticEntity._descriptionTemplates);
else if (item.prefix(DmpElasticEntity._descriptions)) return this.queryFactory.query(NestedDescriptionElasticQuery.class).nestedPath(DmpElasticEntity._descriptions);
else return null;
}
}

View File

@ -0,0 +1,97 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticInnerObjectQuery;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObjectQuery<InnerObjectDescriptionTemplateElasticQuery, NestedDescriptionTemplateElasticEntity, UUID> {
private String innerPath;
@Override
public InnerObjectDescriptionTemplateElasticQuery innerPath(String value) {
this.innerPath = value;
return this;
}
public InnerObjectDescriptionTemplateElasticQuery(
ElasticsearchTemplate elasticsearchRestTemplate,
ElasticProperties elasticProperties
) {
super(elasticsearchRestTemplate, elasticProperties);
}
@Override
protected Class<NestedDescriptionTemplateElasticEntity> entityClass() {
return NestedDescriptionTemplateElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
return null;
}
@Override
public NestedDescriptionTemplateElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedDescriptionTemplateElasticEntity mocDoc = new NestedDescriptionTemplateElasticEntity();
if (columns.contains(NestedDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._versionStatus), DescriptionTemplateVersionStatus.class));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._label).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._versionStatus).disableInfer(true);
else return null;
}
@Override
protected String getInnerPath() {
return this.innerPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
return null;
}
}

View File

@ -0,0 +1,273 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.NestedDmpElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticFields;
import gr.cite.tools.elastic.query.ElasticInnerObjectQuery;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
//Like in C# make it Transient
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class InnerObjectDmpElasticQuery extends ElasticInnerObjectQuery<InnerObjectDmpElasticQuery, NestedDmpElasticEntity, UUID> {
private String like;
private Collection<UUID> ids;
private Collection<UUID> excludedIds;
private Collection<DmpStatus> statuses;
private Collection<DmpVersionStatus> versionStatuses;
private Collection<DmpAccessType> accessTypes;
private Collection<Integer> versions;
private Collection<UUID> groupIds;
public InnerObjectDmpElasticQuery like(String value) {
this.like = value;
return this;
}
public InnerObjectDmpElasticQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
public InnerObjectDmpElasticQuery excludedIds(Collection<UUID> values) {
this.excludedIds = values;
return this;
}
public InnerObjectDmpElasticQuery excludedIds(UUID value) {
this.excludedIds = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery excludedIds(UUID... value) {
this.excludedIds = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery versionStatuses(DmpVersionStatus value) {
this.versionStatuses = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery versionStatuses(DmpVersionStatus... value) {
this.versionStatuses = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery versionStatuses(Collection<DmpVersionStatus> values) {
this.versionStatuses = values;
return this;
}
public InnerObjectDmpElasticQuery accessTypes(DmpAccessType value) {
this.accessTypes = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery accessTypes(DmpAccessType... value) {
this.accessTypes = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery accessTypes(Collection<DmpAccessType> values) {
this.accessTypes = values;
return this;
}
public InnerObjectDmpElasticQuery statuses(DmpStatus value) {
this.statuses = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery statuses(DmpStatus... value) {
this.statuses = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery statuses(Collection<DmpStatus> values) {
this.statuses = values;
return this;
}
public InnerObjectDmpElasticQuery versions(Integer value) {
this.versions = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery versions(Integer... value) {
this.versions = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery versions(Collection<Integer> values) {
this.versions = values;
return this;
}
public InnerObjectDmpElasticQuery groupIds(UUID value) {
this.groupIds = List.of(value);
return this;
}
public InnerObjectDmpElasticQuery groupIds(UUID... value) {
this.groupIds = Arrays.asList(value);
return this;
}
public InnerObjectDmpElasticQuery groupIds(Collection<UUID> values) {
this.groupIds = values;
return this;
}
private String innerPath;
@Override
public InnerObjectDmpElasticQuery innerPath(String value) {
this.innerPath = value;
return this;
}
private final QueryFactory queryFactory;
@Autowired()
public InnerObjectDmpElasticQuery(ElasticsearchTemplate elasticsearchTemplate, ElasticProperties elasticProperties, QueryFactory queryFactory) {
super(elasticsearchTemplate, elasticProperties);
this.queryFactory = queryFactory;
}
@Override
protected Class<NestedDmpElasticEntity> entityClass() {
return NestedDmpElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyFilters() {
List<Query> predicates = new ArrayList<>();
if (like != null && !like.isBlank()) {
if (!like.startsWith("*")) like = "*" + like;
if (!like.endsWith("*")) like = like + "*";
ElasticFields elasticFields = new ElasticFields(this.entityClass(), List.of(this.getInnerPath()));
elasticFields.add(DmpElasticEntity._label, true);
elasticFields.add(DmpElasticEntity._descriptions, true);
predicates.add(this.like(elasticFields, List.of(like))._toQuery());
}
if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id).disableInfer(true), ids)._toQuery());
}
if (groupIds != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._groupId).disableInfer(true), groupIds)._toQuery());
}
if (versions != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._version).disableInfer(true), versions.toArray(new Integer[versions.size()]))._toQuery());
}
if (excludedIds != null) {
predicates.add(this.not(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id).disableInfer(true), excludedIds)._toQuery())._toQuery());
}
if (statuses != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._status).disableInfer(true), statuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[statuses.size()]))._toQuery());
}
if (versionStatuses != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._versionStatus).disableInfer(true), versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[versionStatuses.size()]))._toQuery());
}
if (accessTypes != null) {
predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._accessType).disableInfer(true), accessTypes.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[accessTypes.size()]))._toQuery());
}
if (!predicates.isEmpty()) {
return this.and(predicates);
} else {
return null;
}
}
@Override
public NestedDmpElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedDmpElasticEntity mocDoc = new NestedDmpElasticEntity();
if (columns.contains(NestedDmpElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._id), UUID.class));
if (columns.contains(NestedDmpElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._label), String.class));
if (columns.contains(NestedDmpElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._description), String.class));
if (columns.contains(NestedDmpElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._status), DmpStatus.class));
if (columns.contains(NestedDmpElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._versionStatus), DmpVersionStatus.class));
if (columns.contains(NestedDmpElasticEntity._version)) mocDoc.setVersion(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._version), Short.class));
if (columns.contains(NestedDmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._groupId), UUID.class));
if (columns.contains(NestedDmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._accessType), DmpAccessType.class));
if (columns.contains(NestedDmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDmpElasticEntity._finalizedAt), Date.class));
mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), NestedDmpElasticEntity._collaborators, null));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedDmpElasticEntity._references, null));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDmpElasticEntity._id)) return this.elasticFieldOf(NestedDmpElasticEntity._id);
else if (item.match(NestedDmpElasticEntity._label)) return this.elasticFieldOf(NestedDmpElasticEntity._label);
else if (item.match(NestedDmpElasticEntity._description)) return this.elasticFieldOf(NestedDmpElasticEntity._description);
else if (item.match(NestedDmpElasticEntity._status)) return this.elasticFieldOf(NestedDmpElasticEntity._status);
else if (item.match(NestedDmpElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDmpElasticEntity._versionStatus);
else if (item.match(NestedDmpElasticEntity._version)) return this.elasticFieldOf(NestedDmpElasticEntity._version);
else if (item.match(NestedDmpElasticEntity._groupId)) return this.elasticFieldOf(NestedDmpElasticEntity._groupId);
else if (item.match(NestedDmpElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDmpElasticEntity._finalizedAt);
else if (item.match(NestedDmpElasticEntity._accessType)) return this.elasticFieldOf(NestedDmpElasticEntity._accessType);
else if (item.prefix(NestedDmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedDmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, NestedDmpElasticEntity._collaborators));
else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, NestedDmpElasticEntity._references));
else return null;
}
@Override
protected String getInnerPath() {
return this.innerPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedDmpElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(NestedDmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(NestedDmpElasticEntity._collaborators);
else if (item.prefix(NestedDmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(NestedDmpElasticEntity._references);
else return null;
}
}

View File

@ -0,0 +1,120 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.elastic.data.DmpElasticEntity;
import eu.eudat.elastic.data.nested.NestedCollaboratorElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedCollaboratorElasticQuery extends ElasticNestedQuery<NestedCollaboratorElasticQuery, NestedCollaboratorElasticEntity, UUID> {
private Collection<UUID> ids;
public NestedCollaboratorElasticQuery ids(UUID value) {
this.ids = List.of(value);
return this;
}
public NestedCollaboratorElasticQuery ids(UUID... value) {
this.ids = Arrays.asList(value);
return this;
}
public NestedCollaboratorElasticQuery ids(Collection<UUID> values) {
this.ids = values;
return this;
}
private String nestedPath;
@Override
public NestedCollaboratorElasticQuery nestedPath(String value) {
this.nestedPath = value;
return this;
}
public NestedCollaboratorElasticQuery(
ElasticsearchTemplate elasticsearchRestTemplate,
ElasticProperties elasticProperties
) {
super(elasticsearchRestTemplate, elasticProperties);
}
@Override
protected Class<NestedCollaboratorElasticEntity> entityClass() {
return NestedCollaboratorElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids);
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
List<Query> predicates = new ArrayList<>();
if (ids != null) {
predicates.add(this.containsUUID(this.elasticFieldOf(NestedCollaboratorElasticEntity._id), ids)._toQuery());
}
if (!predicates.isEmpty()) {
return this.and(predicates);
} else {
return null;
}
}
@Override
public NestedCollaboratorElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedCollaboratorElasticEntity mocDoc = new NestedCollaboratorElasticEntity();
if (columns.contains(NestedCollaboratorElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._id), UUID.class));
if (columns.contains(NestedCollaboratorElasticEntity._name)) mocDoc.setName(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._name), String.class));
if (columns.contains(NestedCollaboratorElasticEntity._role)) mocDoc.setRole(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedCollaboratorElasticEntity._role), DmpUserRole.class));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedCollaboratorElasticEntity._id)) return this.elasticFieldOf(NestedCollaboratorElasticEntity._id).disableInfer(true);
else if (item.match(NestedCollaboratorElasticEntity._name)) return this.elasticFieldOf(NestedCollaboratorElasticEntity._name).disableInfer(true);
else if (item.match(NestedCollaboratorElasticEntity._role)) return this.elasticFieldOf(NestedCollaboratorElasticEntity._role).disableInfer(true);
else return null;
}
@Override
protected String getNestedPath() {
return this.nestedPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedCollaboratorElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
return null;
}
}

View File

@ -0,0 +1,114 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.convention.ConventionService;
import eu.eudat.elastic.data.nested.NestedDescriptionElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDescriptionElasticQuery extends ElasticNestedQuery<NestedDescriptionElasticQuery, NestedDescriptionElasticEntity, UUID> {
private String nestedPath;
@Override
public NestedDescriptionElasticQuery nestedPath(String value) {
this.nestedPath = value;
return this;
}
private final QueryFactory queryFactory;
private final ConventionService conventionService;
public NestedDescriptionElasticQuery(
ElasticsearchTemplate elasticsearchRestTemplate,
ElasticProperties elasticProperties,
QueryFactory queryFactory, ConventionService conventionService) {
super(elasticsearchRestTemplate, elasticProperties);
this.queryFactory = queryFactory;
this.conventionService = conventionService;
}
@Override
protected Class<NestedDescriptionElasticEntity> entityClass() {
return NestedDescriptionElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
return null;
}
@Override
public NestedDescriptionElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedDescriptionElasticEntity mocDoc = new NestedDescriptionElasticEntity();
if (columns.contains(NestedDescriptionElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionElasticEntity._dmpId)) mocDoc.setDmpId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._dmpId), UUID.class));
if (columns.contains(NestedDescriptionElasticEntity._description)) mocDoc.setDescription(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._description), String.class));
if (columns.contains(NestedDescriptionElasticEntity._status)) mocDoc.setStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._status), DescriptionStatus.class));
if (columns.contains(NestedDescriptionElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionElasticEntity._finalizedAt), Date.class));
mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), NestedDescriptionElasticEntity._references, this.getNestedPath()));
mocDoc.setTags(this.convertNested(rawData, columns, this.queryFactory.query(NestedTagElasticQuery.class), NestedDescriptionElasticEntity._tags, this.getNestedPath()));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDescriptionElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionElasticEntity._id);
else if (item.match(NestedDescriptionElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionElasticEntity._label);
else if (item.match(NestedDescriptionElasticEntity._dmpId)) return this.elasticFieldOf(NestedDescriptionElasticEntity._dmpId);
else if (item.match(NestedDescriptionElasticEntity._description)) return this.elasticFieldOf(NestedDescriptionElasticEntity._description);
else if (item.match(NestedDescriptionElasticEntity._status)) return this.elasticFieldOf(NestedDescriptionElasticEntity._status);
else if (item.match(NestedDescriptionElasticEntity._finalizedAt)) return this.elasticFieldOf(NestedDescriptionElasticEntity._finalizedAt);
else if (item.prefix(NestedDescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._references)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._references));
else if (item.prefix(NestedDescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._tags)).fieldNameOf(this.extractPrefixed(item, NestedDescriptionElasticEntity._tags));
else return null;
}
@Override
protected String getNestedPath() {
return this.nestedPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedDescriptionElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
if (item.prefix(NestedDescriptionElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._references));
else if (item.prefix(NestedDescriptionElasticEntity._tags)) return this.queryFactory.query(NestedTagElasticQuery.class).nestedPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._tags));
else return null;
}
}

View File

@ -0,0 +1,96 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery<NestedDescriptionTemplateElasticQuery, NestedDescriptionTemplateElasticEntity, UUID> {
private String nestedPath;
@Override
public NestedDescriptionTemplateElasticQuery nestedPath(String value) {
this.nestedPath = value;
return this;
}
public NestedDescriptionTemplateElasticQuery(
ElasticsearchTemplate elasticsearchRestTemplate,
ElasticProperties elasticProperties
) {
super(elasticsearchRestTemplate, elasticProperties);
}
@Override
protected Class<NestedDescriptionTemplateElasticEntity> entityClass() {
return NestedDescriptionTemplateElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
return null;
}
@Override
public NestedDescriptionTemplateElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedDescriptionTemplateElasticEntity mocDoc = new NestedDescriptionTemplateElasticEntity();
if (columns.contains(NestedDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._id), UUID.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._label), String.class));
if (columns.contains(NestedDescriptionTemplateElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._versionStatus), DescriptionTemplateVersionStatus.class));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._label).disableInfer(true);
else if (item.match(NestedDescriptionTemplateElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._versionStatus).disableInfer(true);
else return null;
}
@Override
protected String getNestedPath() {
return this.nestedPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
return null;
}
}

View File

@ -0,0 +1,90 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.elastic.data.nested.NestedReferenceElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedReferenceElasticQuery extends ElasticNestedQuery<NestedReferenceElasticQuery, NestedReferenceElasticEntity, UUID> {
private String nestedPath;
@Override
public NestedReferenceElasticQuery nestedPath(String value) {
this.nestedPath = value;
return this;
}
public NestedReferenceElasticQuery(
ElasticsearchTemplate elasticsearchTemplate,
ElasticProperties elasticProperties
) {
super(elasticsearchTemplate, elasticProperties);
}
@Override
protected Class<NestedReferenceElasticEntity> entityClass() {
return NestedReferenceElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
return null;
}
@Override
public NestedReferenceElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedReferenceElasticEntity mocDoc = new NestedReferenceElasticEntity();
if (columns.contains(NestedReferenceElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedReferenceElasticEntity._id), UUID.class));
if (columns.contains(NestedReferenceElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedReferenceElasticEntity._label), String.class));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedReferenceElasticEntity._id)) return this.elasticFieldOf(NestedReferenceElasticEntity._id).disableInfer(true);
else if (item.match(NestedReferenceElasticEntity._label)) return this.elasticFieldOf(NestedReferenceElasticEntity._label).disableInfer(true);
else return null;
}
@Override
protected String getNestedPath() {
return this.nestedPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedReferenceElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
return null;
}
}

View File

@ -0,0 +1,91 @@
package eu.eudat.elastic.query;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import eu.eudat.elastic.data.nested.NestedTagElasticEntity;
import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.elastic.configuration.ElasticProperties;
import gr.cite.tools.elastic.mapper.FieldBasedMapper;
import gr.cite.tools.elastic.query.ElasticField;
import gr.cite.tools.elastic.query.ElasticNestedQuery;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedTagElasticQuery extends ElasticNestedQuery<NestedTagElasticQuery, NestedTagElasticEntity, UUID> {
private String nestedPath;
@Override
public NestedTagElasticQuery nestedPath(String value) {
this.nestedPath = value;
return this;
}
public NestedTagElasticQuery(
ElasticsearchTemplate elasticsearchTemplate,
ElasticProperties elasticProperties
) {
super(elasticsearchTemplate, elasticProperties);
}
@Override
protected Class<NestedTagElasticEntity> entityClass() {
return NestedTagElasticEntity.class;
}
@Override
protected Boolean isFalseQuery() {
return false;
}
@Override
protected Query applyAuthZ() {
return null;
}
@Override
protected Query applyFilters() {
return null;
}
@Override
public NestedTagElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
NestedTagElasticEntity mocDoc = new NestedTagElasticEntity();
if (columns.contains(NestedTagElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedTagElasticEntity._id), UUID.class));
if (columns.contains(NestedTagElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedTagElasticEntity._label), String.class));
return mocDoc;
}
@Override
protected ElasticField fieldNameOf(FieldResolver item) {
if (item.match(NestedTagElasticEntity._id)) return this.elasticFieldOf(NestedTagElasticEntity._id).disableInfer(true);
else if (item.match(NestedTagElasticEntity._label)) return this.elasticFieldOf(NestedTagElasticEntity._label).disableInfer(true);
else return null;
}
@Override
protected String getNestedPath() {
return this.nestedPath;
}
@Override
protected UUID toKey(String key) {
return UUID.fromString(key);
}
@Override
protected ElasticField getKeyField() {
return this.elasticFieldOf(NestedTagElasticEntity._id);
}
@Override
protected ElasticNestedQuery<?, ?, ?> nestedQueryOf(FieldResolver item) {
return null;
}
}

View File

@ -67,6 +67,10 @@ public class Description {
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
private Dmp dmp;
public static final String _dmp = "dmp";
public UUID getId() { public UUID getId() {
return id; return id;
} }
@ -179,4 +183,12 @@ public class Description {
public void setDescriptionTags(List<DescriptionTag> descriptionTags) { public void setDescriptionTags(List<DescriptionTag> descriptionTags) {
this.descriptionTags = descriptionTags; this.descriptionTags = descriptionTags;
} }
public Dmp getDmp() {
return dmp;
}
public void setDmp(Dmp dmp) {
this.dmp = dmp;
}
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionTemplateStatus; import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus; import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.descriptiontemplatedefinition.Definition; import eu.eudat.model.descriptiontemplatedefinition.Definition;
@ -23,6 +24,9 @@ public class DescriptionTemplate {
public final static String _groupId = "groupId"; public final static String _groupId = "groupId";
private UUID groupId; private UUID groupId;
public static final String _versionStatus = "versionStatus";
private DescriptionTemplateVersionStatus versionStatus;
public final static String _version = "version"; public final static String _version = "version";
private Short version; private Short version;
@ -164,4 +168,12 @@ public class DescriptionTemplate {
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
public DescriptionTemplateVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
} }

View File

@ -2,6 +2,7 @@ package eu.eudat.model;
import eu.eudat.commons.enums.DmpAccessType; import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus; import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.DmpVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import java.time.Instant; import java.time.Instant;
@ -25,6 +26,10 @@ public class Dmp {
private DmpStatus status; private DmpStatus status;
public static final String _status = "status"; public static final String _status = "status";
private DmpVersionStatus versionStatus;
public static final String _versionStatus = "versionStatus";
private String properties; private String properties;
@ -250,4 +255,11 @@ public class Dmp {
this.dmpUsers = dmpUsers; this.dmpUsers = dmpUsers;
} }
public DmpVersionStatus getVersionStatus() {
return versionStatus;
}
public void setVersionStatus(DmpVersionStatus versionStatus) {
this.versionStatus = versionStatus;
}
} }

View File

@ -1,11 +1,13 @@
package eu.eudat.model; package eu.eudat.model;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.old.queryableentity.DataEntity;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public class DmpDescriptionTemplate { public class DmpDescriptionTemplate{
private UUID id; private UUID id;
@ -90,5 +92,4 @@ public class DmpDescriptionTemplate {
public void setIsActive(IsActive isActive) { public void setIsActive(IsActive isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.model; package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionTemplateStatus; import eu.eudat.commons.enums.DescriptionTemplateStatus;
import eu.eudat.commons.enums.DescriptionTemplateVersionStatus;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.model.descriptiontemplatedefinition.Definition; import eu.eudat.model.descriptiontemplatedefinition.Definition;
@ -18,7 +19,7 @@ public class PublicDescriptionTemplate {
public final static String _description = "description"; public final static String _description = "description";
private String description; private String description;
public UUID getId() { public UUID getId() {
return id; return id;
} }

View File

@ -35,34 +35,34 @@ public abstract class BaseBuilder<M, D> implements Builder {
return models.stream().findFirst().orElse(null); //TODO return models.stream().findFirst().orElse(null); //TODO
} }
public abstract List<M> build(FieldSet directives, List<D> datas) throws MyApplicationException; public abstract List<M> build(FieldSet directives, List<D> data) throws MyApplicationException;
public <K> Map<K, M> asForeignKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException { public <K> Map<K, M> asForeignKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("Building references from query"); this.logger.trace("Building references from query");
List<D> datas = query.collectAs(directives); List<D> data = query.collectAs(directives);
this.logger.debug("collected {} items to build", Optional.ofNullable(datas).map(e -> e.size()).orElse(0)); this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
return this.asForeignKey(datas, directives, keySelector); return this.asForeignKey(data, directives, keySelector);
} }
public <K> Map<K, M> asForeignKey(List<D> datas, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException { public <K> Map<K, M> asForeignKey(List<D> data, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("building references"); this.logger.trace("building references");
List<M> models = this.build(directives, datas); List<M> models = this.build(directives, data);
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(e -> e.size()).orElse(0), Optional.ofNullable(datas).map(e -> e.size()).orElse(0)); this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
Map<K, M> map = models.stream().collect(Collectors.toMap(o -> keySelector.apply(o), o -> o)); Map<K, M> map = models.stream().collect(Collectors.toMap(keySelector, o -> o));
return map; return map;
} }
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException { public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("Building details from query"); this.logger.trace("Building details from query");
List<D> datas = query.collectAs(directives); List<D> data = query.collectAs(directives);
this.logger.debug("collected {} items to build", Optional.ofNullable(datas).map(e -> e.size()).orElse(0)); this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
return this.asMasterKey(datas, directives, keySelector); return this.asMasterKey(data, directives, keySelector);
} }
public <K> Map<K, List<M>> asMasterKey(List<D> datas, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException { public <K> Map<K, List<M>> asMasterKey(List<D> data, FieldSet directives, Function<M, K> keySelector) throws MyApplicationException {
this.logger.trace("building details"); this.logger.trace("building details");
List<M> models = this.build(directives, datas); List<M> models = this.build(directives, data);
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(e -> e.size()).orElse(0), Optional.ofNullable(datas).map(e -> e.size()).orElse(0)); this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
Map<K, List<M>> map = new HashMap<>(); Map<K, List<M>> map = new HashMap<>();
for (M model : models) { for (M model : models) {
K key = keySelector.apply(model); K key = keySelector.apply(model);
@ -74,9 +74,9 @@ public abstract class BaseBuilder<M, D> implements Builder {
public <FK, FM> Map<FK, FM> asEmpty(List<FK> keys, Function<FK, FM> mapper, Function<FM, FK> keySelector) { public <FK, FM> Map<FK, FM> asEmpty(List<FK> keys, Function<FK, FM> mapper, Function<FM, FK> keySelector) {
this.logger.trace("building static references"); this.logger.trace("building static references");
List<FM> models = keys.stream().map(x -> mapper.apply(x)).collect(Collectors.toList()); List<FM> models = keys.stream().map(mapper).collect(Collectors.toList());
this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(x -> x.size()).orElse(0), Optional.ofNullable(keys).map(x -> x.size())); this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(keys).map(List::size));
Map<FK, FM> map = models.stream().collect(Collectors.toMap(o -> keySelector.apply(o), o -> o)); Map<FK, FM> map = models.stream().collect(Collectors.toMap(keySelector, o -> o));
return map; return map;
} }

Some files were not shown because too many files have changed in this diff Show More