Merge branch 'Development'

This commit is contained in:
Diamantis Tziotzios 2019-09-17 11:31:58 +03:00
commit 7cf64c18f2
1731 changed files with 77961 additions and 34172 deletions

8
.env
View File

@ -1,6 +1,6 @@
TAG=6.2.1 TAG=6.3.0
ENV=dev ENV=prod
PROFILE=production PROFILE=production
AOT=no-aot AOT=aot
ELASTIC_VERSION=6.2.1 ELASTIC_VERSION=6.3.0
ELASTIC_PASSWORD=changeme ELASTIC_PASSWORD=changeme

12
.gitignore vendored
View File

@ -25,3 +25,15 @@ dmp-backend/web/src/main/ui-resources/static/
dmp-backend/data/target/data-1.0-SNAPSHOT.jar dmp-backend/data/target/data-1.0-SNAPSHOT.jar
dmp-backend/data/target/ dmp-backend/data/target/
dmp-backend/queryable/target/ dmp-backend/queryable/target/
dmp-backend/elastic/target/
dmp-backend/queryengine/target/
*.tar
*.gz
final/
temp/
*.jar
*.lst
dmp-frontend/.vscode/
*.docx

View File

@ -1,3 +1,3 @@
TAG=6.2.1 TAG=6.3.1
ELASTIC_VERSION=6.2.1 ELASTIC_VERSION=6.3.1
ELASTIC_PASSWORD=changeme ELASTIC_PASSWORD=changeme

View File

@ -100,7 +100,72 @@ services:
networks: ['stack'] networks: ['stack']
depends_on: ['kibana'] depends_on: ['kibana']
#volumes:
##########################DOCSBOX######################################################################
web:
restart: always
build: ./docsbox-master/docsbox
expose:
- "8000"
links:
- redis:redis
volumes:
- docsbox:/home/docsbox
- media:/home/docsbox/media
command: gunicorn -b :8000 docsbox:app
networks: ['stack']
rqworker:
restart: always
build: ./docsbox-master/docsbox
links:
- redis:redis
volumes:
- web
command: rq worker -c docsbox.settings
networks: ['stack']
rqscheduler:
restart: always
build: ./docsbox-master/docsbox
links:
- redis:redis
volumes:
- web
command: rqscheduler -H redis -p 6379 -d 0
networks: ['stack']
nginx:
restart: always
build: ./docsbox-master/nginx/
ports:
- "81:80"
volumes:
- web
links:
- web:web
networks: ['stack']
redis:
restart: always
image: redis:latest
expose:
- "6379"
volumes:
- redisdata:/data
networks: ['stack']
##########################SETTIGNS######################################################################
volumes:
#esdata: #esdata:
# driver: local #driver: local
redisdata:
driver: local
docsbox:
driver: local
media:
driver: local
networks: {stack: {}} networks: {stack: {}}

View File

@ -1,5 +1,11 @@
FROM openjdk:8-jdk-alpine FROM openjdk:8-jdk-alpine
RUN apk add --update \
curl \
&& rm -rf /var/cache/apk/*
VOLUME /tmp VOLUME /tmp
ARG PROFILE=dev ARG PROFILE=production
ENV PROF $PROFILE
ADD web/src/main/resources/ProjectConfiguration.xml /tmp/ProjectConfiguration.xml
ADD web/src/main/resources/ExternalUrls.xml /tmp/ExternalUrls.xml
ADD web/target/web-1.0-SNAPSHOT.jar app.jar ADD web/target/web-1.0-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=${PROFILE}","-jar","/app.jar"] ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROF}","-jar","/app.jar"]

View File

@ -21,5 +21,10 @@
<artifactId>queryable</artifactId> <artifactId>queryable</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>eu.eudat</groupId>
<artifactId>elastic</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,46 @@
package eu.eudat.data.converters;
import org.springframework.format.datetime.DateFormatter;
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<Date, Date> {
@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) {
e.printStackTrace();
}
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) {
e.printStackTrace();
}
return null;
}
}

View File

@ -1,7 +1,8 @@
package eu.eudat.data.dao.criteria; package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.Grant;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -10,39 +11,19 @@ import java.util.UUID;
public class DataManagementPlanCriteria extends Criteria<DMP> { public class DataManagementPlanCriteria extends Criteria<DMP> {
private Date periodStart; private Date periodStart;
private Date periodEnd; private Date periodEnd;
private List<eu.eudat.data.entities.Grant> grants;
private boolean allVersions; private boolean allVersions;
private List<UUID> groupIds; private List<UUID> groupIds;
private Integer status;
private List<eu.eudat.data.entities.Project> projects; private List<String> organisations;
private Integer role;
public boolean getAllVersions() { private List<UUID> collaborators;
return allVersions; private List<UUID> datasetTemplates;
} private boolean isPublic;
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public Date getPeriodStart() { public Date getPeriodStart() {
return periodStart; return periodStart;
} }
public List<Project> getProjects() {
return projects;
}
public void setProjects(List<Project> projects) {
this.projects = projects;
}
public void setPeriodStart(Date periodStart) { public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart; this.periodStart = periodStart;
} }
@ -50,9 +31,70 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
public Date getPeriodEnd() { public Date getPeriodEnd() {
return periodEnd; return periodEnd;
} }
public void setPeriodEnd(Date periodEnd) { public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd; this.periodEnd = periodEnd;
} }
public List<Grant> getGrants() {
return grants;
}
public void setGrants(List<Grant> grants) {
this.grants = grants;
}
public boolean getAllVersions() {
return allVersions;
}
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<String> getOrganisations() {
return organisations;
}
public void setOrganisations(List<String> organisations) {
this.organisations = organisations;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public List<UUID> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<UUID> collaborators) {
this.collaborators = collaborators;
}
public List<UUID> getDatasetTemplates() {
return datasetTemplates;
}
public void setDatasetTemplates(List<UUID> datasetTemplates) {
this.datasetTemplates = datasetTemplates;
}
public boolean getIsPublic() {
return isPublic;
}
public void setIsPublic(boolean isPublic) {
this.isPublic = isPublic;
}
} }

View File

@ -0,0 +1,42 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.types.grant.GrantStateType;
import java.util.List;
import java.util.UUID;
public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
private GrantStateType grantStatus;
private List<UUID> grants;
public List<UUID> datasetProfile;
private List<String> dmpOrganisations;
public GrantStateType getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(GrantStateType grantStatus) {
this.grantStatus = grantStatus;
}
public List<UUID> getGrants() {
return grants;
}
public void setGrants(List<UUID> grants) {
this.grants = grants;
}
public List<UUID> getDatasetProfile() {
return datasetProfile;
}
public void setDatasetProfile(List<UUID> datasetProfile) {
this.datasetProfile = datasetProfile;
}
public List<String> getDmpOrganisations() {
return dmpOrganisations;
}
public void setDmpOrganisations(List<String> dmpOrganisations) {
this.dmpOrganisations = dmpOrganisations;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.criteria; package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.elastic.entities.Tag;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -12,12 +13,18 @@ public class DatasetCriteria extends Criteria<Dataset> {
private Date periodStart; private Date periodStart;
private Date periodEnd; private Date periodEnd;
private List<UUID> dmpIds; private List<UUID> dmpIds;
private List<Tag> tags;
private boolean allVersions; private boolean allVersions;
private UUID profileDatasetId;
private List<String> organisations;
private Integer role;
private List<UUID> grants;
private List<UUID> collaborators;
private List<UUID> datasetTemplates;
public boolean getAllVersions() { public boolean getAllVersions() {
return allVersions; return allVersions;
} }
public void setAllVersions(boolean allVersions) { public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions; this.allVersions = allVersions;
} }
@ -25,7 +32,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
@ -33,7 +39,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Date getPeriodStart() { public Date getPeriodStart() {
return periodStart; return periodStart;
} }
public void setPeriodStart(Date periodStart) { public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart; this.periodStart = periodStart;
} }
@ -41,7 +46,6 @@ public class DatasetCriteria extends Criteria<Dataset> {
public Date getPeriodEnd() { public Date getPeriodEnd() {
return periodEnd; return periodEnd;
} }
public void setPeriodEnd(Date periodEnd) { public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd; this.periodEnd = periodEnd;
} }
@ -49,8 +53,56 @@ public class DatasetCriteria extends Criteria<Dataset> {
public List<UUID> getDmpIds() { public List<UUID> getDmpIds() {
return dmpIds; return dmpIds;
} }
public void setDmpIds(List<UUID> dmpIds) { public void setDmpIds(List<UUID> dmpIds) {
this.dmpIds = dmpIds; this.dmpIds = dmpIds;
} }
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
public UUID getProfileDatasetId() {
return profileDatasetId;
}
public void setProfileDatasetId(UUID profileDatasetId) {
this.profileDatasetId = profileDatasetId;
}
public List<String> getOrganisations() {
return organisations;
}
public void setOrganisations(List<String> organisations) {
this.organisations = organisations;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public List<UUID> getGrants() {
return grants;
}
public void setGrants(List<UUID> grants) {
this.grants = grants;
}
public List<UUID> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<UUID> collaborators) {
this.collaborators = collaborators;
}
public List<UUID> getDatasetTemplates() {
return datasetTemplates;
}
public void setDatasetTemplates(List<UUID> datasetTemplates) {
this.datasetTemplates = datasetTemplates;
}
} }

View File

@ -2,6 +2,54 @@ package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import java.util.List;
import java.util.UUID;
public class DatasetProfileCriteria extends Criteria<DatasetProfile> { public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
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 DatasetProfile filter");
}
}
}
private boolean allVersions;
private List<UUID> groupIds;
private Short filter;
private UUID userId;
public boolean getAllVersions() { return allVersions; }
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
public List<UUID> getGroupIds() { return groupIds; }
public void setGroupIds(List<UUID> 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;
}
} }

View File

@ -0,0 +1,62 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.types.grant.GrantStateType;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 10/2/2018.
*/
public class DatasetPublicCriteria extends Criteria<Dataset>{
private GrantStateType grantStatus;
private List<UUID> grants;
private List<UUID> datasetProfile;
private List<String> dmpOrganisations;
private List<Tag> tags;
private List<UUID> dmpIds;
public GrantStateType getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(GrantStateType grantStatus) {
this.grantStatus = grantStatus;
}
public List<UUID> getGrants() {
return grants;
}
public void setGrants(List<UUID> grants) {
this.grants = grants;
}
public List<UUID> getDatasetProfile() {
return datasetProfile;
}
public void setDatasetProfile(List<UUID> datasetProfile) {
this.datasetProfile = datasetProfile;
}
public List<String> getDmpOrganisations() {
return dmpOrganisations;
}
public void setDmpOrganisations(List<String> dmpOrganisations) {
this.dmpOrganisations = dmpOrganisations;
}
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
public List<UUID> getDmpIds() {
return dmpIds;
}
public void setDmpIds(List<UUID> dmpIds) {
this.dmpIds = dmpIds;
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Funder;
public class FunderCriteria extends Criteria<Funder> {
private String reference;
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
}

View File

@ -0,0 +1,65 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Grant;
import eu.eudat.types.grant.GrantStateType;
import java.util.Date;
public class GrantCriteria extends Criteria<Grant> {
private Date periodStart;
private Date periodEnd;
private String reference;
private Integer grantStateType;
private boolean isPublic;
private String funderId;
private String funderReference;
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;
}
}

View File

@ -0,0 +1,6 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.LoginConfirmationEmail;
public class LoginConfirmationEmailCriteria extends Criteria<LoginConfirmationEmail>{
}

View File

@ -3,4 +3,20 @@ package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
public class OrganisationCriteria extends Criteria<Organisation> { public class OrganisationCriteria extends Criteria<Organisation> {
private String labelLike;
private Boolean isPublic;
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;
}
} }

