diff --git a/dmp-backend/core/target/maven-archiver/pom.properties b/dmp-backend/core/target/maven-archiver/pom.properties
deleted file mode 100644
index bc6d378ce..000000000
--- a/dmp-backend/core/target/maven-archiver/pom.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-artifactId=core
-groupId=eu.eudat
-version=1.0.0-SNAPSHOT
diff --git a/dmp-migration-tool/core/pom.xml b/dmp-migration-tool/core/pom.xml
new file mode 100644
index 000000000..6b4369902
--- /dev/null
+++ b/dmp-migration-tool/core/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+
+ eu.eudat
+ dmp-backend
+ 1.0.0-SNAPSHOT
+
+
+ core
+
+
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 17
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/commons/enums/DescriptionTemplateTypeStatus.java b/dmp-migration-tool/core/src/main/java/eu/eudat/commons/enums/DescriptionTemplateTypeStatus.java
new file mode 100644
index 000000000..718809a01
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/commons/enums/DescriptionTemplateTypeStatus.java
@@ -0,0 +1,43 @@
+package eu.eudat.commons.enums;
+
+public enum DescriptionTemplateTypeStatus {
+
+ SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
+
+ private final short value;
+
+ DescriptionTemplateTypeStatus(short value) {
+ this.value = value;
+ }
+
+ public short getValue() {
+ return value;
+ }
+
+ public static DescriptionTemplateTypeStatus fromInteger(int value) {
+ switch (value) {
+ case 0:
+ return SAVED;
+ case 1:
+ return FINALIZED;
+ case 99:
+ return DELETED;
+ default:
+ throw new RuntimeException("Unsupported Description Template Type Status");
+ }
+ }
+
+ public static DescriptionTemplateTypeStatus fromLabel(String value) {
+ switch (value) {
+ case "SAVED":
+ return SAVED;
+ case "FINALISED":
+ return FINALIZED;
+ case "DELETED":
+ return DELETED;
+ default:
+ throw new RuntimeException("Unsupported Description Template Type Status");
+ }
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DataType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DataType.java
new file mode 100644
index 000000000..bf144db9d
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DataType.java
@@ -0,0 +1,13 @@
+package eu.eudat.configurations.typedefinition;
+
+public enum DataType {
+ TINY,
+ SHORT,
+ INTEGER,
+ LONG,
+ DOUBLE,
+ FLOAT,
+ DATE,
+ STRING,
+ TEXT
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DatabaseColumnType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DatabaseColumnType.java
new file mode 100644
index 000000000..6e24625b4
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/DatabaseColumnType.java
@@ -0,0 +1,5 @@
+package eu.eudat.configurations.typedefinition;
+
+public interface DatabaseColumnType {
+ public String getType(DataType dt);
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLDatabaseColumnType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLDatabaseColumnType.java
new file mode 100644
index 000000000..bf8812277
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLDatabaseColumnType.java
@@ -0,0 +1,25 @@
+package eu.eudat.configurations.typedefinition;
+
+public class PostgreSQLDatabaseColumnType implements DatabaseColumnType {
+
+ public String getType(DataType dt) {
+ switch (dt) {
+ case TINY:
+ case SHORT:
+ case INTEGER:
+ return "integer";
+ case LONG:
+ return "bigint";
+ case FLOAT:
+ case DOUBLE:
+ return "numeric";
+ case DATE:
+ return "timestamp";
+ case STRING:
+ return "character varying(250)";
+ case TEXT:
+ return "text";
+ }
+ return "character varying(250)";
+ }
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java
new file mode 100644
index 000000000..26f6ebcc2
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/PostgreSQLEnumType.java
@@ -0,0 +1,26 @@
+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;
+
+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
+ );
+ }
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java
new file mode 100644
index 000000000..2a1fb5cbe
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/UUIDType.java
@@ -0,0 +1,113 @@
+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 {
+ 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 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 {
+ return null;
+ }
+
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java
new file mode 100644
index 000000000..bd825ae3c
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/configurations/typedefinition/XMLType.java
@@ -0,0 +1,93 @@
+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 {
+
+ private final int[] sqlTypesSupported = new int[]{Types.VARCHAR};
+
+ public int[] sqlTypes() {
+ return sqlTypesSupported;
+ }
+
+ @Override
+ public int getSqlType() {
+ return sqlTypesSupported[0];
+ }
+
+ public Class 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 {
+ return null;
+ }
+
+ 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);
+ }
+
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionService.java b/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionService.java
new file mode 100644
index 000000000..fc051a956
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionService.java
@@ -0,0 +1,40 @@
+package eu.eudat.convention;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+
+public interface ConventionService {
+
+ Boolean isValidId(Integer id);
+
+ Boolean isValidGuid(UUID guid);
+
+ Boolean isValidUUID(String str);
+ UUID parseUUIDSafe(String str);
+
+ Boolean isValidHash(String hash);
+
+ String hashValue(Object value);
+
+ String limit(String text, int maxLength);
+
+ String truncate(String text, int maxLength);
+
+ UUID getEmptyUUID();
+
+ boolean isNullOrEmpty(String value);
+
+ boolean isListNullOrEmpty(List> value);
+
+ String stringEmpty();
+
+ String asPrefix(String name);
+
+ String asIndexerPrefix(String part);
+
+ String asIndexer(String... names);
+
+ Map> toDictionaryOfList(List items, Function keySelector);
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionServiceImpl.java b/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionServiceImpl.java
new file mode 100644
index 000000000..a57333284
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/convention/ConventionServiceImpl.java
@@ -0,0 +1,150 @@
+package eu.eudat.convention;
+
+import eu.eudat.errorcode.ErrorThesaurusProperties;
+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.time.Instant;
+import java.util.*;
+import java.util.function.Function;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+public class ConventionServiceImpl implements ConventionService {
+ private final static Pattern UUID_REGEX_PATTERN = Pattern.compile("^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$");
+
+ private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ConventionServiceImpl.class));
+ private final ErrorThesaurusProperties errors;
+
+ @Autowired
+ public ConventionServiceImpl(ErrorThesaurusProperties errors) {
+ this.errors = errors;
+ }
+
+ @Override
+ public Boolean isValidId(Integer id) {
+ return id != null && id > 0;
+ }
+
+ @Override
+ public Boolean isValidGuid(UUID guid) {
+ return guid != null && !guid.equals(this.getEmptyUUID());
+ }
+
+ @Override
+ public Boolean isValidUUID(String str) {
+ if (this.isNullOrEmpty(str)) {
+ return false;
+ }
+ return UUID_REGEX_PATTERN.matcher(str).matches();
+ }
+
+ @Override
+ public UUID parseUUIDSafe(String str) {
+ if (!this.isValidUUID(str)) {
+ return null;
+ }
+ try {
+ return UUID.fromString(str);
+ } catch (Exception ex){
+ logger.warn("invalid uuid" + str, ex);
+ return null;
+ }
+ }
+
+ @Override
+ public Boolean isValidHash(String hash) {
+ return !this.isNullOrEmpty(hash);
+ }
+
+ @Override
+ public String hashValue(Object value) throws MyApplicationException {
+ if (value == null) return this.stringEmpty();
+ if (value instanceof Instant) return String.format("%ts", (Instant) value);
+ throw new MyApplicationException(this.errors.getSystemError().getCode(), this.errors.getSystemError().getMessage());
+ }
+
+ @Override
+ public String limit(String text, int maxLength) {
+ if (this.isNullOrEmpty(text)) return text;
+ if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
+ else return text;
+ }
+
+ @Override
+ public String truncate(String text, int maxLength) {
+ String truncated = text;
+ if (text.length() < maxLength) return text;
+
+ truncated = truncated.trim();
+ truncated = truncated.replaceAll("\\s+", " ");//remove multiple spaces
+ if (truncated.length() < maxLength) return truncated;
+ truncated = truncated.replaceAll("([.!@#$%^&-=':;,<>?*\"/|])+", "");//remove multiple spaces
+ if (truncated.length() < maxLength) return truncated;
+ truncated = truncated.replaceAll("([aeiou])+", "");//remove multiple spaces
+ if (truncated.length() < maxLength) return truncated;
+ truncated = truncated.replaceAll("([AEIOU])+", "");//remove multiple spaces
+ if (truncated.length() < maxLength) return truncated;
+
+ if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
+ return text;
+
+ }
+
+ @Override
+ public UUID getEmptyUUID() {
+ return new UUID(0L, 0L);
+ }
+
+ @Override
+ public boolean isNullOrEmpty(String value) {
+ return value == null || value.isEmpty();
+ }
+
+ @Override
+ public boolean isListNullOrEmpty(List> value) {
+ if(value == null) return true;
+ return value.isEmpty();
+ }
+
+ @Override
+ public String stringEmpty() {
+ return "";
+ }
+
+ @Override
+ public String asPrefix(String name) {
+ if (name == null) return null;
+ return name + ".";
+ }
+
+ @Override
+ public String asIndexer(String... names) {
+ if (names == null) return null;
+ return String.join(".", Arrays.stream(names).filter(x -> !this.isNullOrEmpty(x)).collect(Collectors.toList()));
+ }
+
+ @Override
+ public String asIndexerPrefix(String part) {
+ if (part == null) return null;
+ return part + ".";
+ }
+
+ @Override
+ public Map> toDictionaryOfList(List items, Function keySelector) {
+ Map> map = new HashMap<>();
+ for (V model : items) {
+ K key = keySelector.apply(model);
+ if (!map.containsKey(key)) map.put(key, new ArrayList());
+ map.get(key).add(model);
+ }
+ return map;
+ }
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/data/BaseEntity.java b/dmp-migration-tool/core/src/main/java/eu/eudat/data/BaseEntity.java
new file mode 100644
index 000000000..df00c3311
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/data/BaseEntity.java
@@ -0,0 +1,5 @@
+package eu.eudat.data;
+
+public interface BaseEntity {
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java b/dmp-migration-tool/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java
new file mode 100644
index 000000000..be7a2477f
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/data/DescriptionTemplateTypeEntity.java
@@ -0,0 +1,54 @@
+package eu.eudat.data;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import jakarta.persistence.*;
+import java.util.UUID;
+
+@Entity
+@Table(name = "DescriptionTemplateType")
+public class DescriptionTemplateTypeEntity implements BaseEntity {
+
+ @Id
+ @GeneratedValue
+ @GenericGenerator(name = "uuid2", strategy = "uuid2")
+ @Column(name = "ID", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
+ private UUID id;
+
+ public static final String _id = "ID";
+
+ @Column(name = "Name", nullable = false)
+ private String name;
+
+ public static final String _name = "Name";
+
+ @Column(name = "Status", nullable = false)
+ private Short status;
+
+ public static final String _status = "Status";
+
+ 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 Short getStatus() {
+ return status;
+ }
+
+ public void setStatus(Short status) {
+ this.status = status;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorDescription.java b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorDescription.java
new file mode 100644
index 000000000..a7387ec9f
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorDescription.java
@@ -0,0 +1,25 @@
+package eu.eudat.errorcode;
+
+public class ErrorDescription {
+
+ private int code;
+
+ private String message;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusConfiguration.java b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusConfiguration.java
new file mode 100644
index 000000000..3aaa16690
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusConfiguration.java
@@ -0,0 +1,12 @@
+package eu.eudat.errorcode;
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableConfigurationProperties(ErrorThesaurusProperties.class)
+public class ErrorThesaurusConfiguration {
+
+
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusProperties.java b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusProperties.java
new file mode 100644
index 000000000..536391a02
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/errorcode/ErrorThesaurusProperties.java
@@ -0,0 +1,48 @@
+package eu.eudat.errorcode;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "error-thesaurus")
+public class ErrorThesaurusProperties {
+
+ private ErrorDescription systemError;
+
+ public ErrorDescription getSystemError() {
+ return systemError;
+ }
+
+ public void setSystemError(ErrorDescription systemError) {
+ this.systemError = systemError;
+ }
+
+ private ErrorDescription forbidden;
+
+ public ErrorDescription getForbidden() {
+ return forbidden;
+ }
+
+ public void setForbidden(ErrorDescription forbidden) {
+ this.forbidden = forbidden;
+ }
+
+ private ErrorDescription hashConflict;
+
+ public ErrorDescription getHashConflict() {
+ return hashConflict;
+ }
+
+ public void setHashConflict(ErrorDescription hashConflict) {
+ this.hashConflict = hashConflict;
+ }
+
+ private ErrorDescription modelValidation;
+
+ public ErrorDescription getModelValidation() {
+ return modelValidation;
+ }
+
+ public void setModelValidation(ErrorDescription modelValidation) {
+ this.modelValidation = modelValidation;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/model/DescriptionTemplateType.java b/dmp-migration-tool/core/src/main/java/eu/eudat/model/DescriptionTemplateType.java
new file mode 100644
index 000000000..1350eb689
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/model/DescriptionTemplateType.java
@@ -0,0 +1,37 @@
+package eu.eudat.model;
+
+import java.util.UUID;
+
+public class DescriptionTemplateType {
+
+ private UUID id;
+
+ private String name;
+
+ private short status;
+
+ 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 short getStatus() {
+ return status;
+ }
+
+ public void setStatus(short status) {
+ this.status = status;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/BaseBuilder.java b/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/BaseBuilder.java
new file mode 100644
index 000000000..4d6b584ab
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/BaseBuilder.java
@@ -0,0 +1,97 @@
+package eu.eudat.model.builder;
+
+import eu.eudat.convention.ConventionService;
+import gr.cite.tools.data.builder.Builder;
+import gr.cite.tools.data.query.QueryBase;
+import gr.cite.tools.fieldset.BaseFieldSet;
+import gr.cite.tools.fieldset.FieldSet;
+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 BaseBuilder implements Builder {
+
+ protected final LoggerService logger;
+
+ protected final ConventionService conventionService;
+
+ public BaseBuilder(
+ ConventionService conventionService,
+ LoggerService logger
+ ) {
+ this.conventionService = conventionService;
+ this.logger = logger;
+ }
+
+ public M build(FieldSet directives, D data) {
+ if (data == null) {
+ return null;
+ }
+ List models = this.build(directives == null ? getFullFieldSet() : directives, List.of(data));
+ return models.stream().findFirst().orElse(null);
+ }
+
+ public abstract List build(FieldSet directives, List data);
+
+ public abstract FieldSet getFullFieldSet();
+
+ public Map asForeignKey(QueryBase query, FieldSet directives, Function keySelector) {
+ this.logger.trace("Building references from query");
+ List data = query.collectAs(directives);
+ this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
+ return this.asForeignKey(data, directives, keySelector);
+ }
+
+ public Map asForeignKey(List data, FieldSet directives, Function keySelector) {
+ this.logger.trace("building references");
+ List models = this.build(directives, data);
+ this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
+ assert models != null;
+ return models.stream().collect(Collectors.toMap(keySelector, o -> o));
+ }
+
+ public Map> asMasterKey(QueryBase query, FieldSet directives, Function keySelector) {
+ this.logger.trace("Building details from query");
+ List data = query.collectAs(directives);
+ this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
+ return this.asMasterKey(data, directives, keySelector);
+ }
+
+ public Map> asMasterKey(List data, FieldSet directives, Function keySelector) {
+ this.logger.trace("building details");
+ List models = this.build(directives, data);
+ this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
+ Map> map = new HashMap<>();
+ assert models != null;
+ for (M model : models) {
+ K key = keySelector.apply(model);
+ if (!map.containsKey(key))
+ map.put(key, new ArrayList());
+ map.get(key).add(model);
+ }
+ return map;
+ }
+
+ public Map asEmpty(List keys, Function mapper, Function keySelector) {
+ this.logger.trace("building static references");
+ List models = keys.stream().map(mapper).collect(Collectors.toList());
+ this.logger.trace("mapping {} build items from {} requested", Optional.of(models).map(List::size).orElse(0), Optional.of(keys).map(List::size));
+ return models.stream().collect(Collectors.toMap(keySelector, o -> o));
+ }
+
+ protected String hashValue(Instant value) {
+ 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);
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java b/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java
new file mode 100644
index 000000000..edafeb799
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/model/builder/DescriptionTemplateTypeBuilder.java
@@ -0,0 +1,56 @@
+package eu.eudat.model.builder;
+
+import eu.eudat.convention.ConventionService;
+import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.model.DescriptionTemplateType;
+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.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+@Component
+public class DescriptionTemplateTypeBuilder extends BaseBuilder {
+
+ public DescriptionTemplateTypeBuilder(ConventionService conventionService) {
+ super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeBuilder.class)));
+ }
+
+ @Override
+ public List build(FieldSet directives, List data) {
+ if (directives == null || directives.isEmpty())
+ return new ArrayList<>();
+
+ List models = new ArrayList<>(100);
+
+ if (data == null)
+ return models;
+ for (DescriptionTemplateTypeEntity d : data) {
+ DescriptionTemplateType m = new DescriptionTemplateType();
+ if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._id)))
+ m.setId(d.getId());
+ if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._name)))
+ m.setName(d.getName());
+ if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._status)))
+ m.setStatus(d.getStatus());
+ models.add(m);
+ }
+
+ return models;
+ }
+
+ @Override
+ public FieldSet getFullFieldSet() {
+ BaseFieldSet fieldSet = new BaseFieldSet();
+ fieldSet.setFields(Set.of(
+ DescriptionTemplateTypeEntity._id,
+ DescriptionTemplateTypeEntity._name,
+ DescriptionTemplateTypeEntity._status
+ ));
+ return fieldSet;
+ }
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/model/result/QueryResult.java b/dmp-migration-tool/core/src/main/java/eu/eudat/model/result/QueryResult.java
new file mode 100644
index 000000000..84cfa612a
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/model/result/QueryResult.java
@@ -0,0 +1,71 @@
+package eu.eudat.model.result;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class QueryResult {
+
+ public QueryResult() {
+ }
+
+ public QueryResult(List items, long count, long countOverride) {
+ this.items = items;
+ this.count = count;
+ this.countOverride = countOverride;
+ }
+
+ public QueryResult(List items, long count) {
+ this.items = items;
+ this.count = count;
+ this.countOverride = 0;
+ }
+
+ public QueryResult(M item) {
+ this.items = List.of(item);
+ this.count = 1;
+ this.countOverride = 0;
+ }
+
+ public QueryResult(List items) {
+ this.items = items;
+ if (items != null)
+ this.count = items.size();
+ else
+ this.count = 0;
+ }
+
+ private List items;
+
+ private long count;
+
+ private long countOverride;
+
+ public List getItems() {
+ return items;
+ }
+
+ public void setItems(List items) {
+ this.items = items;
+ }
+
+ public long getCount() {
+ return count;
+ }
+
+ public void setCount(long count) {
+ this.count = count;
+ }
+
+ public long getCountOverride() {
+ return countOverride;
+ }
+
+ public void setCountOverride(long countOverride) {
+ this.countOverride = countOverride;
+ }
+
+ public static QueryResult> empty() {
+ return new QueryResult<>(new ArrayList<>(), 0L);
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java b/dmp-migration-tool/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java
new file mode 100644
index 000000000..8476fb6b6
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/query/DescriptionTemplateTypeQuery.java
@@ -0,0 +1,132 @@
+package eu.eudat.query;
+
+import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
+import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
+import eu.eudat.query.lookup.LookupAware;
+import gr.cite.tools.data.query.FieldResolver;
+import gr.cite.tools.data.query.QueryBase;
+import gr.cite.tools.data.query.QueryContext;
+import jakarta.persistence.Tuple;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.Predicate;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class DescriptionTemplateTypeQuery extends QueryBase implements LookupAware {
+
+ private Collection ids;
+
+ private Collection names;
+
+ private Collection statuses;
+
+ public DescriptionTemplateTypeQuery ids(UUID value) {
+ this.ids = List.of(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery ids(UUID... value) {
+ this.ids = Arrays.asList(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery ids(List value) {
+ this.ids = value;
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery names(String value) {
+ this.names = List.of(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery names(String... value) {
+ this.names = Arrays.asList(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery names(List value) {
+ this.names = value;
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery statuses(Short value) {
+ this.statuses = List.of(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery statuses(Short... value) {
+ this.statuses = Arrays.asList(value);
+ return this;
+ }
+
+ public DescriptionTemplateTypeQuery statuses(List value) {
+ this.statuses = value;
+ return this;
+ }
+
+ @Override
+ public DescriptionTemplateTypeQuery fromLookup(DescriptionTemplateTypeLookup lookup) {
+ if (lookup == null) return this;
+ if (lookup.getName() != null) names(lookup.getName());
+ if (lookup.getStatus() != null) statuses(DescriptionTemplateTypeStatus.fromLabel(lookup.getStatus()).getValue());
+ return this;
+ }
+
+ @Override
+ protected Boolean isFalseQuery() {
+ return Boolean.FALSE;
+ }
+
+ @Override
+ protected Class entityClass() {
+ return DescriptionTemplateTypeEntity.class;
+ }
+
+ @Override
+ protected Predicate applyFilters(QueryContext queryContext) {
+ List predicates = new ArrayList<>();
+
+ if (this.ids != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
+ for (UUID item : this.ids) inClause.value(item);
+ predicates.add(inClause);
+ }
+
+ if (this.names != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._name));
+ for (String item : this.names) inClause.value(item);
+ predicates.add(inClause);
+ }
+
+ if (this.statuses != null) {
+ CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
+ for (Short item : this.statuses) inClause.value(item);
+ predicates.add(inClause);
+ }
+
+ if (!predicates.isEmpty()) {
+ Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
+ return queryContext.CriteriaBuilder.and(predicatesArray);
+ } else {
+ return queryContext.CriteriaBuilder.and();
+ }
+ }
+
+ @Override
+ protected String fieldNameOf(FieldResolver item) {
+ return null;
+ }
+
+ @Override
+ protected DescriptionTemplateTypeEntity convert(Tuple tuple, Set columns) {
+ return null;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java b/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java
new file mode 100644
index 000000000..0c928c99e
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateTypeLookup.java
@@ -0,0 +1,25 @@
+package eu.eudat.query.lookup;
+
+import gr.cite.tools.data.query.Lookup;
+
+public class DescriptionTemplateTypeLookup extends Lookup {
+
+ private String name, status;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/LookupAware.java b/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/LookupAware.java
new file mode 100644
index 000000000..993c6b137
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/query/lookup/LookupAware.java
@@ -0,0 +1,12 @@
+package eu.eudat.query.lookup;
+
+public interface LookupAware {
+
+ /**
+ * Every query that supports building from a lookup object should implement this interface
+ * @param lookup The object containing all the lookup options
+ * @return The query built from all the set options
+ */
+ Q fromLookup(L lookup);
+
+}
diff --git a/dmp-migration-tool/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java b/dmp-migration-tool/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java
new file mode 100644
index 000000000..3f8ebef88
--- /dev/null
+++ b/dmp-migration-tool/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java
@@ -0,0 +1,101 @@
+package eu.eudat.service;
+
+import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
+import eu.eudat.data.DescriptionTemplateTypeEntity;
+import eu.eudat.model.DescriptionTemplateType;
+import eu.eudat.model.builder.DescriptionTemplateTypeBuilder;
+import eu.eudat.query.DescriptionTemplateTypeQuery;
+import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
+import gr.cite.tools.data.builder.BuilderFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.PersistenceContext;
+import java.util.List;
+import java.util.UUID;
+
+@Service
+public class DescriptionTemplateTypeService {
+
+ private final ApplicationContext applicationContext;
+
+ private final BuilderFactory builderFactory;
+
+ private final PlatformTransactionManager transactionManager;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public DescriptionTemplateTypeService(ApplicationContext applicationContext, BuilderFactory builderFactory, PlatformTransactionManager platformTransactionManager) {
+ this.applicationContext = applicationContext;
+ this.builderFactory = builderFactory;
+ this.transactionManager = platformTransactionManager;
+ }
+
+ public List getAll(DescriptionTemplateTypeLookup lookup) {
+ DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
+ return builderFactory
+ .builder(DescriptionTemplateTypeBuilder.class)
+ .build(lookup.getProject(), query.fromLookup(lookup).collect());
+ }
+
+ public DescriptionTemplateType getById(UUID id) {
+ DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
+ return builderFactory
+ .builder(DescriptionTemplateTypeBuilder.class)
+ .build(null, query.ids(id).first());
+ }
+
+ public DescriptionTemplateType create(DescriptionTemplateType payload) {
+ DescriptionTemplateTypeEntity created = new DescriptionTemplateTypeEntity();
+ created.setId(UUID.randomUUID());
+ created.setName(payload.getName());
+ created.setStatus(DescriptionTemplateTypeStatus.SAVED.getValue());
+
+ DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
+ definition.setName(UUID.randomUUID().toString());
+ definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
+ definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
+ TransactionStatus status = null;
+ try {
+ status = transactionManager.getTransaction(definition);
+ entityManager.persist(created);
+
+ entityManager.flush();
+ transactionManager.commit(status);
+ } catch (Exception ex) {
+ if (status != null)
+ transactionManager.rollback(status);
+ throw ex;
+ }
+
+ DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
+ return builderFactory
+ .builder(DescriptionTemplateTypeBuilder.class)
+ .build(null, query.ids(created.getId()).first());
+ }
+
+ public DescriptionTemplateType update(DescriptionTemplateType payload) {
+ DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, payload.getId());
+ entity.setName(payload.getName());
+ entity.setStatus(payload.getStatus());
+ entityManager.merge(entity);
+ entityManager.flush();
+ return builderFactory.builder(DescriptionTemplateTypeBuilder.class).build(null, entity);
+ }
+
+ public boolean delete (UUID id) {
+ DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, id);
+ if (entity == null) return false;
+ entity.setStatus(DescriptionTemplateTypeStatus.DELETED.getValue());
+ entityManager.merge(entity);
+ entityManager.flush();
+ return true;
+ }
+
+}
diff --git a/dmp-migration-tool/data/pom.xml b/dmp-migration-tool/data/pom.xml
index 6c162868f..59d45c51d 100644
--- a/dmp-migration-tool/data/pom.xml
+++ b/dmp-migration-tool/data/pom.xml
@@ -15,6 +15,13 @@
+
+
+ eu.eudat
+ core
+ 1.0.0-SNAPSHOT
+
+
dmp-backend
queryable
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/converters/DateToUTCConverter.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/converters/DateToUTCConverter.java
new file mode 100644
index 000000000..3a9207eb2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/converters/DateToUTCConverter.java
@@ -0,0 +1,49 @@
+package eu.eudat.data.converters;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.format.datetime.DateFormatter;
+
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Created by ikalyvas on 9/25/2018.
+ */
+@Converter
+public class DateToUTCConverter implements AttributeConverter {
+ private static final Logger logger = LoggerFactory.getLogger(DateToUTCConverter.class);
+
+ @Override
+ public Date convertToDatabaseColumn(Date attribute) {
+ if(attribute == null) return null;
+ DateFormat formatterIST = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ formatterIST.setTimeZone(TimeZone.getTimeZone("UTC"));
+ try {
+ String date = formatterIST.format(attribute);
+ return formatterIST.parse(date);
+ } catch (ParseException e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ @Override
+ public Date convertToEntityAttribute(Date dbData) {
+ if(dbData == null) return null;
+ DateFormat formatterIST = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ formatterIST.setTimeZone(TimeZone.getTimeZone("UTC"));
+ try {
+ String date = formatterIST.format(dbData);
+ return formatterIST.parse(date);
+ } catch (ParseException e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccess.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccess.java
new file mode 100644
index 000000000..c3b5603a4
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccess.java
@@ -0,0 +1,22 @@
+package eu.eudat.data.dao;
+
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.queryable.queryableentity.DataEntity;
+
+
+public class DatabaseAccess {
+
+ public DatabaseAccess(DatabaseService databaseService) {
+ this.databaseService = databaseService;
+ }
+
+ private DatabaseService databaseService;
+
+ public DatabaseService getDatabaseService() {
+ return databaseService;
+ }
+
+ public void setDatabaseService(DatabaseService databaseService) {
+ this.databaseService = databaseService;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccessLayer.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccessLayer.java
new file mode 100644
index 000000000..dd6f524db
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/DatabaseAccessLayer.java
@@ -0,0 +1,21 @@
+package eu.eudat.data.dao;
+
+
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.queryableentity.DataEntity;
+
+import java.util.concurrent.CompletableFuture;
+
+public interface DatabaseAccessLayer {
+ T createOrUpdate(T item);
+
+ CompletableFuture createOrUpdateAsync(T item);
+
+ T find(I id);
+
+ T find(I id, String hint);
+
+ void delete(T item);
+
+ QueryableList asQueryable();
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java
new file mode 100644
index 000000000..42b693035
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/Criteria.java
@@ -0,0 +1,18 @@
+package eu.eudat.data.dao.criteria;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public abstract class Criteria {
+ @ApiModelProperty(value = "like", name = "like", dataType = "String", allowEmptyValue = true, example = "\"\"")
+ private String like;
+
+ public String getLike() {
+ return like;
+ }
+
+ public void setLike(String like) {
+ this.like = like;
+ }
+
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java
new file mode 100644
index 000000000..f2348d016
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java
@@ -0,0 +1,16 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DMPProfile;
+
+public class DataManagementPlanBlueprintCriteria extends Criteria {
+
+ private Integer status;
+
+ public Integer getStatus() {
+ return status;
+ }
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java
new file mode 100644
index 000000000..6b8de9a48
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java
@@ -0,0 +1,126 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.Grant;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class DataManagementPlanCriteria extends Criteria {
+ private Date periodStart;
+ private Date periodEnd;
+ private List grants;
+ private boolean allVersions;
+ private List groupIds;
+ private Integer status;
+ private List organisations;
+ private Integer role;
+ private List collaborators;
+ private List datasetTemplates;
+ private boolean isPublic;
+ private boolean onlyPublic;
+ private Short grantStatus;
+ private boolean hasDoi;
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+
+ public Date getPeriodEnd() {
+ return periodEnd;
+ }
+ public void setPeriodEnd(Date periodEnd) {
+ this.periodEnd = periodEnd;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public boolean getAllVersions() {
+ return allVersions;
+ }
+ public void setAllVersions(boolean allVersions) {
+ this.allVersions = allVersions;
+ }
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public List getOrganisations() {
+ return organisations;
+ }
+ public void setOrganisations(List organisations) {
+ this.organisations = organisations;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+
+ public List getCollaborators() {
+ return collaborators;
+ }
+ public void setCollaborators(List collaborators) {
+ this.collaborators = collaborators;
+ }
+
+ public List getDatasetTemplates() {
+ return datasetTemplates;
+ }
+ public void setDatasetTemplates(List datasetTemplates) {
+ this.datasetTemplates = datasetTemplates;
+ }
+
+ public boolean getIsPublic() {
+ return isPublic;
+ }
+ public void setIsPublic(boolean isPublic) {
+ this.isPublic = isPublic;
+ }
+
+ public boolean isOnlyPublic() {
+ return onlyPublic;
+ }
+
+ public void setOnlyPublic(boolean onlyPublic) {
+ this.onlyPublic = onlyPublic;
+ }
+
+ public Short getGrantStatus() {
+ return grantStatus;
+ }
+
+ public void setGrantStatus(Short grantStatus) {
+ this.grantStatus = grantStatus;
+ }
+
+ public boolean hasDoi() {
+ return hasDoi;
+ }
+
+ public void setHasDoi(boolean hasDoi) {
+ this.hasDoi = hasDoi;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java
new file mode 100644
index 000000000..a601fcd6b
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java
@@ -0,0 +1,9 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DMPProfile;
+
+/**
+ * Created by ikalyvas on 3/21/2018.
+ */
+public class DataManagementPlanProfileCriteria extends Criteria {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java
new file mode 100644
index 000000000..cc96186fc
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java
@@ -0,0 +1,66 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.types.grant.GrantStateType;
+
+import java.util.List;
+import java.util.UUID;
+
+public class DataManagementPlanPublicCriteria extends Criteria {
+ private GrantStateType grantStatus;
+ private List grants;
+ public List datasetProfile;
+ private List dmpOrganisations;
+ private Integer role;
+ private boolean allVersions;
+ private List groupIds;
+
+ public GrantStateType getGrantStatus() {
+ return grantStatus;
+ }
+ public void setGrantStatus(GrantStateType grantStatus) {
+ this.grantStatus = grantStatus;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public List getDatasetProfile() {
+ return datasetProfile;
+ }
+ public void setDatasetProfile(List datasetProfile) {
+ this.datasetProfile = datasetProfile;
+ }
+
+ public List getDmpOrganisations() {
+ return dmpOrganisations;
+ }
+ public void setDmpOrganisations(List dmpOrganisations) {
+ this.dmpOrganisations = dmpOrganisations;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+
+ public boolean getAllVersions() {
+ return allVersions;
+ }
+ public void setAllVersions(boolean allVersions) {
+ this.allVersions = allVersions;
+ }
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataRepositoryCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataRepositoryCriteria.java
new file mode 100644
index 000000000..ecd577308
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DataRepositoryCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DataRepository;
+
+import java.util.UUID;
+
+public class DataRepositoryCriteria extends Criteria {
+
+ private UUID creationUserId;
+
+ public UUID getCreationUserId() {
+ return creationUserId;
+ }
+ public void setCreationUserId(UUID creationUserId) {
+ this.creationUserId = creationUserId;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java
new file mode 100644
index 000000000..d730d0127
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetCriteria.java
@@ -0,0 +1,144 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.elastic.entities.Tag;
+import eu.eudat.types.grant.GrantStateType;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+
+public class DatasetCriteria extends Criteria {
+ private Integer status;
+ private Date periodStart;
+ private Date periodEnd;
+ private List dmpIds;
+ private List tags;
+ private boolean allVersions;
+ private UUID profileDatasetId;
+ private List organisations;
+ private Integer role;
+ private List grants;
+ private List collaborators;
+ private List datasetTemplates;
+ private List groupIds;
+ private Boolean isPublic;
+ private Short grantStatus;
+ private boolean hasDoi;
+
+ public boolean getAllVersions() {
+ return allVersions;
+ }
+ public void setAllVersions(boolean allVersions) {
+ this.allVersions = allVersions;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+
+ public Date getPeriodEnd() {
+ return periodEnd;
+ }
+ public void setPeriodEnd(Date periodEnd) {
+ this.periodEnd = periodEnd;
+ }
+
+ public List getDmpIds() {
+ return dmpIds;
+ }
+ public void setDmpIds(List dmpIds) {
+ this.dmpIds = dmpIds;
+ }
+
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public UUID getProfileDatasetId() {
+ return profileDatasetId;
+ }
+ public void setProfileDatasetId(UUID profileDatasetId) {
+ this.profileDatasetId = profileDatasetId;
+ }
+
+ public List getOrganisations() {
+ return organisations;
+ }
+ public void setOrganisations(List organisations) {
+ this.organisations = organisations;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public List getCollaborators() {
+ return collaborators;
+ }
+ public void setCollaborators(List collaborators) {
+ this.collaborators = collaborators;
+ }
+
+ public List getDatasetTemplates() {
+ return datasetTemplates;
+ }
+ public void setDatasetTemplates(List datasetTemplates) {
+ this.datasetTemplates = datasetTemplates;
+ }
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+
+ public Boolean getIsPublic() {
+ return isPublic;
+ }
+
+ public void setIsPublic(Boolean isPublic) {
+ this.isPublic = isPublic;
+ }
+
+ public Short getGrantStatus() {
+ return grantStatus;
+ }
+
+ public void setGrantStatus(Short grantStatus) {
+ this.grantStatus = grantStatus;
+ }
+
+ public boolean hasDoi() {
+ return hasDoi;
+ }
+
+ public void setHasDoi(boolean hasDoi) {
+ this.hasDoi = hasDoi;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileCriteria.java
new file mode 100644
index 000000000..c859cb2c8
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileCriteria.java
@@ -0,0 +1,101 @@
+package eu.eudat.data.dao.criteria;
+
+
+import eu.eudat.data.entities.DescriptionTemplate;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class DatasetProfileCriteria extends Criteria {
+
+ public enum DatasetProfileFilter {
+ DMPs((short) 0), Datasets((short) 1);
+
+ private short value;
+ private DatasetProfileFilter(short value) {
+ this.value = value;
+ }
+ public short getValue() { return value; }
+
+ public static DatasetProfileFilter fromInteger(short value) {
+ switch (value) {
+ case 0:
+ return DMPs;
+ case 1:
+ return Datasets;
+ default:
+ throw new RuntimeException("Unsupported DescriptionTemplate filter");
+ }
+ }
+ }
+
+ private boolean allVersions;
+ private List groupIds;
+ private Short filter;
+ private UUID userId;
+ private boolean finalized;
+ private Integer status;
+ private Integer role;
+ private List ids;
+ private Date periodStart;
+
+ public boolean getAllVersions() { return allVersions; }
+ public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
+
+ public List getGroupIds() { return groupIds; }
+ public void setGroupIds(List groupIds) { this.groupIds = groupIds; }
+
+ public Short getFilter() {
+ return filter;
+ }
+ public void setFilter(Short filter) {
+ this.filter = filter;
+ }
+
+ public UUID getUserId() {
+ return userId;
+ }
+ public void setUserId(UUID userId) {
+ this.userId = userId;
+ }
+
+ public boolean getFinalized() {
+ return finalized;
+ }
+ public void setFinalized(boolean finalized) {
+ this.finalized = finalized;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+
+ public List getIds() {
+ return ids;
+ }
+
+ public void setIds(List ids) {
+ this.ids = ids;
+ }
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileWizardCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileWizardCriteria.java
new file mode 100644
index 000000000..9e1d5d9e2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetProfileWizardCriteria.java
@@ -0,0 +1,18 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.DescriptionTemplate;
+
+import java.util.UUID;
+
+
+public class DatasetProfileWizardCriteria extends Criteria {
+ private UUID id;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java
new file mode 100644
index 000000000..9554ed5b4
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java
@@ -0,0 +1,70 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.elastic.entities.Tag;
+import eu.eudat.types.grant.GrantStateType;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Created by ikalyvas on 10/2/2018.
+ */
+public class DatasetPublicCriteria extends Criteria{
+ private GrantStateType grantStatus;
+ private List grants;
+ private List datasetProfile;
+ private List dmpOrganisations;
+ private List tags;
+ private List dmpIds;
+ private Integer role;
+
+ public GrantStateType getGrantStatus() {
+ return grantStatus;
+ }
+ public void setGrantStatus(GrantStateType grantStatus) {
+ this.grantStatus = grantStatus;
+ }
+
+ public List getGrants() {
+ return grants;
+ }
+ public void setGrants(List grants) {
+ this.grants = grants;
+ }
+
+ public List getDatasetProfile() {
+ return datasetProfile;
+ }
+ public void setDatasetProfile(List datasetProfile) {
+ this.datasetProfile = datasetProfile;
+ }
+
+ public List getDmpOrganisations() {
+ return dmpOrganisations;
+ }
+ public void setDmpOrganisations(List dmpOrganisations) {
+ this.dmpOrganisations = dmpOrganisations;
+ }
+
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+ public List getDmpIds() {
+ return dmpIds;
+ }
+ public void setDmpIds(List dmpIds) {
+ this.dmpIds = dmpIds;
+ }
+
+ public Integer getRole() {
+ return role;
+ }
+ public void setRole(Integer role) {
+ this.role = role;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetWizardUserDmpCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetWizardUserDmpCriteria.java
new file mode 100644
index 000000000..c5cbfc984
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DatasetWizardUserDmpCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.data.dao.criteria;
+
+
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.UserInfo;
+
+public class DatasetWizardUserDmpCriteria extends Criteria {
+ private UserInfo userInfo;
+
+ public UserInfo getUserInfo() {
+ return userInfo;
+ }
+
+ public void setUserInfo(UserInfo userInfo) {
+ this.userInfo = userInfo;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DynamicFieldsCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DynamicFieldsCriteria.java
new file mode 100644
index 000000000..1367e8068
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/DynamicFieldsCriteria.java
@@ -0,0 +1,51 @@
+package eu.eudat.data.dao.criteria;
+
+import java.util.List;
+
+/**
+ * Created by ikalyvas on 3/26/2018.
+ */
+public class DynamicFieldsCriteria extends Criteria {
+ public static class DynamicFieldDependencyCriteria {
+ private String property;
+ private String value;
+
+ public DynamicFieldDependencyCriteria() {
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+
+ private String id;
+ private List dynamicFields;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List getDynamicFields() {
+ return dynamicFields;
+ }
+
+ public void setDynamicFields(List dynamicFields) {
+ this.dynamicFields = dynamicFields;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/EmailConfirmationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/EmailConfirmationCriteria.java
new file mode 100644
index 000000000..1436752b9
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/EmailConfirmationCriteria.java
@@ -0,0 +1,6 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.EmailConfirmation;
+
+public class EmailConfirmationCriteria extends Criteria{
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ExternalDatasetCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ExternalDatasetCriteria.java
new file mode 100644
index 000000000..a5a6275e8
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ExternalDatasetCriteria.java
@@ -0,0 +1,15 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.ExternalDataset;
+import java.util.UUID;
+
+public class ExternalDatasetCriteria extends Criteria {
+ private UUID creationUserId;
+
+ public UUID getCreationUserId() {
+ return creationUserId;
+ }
+ public void setCreationUserId(UUID creationUserId) {
+ this.creationUserId = creationUserId;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/FunderCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/FunderCriteria.java
new file mode 100644
index 000000000..b67983aa0
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/FunderCriteria.java
@@ -0,0 +1,34 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Funder;
+
+import java.util.Date;
+
+public class FunderCriteria extends Criteria {
+ private String reference;
+ private String exactReference;
+ private Date periodStart;
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getExactReference() {
+ return exactReference;
+ }
+
+ public void setExactReference(String exactReference) {
+ this.exactReference = exactReference;
+ }
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/GrantCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/GrantCriteria.java
new file mode 100644
index 000000000..1cfd88be7
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/GrantCriteria.java
@@ -0,0 +1,83 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Grant;
+import eu.eudat.types.grant.GrantStateType;
+
+import java.util.Date;
+
+public class GrantCriteria extends Criteria {
+ private Date periodStart;
+ private Date periodEnd;
+ private String reference;
+ private Integer grantStateType;
+ private boolean isPublic;
+ private String funderId;
+ private String funderReference;
+ private String exactReference;
+ private boolean isActive;
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+
+ public Date getPeriodEnd() {
+ return periodEnd;
+ }
+ public void setPeriodEnd(Date periodEnd) {
+ this.periodEnd = periodEnd;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public Integer getGrantStateType() {
+ return grantStateType;
+ }
+ public void setGrantStateType(Integer grantStateType) {
+ this.grantStateType = grantStateType;
+ }
+
+ public boolean isPublic() {
+ return isPublic;
+ }
+ public void setPublic(boolean aPublic) {
+ isPublic = aPublic;
+ }
+
+ public String getFunderId() {
+ return funderId;
+ }
+ public void setFunderId(String funderId) {
+ this.funderId = funderId;
+ }
+
+ public String getFunderReference() {
+ return funderReference;
+ }
+ public void setFunderReference(String funderReference) {
+ this.funderReference = funderReference;
+ }
+
+ public String getExactReference() {
+ return exactReference;
+ }
+
+ public void setExactReference(String exactReference) {
+ this.exactReference = exactReference;
+ }
+
+ public boolean isActive() {
+ return isActive;
+ }
+
+ public void setActive(boolean active) {
+ isActive = active;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/InvitationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/InvitationCriteria.java
new file mode 100644
index 000000000..50cdeb6a1
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/InvitationCriteria.java
@@ -0,0 +1,6 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Invitation;
+
+public class InvitationCriteria extends Criteria {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/LockCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/LockCriteria.java
new file mode 100644
index 000000000..55b8e48e5
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/LockCriteria.java
@@ -0,0 +1,38 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Lock;
+import eu.eudat.data.entities.UserInfo;
+
+import java.util.Date;
+import java.util.UUID;
+
+public class LockCriteria extends Criteria {
+
+ private UUID target;
+ private UserInfo lockedBy;
+ private Date touchedAt;
+
+ public UUID getTarget() {
+ return target;
+ }
+
+ public void setTarget(UUID target) {
+ this.target = target;
+ }
+
+ public UserInfo getLockedBy() {
+ return lockedBy;
+ }
+
+ public void setLockedBy(UserInfo lockedBy) {
+ this.lockedBy = lockedBy;
+ }
+
+ public Date getTouchedAt() {
+ return touchedAt;
+ }
+
+ public void setTouchedAt(Date touchedAt) {
+ this.touchedAt = touchedAt;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/NotificationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/NotificationCriteria.java
new file mode 100644
index 000000000..1cd361014
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/NotificationCriteria.java
@@ -0,0 +1,26 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.enumeration.notification.ActiveStatus;
+import eu.eudat.data.enumeration.notification.NotifyState;
+
+public class NotificationCriteria {
+
+ private ActiveStatus isActive;
+ private NotifyState notifyState;
+
+ public ActiveStatus getIsActive() {
+ return isActive;
+ }
+
+ public void setIsActive(ActiveStatus isActive) {
+ this.isActive = isActive;
+ }
+
+ public NotifyState getNotifyState() {
+ return notifyState;
+ }
+
+ public void setNotifyState(NotifyState notifyState) {
+ this.notifyState = notifyState;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/OrganisationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/OrganisationCriteria.java
new file mode 100644
index 000000000..30e437df0
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/OrganisationCriteria.java
@@ -0,0 +1,31 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Organisation;
+
+public class OrganisationCriteria extends Criteria {
+ private String labelLike;
+ private Boolean isPublic;
+ private boolean isActive;
+
+ public String getLabelLike() {
+ return labelLike;
+ }
+ public void setLabelLike(String labelLike) {
+ this.labelLike = labelLike;
+ }
+
+ public Boolean getPublic() {
+ return isPublic;
+ }
+ public void setPublic(Boolean aPublic) {
+ isPublic = aPublic;
+ }
+
+ public boolean isActive() {
+ return isActive;
+ }
+
+ public void setActive(boolean active) {
+ isActive = active;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ProjectCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ProjectCriteria.java
new file mode 100644
index 000000000..a9d266ea6
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ProjectCriteria.java
@@ -0,0 +1,34 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Project;
+
+import java.util.Date;
+
+public class ProjectCriteria extends Criteria {
+ private String reference;
+ private String exactReference;
+ private Date periodStart;
+
+ public String getReference() {
+ return reference;
+ }
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getExactReference() {
+ return exactReference;
+ }
+
+ public void setExactReference(String exactReference) {
+ this.exactReference = exactReference;
+ }
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RegistryCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RegistryCriteria.java
new file mode 100644
index 000000000..186f5e281
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RegistryCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Registry;
+
+import java.util.UUID;
+
+public class RegistryCriteria extends Criteria {
+
+ private UUID creationUserId;
+
+ public UUID getCreationUserId() {
+ return creationUserId;
+ }
+ public void setCreationUserId(UUID creationUserId) {
+ this.creationUserId = creationUserId;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RequestItem.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RequestItem.java
new file mode 100644
index 000000000..85bc7522c
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/RequestItem.java
@@ -0,0 +1,16 @@
+package eu.eudat.data.dao.criteria;
+
+/**
+ * Created by ikalyvas on 3/26/2018.
+ */
+public class RequestItem {
+ T criteria;
+
+ public T getCriteria() {
+ return criteria;
+ }
+
+ public void setCriteria(T criteria) {
+ this.criteria = criteria;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ResearcherCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ResearcherCriteria.java
new file mode 100644
index 000000000..21cb1e5d2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ResearcherCriteria.java
@@ -0,0 +1,35 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Researcher;
+
+import java.util.Date;
+
+public class ResearcherCriteria extends Criteria {
+ private String name;
+ private String reference;
+ private Date periodStart;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public Date getPeriodStart() {
+ return periodStart;
+ }
+
+ public void setPeriodStart(Date periodStart) {
+ this.periodStart = periodStart;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ServiceCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ServiceCriteria.java
new file mode 100644
index 000000000..715511fb3
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/ServiceCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.Service;
+
+import java.util.UUID;
+
+public class ServiceCriteria extends Criteria {
+
+ private UUID creationUserId;
+
+ public UUID getCreationUserId() {
+ return creationUserId;
+ }
+ public void setCreationUserId(UUID creationUserId) {
+ this.creationUserId = creationUserId;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserInfoCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserInfoCriteria.java
new file mode 100644
index 000000000..3d21d809e
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserInfoCriteria.java
@@ -0,0 +1,33 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.UserInfo;
+
+import java.util.List;
+
+
+public class UserInfoCriteria extends Criteria {
+ private String email;
+ private List appRoles;
+ private String collaboratorLike;
+
+ public List getAppRoles() {
+ return appRoles;
+ }
+ public void setAppRoles(List appRoles) {
+ this.appRoles = appRoles;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getCollaboratorLike() {
+ return collaboratorLike;
+ }
+ public void setCollaboratorLike(String collaboratorLike) {
+ this.collaboratorLike = collaboratorLike;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserRoleCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserRoleCriteria.java
new file mode 100644
index 000000000..10654c0a6
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/criteria/UserRoleCriteria.java
@@ -0,0 +1,20 @@
+package eu.eudat.data.dao.criteria;
+
+import eu.eudat.data.entities.UserRole;
+
+import java.util.List;
+
+/**
+ * Created by ikalyvas on 2/1/2018.
+ */
+public class UserRoleCriteria extends Criteria {
+ private List appRoles;
+
+ public List getAppRoles() {
+ return appRoles;
+ }
+
+ public void setAppRoles(List appRoles) {
+ this.appRoles = appRoles;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/context/DatabaseContext.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/context/DatabaseContext.java
new file mode 100644
index 000000000..6857e4ffd
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/context/DatabaseContext.java
@@ -0,0 +1,50 @@
+package eu.eudat.data.dao.databaselayer.context;
+
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
+import eu.eudat.queryable.queryableentity.DataEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.PersistenceContext;
+
+
+@Repository("databaseCtx")
+public class DatabaseContext {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ public DatabaseContext(EntityManagerFactory entityManagerFactory) {
+ this.entityManager = entityManagerFactory.createEntityManager();
+ }
+
+ public QueryableList getQueryable(Class type) {
+ return new QueryableHibernateList<>(this.entityManager, type).setEntity(type);
+ }
+
+ @Transactional
+ public T createOrUpdate(T item, Class type) {
+ EntityManager entityManager = this.entityManager;
+ if (item.getKeys() != null) {
+ T oldItem = entityManager.find(type, item.getKeys());
+ if (oldItem != null) {
+ oldItem.update(item);
+ entityManager.merge(oldItem);
+ return oldItem;
+ } else {
+ entityManager.persist(item);
+ }
+ } else entityManager.persist(item);
+ return item;
+ }
+
+ public void delete(T item) {
+ this.entityManager.remove(item);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/service/DatabaseService.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/service/DatabaseService.java
new file mode 100644
index 000000000..6ef82d736
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/databaselayer/service/DatabaseService.java
@@ -0,0 +1,41 @@
+package eu.eudat.data.dao.databaselayer.service;
+
+
+import eu.eudat.data.dao.databaselayer.context.DatabaseContext;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.queryableentity.DataEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import jakarta.transaction.Transactional;
+import java.util.Set;
+
+
+@Service("databaseService")
+public class DatabaseService {
+
+ private DatabaseContext databaseCtx;
+
+ @Autowired
+ public DatabaseService(DatabaseContext databaseCtx) {
+ this.databaseCtx = databaseCtx;
+ }
+
+ public QueryableList getQueryable(Class tClass) {
+ return this.databaseCtx.getQueryable(tClass);
+ }
+
+ public QueryableList getQueryable(Set hints, Class tClass) {
+ return this.databaseCtx.getQueryable(tClass);
+ }
+
+ @Transactional
+ public T createOrUpdate(T item, Class tClass) {
+ return this.databaseCtx.createOrUpdate(item, tClass);
+ }
+
+ public void delete(T item) {
+ this.databaseCtx.delete(item);
+ }
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDao.java
new file mode 100644
index 000000000..438f9b3c5
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDao.java
@@ -0,0 +1,12 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccessLayer;
+import eu.eudat.data.entities.Content;
+
+import java.util.UUID;
+
+/**
+ * Created by ikalyvas on 3/16/2018.
+ */
+public interface ContentDao extends DatabaseAccessLayer {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDaoImpl.java
new file mode 100644
index 000000000..1d3f559d5
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/ContentDaoImpl.java
@@ -0,0 +1,55 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccess;
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.data.entities.Content;
+import eu.eudat.queryable.QueryableList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Created by ikalyvas on 3/16/2018.
+ */
+@Service("contentDao")
+public class ContentDaoImpl extends DatabaseAccess implements ContentDao {
+
+ @Autowired
+ public ContentDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public Content createOrUpdate(Content item) {
+ return this.getDatabaseService().createOrUpdate(item, Content.class);
+ }
+
+ @Override
+ @Async
+ public CompletableFuture createOrUpdateAsync(Content item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public Content find(UUID id) {
+ return this.getDatabaseService().getQueryable(Content.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public Content find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void delete(Content item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(Content.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDao.java
new file mode 100644
index 000000000..3073e1857
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDao.java
@@ -0,0 +1,22 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccessLayer;
+import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
+import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.UserDMP;
+import eu.eudat.data.entities.UserInfo;
+import eu.eudat.queryable.QueryableList;
+
+import java.util.List;
+import java.util.UUID;
+
+public interface DMPDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(DataManagementPlanCriteria criteria);
+
+ QueryableList getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
+
+ QueryableList getAuthenticated(QueryableList query, UUID principalId, List roles);
+
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDaoImpl.java
new file mode 100644
index 000000000..ab9c07b93
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPDaoImpl.java
@@ -0,0 +1,149 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccess;
+import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
+import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.UserInfo;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.types.FieldSelectionType;
+import eu.eudat.queryable.types.SelectionField;
+import eu.eudat.types.grant.GrantStateType;
+import jakarta.persistence.criteria.Join;
+import jakarta.persistence.criteria.JoinType;
+import jakarta.transaction.Transactional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("dMPDao")
+public class DMPDaoImpl extends DatabaseAccess implements DMPDao {
+
+ @Autowired
+ public DMPDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public QueryableList getWithCriteria(DataManagementPlanCriteria criteria) {
+ QueryableList query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
+ if (criteria.getLike() != null && !criteria.getLike().isEmpty())
+ query.where((builder, root) -> builder.or(
+ builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
+ builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
+ if (criteria.getPeriodEnd() != null)
+ query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
+ if (criteria.getPeriodStart() != null)
+ query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
+ if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
+ query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
+ if (!criteria.getAllVersions())
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
+ query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
+ builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
+ builder1.notEqual(nestedRoot.get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
+ if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
+ query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
+ if (criteria.getStatus() != null) {
+ if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
+ query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
+ } else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
+ query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
+ }
+ }
+ if (criteria.getIsPublic()) {
+ query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
+ }
+ /*if (criteria.getRole() != null) {
+ if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
+ query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
+ } else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
+ query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
+ }
+ }*/
+ if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
+ query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
+ }
+ if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
+ query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
+ }
+ if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
+ query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
+ }
+ if (criteria.getGrantStatus() != null) {
+ if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
+ query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
+ if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
+ query.where((builder, root) ->
+ builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
+ , builder.isNull(root.get("grant").get("enddate"))));
+ }
+
+ if (criteria.hasDoi()) {
+ query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
+ }
+ query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
+ return query;
+ }
+
+ public QueryableList getAuthenticated(QueryableList query, UUID principal, List roles) {
+ if (roles != null && !roles.isEmpty()) {
+ query.where((builder, root) -> {
+ Join userJoin = root.join("users", JoinType.LEFT);
+ return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal), userJoin.get("role").in(roles));
+ });
+ } else {
+ query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
+ }
+
+ return query;
+ }
+
+ @Override
+ @Transactional
+ public DMP createOrUpdate(DMP item) {
+ return this.getDatabaseService().createOrUpdate(item, DMP.class);
+ }
+
+ @Override
+ public DMP find(UUID id) {
+ return getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
+ }
+
+ @Override
+ public QueryableList getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
+ QueryableList query = getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
+ if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
+ query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
+ }
+ return query;
+ }
+
+ @Override
+ public void delete(DMP item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DMP.class);
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(DMP item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DMP find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java
new file mode 100644
index 000000000..36fc58752
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java
@@ -0,0 +1,21 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccessLayer;
+import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
+import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.DMPProfile;
+import eu.eudat.queryable.QueryableList;
+
+import java.util.UUID;
+
+/**
+ * Created by ikalyvas on 3/21/2018.
+ */
+public interface DMPProfileDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria);
+
+ QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java
new file mode 100644
index 000000000..7033473c2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java
@@ -0,0 +1,85 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccess;
+import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
+import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.data.entities.DMPProfile;
+import eu.eudat.queryable.QueryableList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Created by ikalyvas on 3/21/2018.
+ */
+@Service("dmpProfileDao")
+public class DMPProfileDaoImpl extends DatabaseAccess implements DMPProfileDao {
+
+ @Autowired
+ public DMPProfileDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(DMPProfile item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DMPProfile createOrUpdate(DMPProfile item) {
+ return this.getDatabaseService().createOrUpdate(item, DMPProfile.class);
+ }
+
+
+ @Override
+ public DMPProfile find(UUID id) {
+ return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
+ }
+
+ @Override
+ public DMPProfile find(UUID id, String hint) {
+ return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
+ }
+
+ @Override
+ public void delete(DMPProfile item) {
+ this.getDatabaseService().delete(item);
+ }
+
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DMPProfile.class);
+ }
+
+
+ @Override
+ public QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria) {
+ QueryableList query = getDatabaseService().getQueryable(DMPProfile.class);
+ if (criteria.getLike() != null && !criteria.getLike().isEmpty())
+ query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
+ query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
+ return query;
+ }
+
+ @Override
+ public QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
+ QueryableList query = getDatabaseService().getQueryable(DMPProfile.class);
+ if (criteria.getLike() != null && !criteria.getLike().isEmpty())
+ query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
+ if (criteria.getStatus() != null) {
+ if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
+ query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
+ } else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
+ query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
+ }
+ }
+ query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
+ return query;
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDao.java
new file mode 100644
index 000000000..68b64022b
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDao.java
@@ -0,0 +1,12 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccessLayer;
+import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
+import eu.eudat.data.entities.DataRepository;
+import eu.eudat.queryable.QueryableList;
+
+import java.util.UUID;
+
+public interface DataRepositoryDao extends DatabaseAccessLayer {
+ QueryableList getWithCriteria(DataRepositoryCriteria criteria);
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDaoImpl.java
new file mode 100644
index 000000000..4658b44f6
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DataRepositoryDaoImpl.java
@@ -0,0 +1,65 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccess;
+import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.data.entities.DataRepository;
+import eu.eudat.queryable.QueryableList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("dataRepositoryDao")
+public class DataRepositoryDaoImpl extends DatabaseAccess implements DataRepositoryDao {
+
+ @Autowired
+ public DataRepositoryDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public QueryableList getWithCriteria(DataRepositoryCriteria criteria) {
+ QueryableList query = this.getDatabaseService().getQueryable(DataRepository.class);
+ if (criteria.getLike() != null)
+ query.where((builder, root) -> builder.or(
+ builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
+ builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
+ if (criteria.getCreationUserId() != null)
+ query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), criteria.getCreationUserId()));
+ return query;
+ }
+
+ @Override
+ public DataRepository find(UUID id) {
+ return this.getDatabaseService().getQueryable(DataRepository.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public DataRepository createOrUpdate(DataRepository item) {
+ return getDatabaseService().createOrUpdate(item, DataRepository.class);
+ }
+
+ @Override
+ @Async
+ public CompletableFuture createOrUpdateAsync(DataRepository item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DataRepository find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void delete(DataRepository item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DataRepository.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDao.java
new file mode 100644
index 000000000..126958e11
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDao.java
@@ -0,0 +1,22 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccessLayer;
+import eu.eudat.data.dao.criteria.DatasetCriteria;
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.entities.UserInfo;
+import eu.eudat.queryable.QueryableList;
+
+import java.util.List;
+import java.util.UUID;
+
+public interface DatasetDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(DatasetCriteria criteria);
+
+ QueryableList filterFromElastic(DatasetCriteria criteria, List ids);
+
+ QueryableList getAuthenticated(QueryableList query, UserInfo principal, List roles);
+
+ Dataset isPublicDataset(UUID id);
+
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java
new file mode 100644
index 000000000..841c2c08c
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java
@@ -0,0 +1,153 @@
+package eu.eudat.data.dao.entities;
+
+import eu.eudat.data.dao.DatabaseAccess;
+import eu.eudat.data.dao.criteria.DatasetCriteria;
+import eu.eudat.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.data.entities.DMP;
+import eu.eudat.data.entities.Dataset;
+import eu.eudat.data.entities.UserDMP;
+import eu.eudat.data.entities.UserInfo;
+import eu.eudat.queryable.QueryableList;
+import eu.eudat.queryable.types.FieldSelectionType;
+import eu.eudat.queryable.types.SelectionField;
+import eu.eudat.types.grant.GrantStateType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import jakarta.persistence.criteria.Join;
+import jakarta.persistence.criteria.JoinType;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("datasetDao")
+public class DatasetDaoImpl extends DatabaseAccess implements DatasetDao {
+
+ @Autowired
+ public DatasetDaoImpl(DatabaseService databaseService) { super(databaseService); }
+
+ @Override
+ public QueryableList getWithCriteria(DatasetCriteria criteria) {
+ QueryableList query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
+ if (criteria.getIsPublic() != null && criteria.getIsPublic()) {
+ query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
+ query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
+ /*query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
+ query.