diff --git a/dmp-migration-tool/Docker/dmp-backend.env b/dmp-migration-tool/Docker/dmp-backend.env
new file mode 100644
index 000000000..50fb7881d
--- /dev/null
+++ b/dmp-migration-tool/Docker/dmp-backend.env
@@ -0,0 +1 @@
+PROFILE=docker
\ No newline at end of file
diff --git a/dmp-migration-tool/Dockerfile b/dmp-migration-tool/Dockerfile
new file mode 100644
index 000000000..54c70beae
--- /dev/null
+++ b/dmp-migration-tool/Dockerfile
@@ -0,0 +1,23 @@
+FROM maven:3-jdk-11 AS MAVEN_BUILD
+
+
+
+COPY pom.xml /build/
+COPY data /build/data/
+COPY elastic /build/elastic/
+#COPY logging /build/logging/
+COPY queryable /build/queryable/
+COPY web /build/web/
+
+
+
+WORKDIR /build/
+RUN mvn package -q
+
+
+
+FROM amazoncorretto:11
+WORKDIR /app
+
+COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app.jar
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROFILE}","-jar","/app.jar"]
\ No newline at end of file
diff --git a/dmp-migration-tool/Dockerfile.CI b/dmp-migration-tool/Dockerfile.CI
new file mode 100644
index 000000000..5747c9969
--- /dev/null
+++ b/dmp-migration-tool/Dockerfile.CI
@@ -0,0 +1,15 @@
+FROM maven:3-openjdk-11 AS MAVEN_BUILD
+
+COPY pom.xml /build/
+COPY data /build/data/
+COPY elastic /build/elastic/
+COPY queryable /build/queryable/
+COPY web /build/web/
+
+WORKDIR /build/
+RUN mvn package
+
+FROM adoptopenjdk/openjdk11:alpine-jre
+WORKDIR /app
+COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
+ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=${PROF}", "-Dspring.config.additional-location=/files/config/", "-cp", "/app/app.jar", "-Dloader.path=/files/repo-jars", "org.springframework.boot.loader.PropertiesLauncher"]
diff --git a/dmp-migration-tool/data/pom.xml b/dmp-migration-tool/data/pom.xml
new file mode 100644
index 000000000..6c162868f
--- /dev/null
+++ b/dmp-migration-tool/data/pom.xml
@@ -0,0 +1,34 @@
+
+
+ 4.0.0
+
+ data
+ 1.0-SNAPSHOT
+ jar
+
+
+ eu.eudat
+ dmp-backend
+ 1.0.0-SNAPSHOT
+
+
+
+
+ dmp-backend
+ queryable
+ 1.0-SNAPSHOT
+
+
+ eu.eudat
+ elastic
+ 1.0.0-SNAPSHOT
+
+
+ io.swagger
+ swagger-annotations
+ 1.5.20
+
+
+
\ No newline at end of file
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/converters/DateToUTCConverter.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/converters/DateToUTCConverter.java
new file mode 100644
index 000000000..6748be7c1
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/converters/DateToUTCConverter.java
@@ -0,0 +1,48 @@
+package eu.eudat.old.data.converters;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.AttributeConverter;
+import javax.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/old/data/dao/DatabaseAccess.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/DatabaseAccess.java
new file mode 100644
index 000000000..bbda433ee
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/DatabaseAccess.java
@@ -0,0 +1,22 @@
+package eu.eudat.old.data.dao;
+
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.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/old/data/dao/DatabaseAccessLayer.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/DatabaseAccessLayer.java
new file mode 100644
index 000000000..bc0b46772
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/DatabaseAccessLayer.java
@@ -0,0 +1,21 @@
+package eu.eudat.old.data.dao;
+
+
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.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/old/data/dao/criteria/Criteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/Criteria.java
new file mode 100644
index 000000000..e38a72b36
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/Criteria.java
@@ -0,0 +1,18 @@
+package eu.eudat.old.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/old/data/dao/criteria/DataManagementPlanBlueprintCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanBlueprintCriteria.java
new file mode 100644
index 000000000..cfdbd39dc
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanBlueprintCriteria.java
@@ -0,0 +1,16 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/DataManagementPlanCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanCriteria.java
new file mode 100644
index 000000000..b02b728b2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanCriteria.java
@@ -0,0 +1,135 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.data.entities.DMPProfile;
+import eu.eudat.old.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 DMPProfile profile;
+ 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 DMPProfile getProfile() {
+ return profile;
+ }
+ public void setProfile(DMPProfile profile) {
+ this.profile = profile;
+ }
+
+ 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/old/data/dao/criteria/DataManagementPlanProfileCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanProfileCriteria.java
new file mode 100644
index 000000000..32663ed57
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanProfileCriteria.java
@@ -0,0 +1,9 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/DataManagementPlanPublicCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanPublicCriteria.java
new file mode 100644
index 000000000..211dcc9fd
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataManagementPlanPublicCriteria.java
@@ -0,0 +1,66 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.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/old/data/dao/criteria/DataRepositoryCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataRepositoryCriteria.java
new file mode 100644
index 000000000..3be8df837
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DataRepositoryCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/DatasetCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetCriteria.java
new file mode 100644
index 000000000..4a0511d3c
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetCriteria.java
@@ -0,0 +1,143 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.Dataset;
+import eu.eudat.old.elastic.entities.Tag;
+
+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/old/data/dao/criteria/DatasetProfileCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetProfileCriteria.java
new file mode 100644
index 000000000..77ce28595
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetProfileCriteria.java
@@ -0,0 +1,101 @@
+package eu.eudat.old.data.dao.criteria;
+
+
+import eu.eudat.old.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/old/data/dao/criteria/DatasetProfileWizardCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetProfileWizardCriteria.java
new file mode 100644
index 000000000..7fc2f17bd
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetProfileWizardCriteria.java
@@ -0,0 +1,18 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/DatasetPublicCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetPublicCriteria.java
new file mode 100644
index 000000000..e8eb86304
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetPublicCriteria.java
@@ -0,0 +1,70 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.Dataset;
+import eu.eudat.old.elastic.entities.Tag;
+import eu.eudat.old.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/old/data/dao/criteria/DatasetWizardUserDmpCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetWizardUserDmpCriteria.java
new file mode 100644
index 000000000..fb513f962
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DatasetWizardUserDmpCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.old.data.dao.criteria;
+
+
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.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/old/data/dao/criteria/DynamicFieldsCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DynamicFieldsCriteria.java
new file mode 100644
index 000000000..bfb839a2b
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/DynamicFieldsCriteria.java
@@ -0,0 +1,51 @@
+package eu.eudat.old.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/old/data/dao/criteria/EmailConfirmationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/EmailConfirmationCriteria.java
new file mode 100644
index 000000000..67b5ca172
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/EmailConfirmationCriteria.java
@@ -0,0 +1,6 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.EmailConfirmation;
+
+public class EmailConfirmationCriteria extends Criteria{
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ExternalDatasetCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ExternalDatasetCriteria.java
new file mode 100644
index 000000000..9ff2bb9cb
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ExternalDatasetCriteria.java
@@ -0,0 +1,15 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/FunderCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/FunderCriteria.java
new file mode 100644
index 000000000..df848b339
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/FunderCriteria.java
@@ -0,0 +1,34 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/GrantCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/GrantCriteria.java
new file mode 100644
index 000000000..cbde37d7a
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/GrantCriteria.java
@@ -0,0 +1,82 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.Grant;
+
+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/old/data/dao/criteria/InvitationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/InvitationCriteria.java
new file mode 100644
index 000000000..bcb9625a5
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/InvitationCriteria.java
@@ -0,0 +1,6 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.Invitation;
+
+public class InvitationCriteria extends Criteria {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/LockCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/LockCriteria.java
new file mode 100644
index 000000000..2cdc14020
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/LockCriteria.java
@@ -0,0 +1,38 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.entities.Lock;
+import eu.eudat.old.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/old/data/dao/criteria/NotificationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/NotificationCriteria.java
new file mode 100644
index 000000000..11d4de3be
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/NotificationCriteria.java
@@ -0,0 +1,26 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.data.enumeration.notification.NotifyState;
+import eu.eudat.old.data.enumeration.notification.ActiveStatus;
+
+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/old/data/dao/criteria/OrganisationCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/OrganisationCriteria.java
new file mode 100644
index 000000000..db3448cae
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/OrganisationCriteria.java
@@ -0,0 +1,31 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/ProjectCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ProjectCriteria.java
new file mode 100644
index 000000000..707b46076
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ProjectCriteria.java
@@ -0,0 +1,34 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/RegistryCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/RegistryCriteria.java
new file mode 100644
index 000000000..061d98032
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/RegistryCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/RequestItem.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/RequestItem.java
new file mode 100644
index 000000000..94138bd2f
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/RequestItem.java
@@ -0,0 +1,16 @@
+package eu.eudat.old.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/old/data/dao/criteria/ResearcherCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ResearcherCriteria.java
new file mode 100644
index 000000000..b1a5130d1
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ResearcherCriteria.java
@@ -0,0 +1,35 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/ServiceCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ServiceCriteria.java
new file mode 100644
index 000000000..192304f81
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/ServiceCriteria.java
@@ -0,0 +1,17 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/UserInfoCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/UserInfoCriteria.java
new file mode 100644
index 000000000..1913f511c
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/UserInfoCriteria.java
@@ -0,0 +1,33 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/criteria/UserRoleCriteria.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/UserRoleCriteria.java
new file mode 100644
index 000000000..ab672febf
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/criteria/UserRoleCriteria.java
@@ -0,0 +1,20 @@
+package eu.eudat.old.data.dao.criteria;
+
+import eu.eudat.old.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/old/data/dao/databaselayer/context/DatabaseContext.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/databaselayer/context/DatabaseContext.java
new file mode 100644
index 000000000..8a944ad16
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/databaselayer/context/DatabaseContext.java
@@ -0,0 +1,49 @@
+package eu.eudat.old.data.dao.databaselayer.context;
+
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
+import eu.eudat.old.queryable.queryableentity.DataEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.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/old/data/dao/databaselayer/service/DatabaseService.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/databaselayer/service/DatabaseService.java
new file mode 100644
index 000000000..ecad37a81
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/databaselayer/service/DatabaseService.java
@@ -0,0 +1,41 @@
+package eu.eudat.old.data.dao.databaselayer.service;
+
+
+import eu.eudat.old.data.dao.databaselayer.context.DatabaseContext;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.queryable.queryableentity.DataEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.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/old/data/dao/entities/ContentDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ContentDao.java
new file mode 100644
index 000000000..fd9cc8f25
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ContentDao.java
@@ -0,0 +1,12 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.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/old/data/dao/entities/ContentDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ContentDaoImpl.java
new file mode 100644
index 000000000..db4468c8a
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ContentDaoImpl.java
@@ -0,0 +1,55 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.Content;
+import eu.eudat.old.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/old/data/dao/entities/DMPDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPDao.java
new file mode 100644
index 000000000..945356035
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPDao.java
@@ -0,0 +1,21 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.data.entities.UserInfo;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanCriteria;
+import eu.eudat.old.data.dao.criteria.DatasetWizardUserDmpCriteria;
+
+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/old/data/dao/entities/DMPDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPDaoImpl.java
new file mode 100644
index 000000000..f58ec313a
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPDaoImpl.java
@@ -0,0 +1,151 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.entities.UserInfo;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.queryable.types.FieldSelectionType;
+import eu.eudat.old.queryable.types.SelectionField;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanCriteria;
+import eu.eudat.old.data.dao.criteria.DatasetWizardUserDmpCriteria;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.types.grant.GrantStateType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.transaction.Transactional;
+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.getProfile() != null)
+ query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
+ 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")), String.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("datasetprofile").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/old/data/dao/entities/DMPProfileDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPProfileDao.java
new file mode 100644
index 000000000..9d49b1593
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPProfileDao.java
@@ -0,0 +1,20 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanBlueprintCriteria;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanProfileCriteria;
+import eu.eudat.old.data.entities.DMPProfile;
+import eu.eudat.old.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/old/data/dao/entities/DMPProfileDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPProfileDaoImpl.java
new file mode 100644
index 000000000..cec8f41d1
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DMPProfileDaoImpl.java
@@ -0,0 +1,85 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanBlueprintCriteria;
+import eu.eudat.old.data.dao.criteria.DataManagementPlanProfileCriteria;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DMPProfile;
+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/old/data/dao/entities/DataRepositoryDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DataRepositoryDao.java
new file mode 100644
index 000000000..e88ca2fa0
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DataRepositoryDao.java
@@ -0,0 +1,12 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.criteria.DataRepositoryCriteria;
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.DataRepository;
+import eu.eudat.old.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/old/data/dao/entities/DataRepositoryDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DataRepositoryDaoImpl.java
new file mode 100644
index 000000000..bd9f81828
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DataRepositoryDaoImpl.java
@@ -0,0 +1,65 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.criteria.DataRepositoryCriteria;
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DataRepository;
+import eu.eudat.old.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/old/data/dao/entities/DatasetDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetDao.java
new file mode 100644
index 000000000..04a89667b
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetDao.java
@@ -0,0 +1,22 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.dao.criteria.DatasetCriteria;
+import eu.eudat.old.data.entities.Dataset;
+import eu.eudat.old.data.entities.UserInfo;
+import eu.eudat.old.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/old/data/dao/entities/DatasetDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetDaoImpl.java
new file mode 100644
index 000000000..c0320dfb7
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetDaoImpl.java
@@ -0,0 +1,152 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.criteria.DatasetCriteria;
+import eu.eudat.old.queryable.types.FieldSelectionType;
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DMP;
+import eu.eudat.old.data.entities.Dataset;
+import eu.eudat.old.data.entities.UserInfo;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.queryable.types.SelectionField;
+import eu.eudat.old.types.grant.GrantStateType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.criteria.Join;
+import javax.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.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
+ Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.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.getStatus() != null)
+ query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
+ if (criteria.getProfileDatasetId() != null)
+ query.where((builder, root) -> builder.equal(root.get("profile").get("id"), criteria.getProfileDatasetId()));
+ 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.getAllVersions())
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
+ if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
+ query.where((builder, root) -> root.get("dmp").get("groupId").in(criteria.getGroupIds()));
+ if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
+ query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
+ /*if (criteria.getRole() != null) {
+ query.where((builder, root) -> builder.equal(root.join("dmp").join("users").get("role"), criteria.getRole()));
+ } else {
+ query.where((builder, root) -> root.join("dmp").join("users").get("role").in(UserDMP.UserDMPRoles.getAllValues()));
+ }*/
+ if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty())
+ query.where((builder, root) -> root.join("dmp").join("organisations").get("reference").in(criteria.getOrganisations()));
+ if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
+ query.where((builder, root) -> root.join("dmp").join("grant").get("id").in(criteria.getGrants()));
+ if (criteria.getGrantStatus() != null) {
+ if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
+ query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
+ if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
+ query.where((builder, root) ->
+ builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
+ , builder.isNull(root.get("dmp").get("grant").get("enddate"))));
+ }
+ if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty())
+ query.where((builder, root) -> root.join("dmp", JoinType.LEFT).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.get("profile").get("id").in(criteria.getDatasetTemplates()));
+
+ if (criteria.hasDoi()) {
+ query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
+ }
+ query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
+ query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
+ return query;
+ }
+
+ public QueryableList filterFromElastic(DatasetCriteria criteria, List ids) {
+ QueryableList query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
+
+ query.where(((builder, root) -> root.get("id").in(ids)));
+ if (!criteria.getAllVersions())
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
+
+ return query;
+ }
+
+ @Override
+ public Dataset createOrUpdate(Dataset item) {
+ return getDatabaseService().createOrUpdate(item, Dataset.class);
+ }
+
+ @Override
+ public Dataset find(UUID id) {
+ return getDatabaseService().getQueryable(Dataset.class)
+ .where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle();
+ }
+
+ @Override
+ public Dataset find(UUID id, String hint) {
+ return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint)
+ .where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle();
+ }
+
+ @Override
+ public Dataset isPublicDataset(UUID id) {
+ QueryableList query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
+ query.where(((builder, root) -> builder.equal(root.get("id"), id)));
+
+ return query.withHint("datasetListingModel").getSingle();
+ }
+
+ @Override
+ public QueryableList getAuthenticated(QueryableList query, UserInfo principal, List roles) {
+ if (roles != null && !roles.isEmpty()) {
+ query.where((builder, root) -> {
+ Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
+ return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal.getId()), userJoin.get("role").in(roles));
+ });
+ } else {
+ query.where((builder, root) -> builder.equal(root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()));
+
+ }
+ return query;
+ }
+
+ @Override
+ public void delete(Dataset item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(Dataset.class);
+ }
+
+ @Async
+ public CompletableFuture createOrUpdateAsync(Dataset item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDao.java
new file mode 100644
index 000000000..dcf38ac08
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDao.java
@@ -0,0 +1,13 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.entities.DatasetExternalDataset;
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+
+import java.util.UUID;
+
+/**
+ * Created by ikalyvas on 5/22/2018.
+ */
+public interface DatasetExternalDatasetDao extends DatabaseAccessLayer {
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDaoImpl.java
new file mode 100644
index 000000000..5896b16e7
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetExternalDatasetDaoImpl.java
@@ -0,0 +1,56 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DatasetExternalDataset;
+import eu.eudat.old.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;
+
+/**
+ * Created by ikalyvas on 5/22/2018.
+ */
+@Component("datasetExternalDatasetDao")
+public class DatasetExternalDatasetDaoImpl extends DatabaseAccess implements DatasetExternalDatasetDao {
+
+ @Autowired
+ public DatasetExternalDatasetDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public DatasetExternalDataset createOrUpdate(DatasetExternalDataset item) {
+ return this.getDatabaseService().createOrUpdate(item,DatasetExternalDataset.class);
+ }
+
+ @Override
+ public CompletableFuture createOrUpdateAsync(DatasetExternalDataset item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ @Async
+ public DatasetExternalDataset find(UUID id) {
+ return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public DatasetExternalDataset find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public void delete(DatasetExternalDataset item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DatasetExternalDataset.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDao.java
new file mode 100644
index 000000000..8f616c615
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDao.java
@@ -0,0 +1,24 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.entities.DescriptionTemplateType;
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.dao.criteria.DatasetProfileCriteria;
+import eu.eudat.old.data.entities.DescriptionTemplate;
+import eu.eudat.old.queryable.QueryableList;
+
+import java.util.List;
+import java.util.UUID;
+
+public interface DatasetProfileDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(DatasetProfileCriteria criteria);
+
+ QueryableList getAll();
+
+ QueryableList getAuthenticated(QueryableList query, UUID principal, List roles);
+
+ List getAllIds();
+
+ Long countWithType(DescriptionTemplateType type);
+
+}
\ No newline at end of file
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDaoImpl.java
new file mode 100644
index 000000000..9e72f926f
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetProfileDaoImpl.java
@@ -0,0 +1,134 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.entities.DescriptionTemplate;
+import eu.eudat.old.data.entities.DescriptionTemplateType;
+import eu.eudat.old.queryable.types.FieldSelectionType;
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.criteria.DatasetProfileCriteria;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.queryable.types.SelectionField;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("datasetProfileDao")
+public class DatasetProfileDaoImpl extends DatabaseAccess implements DatasetProfileDao {
+
+ @Autowired
+ public DatasetProfileDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public QueryableList getWithCriteria(DatasetProfileCriteria criteria) {
+ QueryableList query = getDatabaseService().getQueryable(DescriptionTemplate.class);
+ if (criteria.getLike() != null && !criteria.getLike().isEmpty())
+ query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
+ if (!criteria.getAllVersions())
+ query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
+ query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
+ nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
+ if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
+ query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
+ if (criteria.getFilter() != null && criteria.getUserId() != null) {
+ if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue())) {
+ query.initSubQuery(UUID.class).where((builder, root) ->
+ builder.and(root.get("id").in(
+ query.subQuery((builder1, root1) -> builder1.equal(root1.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()),
+ Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))),
+ builder.notEqual(root.get("id"), criteria.getUserId())));
+ //query.where(((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId())));
+ }
+ if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue())) {
+ query.initSubQuery(UUID.class).where((builder, root) ->
+ builder.and(root.get("id").in(
+ query.subQuery((builder1, root1) -> builder1.equal(root1.join("dataset", JoinType.LEFT).join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()),
+ Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))),
+ builder.notEqual(root.get("id"), criteria.getUserId())));
+ }
+ }
+ if (criteria.getStatus() != null) {
+ query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
+ }
+ if (criteria.getIds() != null) {
+ query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
+ }
+ if (criteria.getFinalized()) {
+ query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplate.Status.FINALIZED.getValue())));
+ } else {
+ query.where(((builder, root) -> builder.notEqual(root.get("status"), DescriptionTemplate.Status.DELETED.getValue())));
+ }
+ if (criteria.getPeriodStart() != null)
+ query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
+ return query;
+ }
+
+ @Override
+ public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
+ return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
+ }
+
+ @Override
+ public DescriptionTemplate find(UUID id) {
+ return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public QueryableList getAll() {
+ return getDatabaseService().getQueryable(DescriptionTemplate.class);
+ }
+
+ @Override
+ public List getAllIds(){
+ return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
+ }
+
+ @Override
+ public void delete(DescriptionTemplate item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(DescriptionTemplate item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DescriptionTemplate find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ 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
+ public Long countWithType(DescriptionTemplateType type) {
+ return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDao.java
new file mode 100644
index 000000000..cfdbec078
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDao.java
@@ -0,0 +1,12 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.DatasetService;
+
+import java.util.UUID;
+
+/**
+ * Created by ikalyvas on 5/22/2018.
+ */
+public interface DatasetServiceDao extends DatabaseAccessLayer {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDaoImpl.java
new file mode 100644
index 000000000..a5e6663c2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DatasetServiceDaoImpl.java
@@ -0,0 +1,55 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.entities.DatasetService;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+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;
+
+/**
+ * Created by ikalyvas on 5/22/2018.
+ */
+@Component("datasetServiceDao")
+public class DatasetServiceDaoImpl extends DatabaseAccess implements DatasetServiceDao {
+
+ @Autowired
+ public DatasetServiceDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public DatasetService createOrUpdate(DatasetService item) {
+ return this.getDatabaseService().createOrUpdate(item, DatasetService.class);
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(DatasetService item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DatasetService find(UUID id) {
+ return getDatabaseService().getQueryable(DatasetService.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public DatasetService find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void delete(DatasetService item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DatasetService.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDao.java
new file mode 100644
index 000000000..1eb60a24d
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDao.java
@@ -0,0 +1,10 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.DescriptionTemplateType;
+
+import java.util.UUID;
+
+public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer {
+ DescriptionTemplateType findFromName(String name);
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDaoImpl.java
new file mode 100644
index 000000000..86651ab94
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DescriptionTemplateTypeDaoImpl.java
@@ -0,0 +1,65 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.entities.DescriptionTemplateType;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.transaction.Transactional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("descriptionTemplateTypeDao")
+public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess implements DescriptionTemplateTypeDao {
+
+ @Autowired
+ public DescriptionTemplateTypeDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public DescriptionTemplateType findFromName(String name){
+ try {
+ return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
+ }
+ catch(Exception e){
+ return null;
+ }
+ }
+
+ @Override
+ @Transactional
+ public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
+ return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
+ }
+
+ @Override
+ public DescriptionTemplateType find(UUID id) {
+ return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
+ }
+
+ @Override
+ public void delete(DescriptionTemplateType item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(DescriptionTemplateType item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DescriptionTemplateType find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDao.java
new file mode 100644
index 000000000..b2e2b3917
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDao.java
@@ -0,0 +1,9 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.DMPDatasetProfile;
+
+import java.util.UUID;
+
+public interface DmpDatasetProfileDao extends DatabaseAccessLayer {
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDaoImpl.java
new file mode 100644
index 000000000..0cb02ac11
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/DmpDatasetProfileDaoImpl.java
@@ -0,0 +1,51 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.DMPDatasetProfile;
+import eu.eudat.old.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;
+
+@Service("dmpDatasetProfileDao")
+public class DmpDatasetProfileDaoImpl extends DatabaseAccess implements DmpDatasetProfileDao {
+ @Autowired
+ public DmpDatasetProfileDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
+ return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
+ }
+
+ @Override
+ @Async
+ public CompletableFuture createOrUpdateAsync(DMPDatasetProfile item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public DMPDatasetProfile find(UUID id) {
+ return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public DMPDatasetProfile find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void delete(DMPDatasetProfile item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDao.java
new file mode 100644
index 000000000..764ef9662
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDao.java
@@ -0,0 +1,13 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.EmailConfirmation;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.criteria.EmailConfirmationCriteria;
+
+import java.util.UUID;
+
+public interface EmailConfirmationDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(EmailConfirmationCriteria criteria);
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDaoImpl.java
new file mode 100644
index 000000000..5a6cc9f2a
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EmailConfirmationDaoImpl.java
@@ -0,0 +1,56 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.criteria.EmailConfirmationCriteria;
+import eu.eudat.old.data.entities.EmailConfirmation;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Service("LoginConfirmationEmailDao")
+public class EmailConfirmationDaoImpl extends DatabaseAccess implements EmailConfirmationDao {
+
+ @Autowired
+ public EmailConfirmationDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public QueryableList getWithCriteria(EmailConfirmationCriteria criteria) {
+ return null;
+ }
+
+ @Override
+ public EmailConfirmation createOrUpdate(EmailConfirmation item) {
+ return this.getDatabaseService().createOrUpdate(item, EmailConfirmation.class);
+ }
+
+ @Override
+ public CompletableFuture createOrUpdateAsync(EmailConfirmation item) {
+ return null;
+ }
+
+ @Override
+ public EmailConfirmation find(UUID id) {
+ return this.getDatabaseService().getQueryable(EmailConfirmation.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public EmailConfirmation find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void delete(EmailConfirmation item) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(EmailConfirmation.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDao.java
new file mode 100644
index 000000000..d967160c2
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDao.java
@@ -0,0 +1,10 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.EntityDoi;
+
+import java.util.UUID;
+
+public interface EntityDoiDao extends DatabaseAccessLayer {
+ EntityDoi findFromDoi(String doi);
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDaoImpl.java
new file mode 100644
index 000000000..67d95a129
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/EntityDoiDaoImpl.java
@@ -0,0 +1,56 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.EntityDoi;
+import eu.eudat.old.queryable.QueryableList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("EntityDoiDao")
+public class EntityDoiDaoImpl extends DatabaseAccess implements EntityDoiDao {
+
+ @Autowired
+ public EntityDoiDaoImpl(DatabaseService databaseService){
+ super(databaseService);
+ }
+
+
+ @Override
+ public EntityDoi createOrUpdate(EntityDoi item) {
+ return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
+ }
+
+ @Override
+ public CompletableFuture createOrUpdateAsync(EntityDoi item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public EntityDoi find(UUID id) {
+ return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public EntityDoi findFromDoi(String doi) {
+ return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("doi"), doi)).getSingle();
+ }
+
+ @Override
+ public EntityDoi find(UUID id, String hint) {
+ return null;
+ }
+
+ @Override
+ public void delete(EntityDoi item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(EntityDoi.class);
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDao.java
new file mode 100644
index 000000000..f61b713e8
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDao.java
@@ -0,0 +1,15 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.criteria.ExternalDatasetCriteria;
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.ExternalDataset;
+import eu.eudat.old.queryable.QueryableList;
+
+import java.util.UUID;
+
+
+public interface ExternalDatasetDao extends DatabaseAccessLayer {
+
+ QueryableList getWithCriteria(ExternalDatasetCriteria criteria);
+
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDaoImpl.java
new file mode 100644
index 000000000..40e7a0275
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/ExternalDatasetDaoImpl.java
@@ -0,0 +1,66 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.criteria.ExternalDatasetCriteria;
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import eu.eudat.old.data.entities.ExternalDataset;
+import eu.eudat.old.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("externalDatasetDao")
+public class ExternalDatasetDaoImpl extends DatabaseAccess implements ExternalDatasetDao {
+
+ @Autowired
+ public ExternalDatasetDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public QueryableList getWithCriteria(ExternalDatasetCriteria criteria) {
+ QueryableList query = this.getDatabaseService().getQueryable(ExternalDataset.class);
+ if (criteria.getLike() != null && !criteria.getLike().isEmpty())
+ 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.join("creationUser").get("id"), criteria.getCreationUserId()));
+ return query;
+ }
+
+ @Override
+ public ExternalDataset createOrUpdate(ExternalDataset item) {
+ return this.getDatabaseService().createOrUpdate(item, ExternalDataset.class);
+ }
+
+ @Override
+ public ExternalDataset find(UUID id) {
+ return this.getDatabaseService().getQueryable(ExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public void delete(ExternalDataset item) {
+ this.getDatabaseService().delete(item);
+ }
+
+ @Override
+ public QueryableList asQueryable() {
+ return this.getDatabaseService().getQueryable(ExternalDataset.class);
+ }
+
+ @Async
+ @Override
+ public CompletableFuture createOrUpdateAsync(ExternalDataset item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public ExternalDataset find(UUID id, String hint) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDao.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDao.java
new file mode 100644
index 000000000..faf4220c9
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDao.java
@@ -0,0 +1,11 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccessLayer;
+import eu.eudat.old.data.entities.FileUpload;
+
+import java.util.List;
+import java.util.UUID;
+
+public interface FileUploadDao extends DatabaseAccessLayer {
+ List getFileUploads(UUID entityId);
+}
diff --git a/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDaoImpl.java b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDaoImpl.java
new file mode 100644
index 000000000..2acdc34db
--- /dev/null
+++ b/dmp-migration-tool/data/src/main/java/eu/eudat/old/data/dao/entities/FileUploadDaoImpl.java
@@ -0,0 +1,56 @@
+package eu.eudat.old.data.dao.entities;
+
+import eu.eudat.old.data.dao.DatabaseAccess;
+import eu.eudat.old.data.entities.FileUpload;
+import eu.eudat.old.queryable.QueryableList;
+import eu.eudat.old.data.dao.databaselayer.service.DatabaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+@Component("FileUploadDao")
+public class FileUploadDaoImpl extends DatabaseAccess implements FileUploadDao {
+
+ @Autowired
+ public FileUploadDaoImpl(DatabaseService databaseService) {
+ super(databaseService);
+ }
+
+ @Override
+ public FileUpload createOrUpdate(FileUpload item) {
+ return getDatabaseService().createOrUpdate(item, FileUpload.class);
+ }
+//
+ @Override
+ public CompletableFuture createOrUpdateAsync(FileUpload item) {
+ return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
+ }
+
+ @Override
+ public FileUpload find(UUID id) {
+ return getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
+ }
+
+ @Override
+ public List