View File

@ -2,33 +2,12 @@ package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import java.util.Date;
public class ProjectCriteria extends Criteria<Project> { public class ProjectCriteria extends Criteria<Project> {
private Date periodStart;
private Date periodEnd;
private String reference; private String reference;
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() { public String getReference() {
return reference; return reference;
} }
public void setReference(String reference) { public void setReference(String reference) {
this.reference = reference; this.reference = reference;
} }

View File

@ -8,11 +8,11 @@ import java.util.List;
public class UserInfoCriteria extends Criteria<UserInfo> { public class UserInfoCriteria extends Criteria<UserInfo> {
private String email; private String email;
private List<Integer> appRoles; private List<Integer> appRoles;
private String collaboratorLike;
public List<Integer> getAppRoles() { public List<Integer> getAppRoles() {
return appRoles; return appRoles;
} }
public void setAppRoles(List<Integer> appRoles) { public void setAppRoles(List<Integer> appRoles) {
this.appRoles = appRoles; this.appRoles = appRoles;
} }
@ -20,8 +20,14 @@ public class UserInfoCriteria extends Criteria<UserInfo> {
public String getEmail() { public String getEmail() {
return email; return email;
} }
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
public String getCollaboratorLike() {
return collaboratorLike;
}
public void setCollaboratorLike(String collaboratorLike) {
this.collaboratorLike = collaboratorLike;
}
} }

View File

@ -4,6 +4,7 @@ import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList; import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;

View File

@ -5,6 +5,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Content; import eu.eudat.data.entities.Content;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -27,6 +28,7 @@ public class ContentDaoImpl extends DatabaseAccess<Content> implements ContentDa
} }
@Override @Override
@Async
public CompletableFuture<Content> createOrUpdateAsync(Content item) { public CompletableFuture<Content> createOrUpdateAsync(Content item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -4,6 +4,7 @@ import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria; import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
@ -15,6 +16,6 @@ public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo); QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UserInfo principal); QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principalId);
} }

View File

@ -5,13 +5,16 @@ import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria; import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP; import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -29,23 +32,52 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) { public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class); QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); 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) if (criteria.getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd())); query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null) if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart())); query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
if (criteria.getProjects() != null && !criteria.getProjects().isEmpty()) if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
query.where(((builder, root) -> root.get("project").in(criteria.getProjects()))); query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
if (!criteria.getAllVersions()) if (!criteria.getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.<String>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()) if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds())); 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.and(builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()), builder.notEqual(root.get("isPublic"), true)));
} 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"), true)));
if (criteria.getRole() != null) {
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
}
}
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
}
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
}
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
query.where(((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates())));
}
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue())); query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
return query; return query;
} }
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UserInfo principal) { public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creator"), principal), builder.isMember(principal, root.get("users")))); query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user").get("id"), principal));
return query; return query;
} }
@ -78,6 +110,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
return this.getDatabaseService().getQueryable(DMP.class); return this.getDatabaseService().getQueryable(DMP.class);
} }
@Async
@Override @Override
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) { public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -22,6 +23,7 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
super(databaseService); super(databaseService);
} }
@Async
@Override @Override
public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) { public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
@ -59,7 +61,8 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
public QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria) { public QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria) {
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class); QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); 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; return query;
} }
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DataRepository; import eu.eudat.data.entities.DataRepository;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -38,6 +39,7 @@ public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implem
} }
@Override @Override
@Async
public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) { public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -14,4 +14,6 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal); QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal);
Dataset isPublicDataset(UUID id);
} }

View File

@ -3,14 +3,17 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DatasetCriteria; import eu.eudat.data.dao.criteria.DatasetCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -19,17 +22,19 @@ import java.util.concurrent.CompletableFuture;
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao { public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
@Autowired @Autowired
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
super(databaseService);
}
@Override @Override
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) { public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class); QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); 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) if (criteria.getStatus() != null)
query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())); 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) if (criteria.getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd())); query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null) if (criteria.getPeriodStart() != null)
@ -38,6 +43,18 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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.getDmpIds() != null && !criteria.getDmpIds().isEmpty()) if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds())); 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()));
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.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())));
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; return query;
} }
@ -48,18 +65,30 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
@Override @Override
public Dataset find(UUID id) { public Dataset find(UUID id) {
return getDatabaseService().getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); 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 @Override
public Dataset find(UUID id, String hint) { public Dataset find(UUID id, String hint) {
return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); 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<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
return query.withHint("datasetListingModel").getSingle();
} }
@Override @Override
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) { public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users")) if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
, builder.equal(root.get("isPublic"), true))); else {
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.equal(root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId())));
}
return query; return query;
} }
@ -73,6 +102,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
return this.getDatabaseService().getQueryable(Dataset.class); return this.getDatabaseService().getQueryable(Dataset.class);
} }
@Async
public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) { public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -33,6 +34,7 @@ public class DatasetExternalDatasetDaoImpl extends DatabaseAccess<DatasetExterna
} }
@Override @Override
@Async
public DatasetExternalDataset find(UUID id) { public DatasetExternalDataset find(UUID id) {
return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }

View File

@ -5,9 +5,14 @@ import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType;
import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -23,7 +28,31 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) { public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) {
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class); QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); 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.<String>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())));
}
}
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue())));
return query; return query;
} }
@ -52,6 +81,7 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
return this.getDatabaseService().getQueryable(DatasetProfile.class); return this.getDatabaseService().getQueryable(DatasetProfile.class);
} }
@Async
@Override @Override
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) { public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -7,6 +7,7 @@ import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService; import eu.eudat.data.entities.DatasetService;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -28,6 +29,7 @@ public class DatasetServiceDaoImpl extends DatabaseAccess<DatasetService> implem
return this.getDatabaseService().createOrUpdate(item, DatasetService.class); return this.getDatabaseService().createOrUpdate(item, DatasetService.class);
} }
@Async
@Override @Override
public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) { public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.ExternalDataset; import eu.eudat.data.entities.ExternalDataset;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -24,7 +25,7 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
public QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria) { public QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria) {
QueryableList<ExternalDataset> query = this.getDatabaseService().getQueryable(ExternalDataset.class); QueryableList<ExternalDataset> query = this.getDatabaseService().getQueryable(ExternalDataset.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
return query; return query;
} }
@ -48,6 +49,7 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
return this.getDatabaseService().getQueryable(ExternalDataset.class); return this.getDatabaseService().getQueryable(ExternalDataset.class);
} }
@Async
@Override @Override
public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) { public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -0,0 +1,16 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public interface FunderDao extends DatabaseAccessLayer<Funder, UUID> {
QueryableList<Funder> getWithCritetia(FunderCriteria criteria);
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal);
}

View File

@ -0,0 +1,70 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("funderDao")
public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
@Autowired
public FunderDaoImpl(DatabaseService<Funder> databaseService) {
super(databaseService);
}
@Override
public QueryableList<Funder> getWithCritetia(FunderCriteria criteria) {
QueryableList<Funder> query = getDatabaseService().getQueryable(Funder.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.or(builder.like(builder.upper(root.get("definition")), "%" + criteria.getLike().toUpperCase() + "%"))));
if (criteria.getReference() != null)
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
return query;
}
@Override
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal) {
return null;
}
@Override
public Funder createOrUpdate(Funder item) {
return this.getDatabaseService().createOrUpdate(item, Funder.class);
}
@Override
public CompletableFuture<Funder> createOrUpdateAsync(Funder item) {
return null;
}
@Override
public Funder find(UUID id) {
return this.getDatabaseService().getQueryable(Funder.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public Funder find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(Funder item) {
throw new UnsupportedOperationException();
}
@Override
public QueryableList<Funder> asQueryable() {
return this.getDatabaseService().getQueryable(Funder.class);
}
}

View File

@ -0,0 +1,17 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public interface GrantDao extends DatabaseAccessLayer<Grant, UUID> {
QueryableList<Grant> getWithCriteria(GrantCriteria criteria);
QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal);
}

View File

@ -0,0 +1,93 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.grant.GrantStateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("grantDao")
public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
@Autowired
public GrantDaoImpl(DatabaseService<Grant> databaseService) {
super(databaseService);
}
@Override
public QueryableList<Grant> getWithCriteria(GrantCriteria criteria) {
QueryableList<Grant> query = getDatabaseService().getQueryable(Grant.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.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
if (criteria.getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
if (criteria.getReference() != null)
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
if (criteria.getGrantStateType() != null) {
if (criteria.getGrantStateType().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("enddate"), new Date()));
if (criteria.getGrantStateType().equals(GrantStateType.ONGOING.getValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("enddate"), new Date())
, builder.isNull(root.get("enddate"))));
}
if (criteria.isPublic()) {
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DMP.DMPStatus.FINALISED.getValue())).distinct();
}
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
return query;
}
@Override
public Grant createOrUpdate(Grant item) {
return getDatabaseService().createOrUpdate(item, Grant.class);
}
@Override
public Grant find(UUID id) {
return getDatabaseService().getQueryable(Grant.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
}
@Override
public void delete(Grant item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<Grant> asQueryable() {
return this.getDatabaseService().getQueryable(Grant.class);
}
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()))).distinct();
return query;
}
@Async
@Override
public CompletableFuture<Grant> createOrUpdateAsync(Grant item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public Grant find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Invitation; import eu.eudat.data.entities.Invitation;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -45,6 +46,7 @@ public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements Inv
return this.getDatabaseService().getQueryable(Invitation.class); return this.getDatabaseService().getQueryable(Invitation.class);
} }
@Async
@Override @Override
public CompletableFuture<Invitation> createOrUpdateAsync(Invitation item) { public CompletableFuture<Invitation> createOrUpdateAsync(Invitation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -0,0 +1,13 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.LoginConfirmationEmailCriteria;
import eu.eudat.data.entities.LoginConfirmationEmail;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public interface LoginConfirmationEmailDao extends DatabaseAccessLayer<LoginConfirmationEmail, UUID> {
QueryableList<LoginConfirmationEmail> getWithCriteria(LoginConfirmationEmailCriteria criteria);
}

View File

@ -0,0 +1,56 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.LoginConfirmationEmailCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.LoginConfirmationEmail;
import eu.eudat.queryable.QueryableList;
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 LoginConfirmationEmailDaoImpl extends DatabaseAccess<LoginConfirmationEmail> implements LoginConfirmationEmailDao {
@Autowired
public LoginConfirmationEmailDaoImpl(DatabaseService<LoginConfirmationEmail> databaseService) {
super(databaseService);
}
@Override
public QueryableList<LoginConfirmationEmail> getWithCriteria(LoginConfirmationEmailCriteria criteria) {
return null;
}
@Override
public LoginConfirmationEmail createOrUpdate(LoginConfirmationEmail item) {
return this.getDatabaseService().createOrUpdate(item, LoginConfirmationEmail.class);
}
@Override
public CompletableFuture<LoginConfirmationEmail> createOrUpdateAsync(LoginConfirmationEmail item) {
return null;
}
@Override
public LoginConfirmationEmail find(UUID id) {
return this.getDatabaseService().getQueryable(LoginConfirmationEmail.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public LoginConfirmationEmail find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(LoginConfirmationEmail item) {
throw new UnsupportedOperationException();
}
@Override
public QueryableList<LoginConfirmationEmail> asQueryable() {
return this.getDatabaseService().getQueryable(LoginConfirmationEmail.class);
}
}

View File

@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.OrganisationCriteria; import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; import java.util.UUID;
@ -10,5 +11,6 @@ import java.util.UUID;
public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> { public interface OrganisationDao extends DatabaseAccessLayer<Organisation, UUID> {
QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria); QueryableList<Organisation> getWithCriteria(OrganisationCriteria criteria);
QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal);
} }

View File

@ -3,11 +3,15 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.OrganisationCriteria; import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -24,6 +28,12 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class); QueryableList<Organisation> query = this.getDatabaseService().getQueryable(Organisation.class);
if (criteria.getLike() != null) if (criteria.getLike() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike()));
if (criteria.getLabelLike() != null) {
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
}
if (criteria.getPublic() != null && criteria.getPublic()) {
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
}
return query; return query;
} }
@ -47,11 +57,17 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
return this.getDatabaseService().getQueryable(Organisation.class); return this.getDatabaseService().getQueryable(Organisation.class);
} }
@Async
@Override @Override
public CompletableFuture<Organisation> createOrUpdateAsync(Organisation item) { public CompletableFuture<Organisation> createOrUpdateAsync(Organisation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }
public QueryableList<Organisation> getAuthenticated(QueryableList<Organisation> query, UserInfo principal) {
query.where((builder, root) -> builder.equal(root.join("dmps").get("creator"), principal));
return query;
}
@Override @Override
public Organisation find(UUID id, String hint) { public Organisation find(UUID id, String hint) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -10,8 +10,7 @@ import java.util.UUID;
public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> { public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
QueryableList<Project> getWithCriteria(ProjectCriteria criteria); QueryableList<Project> getWithCritetia(ProjectCriteria criteria);
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal); QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal);
} }

View File

@ -6,68 +6,64 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Project; import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@Component("projectDao") @Service("projectDao")
public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDao { public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDao {
@Autowired
public ProjectDaoImpl(DatabaseService<Project> databaseService) { public ProjectDaoImpl(DatabaseService<Project> databaseService) {
super(databaseService); super(databaseService);
} }
@Override @Override
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) { public QueryableList<Project> getWithCritetia(ProjectCriteria criteria) {
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class); QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); query.where((builder, root) ->
if (criteria.getPeriodEnd() != null) builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd())); builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
if (criteria.getReference() != null) if (criteria.getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference())); query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue())); query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query; return query;
} }
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()))).distinct();
return query;
}
@Override @Override
public Project createOrUpdate(Project item) { public Project createOrUpdate(Project item) {
return getDatabaseService().createOrUpdate(item, Project.class); return this.getDatabaseService().createOrUpdate(item, Project.class);
}
@Override
public Project find(UUID id) {
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
}
@Override
public void delete(Project item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<Project> asQueryable() {
return this.getDatabaseService().getQueryable(Project.class);
}
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps", JoinType.LEFT).get("users")))).distinct();
return query;
} }
@Override @Override
public CompletableFuture<Project> createOrUpdateAsync(Project item) { public CompletableFuture<Project> createOrUpdateAsync(Project item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return null;
}
@Override
public Project find(UUID id) {
return this.getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }
@Override @Override
public Project find(UUID id, String hint) { public Project find(UUID id, String hint) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void delete(Project item) {
throw new UnsupportedOperationException();
}
@Override
public QueryableList<Project> asQueryable() {
return this.getDatabaseService().getQueryable(Project.class);
}
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Registry; import eu.eudat.data.entities.Registry;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -47,6 +48,7 @@ public class RegistryDaoImpl extends DatabaseAccess<Registry> implements Registr
return this.getDatabaseService().getQueryable(Registry.class); return this.getDatabaseService().getQueryable(Registry.class);
} }
@Async
@Override @Override
public CompletableFuture<Registry> createOrUpdateAsync(Registry item) { public CompletableFuture<Registry> createOrUpdateAsync(Registry item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Researcher; import eu.eudat.data.entities.Researcher;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -21,11 +22,11 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
@Override @Override
public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) { public QueryableList<Researcher> getWithCriteria(ResearcherCriteria criteria) {
QueryableList<Researcher> query = this.getDatabaseService().getQueryable(Researcher.class); QueryableList<Researcher> query = asQueryable();
if (criteria.getLike() != null) if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getLike())); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%")));
if (criteria.getName() != null) if (criteria.getName() != null && !criteria.getName().isEmpty())
query.where((builder, root) -> builder.equal(root.get("label"), criteria.getName())); query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%")));
return query; return query;
} }
@ -49,6 +50,7 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
return this.getDatabaseService().getQueryable(Researcher.class); return this.getDatabaseService().getQueryable(Researcher.class);
} }
@Async
@Override @Override
public CompletableFuture<Researcher> createOrUpdateAsync(Researcher item) { public CompletableFuture<Researcher> createOrUpdateAsync(Researcher item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Service; import eu.eudat.data.entities.Service;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -47,6 +48,7 @@ public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDa
return this.getDatabaseService().getQueryable(Service.class); return this.getDatabaseService().getQueryable(Service.class);
} }
@Async
@Override @Override
public CompletableFuture<Service> createOrUpdateAsync(Service item) { public CompletableFuture<Service> createOrUpdateAsync(Service item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -5,6 +5,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserDMP; import eu.eudat.data.entities.UserDMP;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -41,6 +42,7 @@ public class UserDmpDaoImpl extends DatabaseAccess<UserDMP> implements UserDmpDa
return this.getDatabaseService().getQueryable(UserDMP.class); return this.getDatabaseService().getQueryable(UserDMP.class);
} }
@Async
@Override @Override
public CompletableFuture<UserDMP> createOrUpdateAsync(UserDMP item) { public CompletableFuture<UserDMP> createOrUpdateAsync(UserDMP item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -11,4 +11,5 @@ public interface UserInfoDao extends DatabaseAccessLayer<UserInfo, UUID> {
QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria); QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria);
QueryableList<UserInfo> getAuthenticated(QueryableList<UserInfo> users, UUID principalId);
} }

View File

@ -5,9 +5,13 @@ import eu.eudat.data.dao.criteria.UserInfoCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService; import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -25,9 +29,21 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty()) if (criteria.getAppRoles() != null && !criteria.getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(criteria.getAppRoles())); users.where((builder, root) -> root.join("userRoles").get("role").in(criteria.getAppRoles()));
if (criteria.getLike() != null) if (criteria.getLike() != null)
users.where((builder, root) -> builder.or(builder.like(root.get("name"), "%" + criteria.getLike() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%"))); users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%")));
if (criteria.getEmail() != null) if (criteria.getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), criteria.getEmail())); users.where((builder, root) -> builder.equal(root.get("email"), criteria.getEmail()));
if (criteria.getCollaboratorLike() != null)
users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + criteria.getCollaboratorLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + criteria.getCollaboratorLike() + "%")));
return users;
}
@Override
public QueryableList<UserInfo> getAuthenticated(QueryableList<UserInfo> users, UUID principalId) {
users.initSubQuery(UUID.class).where((builder, root) ->
builder.and(root.join("dmps").get("id").in(
users.subQuery((builder1, root1) -> builder1.equal(root1.get("id"), principalId),
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmps:id")))),
builder.notEqual(root.get("id"), principalId)));
return users; return users;
} }
@ -51,6 +67,7 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
return this.getDatabaseService().getQueryable(UserInfo.class); return this.getDatabaseService().getQueryable(UserInfo.class);
} }
@Async
@Override @Override
public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) { public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -7,6 +7,7 @@ import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserRole; import eu.eudat.data.entities.UserRole;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@ -57,6 +58,7 @@ public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRol
return this.getDatabaseService().getQueryable(UserRole.class); return this.getDatabaseService().getQueryable(UserRole.class);
} }
@Async
@Override @Override
public CompletableFuture<UserRole> createOrUpdateAsync(UserRole item) { public CompletableFuture<UserRole> createOrUpdateAsync(UserRole item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -1,9 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -14,7 +16,7 @@ import java.util.UUID;
public class Content implements DataEntity<Content, UUID> { public class Content implements DataEntity<Content, UUID> {
public enum ParentType { public enum ParentType {
PROJECT(0); GRANT(0);
private int value; private int value;
@ -29,7 +31,7 @@ public class Content implements DataEntity<Content, UUID> {
public static ParentType fromInteger(int value) { public static ParentType fromInteger(int value) {
switch (value) { switch (value) {
case 0: case 0:
return PROJECT; return GRANT;
default: default:
throw new RuntimeException("Unsupported Content Parent Type Status"); throw new RuntimeException("Unsupported Content Parent Type Status");
} }
@ -143,4 +145,11 @@ public class Content implements DataEntity<Content, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Content buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,9 +1,12 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -14,7 +17,7 @@ import java.util.UUID;
name = "credentialUserInfo", name = "credentialUserInfo",
attributeNodes = {@NamedAttributeNode("userInfo")}) attributeNodes = {@NamedAttributeNode("userInfo")})
}) })
public class Credential implements DataEntity<Credential,UUID> { public class Credential implements DataEntity<Credential, UUID> {
@Id @Id
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@ -33,9 +36,13 @@ public class Credential implements DataEntity<Credential,UUID> {
private String publicValue; private String publicValue;
@Column(name = "\"Secret\"", nullable = false) @Column(name = "\"Secret\"", nullable = false)
private String secret; private String secret;
@Column(name = "\"CreationTime\"", nullable = false) @Column(name = "\"CreationTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date creationTime; private Date creationTime;
@Column(name = "\"LastUpdateTime\"", nullable = false) @Column(name = "\"LastUpdateTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date lastUpdateTime; private Date lastUpdateTime;
@Column(name = "\"ExternalId\"", nullable = false) @Column(name = "\"ExternalId\"", nullable = false)
@ -140,4 +147,11 @@ public class Credential implements DataEntity<Credential,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Credential buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,12 +1,13 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Entity @Entity
@ -14,13 +15,16 @@ import java.util.*;
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
name = "dataManagementPlanListingModel", name = "dataManagementPlanListingModel",
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
@NamedAttributeNode("project"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")} @NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
subgraphs = {
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
}
), ),
@NamedEntityGraph( @NamedEntityGraph(
name = "fullyDetailed", name = "fullyDetailed",
attributeNodes = { attributeNodes = {
@NamedAttributeNode("project"), @NamedAttributeNode("profile"), @NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}), @NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
@NamedEntityGraph( @NamedEntityGraph(
name = "dmpRecentActivity", name = "dmpRecentActivity",
@ -30,7 +34,7 @@ import java.util.*;
public class DMP implements DataEntity<DMP, UUID> { public class DMP implements DataEntity<DMP, UUID> {
public enum DMPStatus { public enum DMPStatus {
ACTIVE((short) 0), DELETED((short) 1); ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
private short value; private short value;
@ -47,6 +51,8 @@ public class DMP implements DataEntity<DMP, UUID> {
case 0: case 0:
return ACTIVE; return ACTIVE;
case 1: case 1:
return FINALISED;
case 99:
return DELETED; return DELETED;
default: default:
throw new RuntimeException("Unsupported DMP Status"); throw new RuntimeException("Unsupported DMP Status");
@ -80,13 +86,20 @@ public class DMP implements DataEntity<DMP, UUID> {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"") @JoinColumn(name = "\"Grant\"")
private Project project; private Grant grant;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") /*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true) @Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
private String associatedDmps; private String associatedDmps;*/
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPDatasetProfile\"",
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
)
private Set<DatasetProfile> associatedDmps;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Profile\"") @JoinColumn(name = "\"Profile\"")
@ -114,12 +127,13 @@ public class DMP implements DataEntity<DMP, UUID> {
private Set<Researcher> researchers; private Set<Researcher> researchers;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
/*@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"", @JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}, joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")} inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
) )*/
private Set<UserInfo> users; private Set<UserDMP> users;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
@ -132,79 +146,80 @@ public class DMP implements DataEntity<DMP, UUID> {
private String dmpProperties; private String dmpProperties;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@Column(name = "\"Description\"") @Column(name = "\"Description\"")
private String description; private String description;
@Column(name= "\"FinalizedAt\"")
@Convert(converter = DateToUTCConverter.class)
private Date finalizedAt;
@Column(name = "\"isPublic\"", nullable = false)
private boolean isPublic;
@Column(name= "\"PublishedAt\"")
@Convert(converter = DateToUTCConverter.class)
private Date publishedAt;
@Column(name = "\"DOI\"")
private String doi;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"")
private Project project;
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public UserInfo getCreator() { public UserInfo getCreator() {
return creator; return creator;
} }
public void setCreator(UserInfo creator) { public void setCreator(UserInfo creator) {
this.creator = creator; this.creator = creator;
} }
public Short getStatus() { public Short getStatus() {
return status; return status;
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = status; this.status = status;
} }
public Date getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(Date created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
public Date getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(Date modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
public Set<UserDMP> getUsers() {
public Set<UserInfo> getUsers() {
return users; return users;
} }
public void setUsers(Set<UserDMP> users) {
public void setUsers(Set<UserInfo> users) {
this.users = users; this.users = users;
} }
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { public void setId(UUID id) {
this.id = id; this.id = id;
} }
@ -212,7 +227,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public UUID getGroupId() { public UUID getGroupId() {
return groupId; return groupId;
} }
public void setGroupId(UUID groupId) { public void setGroupId(UUID groupId) {
this.groupId = groupId; this.groupId = groupId;
} }
@ -220,7 +234,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
@ -228,31 +241,27 @@ public class DMP implements DataEntity<DMP, UUID> {
public Integer getVersion() { public Integer getVersion() {
return version; return version;
} }
public void setVersion(Integer version) { public void setVersion(Integer version) {
this.version = version; this.version = version;
} }
public Project getProject() { public Grant getGrant() {
return project; return grant;
}
public void setGrant(Grant grant) {
this.grant = grant;
} }
public void setProject(Project project) { public Set<DatasetProfile> getAssociatedDmps() {
this.project = project;
}
public String getAssociatedDmps() {
return associatedDmps; return associatedDmps;
} }
public void setAssociatedDmps(Set<DatasetProfile> associatedDmps) {
public void setAssociatedDmps(String associatedDmps) {
this.associatedDmps = associatedDmps; this.associatedDmps = associatedDmps;
} }
public DMPProfile getProfile() { public DMPProfile getProfile() {
return profile; return profile;
} }
public void setProfile(DMPProfile profile) { public void setProfile(DMPProfile profile) {
this.profile = profile; this.profile = profile;
} }
@ -260,7 +269,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public Set<Dataset> getDataset() { public Set<Dataset> getDataset() {
return dataset; return dataset;
} }
public void setDataset(Set<Dataset> dataset) { public void setDataset(Set<Dataset> dataset) {
this.dataset = dataset; this.dataset = dataset;
} }
@ -268,7 +276,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public Set<Organisation> getOrganisations() { public Set<Organisation> getOrganisations() {
return organisations; return organisations;
} }
public void setOrganisations(Set<Organisation> organisations) { public void setOrganisations(Set<Organisation> organisations) {
this.organisations = organisations; this.organisations = organisations;
} }
@ -276,7 +283,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public Set<Researcher> getResearchers() { public Set<Researcher> getResearchers() {
return researchers; return researchers;
} }
public void setResearchers(Set<Researcher> researchers) { public void setResearchers(Set<Researcher> researchers) {
this.researchers = researchers; this.researchers = researchers;
} }
@ -284,7 +290,6 @@ public class DMP implements DataEntity<DMP, UUID> {
public String getProperties() { public String getProperties() {
return properties; return properties;
} }
public void setProperties(String properties) { public void setProperties(String properties) {
this.properties = properties; this.properties = properties;
} }
@ -292,11 +297,45 @@ public class DMP implements DataEntity<DMP, UUID> {
public String getDmpProperties() { public String getDmpProperties() {
return dmpProperties; return dmpProperties;
} }
public void setDmpProperties(String dmpProperties) { public void setDmpProperties(String dmpProperties) {
this.dmpProperties = dmpProperties; this.dmpProperties = dmpProperties;
} }
public Date getFinalizedAt() {
return finalizedAt;
}
public void setFinalizedAt(Date finalizedAt) {
this.finalizedAt = finalizedAt;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
public Date getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(Date publishedAt) {
this.publishedAt = publishedAt;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
@Override @Override
public void update(DMP entity) { public void update(DMP entity) {
this.associatedDmps = entity.associatedDmps; this.associatedDmps = entity.associatedDmps;
@ -305,13 +344,18 @@ public class DMP implements DataEntity<DMP, UUID> {
this.status = entity.getStatus(); this.status = entity.getStatus();
this.created = entity.created; this.created = entity.created;
this.properties = entity.getProperties(); this.properties = entity.getProperties();
this.project = entity.getProject(); this.grant = entity.getGrant();
this.description = entity.getDescription(); this.description = entity.getDescription();
this.researchers = entity.getResearchers(); this.researchers = entity.getResearchers();
this.organisations = entity.getOrganisations(); this.organisations = entity.getOrganisations();
this.dmpProperties = entity.getDmpProperties(); this.dmpProperties = entity.getDmpProperties();
this.isPublic = entity.isPublic;
this.project = entity.getProject();
this.setModified(new Date()); this.setModified(new Date());
if (entity.getStatus().equals(DMPStatus.FINALISED.getValue())) this.setFinalizedAt(new Date());
if (entity.isPublic) this.setPublishedAt(new Date());
if (entity.getUsers() != null) this.users = entity.getUsers(); if (entity.getUsers() != null) this.users = entity.getUsers();
if (entity.getDoi() != null && entity.getDoi().trim().isEmpty()) this.doi = entity.doi;
} }
@Override @Override
@ -319,4 +363,11 @@ public class DMP implements DataEntity<DMP, UUID> {
return this.id; return this.id;
} }
@Override
public DMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
this.dataset = tuple.stream().map(x -> new Dataset().buildFromTuple(tuple, fields ,base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
return this;
}
} }

View File

@ -1,12 +1,15 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -15,6 +18,33 @@ import java.util.UUID;
@Table(name = "\"DMPProfile\"") @Table(name = "\"DMPProfile\"")
public class DMPProfile implements DataEntity<DMPProfile, UUID> { public class DMPProfile implements DataEntity<DMPProfile, UUID> {
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dmp Profile Status");
}
}
}
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @GenericGenerator(name = "uuid2", strategy = "uuid2")
@ -39,9 +69,11 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
public int getStatus() { public int getStatus() {
@ -105,10 +137,18 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
this.modified = new Date(); this.modified = new Date();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.status= entity.getStatus();
} }
@Override @Override
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DMPProfile buildFromTuple(List<Tuple> tuple,List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -8,12 +9,13 @@ import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"DataRepository\"") @Table(name = "\"DataRepository\"")
public class DataRepository implements Serializable, DataEntity<DataRepository,UUID> { public class DataRepository implements Serializable, DataEntity<DataRepository, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@ -147,4 +149,11 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,U
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DataRepository buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,6 +1,8 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -14,15 +16,25 @@ import java.util.stream.Collectors;
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
name = "datasetListingModel", name = "datasetListingModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"), attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}, @NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})), subgraphs = {
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
}),
@NamedEntityGraph( @NamedEntityGraph(
name = "datasetWizardModel", name = "datasetWizardModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"), attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}), @NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
@NamedEntityGraph( @NamedEntityGraph(
name = "datasetRecentActivity", name = "datasetRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("users")})),
@NamedEntityGraph(
name = "datasetDataRepositories",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")}, attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})) subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}))
}) })
@ -35,7 +47,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel")); private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
public enum Status { public enum Status {
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99); SAVED((short) 0), FINALISED((short) 1), CANCELED((short) 2), DELETED((short) 99),;
private short value; private short value;
@ -53,8 +65,12 @@ public class Dataset implements DataEntity<Dataset, UUID> {
return SAVED; return SAVED;
case 1: case 1:
return FINALISED; return FINALISED;
case 2:
return CANCELED;
case 99:
return DELETED;
default: default:
throw new RuntimeException("Unsupported Project Status"); throw new RuntimeException("Unsupported Dataset Status");
} }
} }
} }
@ -68,13 +84,11 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL) // @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"DMP\"", nullable = true) @JoinColumn(name = "\"DMP\"", nullable = false)
private DMP dmp; private DMP dmp;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@ -82,7 +96,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties; private String properties;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL) //@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"", nullable = true) @JoinColumn(name = "\"Profile\"", nullable = true)
@ -99,28 +112,25 @@ public class Dataset implements DataEntity<Dataset, UUID> {
) )
private Set<Registry> registries; private Set<Registry> registries;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories; private Set<DatasetDataRepository> datasetDataRepositories;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services; private Set<DatasetService> services;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetExternalDataset> datasetExternalDatasets; private Set<DatasetExternalDataset> datasetExternalDatasets;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"IsPublic\"", nullable = false)
private boolean isPublic;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@ -130,11 +140,14 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@Column(name = "\"Description\"") @Column(name = "\"Description\"")
private String description; private String description;
@Column(name= "\"FinalizedAt\"")
@Convert(converter = DateToUTCConverter.class)
private Date finalizedAt;
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
@ -143,7 +156,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public UserInfo getCreator() { public UserInfo getCreator() {
return creator; return creator;
} }
public void setCreator(UserInfo creator) { public void setCreator(UserInfo creator) {
this.creator = creator; this.creator = creator;
} }
@ -151,8 +163,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Short getStatus() { public Short getStatus() {
return status; return status;
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = status; this.status = status;
} }
@ -161,8 +171,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Date getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(Date created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
@ -171,8 +179,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Date getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(Date modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
@ -181,8 +187,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Set<Registry> getRegistries() { public Set<Registry> getRegistries() {
return registries; return registries;
} }
public void setRegistries(Set<Registry> registries) { public void setRegistries(Set<Registry> registries) {
this.registries = registries; this.registries = registries;
} }
@ -190,7 +194,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Set<DatasetService> getServices() { public Set<DatasetService> getServices() {
return services; return services;
} }
public void setServices(Set<DatasetService> services) { public void setServices(Set<DatasetService> services) {
this.services = services; this.services = services;
} }
@ -198,8 +201,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { public void setId(UUID id) {
this.id = id; this.id = id;
} }
@ -208,8 +209,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
@ -218,8 +217,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public DMP getDmp() { public DMP getDmp() {
return dmp; return dmp;
} }
public void setDmp(DMP dmp) { public void setDmp(DMP dmp) {
this.dmp = dmp; this.dmp = dmp;
} }
@ -228,8 +225,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public String getUri() { public String getUri() {
return uri; return uri;
} }
public void setUri(String uri) { public void setUri(String uri) {
this.uri = uri; this.uri = uri;
} }
@ -238,8 +233,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public String getProperties() { public String getProperties() {
return properties; return properties;
} }
public void setProperties(String properties) { public void setProperties(String properties) {
this.properties = properties; this.properties = properties;
} }
@ -248,8 +241,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public DatasetProfile getProfile() { public DatasetProfile getProfile() {
return profile; return profile;
} }
public void setProfile(DatasetProfile profile) { public void setProfile(DatasetProfile profile) {
this.profile = profile; this.profile = profile;
} }
@ -258,7 +249,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Set<DatasetDataRepository> getDatasetDataRepositories() { public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories; return datasetDataRepositories;
} }
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) { public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.datasetDataRepositories = datasetDataRepositories; this.datasetDataRepositories = datasetDataRepositories;
} }
@ -266,8 +256,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public String getReference() { public String getReference() {
return reference; return reference;
} }
public void setReference(String reference) { public void setReference(String reference) {
this.reference = reference; this.reference = reference;
} }
@ -275,44 +263,50 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public Set<DatasetExternalDataset> getDatasetExternalDatasets() { public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
return datasetExternalDatasets; return datasetExternalDatasets;
} }
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) { public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
this.datasetExternalDatasets = datasetExternalDatasets; this.datasetExternalDatasets = datasetExternalDatasets;
} }
public boolean isPublic() { public Date getFinalizedAt() {
return isPublic; return finalizedAt;
} }
public void setFinalizedAt(Date finalizedAt) {
public void setPublic(boolean aPublic) { this.finalizedAt = finalizedAt;
isPublic = aPublic;
} }
@Override @Override
public void update(Dataset entity) { public void update(Dataset entity) {
this.setRegistries(entity.getRegistries()); this.setRegistries(entity.getRegistries());
if(this.getDatasetDataRepositories()==null) this.setDatasetDataRepositories(new HashSet<>()); if (this.getDatasetDataRepositories() == null) this.setDatasetDataRepositories(new HashSet<>());
if(!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())){ if (!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())) {
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories()); this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item->{ this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item -> {
item.setDataset(this); item.setDataset(this);
return item; return item;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
this.setUri(entity.getUri());
this.setDescription(entity.getDescription()); this.setDescription(entity.getDescription());
this.setLabel(entity.getLabel()); this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties()); this.setProperties(entity.getProperties());
if(this.getDatasetExternalDatasets()==null) this.setDatasetExternalDatasets(new HashSet<>()); if (this.getDatasetExternalDatasets() == null) this.setDatasetExternalDatasets(new HashSet<>());
if(!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) { if (!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) {
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets()); this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> { this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
item.setDataset(this); item.setDataset(this);
return item; return item;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
if (this.getServices() == null) this.setServices(new HashSet<>());
if(!this.getServices().containsAll(entity.getServices())) {
this.getServices().removeAll(this.getServices());
this.getServices().addAll(entity.getServices());
}
this.setDmp(entity.getDmp());
this.setStatus(entity.getStatus()); this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile()); this.setProfile(entity.getProfile());
this.setModified(new Date()); this.setModified(new Date());
if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
if (entity.getCreator() != null) this.creator = entity.getCreator(); if (entity.getCreator() != null) this.creator = entity.getCreator();
} }
@ -320,4 +314,11 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Dataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,10 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -13,7 +14,7 @@ import java.util.UUID;
@Entity @Entity
@Table(name = "\"DatasetDataRepository\"") @Table(name = "\"DatasetDataRepository\"")
public class DatasetDataRepository implements DataEntity<DatasetDataRepository,UUID> { public class DatasetDataRepository implements DataEntity<DatasetDataRepository, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@ -32,7 +33,6 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,U
@Column(name = "\"Role\"") @Column(name = "\"Role\"")
private Integer role; private Integer role;
@Column(name = "\"Data\"") @Column(name = "\"Data\"")
private String data; private String data;
@ -87,4 +87,11 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,U
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetDataRepository buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,16 +1,17 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"DatasetExternalDataset\"") @Table(name = "\"DatasetExternalDataset\"")
public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset,UUID> { public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@ -18,7 +19,6 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false) @JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset; private Dataset dataset;
@ -85,4 +85,11 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetExternalDataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,19 +1,47 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"DatasetProfile\"") @Table(name = "\"DatasetProfile\"")
public class DatasetProfile implements DataEntity<DatasetProfile,UUID> { public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dataset Profile Status");
}
}
}
@Id @Id
@GeneratedValue @GeneratedValue
@ -31,108 +59,111 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition; private String definition;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created; private Date created;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@Column(name = "\"Description\"") @Column(name = "\"Description\"")
private String description; private String description;
@Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID groupId;
@Column(name = "\"Version\"", nullable = false)
private Short version;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPDatasetProfile\"",
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
)
private List<DMP> dmps;
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public Short getStatus() { public Short getStatus() {
return status; return status;
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = status; this.status = status;
} }
public Date getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(Date created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
public Date getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(Date modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { this.id = id;}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
public String getDefinition() { public String getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(String definition) {
this.definition = definition; this.definition = definition;
} }
public Set<Dataset> getDataset() { public Set<Dataset> getDataset() {
return dataset; return dataset;
} }
public void setDataset(Set<Dataset> dataset) { public void setDataset(Set<Dataset> dataset) {
this.dataset = dataset; this.dataset = dataset;
} }
public UUID getGroupId() { return groupId; }
public void setGroupId(UUID groupId) { this.groupId = groupId;}
public Short getVersion() { return version; }
public void setVersion(Short version) { this.version = version; }
@Override @Override
public String toString() { public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + "]"; return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
} }
@Override @Override
public void update(DatasetProfile entity) { public void update(DatasetProfile entity) {
} }
@Override @Override
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -3,10 +3,9 @@ package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -87,4 +86,11 @@ public class DatasetService implements DataEntity<DatasetService, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetService buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if(fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
return this;
}
} }

View File

@ -1,10 +1,13 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -14,8 +17,6 @@ import java.util.UUID;
public class ExternalDataset implements DataEntity<ExternalDataset,UUID> { public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
@Id @Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ -29,9 +30,11 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
private String reference; private String reference;
@Column(name = "\"Created\"", nullable = false) @Column(name = "\"Created\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created; private Date created;
@Column(name = "\"Modified\"", nullable = false) @Column(name = "\"Modified\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date modified; private Date modified;
@OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true)
@ -104,4 +107,11 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public ExternalDataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -0,0 +1,174 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"Funder\"")
public class Funder implements DataEntity<Funder, UUID> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return INACTIVE;
case 1:
return ACTIVE;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Funder Status");
}
}
}
public enum FunderType {
EXTERNAL(0), INTERNAL(1);
private Integer value;
FunderType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static FunderType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Grant Type");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Type\"")
private Integer type;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Override
public void update(Funder entity) {
this.label = entity.getLabel();
this.reference = entity.getReference();
this.definition = entity.getDefinition();
this.status = entity.getStatus();
this.created = entity.getCreated();
this.modified = new Date();
this.type = entity.getType();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Funder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -0,0 +1,301 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.*;
import java.util.stream.Collectors;
@Entity
@Table(name = "\"Grant\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "grantRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
),
@NamedEntityGraph(
name = "grantListingItem",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
)
})
public class Grant implements DataEntity<Grant, UUID> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return INACTIVE;
case 1:
return ACTIVE;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Grant Status");
}
}
}
public enum GrantType {
EXTERNAL(0), INTERNAL(1);
private Integer value;
private GrantType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static GrantType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Grant Type");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToMany(mappedBy = "grant")
private Set<DMP> dmps;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date startdate = null;
@Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date enddate = null;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Type\"")
private Integer type;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Content\"")
private Content content;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Funder\"")
private Funder funder;
public Grant() {
}
public Grant(Grant grant) {
this.id = grant.getId();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<DMP> getDmps() {
return dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public UserInfo getCreationUser() {
return creationUser;
}
public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Content getContent() {
return content;
}
public void setContent(Content content) {
this.content = content;
}
public Funder getFunder() {
return funder;
}
public void setFunder(Funder funder) {
this.funder = funder;
}
@Override
public void update(Grant entity) {
this.description = entity.getDescription();
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated();
this.definition = entity.getDefinition();
this.dmps = entity.getDmps();
this.startdate = entity.getStartdate();
this.enddate = entity.getEnddate();
this.modified = new Date();
this.uri = entity.getUri();
this.funder = entity.getFunder();
if (entity.getContent() != null) this.content = entity.getContent();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Grant buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "dmps"))
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this;
}
}

View File

@ -1,16 +1,18 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Invitation\"") @Table(name = "\"Invitation\"")
public class Invitation implements DataEntity<Invitation,UUID> { public class Invitation implements DataEntity<Invitation, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@ -104,4 +106,11 @@ public class Invitation implements DataEntity<Invitation,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Invitation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -0,0 +1,94 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"LoginConfirmationEmail\"")
public class LoginConfirmationEmail implements DataEntity<LoginConfirmationEmail, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false)
private UUID id;
@Column(name = "\"email\"", nullable = false)
private String email;
@Column(name = "\"isConfirmed\"", nullable = false)
private boolean isConfirmed;
@Column(name = "\"token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Column(name = "\"userId\"", nullable = false)
private UUID userId;
@Column(name = "\"expiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean getIsConfirmed() {
return isConfirmed;
}
public void setIsConfirmed(boolean confirmed) {
isConfirmed = confirmed;
}
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public Date getExpiresAt() {
return expiresAt;
}
public void setExpiresAt(Date expiresAt) {
this.expiresAt = expiresAt;
}
@Override
public void update(LoginConfirmationEmail entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public LoginConfirmationEmail buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -8,12 +9,18 @@ import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Organisation\"") @Table(name = "\"Organisation\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "organisationRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps")}
)
})
public class Organisation implements Serializable, DataEntity<Organisation,UUID> { public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
@Id @Id
@ -39,60 +46,49 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPOrganisation\"", @JoinTable(name = "\"DMPOrganisation\"",
joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}, joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")} inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
) )
private Set<DMP> dMPs; private Set<DMP> dmps;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
public Short getStatus() { public Short getStatus() {
return status; return status;
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = status; this.status = status;
} }
public Date getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(Date created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
public Date getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(Date modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { public void setId(UUID id) {
this.id = id; this.id = id;
} }
@ -100,7 +96,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
@ -108,7 +103,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
@ -116,7 +110,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getReference() { public String getReference() {
return reference; return reference;
} }
public void setReference(String reference) { public void setReference(String reference) {
this.reference = reference; this.reference = reference;
} }
@ -124,7 +117,6 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getUri() { public String getUri() {
return uri; return uri;
} }
public void setUri(String uri) { public void setUri(String uri) {
this.uri = uri; this.uri = uri;
} }
@ -132,20 +124,17 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public String getDefinition() { public String getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(String definition) {
this.definition = definition; this.definition = definition;
} }
public Set<DMP> getdMPs() { public Set<DMP> getDmps() {
return dMPs; return dmps;
} }
public void setDmps(Set<DMP> dmps) {
public void setdMPs(Set<DMP> dMPs) { this.dmps = dmps;
this.dMPs = dMPs;
} }
@Override @Override
public void update(Organisation entity) { public void update(Organisation entity) {
@ -155,4 +144,11 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Organisation buildFromTuple(List<Tuple> tuple,List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,30 +1,17 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.*;
import java.util.Set; import java.util.stream.Collectors;
import java.util.UUID;
@Entity @Entity
@Table(name = "\"Project\"") @Table(name = "\"Project\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "projectRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
),
@NamedEntityGraph(
name = "projectListingItem",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})
)
})
public class Project implements DataEntity<Project, UUID> { public class Project implements DataEntity<Project, UUID> {
public enum Status { public enum Status {
@ -32,7 +19,7 @@ public class Project implements DataEntity<Project, UUID> {
private short value; private short value;
private Status(short value) { Status(short value) {
this.value = value; this.value = value;
} }
@ -59,7 +46,7 @@ public class Project implements DataEntity<Project, UUID> {
private Integer value; private Integer value;
private ProjectType(Integer value) { ProjectType(Integer value) {
this.value = value; this.value = value;
} }
@ -85,18 +72,15 @@ public class Project implements DataEntity<Project, UUID> {
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@OneToMany(mappedBy = "project") @OneToMany(mappedBy = "project")
private Set<DMP> dmps; private Set<DMP> dmps;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference; private String reference;
@ -107,23 +91,21 @@ public class Project implements DataEntity<Project, UUID> {
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Column(name = "\"StartDate\"", nullable = false) @Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date startdate = null; private Date startdate = null;
@Column(name = "\"EndDate\"", nullable = false) @Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date enddate = null; private Date enddate = null;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"CreationUser\"", nullable = true) @JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser; private UserInfo creationUser;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; private Date created = null;
@ -140,71 +122,28 @@ public class Project implements DataEntity<Project, UUID> {
@JoinColumn(name = "\"Content\"") @JoinColumn(name = "\"Content\"")
private Content content; private Content content;
public String getDescription() { public Project() {
return description;
} }
public void setDescription(String description) { public Project(Project project) {this.id = project.getId();}
this.description = description;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { public void setId(UUID id) {
this.id = id; this.id = id;
} }
public Set<DMP> getDmps() {
return dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
@ -212,7 +151,6 @@ public class Project implements DataEntity<Project, UUID> {
public String getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
@ -220,7 +158,6 @@ public class Project implements DataEntity<Project, UUID> {
public String getReference() { public String getReference() {
return reference; return reference;
} }
public void setReference(String reference) { public void setReference(String reference) {
this.reference = reference; this.reference = reference;
} }
@ -228,7 +165,6 @@ public class Project implements DataEntity<Project, UUID> {
public String getUri() { public String getUri() {
return uri; return uri;
} }
public void setUri(String uri) { public void setUri(String uri) {
this.uri = uri; this.uri = uri;
} }
@ -236,32 +172,62 @@ public class Project implements DataEntity<Project, UUID> {
public String getDefinition() { public String getDefinition() {
return definition; return definition;
} }
public void setDefinition(String definition) { public void setDefinition(String definition) {
this.definition = definition; this.definition = definition;
} }
public Date getStartdate() {
public Set<DMP> getDmps() { return startdate;
return dmps; }
public void setStartdate(Date startdate) {
this.startdate = startdate;
} }
public void setDmps(Set<DMP> dmps) { public Date getEnddate() {
this.dmps = dmps; return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
} }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
return creationUser; return creationUser;
} }
public void setCreationUser(UserInfo creationUser) { public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser; this.creationUser = creationUser;
} }
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getType() { public Integer getType() {
return type; return type;
} }
public void setType(Integer type) { public void setType(Integer type) {
this.type = type; this.type = type;
} }
@ -269,7 +235,6 @@ public class Project implements DataEntity<Project, UUID> {
public Content getContent() { public Content getContent() {
return content; return content;
} }
public void setContent(Content content) { public void setContent(Content content) {
this.content = content; this.content = content;
} }
@ -282,14 +247,45 @@ public class Project implements DataEntity<Project, UUID> {
this.created = entity.getCreated(); this.created = entity.getCreated();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.dmps = entity.getDmps(); this.dmps = entity.getDmps();
this.startdate = entity.getStartdate();
this.enddate = entity.getEnddate(); this.enddate = entity.getEnddate();
this.modified = new Date(); this.modified = new Date();
this.uri = entity.getUri();
if (entity.getContent() != null) this.content = entity.getContent(); if (entity.getContent() != null) this.content = entity.getContent();
//this.creationUser = entity.getCreationUser(); //TODO }
public Project projectFromGrant(Grant grant) {
Project project = new Project();
project.setDescription(grant.getDescription());
project.setLabel(grant.getLabel());
project.setAbbreviation(grant.getAbbreviation());
project.setCreated(new Date());
project.setDefinition(grant.getDefinition());
project.setDmps(grant.getDmps());
project.setStartdate(grant.getStartdate());
project.setEnddate(grant.getEnddate());
project.setModified(new Date());
project.setUri(grant.getUri());
project.setContent(grant.getContent());
project.setReference(grant.getReference());
project.setStatus(grant.getStatus());
return project;
} }
@Override @Override
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "dmps"))
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this;
}
} }

View File

@ -1,24 +1,24 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Registry\"") @Table(name = "\"Registry\"")
public class Registry implements DataEntity<Registry,UUID> { public class Registry implements DataEntity<Registry, UUID> {
@Id @Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ -52,9 +52,11 @@ public class Registry implements DataEntity<Registry,UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -153,4 +155,11 @@ public class Registry implements DataEntity<Registry,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Registry buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,19 +1,22 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@Table(name = "\"Researcher\"") @Table(name = "\"Researcher\"")
public class Researcher implements DataEntity<Researcher,UUID> { public class Researcher implements DataEntity<Researcher, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@ -52,9 +55,11 @@ public class Researcher implements DataEntity<Researcher,UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -154,4 +159,11 @@ public class Researcher implements DataEntity<Researcher,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Researcher buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,12 +1,13 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -16,8 +17,6 @@ import java.util.UUID;
public class Service implements DataEntity<Service, UUID> { public class Service implements DataEntity<Service, UUID> {
@Id @Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ -48,9 +47,11 @@ public class Service implements DataEntity<Service, UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -149,4 +150,11 @@ public class Service implements DataEntity<Service, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Service buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
return this;
}
} }

View File

@ -1,9 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@ -94,4 +96,11 @@ public class UserDMP implements DataEntity<UserDMP, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserDMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,14 +1,13 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@Entity @Entity
@ -16,7 +15,7 @@ import java.util.UUID;
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
name = "userInfo", name = "userInfo",
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}) attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}),
}) })
public class UserInfo implements DataEntity<UserInfo, UUID> { public class UserInfo implements DataEntity<UserInfo, UUID> {
@ -44,10 +43,12 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
@Column(name = "created", nullable = false) @Column(name = "created", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "lastloggedin", nullable = true) @Column(name = "lastloggedin", nullable = true)
@Convert(converter = DateToUTCConverter.class)
private Date lastloggedin = null; private Date lastloggedin = null;
@ -177,4 +178,11 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserInfo buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,9 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -57,4 +59,11 @@ public class UserRole implements DataEntity<UserRole, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserRole buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,9 +1,12 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -20,10 +23,12 @@ public class UserToken implements DataEntity<UserToken, UUID> {
private UserInfo user; private UserInfo user;
@Column(name = "\"IssuedAt\"", nullable = false) @Column(name = "\"IssuedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date issuedAt = null; private Date issuedAt = null;
@Column(name = "\"ExpiresAt\"", nullable = false) @Column(name = "\"ExpiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt = null; private Date expiresAt = null;
public UUID getToken() { public UUID getToken() {
@ -67,4 +72,11 @@ public class UserToken implements DataEntity<UserToken, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.token; return this.token;
} }
@Override
public UserToken buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "token")) this.token = EntityBinder.fromTuple(tuple, currentBase + "token");
return this;
}
} }

View File

@ -0,0 +1,14 @@
package eu.eudat.data.entities.helpers;
import javax.persistence.Tuple;
import java.util.List;
public class EntityBinder {
public static <T> T fromTuple(List<Tuple> tuple, String path) {
try {
return (T) tuple.get(0).get(path);
}catch (IllegalArgumentException illegalArgument){
return null;
}
}
}

View File

@ -13,7 +13,7 @@ public class DatasetWizardAutocompleteRequest extends Query<DatasetWizardUserDmp
public QueryableList<DMP> applyCriteria() { public QueryableList<DMP> applyCriteria() {
QueryableList<DMP> query = this.getQuery().where((builder, root) -> builder.or(builder.equal(root.get("creator"), this.getCriteria().getUserInfo()), builder.isMember(this.getCriteria().getUserInfo(), root.get("users")))); QueryableList<DMP> query = this.getQuery().where((builder, root) -> builder.or(builder.equal(root.get("creator"), this.getCriteria().getUserInfo()), builder.isMember(this.getCriteria().getUserInfo(), root.get("users"))));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) { if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
} }
return query; return query;
} }

View File

@ -12,7 +12,7 @@ public class DatasetProfileAutocompleteRequest extends Query<DatasetProfileCrite
public QueryableList<DatasetProfile> applyCriteria() { public QueryableList<DatasetProfile> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery(); QueryableList<DatasetProfile> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }
} }

View File

@ -16,13 +16,15 @@ public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanC
public QueryableList<DMP> applyCriteria() { public QueryableList<DMP> applyCriteria() {
QueryableList<DMP> query = this.getQuery(); QueryableList<DMP> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getPeriodEnd() != null) if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd())); query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null) if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart())); query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getProjects() != null && !this.getCriteria().getProjects().isEmpty()) if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("project").in(this.getCriteria().getProjects()))); query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants())));
if (!this.getCriteria().getAllVersions()) if (!this.getCriteria().getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())

View File

@ -13,7 +13,7 @@ public class DataManagementPlanProfileCriteriaRequest extends Query<DataManageme
public QueryableList<DMPProfile> applyCriteria() { public QueryableList<DMPProfile> applyCriteria() {
QueryableList<DMPProfile> query = this.getQuery(); QueryableList<DMPProfile> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }
} }

View File

@ -0,0 +1,17 @@
package eu.eudat.data.query.items.item.funder;
import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList;
public class FunderCriteriaRequest extends Query<FunderCriteria, Funder> {
@Override
public QueryableList<Funder> applyCriteria() {
QueryableList<Funder> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
return query;
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.data.query.items.item.grant;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList;
public class GrantCriteriaRequest extends Query<GrantCriteria, Grant> {
private Integer length;
public Integer getLength() {
return length;
}
public void setLength(Integer length) {
this.length = length;
}
private GrantCriteriaRequest() {
}
@Override
public QueryableList<Grant> applyCriteria() {
QueryableList<Grant> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
return query;
}
}

View File

@ -5,23 +5,12 @@ import eu.eudat.data.entities.Project;
import eu.eudat.data.query.definition.Query; import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import java.util.UUID; public class ProjectCriteriaRequest extends Query<ProjectCriteria, Project> {
public class ProjectCriteriaRequest extends Query<ProjectCriteria,Project> {
private ProjectCriteriaRequest() {
}
@Override @Override
public QueryableList<Project> applyCriteria() { public QueryableList<Project> applyCriteria() {
QueryableList<Project> query = this.getQuery(); QueryableList<Project> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue())); query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query; return query;
} }

View File

@ -13,7 +13,7 @@ public class UserInfoRequestItem extends Query<UserInfoCriteria, UserInfo> {
if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty()) if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles())); users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles()));
if (this.getCriteria().getLike() != null) if (this.getCriteria().getLike() != null)
users.where((builder, root) -> builder.or(builder.like(root.get("name"), "%" + this.getCriteria().getLike() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%"))); users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%")));
if (this.getCriteria().getEmail() != null) if (this.getCriteria().getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail())); users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail()));
return users; return users;

View File

@ -0,0 +1,55 @@
package eu.eudat.data.query.items.table.dataset;
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
/**
* Created by ikalyvas on 10/2/2018.
*/
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, Dataset, UUID> {
@Override
public QueryableList<Dataset> applyCriteria() {
QueryableList<Dataset> query = this.getQuery();
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.<String>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 (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("dmp").get("grant").get("id").in(this.getCriteria().getGrants())));
if (this.getCriteria().getGrantStatus() != null) {
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
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 (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) {
query.where(((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds())));
}
if (this.getCriteria().getDatasetProfile() != null && !this.getCriteria().getDatasetProfile().isEmpty()) query
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().getDatasetProfile())));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
return query;
}
@Override
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
return null;
}
}

View File

@ -10,12 +10,14 @@ import eu.eudat.queryable.types.SelectionField;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
public class DatasetTableRequest extends TableQuery<DatasetCriteria, eu.eudat.data.entities.Dataset,UUID> { public class DatasetTableRequest extends TableQuery<DatasetCriteria, eu.eudat.data.entities.Dataset, UUID> {
@Override @Override
public QueryableList<Dataset> applyCriteria() { public QueryableList<Dataset> applyCriteria() {
QueryableList<Dataset> query = this.getQuery(); QueryableList<Dataset> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getStatus() != null) if (this.getCriteria().getStatus() != null)
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus())); query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
if (this.getCriteria().getPeriodEnd() != null) if (this.getCriteria().getPeriodEnd() != null)
@ -26,6 +28,7 @@ public class DatasetTableRequest extends TableQuery<DatasetCriteria, eu.eudat.da
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>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 (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty()) if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty())
query.where((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds())); query.where((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds()));
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED));
return query; return query;
} }

View File

@ -12,7 +12,7 @@ public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCri
public QueryableList<DatasetProfile> applyCriteria() { public QueryableList<DatasetProfile> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery(); QueryableList<DatasetProfile> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }

View File

@ -16,13 +16,15 @@ public class DataManagementPlanTableRequest extends TableQuery<DataManagementPla
public QueryableList<DMP> applyCriteria() { public QueryableList<DMP> applyCriteria() {
QueryableList<DMP> query = this.getQuery(); QueryableList<DMP> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getPeriodEnd() != null) if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd())); query.where((builder, root) -> builder.lessThan(root.get("created"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null) if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart())); query.where((builder, root) -> builder.greaterThan(root.get("created"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getProjects() != null && !this.getCriteria().getProjects().isEmpty()) if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("project").in(this.getCriteria().getProjects()))); query.where(((builder, root) -> root.get("grant").in(this.getCriteria().getGrants())));
if (!this.getCriteria().getAllVersions()) if (!this.getCriteria().getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())

View File

@ -0,0 +1,43 @@
package eu.eudat.data.query.items.table.dmp;
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.grant.GrantStateType;
import java.util.Date;
import java.util.UUID;
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DMP, UUID> {
public QueryableList<DMP> applyCriteria() {
QueryableList<DMP> query = this.getQuery();
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getGrants() != null && !this.getCriteria().getGrants().isEmpty())
query.where(((builder, root) -> root.get("grant").get("id").in(this.getCriteria().getGrants())));
if (this.getCriteria().getGrantStatus() != null) {
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.FINISHED.getValue()))
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
if (this.getCriteria().getGrantStatus().getValue().equals(GrantStateType.ONGOING.getValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate"))));
}
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty()) query
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
return query;
}
@Override
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -13,7 +13,7 @@ public class ExternalDatasetTableRequest extends TableQuery<ExternalDatasetCrite
public QueryableList<ExternalDataset> applyCriteria() { public QueryableList<ExternalDataset> applyCriteria() {
QueryableList<ExternalDataset> query = this.getQuery(); QueryableList<ExternalDataset> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query; return query;
} }

View File

@ -0,0 +1,32 @@
package eu.eudat.data.query.items.table.grant;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class GrantTableRequest extends TableQuery<GrantCriteria,Grant,UUID> {
@Override
public QueryableList<Grant> applyCriteria() {
QueryableList<Grant> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
builder.like(builder.upper(root.get("description")), "%" + this.getCriteria().getLike().toUpperCase() + "%")));
if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
return query;
}
@Override
public QueryableList<Grant> applyPaging(QueryableList<Grant> items) {
return null;
}
}

View File

@ -0,0 +1,25 @@
package eu.eudat.data.query.items.table.organisations;
import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.entities.Organisation;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class OrganisationsTableRequest extends TableQuery<OrganisationCriteria, Organisation, UUID> {
@Override
public QueryableList<Organisation> applyCriteria() {
QueryableList<Organisation> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
}
return query;
}
@Override
public QueryableList<Organisation> applyPaging(QueryableList<Organisation> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.data.query.items.table.project;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.entities.Project;
import eu.eudat.data.query.definition.Query;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class ProjectTableRequest extends TableQuery<ProjectCriteria,Project,UUID> {
@Override
public QueryableList<Project> applyCriteria() {
QueryableList<Project> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
if (this.getCriteria().getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), this.getCriteria().getPeriodEnd()));
if (this.getCriteria().getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), this.getCriteria().getPeriodStart()));
if (this.getCriteria().getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), this.getCriteria().getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query;
}
@Override
public QueryableList<Project> applyPaging(QueryableList<Project> items) {
return null;
}
}

View File

@ -16,7 +16,7 @@ public class UserInfoTableRequestItem extends TableQuery<UserInfoCriteria, UserI
if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty()) if (this.getCriteria().getAppRoles() != null && !this.getCriteria().getAppRoles().isEmpty())
users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles())); users.where((builder, root) -> root.join("userRoles").get("role").in(this.getCriteria().getAppRoles()));
if (this.getCriteria().getLike() != null) if (this.getCriteria().getLike() != null)
users.where((builder, root) -> builder.or(builder.like(root.get("name"), "%" + this.getCriteria().getLike() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%"))); users.where((builder, root) -> builder.or(builder.like(builder.upper(root.get("name")), "%" + this.getCriteria().getLike().toUpperCase() + "%"), builder.like(root.get("email"), "%" + this.getCriteria().getLike() + "%")));
if (this.getCriteria().getEmail() != null) if (this.getCriteria().getEmail() != null)
users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail())); users.where((builder, root) -> builder.equal(root.get("email"), this.getCriteria().getEmail()));
return users; return users;

View File

@ -0,0 +1,143 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.criteria.Subquery;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DMPQuery extends Query<DMP, UUID> {
private UUID id;
private UUID groupId;
private String label;
private int version;
private GrantQuery grantQuery;
private UserQuery userQuery;
private DatasetQuery datasetQuery;
private List<Integer> statuses;
private Date created;
private Date modified;
public DMPQuery(DatabaseAccessLayer<DMP, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public DMPQuery(DatabaseAccessLayer<DMP, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public GrantQuery getGrantQuery() {
return grantQuery;
}
public void setGrantQuery(GrantQuery grantQuery) {
this.grantQuery = grantQuery;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
statuses = statuses;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UserQuery getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQuery userQuery) {
this.userQuery = userQuery;
}
public DatasetQuery getDatasetQuery() {
return datasetQuery;
}
public void setDatasetQuery(DatasetQuery datasetQuery) {
this.datasetQuery = datasetQuery;
}
public QueryableList<DMP> getQuery() {
QueryableList<DMP> query = this.databaseAccessLayer.asQueryable();
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
if (this.grantQuery != null) {
Subquery<Grant> grantQuery = this.grantQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("grant").get("id").in(grantQuery));
}
if (this.getStatuses() != null && !this.getStatuses().isEmpty()) {
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
}
if (this.userQuery != null) {
Subquery<UserInfo> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
}
if(this.datasetQuery != null){
Subquery<Dataset> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id")));
query.where((builder, root) -> root.get("id").in(datasetSubQuery ));
}
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
query.withFields(this.getSelectionFields());
}
return query;
}
}

View File

@ -0,0 +1,7 @@
package eu.eudat.query;
import java.util.UUID;
public class DatasetProfileQuery {
}

View File

@ -0,0 +1,65 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.criteria.Subquery;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class DatasetQuery extends Query<Dataset, UUID> {
private UUID id;
private String label;
private DMPQuery dmpQuery;
public DatasetQuery(DatabaseAccessLayer<Dataset, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public DatasetQuery(DatabaseAccessLayer<Dataset, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public DMPQuery getDmpQuery() {
return dmpQuery;
}
public void setDmpQuery(DMPQuery dmpQuery) {
this.dmpQuery = dmpQuery;
}
@Override
public QueryableList<Dataset> getQuery() {
QueryableList<Dataset> query = this.databaseAccessLayer.asQueryable();
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
if (this.dmpQuery != null) {
Subquery<DMP> dmpSubQuery = this.dmpQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("dmp").get("id").in(dmpSubQuery));
}
return query;
}
}

View File

@ -0,0 +1,108 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.criteria.Subquery;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class GrantQuery extends Query<Grant, UUID> {
private UUID id;
private List<UUID> ids;
private String label;
private List<Integer> statuses;
private Date created;
private Date modified;
private UserQuery userQuery;
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public GrantQuery(DatabaseAccessLayer<Grant, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public List<UUID> getIds() {
return ids;
}
public void setIds(List<UUID> ids) {
this.ids = ids;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
statuses = statuses;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UserQuery getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQuery userQuery) {
this.userQuery = userQuery;
}
@Override
public QueryableList<Grant> getQuery() {
QueryableList<Grant> query = this.databaseAccessLayer.asQueryable();
if (this.id != null)
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
if (this.ids != null && !this.ids.isEmpty())
query.where((builder, root) -> root.get("id").in(this.ids));
if (this.getStatuses() != null && !this.getStatuses().isEmpty())
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
if (this.userQuery != null) {
Subquery<UserInfo> userInfoSubQuery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubQuery));
}
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
query.withFields(this.getSelectionFields());
}
return query;
}
}

View File

@ -0,0 +1,29 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.queryableentity.DataEntity;
import java.util.LinkedList;
import java.util.List;
public abstract class Query<T extends DataEntity, K> {
protected DatabaseAccessLayer<T, K> databaseAccessLayer;
private List<String> selectionFields = new LinkedList<>();
public Query(DatabaseAccessLayer<T, K> databaseAccessLayer, List<String> selectionFields) {
this.databaseAccessLayer = databaseAccessLayer;
this.selectionFields = selectionFields;
}
public Query(DatabaseAccessLayer<T, K> databaseAccessLayer) {
this.databaseAccessLayer = databaseAccessLayer;
}
public abstract QueryableList<T> getQuery();
protected List<String> getSelectionFields() {
return selectionFields;
}
}

View File

@ -0,0 +1,37 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import java.util.List;
import java.util.UUID;
public class UserQuery extends Query<UserInfo, UUID> {
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserQuery(DatabaseAccessLayer<UserInfo, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public UserQuery(DatabaseAccessLayer<UserInfo, UUID> databaseAccessLayer, List<String> selectionFields) {
super(databaseAccessLayer, selectionFields);
}
@Override
public QueryableList<UserInfo> getQuery() {
QueryableList<UserInfo> query = this.databaseAccessLayer.asQueryable();
if (this.id != null)
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
return query;
}
}

View File

@ -0,0 +1,29 @@
package eu.eudat.types.grant;
/**
* Created by ikalyvas on 8/24/2018.
*/
public enum GrantStateType {
ONGOING(0), FINISHED(1);
private Integer value;
private GrantStateType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static GrantStateType fromInteger(Integer value) {
switch (value) {
case 0:
return ONGOING;
case 1:
return FINISHED;
default:
throw new RuntimeException("Unsupported Grant State Type");
}
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dmp-backend</artifactId>
<groupId>eu.eudat</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>elastic</artifactId>
</project>

View File

@ -0,0 +1,7 @@
package eu.eudat.elastic.criteria;
/**
* Created by ikalyvas on 7/5/2018.
*/
public abstract class Criteria {
}

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