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,34 +2,13 @@ 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 String reference;
private Date periodEnd;
private String reference;
public Date getPeriodStart() { public String getReference() {
return periodStart; return reference;
} }
public void setReference(String reference) {
public void setPeriodStart(Date periodStart) { this.reference = reference;
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;
}
} }

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) if (criteria.getReference() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart())); query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
if (criteria.getReference() != null) query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference())); return query;
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue())); }
return query;
}
@Override public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
public Project createOrUpdate(Project item) { 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 getDatabaseService().createOrUpdate(item, Project.class); return query;
} }
@Override @Override
public Project find(UUID id) { public Project createOrUpdate(Project item) {
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); return this.getDatabaseService().createOrUpdate(item, Project.class);
} }
@Override @Override
public void delete(Project item) { public CompletableFuture<Project> createOrUpdateAsync(Project item) {
this.getDatabaseService().delete(item); return null;
} }
@Override @Override
public QueryableList<Project> asQueryable() { public Project find(UUID id) {
return this.getDatabaseService().getQueryable(Project.class); return this.getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) { @Override
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps", JoinType.LEFT).get("users")))).distinct(); public Project find(UUID id, String hint) {
return query; throw new UnsupportedOperationException();
} }
@Override @Override
public CompletableFuture<Project> createOrUpdateAsync(Project item) { public void delete(Project item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); throw new UnsupportedOperationException();
} }
@Override @Override
public Project find(UUID id, String hint) { public QueryableList<Project> asQueryable() {
throw new UnsupportedOperationException(); 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,59 +5,76 @@ 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;
@Component("userInfoDao") @Component("userInfoDao")
public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInfoDao { public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInfoDao {
@Autowired @Autowired
public UserInfoDaoImpl(DatabaseService<UserInfo> databaseService) { public UserInfoDaoImpl(DatabaseService<UserInfo> databaseService) {
super(databaseService); super(databaseService);
} }
@Override @Override
public QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria) { public QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria) {
QueryableList<UserInfo> users = this.getDatabaseService().getQueryable(UserInfo.class); QueryableList<UserInfo> users = this.getDatabaseService().getQueryable(UserInfo.class);
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()));
return users; 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 @Override
public UserInfo createOrUpdate(UserInfo item) { public QueryableList<UserInfo> getAuthenticated(QueryableList<UserInfo> users, UUID principalId) {
return this.getDatabaseService().createOrUpdate(item, UserInfo.class); 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;
}
@Override @Override
public UserInfo find(UUID id) { public UserInfo createOrUpdate(UserInfo item) {
return this.getDatabaseService().getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); return this.getDatabaseService().createOrUpdate(item, UserInfo.class);
} }
@Override @Override
public void delete(UserInfo item) { public UserInfo find(UUID id) {
this.getDatabaseService().delete(item); return this.getDatabaseService().getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }
@Override @Override
public QueryableList<UserInfo> asQueryable() { public void delete(UserInfo item) {
return this.getDatabaseService().getQueryable(UserInfo.class); this.getDatabaseService().delete(item);
} }
@Override @Override
public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) { public QueryableList<UserInfo> asQueryable() {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return this.getDatabaseService().getQueryable(UserInfo.class);
} }
@Override @Async
public UserInfo find(UUID id, String hint) { @Override
throw new UnsupportedOperationException(); public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) {
} return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserInfo find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
} }

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;
/** /**
@ -13,134 +15,141 @@ import java.util.UUID;
@Table(name = "\"Content\"") @Table(name = "\"Content\"")
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;
private ParentType(int value) { private ParentType(int value) {
this.value = value; this.value = value;
} }
public int getValue() { public int getValue() {
return value; return value;
} }
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");
} }
} }
} }
public enum LocationType { public enum LocationType {
EXTERNAL(0), INTERNAL(1); EXTERNAL(0), INTERNAL(1);
private Integer value; private Integer value;
private LocationType(Integer value) { private LocationType(Integer value) {
this.value = value; this.value = value;
} }
public Integer getValue() { public Integer getValue() {
return value; return value;
} }
public static LocationType fromInteger(int value) { public static LocationType fromInteger(int value) {
switch (value) { switch (value) {
case 0: case 0:
return EXTERNAL; return EXTERNAL;
case 1: case 1:
return INTERNAL; return INTERNAL;
default: default:
throw new RuntimeException("Unsupported Content Location Type"); throw new RuntimeException("Unsupported Content Location Type");
} }
} }
} }
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@Column(name = "\"Filename\"", nullable = false) @Column(name = "\"Filename\"", nullable = false)
private String label; private String label;
@Column(name = "\"Extension\"", nullable = false) @Column(name = "\"Extension\"", nullable = false)
private String extension; private String extension;
@Column(name = "\"ParentType\"", nullable = false) @Column(name = "\"ParentType\"", nullable = false)
private Integer parentType; private Integer parentType;
@Column(name = "\"Uri\"", nullable = false) @Column(name = "\"Uri\"", nullable = false)
private String uri; private String uri;
@Column(name = "\"LocationType\"", nullable = false) @Column(name = "\"LocationType\"", nullable = false)
private Integer locationType; private Integer locationType;
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 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 getExtension() { public String getExtension() {
return extension; return extension;
} }
public void setExtension(String extension) { public void setExtension(String extension) {
this.extension = extension; this.extension = extension;
} }
public Integer getParentType() { public Integer getParentType() {
return parentType; return parentType;
} }
public void setParentType(Integer parentType) { public void setParentType(Integer parentType) {
this.parentType = parentType; this.parentType = parentType;
} }
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;
} }
public Integer getLocationType() { public Integer getLocationType() {
return locationType; return locationType;
} }
public void setLocationType(Integer locationType) { public void setLocationType(Integer locationType) {
this.locationType = locationType; this.locationType = locationType;
} }
@Override @Override
public void update(Content entity) { public void update(Content entity) {
this.extension = entity.getExtension(); this.extension = entity.getExtension();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.locationType = entity.getLocationType(); this.locationType = entity.getLocationType();
this.parentType = entity.getParentType(); this.parentType = entity.getParentType();
this.uri = entity.getUri(); this.uri = entity.getUri();
} }
@Override @Override
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,143 +1,157 @@
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;
@Entity @Entity
@Table(name = "\"Credential\"") @Table(name = "\"Credential\"")
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
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)")
private UUID id; private UUID id;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"UserId\"", nullable = false) @JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo; private UserInfo userInfo;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Integer status; private Integer status;
@Column(name = "\"Provider\"", nullable = false) @Column(name = "\"Provider\"", nullable = false)
private Integer provider; private Integer provider;
@Column(name = "\"Public\"", nullable = false) @Column(name = "\"Public\"", nullable = false)
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)
private Date creationTime;
@Column(name = "\"LastUpdateTime\"", nullable = false)
private Date lastUpdateTime;
@Column(name = "\"ExternalId\"", nullable = false) @Column(name = "\"CreationTime\"", nullable = false)
private String externalId; @Convert(converter = DateToUTCConverter.class)
private Date creationTime;
public UUID getId() { @Column(name = "\"LastUpdateTime\"", nullable = false)
return id; @Convert(converter = DateToUTCConverter.class)
} private Date lastUpdateTime;
public void setId(UUID id) { @Column(name = "\"ExternalId\"", nullable = false)
this.id = id; private String externalId;
}
public UserInfo getUserInfo() { public UUID getId() {
return userInfo; return id;
} }
public void setUserInfo(UserInfo userInfo) { public void setId(UUID id) {
this.userInfo = userInfo; this.id = id;
} }
public Integer getStatus() { public UserInfo getUserInfo() {
return status; return userInfo;
} }
public void setStatus(Integer status) { public void setUserInfo(UserInfo userInfo) {
this.status = status; this.userInfo = userInfo;
} }
public Integer getProvider() { public Integer getStatus() {
return provider; return status;
} }
public void setProvider(Integer provider) { public void setStatus(Integer status) {
this.provider = provider; this.status = status;
} }
public String getPublicValue() { public Integer getProvider() {
return publicValue; return provider;
} }
public void setPublicValue(String publicValue) { public void setProvider(Integer provider) {
this.publicValue = publicValue; this.provider = provider;
} }
public String getSecret() { public String getPublicValue() {
return secret; return publicValue;
} }
public void setSecret(String secret) { public void setPublicValue(String publicValue) {
this.secret = secret; this.publicValue = publicValue;
} }
public Date getCreationTime() { public String getSecret() {
return creationTime; return secret;
} }
public void setCreationTime(Date creationTime) { public void setSecret(String secret) {
this.creationTime = creationTime; this.secret = secret;
} }
public Date getLastUpdateTime() { public Date getCreationTime() {
return lastUpdateTime; return creationTime;
} }
public void setLastUpdateTime(Date lastUpdateTime) { public void setCreationTime(Date creationTime) {
this.lastUpdateTime = lastUpdateTime; this.creationTime = creationTime;
} }
public String getExternalId() { public Date getLastUpdateTime() {
return externalId; return lastUpdateTime;
} }
public void setExternalId(String externalId) { public void setLastUpdateTime(Date lastUpdateTime) {
this.externalId = externalId; this.lastUpdateTime = lastUpdateTime;
} }
@Override public String getExternalId() {
public boolean equals(Object o) { return externalId;
if (this == o) return true; }
if (o == null || getClass() != o.getClass()) return false;
Credential that = (Credential) o; public void setExternalId(String externalId) {
this.externalId = externalId;
}
return provider.intValue() == that.provider.intValue(); @Override
} public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override Credential that = (Credential) o;
public int hashCode() {
return provider.intValue();
}
@Override return provider.intValue() == that.provider.intValue();
public void update(Credential entity) { }
this.status = entity.status;
this.publicValue = entity.getPublicValue();
this.secret = entity.getSecret();
this.lastUpdateTime = new Date();
}
@Override @Override
public UUID getKeys() { public int hashCode() {
return this.id; return provider.intValue();
} }
@Override
public void update(Credential entity) {
this.status = entity.status;
this.publicValue = entity.getPublicValue();
this.secret = entity.getSecret();
this.lastUpdateTime = new Date();
}
@Override
public UUID getKeys() {
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,143 +9,151 @@ 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
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Column(name = "\"Reference\"", nullable = false) @Column(name = "\"Reference\"", nullable = false)
private String reference; private String reference;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories; private Set<DatasetDataRepository> datasetDataRepositories;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
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;
} }
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 getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
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;
} }
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;
} }
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<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;
} }
@Override @Override
public void update(DataRepository entity) { public void update(DataRepository entity) {
} }
@Override @Override
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;
@ -12,312 +14,311 @@ import java.util.stream.Collectors;
@Entity @Entity
@Table(name = "\"Dataset\"") @Table(name = "\"Dataset\"")
@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 = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}, @NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})), @NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
@NamedEntityGraph( subgraphs = {
name = "datasetWizardModel", @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"), @NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}), @NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
@NamedEntityGraph( }),
name = "datasetRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")}, @NamedEntityGraph(
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})) name = "datasetWizardModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
@NamedEntityGraph(
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")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}))
}) })
public class Dataset implements DataEntity<Dataset, UUID> { public class Dataset implements DataEntity<Dataset, UUID> {
public static Set<String> getHints() { public static Set<String> getHints() {
return hints; return hints;
} }
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;
private Status(short value) { private Status(short value) {
this.value = value; this.value = value;
} }
public short getValue() { public short getValue() {
return value; return value;
} }
public static Status fromInteger(int value) { public static Status fromInteger(int value) {
switch (value) { switch (value) {
case 0: case 0:
return SAVED; return SAVED;
case 1: case 1:
return FINALISED; return FINALISED;
default: case 2:
throw new RuntimeException("Unsupported Project Status"); return CANCELED;
} case 99:
} return DELETED;
} default:
throw new RuntimeException("Unsupported Dataset Status");
}
}
}
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@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\"")
private String uri;
@Column(name = "\"Uri\"") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
private String uri; @Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @ManyToOne(fetch = FetchType.LAZY)
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true) //@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
private String properties; @JoinColumn(name = "\"Profile\"", nullable = true)
private DatasetProfile profile;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@ManyToOne(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL) @JoinTable(name = "\"DatasetRegistry\"",
@JoinColumn(name = "\"Profile\"", nullable = true) joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
private DatasetProfile profile; inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
)
private Set<Registry> registries;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true) private Set<DatasetService> services;
private String reference;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetExternalDataset> datasetExternalDatasets;
@OneToMany(fetch = FetchType.LAZY) @Column(name = "\"Status\"", nullable = false)
@JoinTable(name = "\"DatasetRegistry\"", private Short status;
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
)
private Set<Registry> registries;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @Column(name = "\"Created\"")
private Set<DatasetDataRepository> datasetDataRepositories; @Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @ManyToOne(fetch = FetchType.LAZY)
private Set<DatasetService> services; @JoinColumn(name = "\"Creator\"", nullable = true)
private UserInfo creator;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true) @Column(name = "\"Description\"")
private Set<DatasetExternalDataset> datasetExternalDatasets; private String description;
@Column(name= "\"FinalizedAt\"")
@Convert(converter = DateToUTCConverter.class)
private Date finalizedAt;
@Column(name = "\"Status\"", nullable = false) public String getDescription() {
private Short status; return description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name = "\"IsPublic\"", nullable = false) public UserInfo getCreator() {
private boolean isPublic; return creator;
}
@Column(name = "\"Created\"") public void setCreator(UserInfo creator) {
private Date created = null; this.creator = creator;
}
@Column(name = "\"Modified\"")
private Date modified = new Date(); public Short getStatus() {
return status;
@ManyToOne(fetch = FetchType.LAZY) }
@JoinColumn(name = "\"Creator\"", nullable = true) public void setStatus(Short status) {
private UserInfo creator; this.status = status;
}
@Column(name = "\"Description\"")
private String description;
public Date getCreated() {
return created;
public String getDescription() { }
return description; public void setCreated(Date created) {
} this.created = created;
}
public void setDescription(String description) {
this.description = description;
} public Date getModified() {
return modified;
}
public UserInfo getCreator() { public void setModified(Date modified) {
return creator; this.modified = modified;
} }
public void setCreator(UserInfo creator) {
this.creator = creator; public Set<Registry> getRegistries() {
} return registries;
}
public Short getStatus() { public void setRegistries(Set<Registry> registries) {
return status; this.registries = registries;
} }
public Set<DatasetService> getServices() {
public void setStatus(Short status) { return services;
this.status = status; }
} public void setServices(Set<DatasetService> services) {
this.services = services;
}
public Date getCreated() {
return created; public UUID getId() {
} return id;
}
public void setId(UUID id) {
public void setCreated(Date created) { this.id = id;
this.created = created; }
}
public String getLabel() {
public Date getModified() { return label;
return modified; }
} public void setLabel(String label) {
this.label = label;
}
public void setModified(Date modified) {
this.modified = modified;
} public DMP getDmp() {
return dmp;
}
public Set<Registry> getRegistries() { public void setDmp(DMP dmp) {
return registries; this.dmp = dmp;
} }
public void setRegistries(Set<Registry> registries) { public String getUri() {
this.registries = registries; return uri;
} }
public void setUri(String uri) {
public Set<DatasetService> getServices() { this.uri = uri;
return services; }
}
public void setServices(Set<DatasetService> services) { public String getProperties() {
this.services = services; return properties;
} }
public void setProperties(String properties) {
public UUID getId() { this.properties = properties;
return id; }
}
public DatasetProfile getProfile() {
public void setId(UUID id) { return profile;
this.id = id; }
} public void setProfile(DatasetProfile profile) {
this.profile = profile;
}
public String getLabel() {
return label;
} public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories;
}
public void setLabel(String label) { public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.label = label; this.datasetDataRepositories = datasetDataRepositories;
} }
public String getReference() {
public DMP getDmp() { return reference;
return dmp; }
} public void setReference(String reference) {
this.reference = reference;
}
public void setDmp(DMP dmp) {
this.dmp = dmp; public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
} return datasetExternalDatasets;
}
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
public String getUri() { this.datasetExternalDatasets = datasetExternalDatasets;
return uri; }
}
public Date getFinalizedAt() {
return finalizedAt;
public void setUri(String uri) { }
this.uri = uri; public void setFinalizedAt(Date finalizedAt) {
} this.finalizedAt = finalizedAt;
}
public String getProperties() { @Override
return properties; public void update(Dataset entity) {
} this.setRegistries(entity.getRegistries());
if (this.getDatasetDataRepositories() == null) this.setDatasetDataRepositories(new HashSet<>());
if (!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())) {
public void setProperties(String properties) { this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
this.properties = properties; this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item -> {
} item.setDataset(this);
return item;
}).collect(Collectors.toList()));
public DatasetProfile getProfile() { }
return profile; this.setUri(entity.getUri());
} this.setDescription(entity.getDescription());
this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties());
public void setProfile(DatasetProfile profile) { if (this.getDatasetExternalDatasets() == null) this.setDatasetExternalDatasets(new HashSet<>());
this.profile = profile; if (!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) {
} this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
item.setDataset(this);
public Set<DatasetDataRepository> getDatasetDataRepositories() { return item;
return datasetDataRepositories; }).collect(Collectors.toList()));
} }
if (this.getServices() == null) this.setServices(new HashSet<>());
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) { if(!this.getServices().containsAll(entity.getServices())) {
this.datasetDataRepositories = datasetDataRepositories; this.getServices().removeAll(this.getServices());
} this.getServices().addAll(entity.getServices());
}
public String getReference() { this.setDmp(entity.getDmp());
return reference; this.setStatus(entity.getStatus());
} this.setProfile(entity.getProfile());
this.setModified(new Date());
if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
public void setReference(String reference) { if (entity.getCreator() != null) this.creator = entity.getCreator();
this.reference = reference; }
}
@Override
public Set<DatasetExternalDataset> getDatasetExternalDatasets() { public UUID getKeys() {
return datasetExternalDatasets; return this.id;
} }
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) { @Override
this.datasetExternalDatasets = datasetExternalDatasets; 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");
public boolean isPublic() { return this;
return isPublic; }
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
@Override
public void update(Dataset entity) {
this.setRegistries(entity.getRegistries());
if(this.getDatasetDataRepositories()==null) this.setDatasetDataRepositories(new HashSet<>());
if(!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())){
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item->{
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setDescription(entity.getDescription());
this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties());
if(this.getDatasetExternalDatasets()==null) this.setDatasetExternalDatasets(new HashSet<>());
if(!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) {
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile());
this.setModified(new Date());
if (entity.getCreator() != null) this.creator = entity.getCreator();
}
@Override
public UUID getKeys() {
return this.id;
}
} }

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,78 +14,84 @@ 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
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false) @JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset; private Dataset dataset;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"DataRepository\"", nullable = false) @JoinColumn(name = "\"DataRepository\"", nullable = false)
private DataRepository dataRepository; private DataRepository dataRepository;
@Column(name = "\"Role\"") @Column(name = "\"Role\"")
private Integer role; private Integer role;
@Column(name = "\"Data\"")
private String data;
@Column(name = "\"Data\"") public UUID getId() {
private String data; return id;
}
public UUID getId() { public void setId(UUID id) {
return id; this.id = id;
} }
public void setId(UUID id) { public Dataset getDataset() {
this.id = id; return dataset;
} }
public Dataset getDataset() { public void setDataset(Dataset dataset) {
return dataset; this.dataset = dataset;
} }
public void setDataset(Dataset dataset) { public DataRepository getDataRepository() {
this.dataset = dataset; return dataRepository;
} }
public DataRepository getDataRepository() { public void setDataRepository(DataRepository dataRepository) {
return dataRepository; this.dataRepository = dataRepository;
} }
public void setDataRepository(DataRepository dataRepository) { public Integer getRole() {
this.dataRepository = dataRepository; return role;
} }
public Integer getRole() { public void setRole(Integer role) {
return role; this.role = role;
} }
public void setRole(Integer role) { public String getData() {
this.role = role; return data;
} }
public String getData() { public void setData(String data) {
return data; this.data = data;
} }
public void setData(String data) { @Override
this.data = data; public void update(DatasetDataRepository entity) {
} this.dataset = entity.getDataset();
this.dataRepository = entity.getDataRepository();
this.role = entity.getRole();
}
@Override @Override
public void update(DatasetDataRepository entity) { public UUID getKeys() {
this.dataset = entity.getDataset(); return this.id;
this.dataRepository = entity.getDataRepository(); }
this.role = entity.getRole();
}
@Override @Override
public UUID getKeys() { public DatasetDataRepository buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return this.id; String currentBase = base.isEmpty() ? "" : base + ".";
} if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
} }

View File

@ -1,88 +1,95 @@
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
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
private ExternalDataset externalDataset;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Data\"")
private String data;
@ManyToOne public UUID getId() {
@JoinColumn(name = "\"Dataset\"", nullable = false) return id;
private Dataset dataset; }
@ManyToOne public void setId(UUID id) {
@JoinColumn(name = "\"ExternalDataset\"", nullable = false) this.id = id;
private ExternalDataset externalDataset; }
@Column(name = "\"Role\"") public Dataset getDataset() {
private Integer role; return dataset;
}
@Column(name = "\"Data\"") public void setDataset(Dataset dataset) {
private String data; this.dataset = dataset;
}
public ExternalDataset getExternalDataset() {
return externalDataset;
}
public UUID getId() { public void setExternalDataset(ExternalDataset externalDataset) {
return id; this.externalDataset = externalDataset;
} }
public void setId(UUID id) { public Integer getRole() {
this.id = id; return role;
} }
public Dataset getDataset() { public void setRole(Integer role) {
return dataset; this.role = role;
} }
public void setDataset(Dataset dataset) { public String getData() {
this.dataset = dataset; return data;
} }
public ExternalDataset getExternalDataset() { public void setData(String data) {
return externalDataset; this.data = data;
} }
public void setExternalDataset(ExternalDataset externalDataset) { @Override
this.externalDataset = externalDataset; public void update(DatasetExternalDataset entity) {
} this.dataset = entity.getDataset();
this.externalDataset = entity.getExternalDataset();
this.role = entity.getRole();
}
public Integer getRole() { @Override
return role; public UUID getKeys() {
} return this.id;
}
public void setRole(Integer role) { @Override
this.role = role; 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");
public String getData() { return this;
return data; }
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DatasetExternalDataset entity) {
this.dataset = entity.getDataset();
this.externalDataset = entity.getExternalDataset();
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
} }

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;
@ -14,77 +13,84 @@ import java.util.UUID;
@Table(name = "\"DatasetService\"") @Table(name = "\"DatasetService\"")
public class DatasetService implements DataEntity<DatasetService, UUID> { public class DatasetService implements DataEntity<DatasetService, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false) @JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset; private Dataset dataset;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"Service\"", nullable = false) @JoinColumn(name = "\"Service\"", nullable = false)
private Service service; private Service service;
@Column(name = "\"Role\"") @Column(name = "\"Role\"")
private Integer role; private Integer role;
@Column(name = "\"Data\"") @Column(name = "\"Data\"")
private String data; private String data;
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 Dataset getDataset() { public Dataset getDataset() {
return dataset; return dataset;
} }
public void setDataset(Dataset dataset) { public void setDataset(Dataset dataset) {
this.dataset = dataset; this.dataset = dataset;
} }
public Service getService() { public Service getService() {
return service; return service;
} }
public void setService(Service service) { public void setService(Service service) {
this.service = service; this.service = service;
} }
public Integer getRole() { public Integer getRole() {
return role; return role;
} }
public void setRole(Integer role) { public void setRole(Integer role) {
this.role = role; this.role = role;
} }
public String getData() { public String getData() {
return data; return data;
} }
public void setData(String data) { public void setData(String data) {
this.data = data; this.data = data;
} }
@Override @Override
public void update(DatasetService entity) { public void update(DatasetService entity) {
this.dataset = entity.getDataset(); this.dataset = entity.getDataset();
this.service = entity.getService(); this.service = entity.getService();
this.role = entity.getRole(); this.role = entity.getRole();
} }
@Override @Override
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,107 +1,116 @@
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
@GenericGenerator(name = "uuid2", strategy = "uuid2") @GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false) @Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id; private UUID id;
@Column(name = "\"InvitationEmail\"", nullable = false) @Column(name = "\"InvitationEmail\"", nullable = false)
private String invitationEmail; private String invitationEmail;
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = false) @JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserInfo user; private UserInfo user;
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Dmp\"", nullable = false) @JoinColumn(name = "\"Dmp\"", nullable = false)
private DMP dmp; private DMP dmp;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token; private UUID token;
@Column(name = "\"AcceptedInvitation\"", nullable = false) @Column(name = "\"AcceptedInvitation\"", nullable = false)
private boolean acceptedInvitation; private boolean acceptedInvitation;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties; private String properties;
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 String getInvitationEmail() { public String getInvitationEmail() {
return invitationEmail; return invitationEmail;
} }
public void setInvitationEmail(String invitationEmail) { public void setInvitationEmail(String invitationEmail) {
this.invitationEmail = invitationEmail; this.invitationEmail = invitationEmail;
} }
public UserInfo getUser() { public UserInfo getUser() {
return user; return user;
} }
public void setUser(UserInfo user) { public void setUser(UserInfo user) {
this.user = user; this.user = user;
} }
public DMP getDmp() { public DMP getDmp() {
return dmp; return dmp;
} }
public void setDmp(DMP dmp) { public void setDmp(DMP dmp) {
this.dmp = dmp; this.dmp = dmp;
} }
public UUID getToken() { public UUID getToken() {
return token; return token;
} }
public void setToken(UUID token) { public void setToken(UUID token) {
this.token = token; this.token = token;
} }
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;
} }
public boolean getAcceptedInvitation() { public boolean getAcceptedInvitation() {
return acceptedInvitation; return acceptedInvitation;
} }
public void setAcceptedInvitation(boolean acceptedInvitation) { public void setAcceptedInvitation(boolean acceptedInvitation) {
this.acceptedInvitation = acceptedInvitation; this.acceptedInvitation = acceptedInvitation;
} }
@Override @Override
public void update(Invitation entity) { public void update(Invitation entity) {
} }
@Override @Override
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,295 +1,291 @@
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 {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99); ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
private short value; public static Status fromInteger(int value) {
switch (value) {
private Status(short value) { case 0:
this.value = value; return INACTIVE;
} case 1:
return ACTIVE;
public short getValue() { case 99:
return value; return DELETED;
} default:
throw new RuntimeException("Unsupported Project Status");
public static Status fromInteger(int value) { }
switch (value) { }
case 0: }
return INACTIVE;
case 1: public enum ProjectType {
return ACTIVE; EXTERNAL(0), INTERNAL(1);
case 99:
return DELETED; private Integer value;
default:
throw new RuntimeException("Unsupported Project Status"); ProjectType(Integer value) {
} this.value = value;
} }
}
public Integer getValue() {
public enum ProjectType { return value;
EXTERNAL(0), INTERNAL(1); }
private Integer value; public static ProjectType fromInteger(int value) {
switch (value) {
private ProjectType(Integer value) { case 0:
this.value = value; return EXTERNAL;
} case 1:
return INTERNAL;
public Integer getValue() { default:
return value; throw new RuntimeException("Unsupported Project Type");
} }
}
public static ProjectType fromInteger(int value) { }
switch (value) {
case 0: @Id
return EXTERNAL; @GeneratedValue
case 1: @GenericGenerator(name = "uuid2", strategy = "uuid2")
return INTERNAL; @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
default: private UUID id;
throw new RuntimeException("Unsupported Project Type");
} @OneToMany(mappedBy = "project")
} private Set<DMP> dmps;
}
@Column(name = "\"Label\"")
@Id private String label;
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @Column(name = "\"Abbreviation\"")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") private String abbreviation;
private UUID id;
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@OneToMany(mappedBy = "project")
private Set<DMP> dmps; @Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Label\"") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
private String label; @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Column(name = "\"Abbreviation\"")
private String abbreviation; @Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") private Date startdate = null;
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference; @Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
@Column(name = "\"Uri\"") private Date enddate = null;
private String uri;
@Column(name = "\"Status\"", nullable = false)
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") private Short status;
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser;
@Column(name = "\"StartDate\"", nullable = false)
private Date startdate = null; @Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"EndDate\"", nullable = false)
private Date enddate = null; @Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Description\"")
private Short status; private String description;
@Column(name = "\"Type\"")
@ManyToOne(fetch = FetchType.LAZY) private Integer type;
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser; @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Content\"")
private Content content;
@Column(name = "\"Created\"")
private Date created = null; public Project() {
}
@Column(name = "\"Modified\"")
private Date modified = new Date(); public Project(Project project) {this.id = project.getId();}
@Column(name = "\"Description\"") public UUID getId() {
private String description; return id;
}
@Column(name = "\"Type\"") public void setId(UUID id) {
private Integer type; this.id = id;
}
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Content\"") public Set<DMP> getDmps() {
private Content content; return dmps;
}
public String getDescription() { public void setDmps(Set<DMP> dmps) {
return description; this.dmps = dmps;
} }
public void setDescription(String description) { public String getLabel() {
this.description = description; return label;
} }
public void setLabel(String label) {
this.label = label;
public Short getStatus() { }
return status;
} public String getAbbreviation() {
return abbreviation;
}
public void setStatus(Short status) { public void setAbbreviation(String abbreviation) {
this.status = status; this.abbreviation = abbreviation;
} }
public String getReference() {
public Date getCreated() { return reference;
return created; }
} public void setReference(String reference) {
this.reference = reference;
}
public void setCreated(Date created) {
this.created = created; public String getUri() {
} return uri;
}
public void setUri(String uri) {
public Date getModified() { this.uri = uri;
return modified; }
}
public String getDefinition() {
public void setModified(Date modified) { return definition;
this.modified = modified; }
} public void setDefinition(String definition) {
this.definition = definition;
public Date getStartdate() { }
return startdate;
} public Date getStartdate() {
return startdate;
public void setStartdate(Date startdate) { }
this.startdate = startdate; public void setStartdate(Date startdate) {
} this.startdate = startdate;
}
public Date getEnddate() {
return enddate; public Date getEnddate() {
} return enddate;
}
public void setEnddate(Date enddate) { public void setEnddate(Date enddate) {
this.enddate = enddate; this.enddate = enddate;
} }
public UUID getId() { public Short getStatus() {
return id; return status;
} }
public void setStatus(Short status) {
public void setId(UUID id) { this.status = status;
this.id = id; }
}
public UserInfo getCreationUser() {
public String getLabel() { return creationUser;
return label; }
} public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
public void setLabel(String label) { }
this.label = label;
} public Date getCreated() {
return created;
public String getAbbreviation() { }
return abbreviation; public void setCreated(Date created) {
} this.created = created;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; public Date getModified() {
} return modified;
}
public String getReference() { public void setModified(Date modified) {
return reference; this.modified = modified;
} }
public void setReference(String reference) { public String getDescription() {
this.reference = reference; return description;
} }
public void setDescription(String description) {
public String getUri() { this.description = description;
return uri; }
}
public Integer getType() {
public void setUri(String uri) { return type;
this.uri = uri; }
} public void setType(Integer type) {
this.type = type;
public String getDefinition() { }
return definition;
} public Content getContent() {
return content;
public void setDefinition(String definition) { }
this.definition = definition; public void setContent(Content content) {
} this.content = content;
}
public Set<DMP> getDmps() { @Override
return dmps; public void update(Project entity) {
} this.description = entity.getDescription();
this.label = entity.getLabel();
public void setDmps(Set<DMP> dmps) { this.abbreviation = entity.getAbbreviation();
this.dmps = dmps; this.created = entity.getCreated();
} this.definition = entity.getDefinition();
this.dmps = entity.getDmps();
public UserInfo getCreationUser() { this.startdate = entity.getStartdate();
return creationUser; this.enddate = entity.getEnddate();
} this.modified = new Date();
this.uri = entity.getUri();
public void setCreationUser(UserInfo creationUser) { if (entity.getContent() != null) this.content = entity.getContent();
this.creationUser = creationUser; }
}
public Project projectFromGrant(Grant grant) {
public Integer getType() { Project project = new Project();
return type; project.setDescription(grant.getDescription());
} project.setLabel(grant.getLabel());
project.setAbbreviation(grant.getAbbreviation());
public void setType(Integer type) { project.setCreated(new Date());
this.type = type; project.setDefinition(grant.getDefinition());
} project.setDmps(grant.getDmps());
project.setStartdate(grant.getStartdate());
public Content getContent() { project.setEnddate(grant.getEnddate());
return content; project.setModified(new Date());
} project.setUri(grant.getUri());
project.setContent(grant.getContent());
public void setContent(Content content) { project.setReference(grant.getReference());
this.content = content; project.setStatus(grant.getStatus());
}
return project;
@Override }
public void update(Project entity) {
this.description = entity.getDescription(); @Override
this.label = entity.getLabel(); public UUID getKeys() {
this.abbreviation = entity.getAbbreviation(); return this.id;
this.created = entity.getCreated(); }
this.definition = entity.getDefinition();
this.dmps = entity.getDmps(); @Override
this.enddate = entity.getEnddate(); public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.modified = new Date(); String currentBase = base.isEmpty() ? "" : base + ".";
if (entity.getContent() != null) this.content = entity.getContent(); if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
//this.creationUser = entity.getCreationUser(); //TODO 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"))
@Override this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
public UUID getKeys() { return this;
return this.id; }
}
} }

View File

@ -1,156 +1,165 @@
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 @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@GenericGenerator(name = "uuid2", strategy = "uuid2") private UUID id;
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Column(name = "\"Reference\"", nullable = true) @Column(name = "\"Reference\"", nullable = true)
private String reference; private String reference;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@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 = "\"DatasetRegistry\"", @JoinTable(name = "\"DatasetRegistry\"",
joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}, joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")} inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
) )
private Set<Dataset> datasets; private Set<Dataset> datasets;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; @Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
private Date modified = new Date(); @Convert(converter = DateToUTCConverter.class)
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;
} }
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 getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
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;
} }
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;
} }
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> getDatasets() { public Set<Dataset> getDatasets() {
return datasets; return datasets;
} }
public void setDatasets(Set<Dataset> datasets) { public void setDatasets(Set<Dataset> datasets) {
this.datasets = datasets; this.datasets = datasets;
} }
@Override @Override
public void update(Registry entity) { public void update(Registry entity) {
} }
@Override @Override
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,157 +1,169 @@
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
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Column(name = "\"PrimaryEmail\"") @Column(name = "\"PrimaryEmail\"")
private String primaryEmail; private String primaryEmail;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition; private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @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;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPResearcher\"", @JoinTable(name = "\"DMPResearcher\"",
joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}, joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")} inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
) )
private Set<DMP> dMPs; private Set<DMP> dMPs;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; @Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
private Date modified = new Date(); @Convert(converter = DateToUTCConverter.class)
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;
} }
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 getPrimaryEmail() { public String getPrimaryEmail() {
return primaryEmail; return primaryEmail;
} }
public void setPrimaryEmail(String primaryEmail) { public void setPrimaryEmail(String primaryEmail) {
this.primaryEmail = primaryEmail; this.primaryEmail = primaryEmail;
} }
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;
} }
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;
} }
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(Researcher entity) { public void update(Researcher entity) {
} }
@Override @Override
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;
@ -15,138 +16,145 @@ import java.util.UUID;
@Table(name = "\"Service\"") @Table(name = "\"Service\"")
public class Service implements DataEntity<Service, UUID> { public class Service implements DataEntity<Service, UUID> {
@Id @Id
@GeneratedValue @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
@GenericGenerator(name = "uuid2", strategy = "uuid2") private UUID id;
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"") @Column(name = "\"Label\"")
private String label; private String label;
@Column(name = "\"Abbreviation\"") @Column(name = "\"Abbreviation\"")
private String abbreviation; private String abbreviation;
@Column(name = "\"Reference\"", nullable = true) @Column(name = "\"Reference\"", nullable = true)
private String reference; private String reference;
@Column(name = "\"Uri\"") @Column(name = "\"Uri\"")
private String uri; private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false) @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition; private String definition;
@OneToMany(mappedBy = "service", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "service", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services; private Set<DatasetService> services;
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; @Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
private Date modified = new Date(); @Convert(converter = DateToUTCConverter.class)
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;
} }
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 getAbbreviation() { public String getAbbreviation() {
return abbreviation; return abbreviation;
} }
public void setAbbreviation(String abbreviation) { public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation; this.abbreviation = abbreviation;
} }
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;
} }
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;
} }
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<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;
} }
@Override @Override
public void update(Service entity) { public void update(Service entity) {
} }
@Override @Override
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,97 +1,106 @@
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
@Table(name = "\"UserDMP\"") @Table(name = "\"UserDMP\"")
public class UserDMP implements DataEntity<UserDMP, UUID> { public class UserDMP implements DataEntity<UserDMP, UUID> {
public enum UserDMPRoles { public enum UserDMPRoles {
OWNER(0), USER(1); OWNER(0), USER(1);
private Integer value; private Integer value;
private UserDMPRoles(Integer value) { private UserDMPRoles(Integer value) {
this.value = value; this.value = value;
} }
public Integer getValue() { public Integer getValue() {
return value; return value;
} }
public static UserDMPRoles fromInteger(Integer value) { public static UserDMPRoles fromInteger(Integer value) {
switch (value) { switch (value) {
case 0: case 0:
return OWNER; return OWNER;
case 1: case 1:
return USER; return USER;
default: default:
throw new RuntimeException("Unsupported User Dmp Role Message Code"); throw new RuntimeException("Unsupported User Dmp Role Message Code");
} }
} }
} }
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "usr") @JoinColumn(name = "usr")
private UserInfo user; private UserInfo user;
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dmp") @JoinColumn(name = "dmp")
private DMP dmp; private DMP dmp;
@Column(name = "role") @Column(name = "role")
private Integer role; private Integer role;
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 UserInfo getUser() { public UserInfo getUser() {
return user; return user;
} }
public void setUser(UserInfo user) { public void setUser(UserInfo user) {
this.user = user; this.user = user;
} }
public DMP getDmp() { public DMP getDmp() {
return dmp; return dmp;
} }
public void setDmp(DMP dmp) { public void setDmp(DMP dmp) {
this.dmp = dmp; this.dmp = dmp;
} }
public Integer getRole() { public Integer getRole() {
return role; return role;
} }
public void setRole(Integer role) { public void setRole(Integer role) {
this.role = role; this.role = role;
} }
@Override @Override
public void update(UserDMP entity) { public void update(UserDMP entity) {
this.role = entity.getRole(); this.role = entity.getRole();
} }
@Override @Override
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,180 +1,188 @@
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
@Table(name = "\"UserInfo\"") @Table(name = "\"UserInfo\"")
@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> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@Column(name = "email", nullable = false) @Column(name = "email", nullable = false)
private String email = null; private String email = null;
@Column(name = "authorization_level", nullable = false) @Column(name = "authorization_level", nullable = false)
private Short authorization_level; //0 admin, 1 user private Short authorization_level; //0 admin, 1 user
@Column(name = "usertype", nullable = false) @Column(name = "usertype", nullable = false)
private Short usertype; // 0 internal, 1 external private Short usertype; // 0 internal, 1 external
@Column(name = "verified_email", nullable = true) @Column(name = "verified_email", nullable = true)
private Boolean verified_email = null; private Boolean verified_email = null;
@Column(name = "name", nullable = true) @Column(name = "name", nullable = true)
private String name = null; private String name = null;
@Column(name = "created", nullable = false) @Column(name = "created", nullable = false)
private Date created = null; @Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "lastloggedin", nullable = true) @Column(name = "lastloggedin", nullable = true)
private Date lastloggedin = null; @Convert(converter = DateToUTCConverter.class)
private Date lastloggedin = null;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType") @Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "additionalinfo", nullable = true) @Column(name = "additionalinfo", nullable = true)
private String additionalinfo; private String additionalinfo;
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"", @JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")} inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
) )
private Set<DMP> dmps; private Set<DMP> dmps;
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY) @OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<Credential> credentials = new HashSet<>(); private Set<Credential> credentials = new HashSet<>();
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY) @OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<UserRole> userRoles = new HashSet<>(); private Set<UserRole> userRoles = new HashSet<>();
public Set<DMP> getDmps() { public Set<DMP> getDmps() {
return dmps; return dmps;
} }
public void setDmps(Set<DMP> dmps) { public void setDmps(Set<DMP> dmps) {
this.dmps = dmps; this.dmps = dmps;
} }
public UUID getId() { public UUID getId() {
return id; return id;
} }
public void setId(UUID id) { public void setId(UUID id) {
this.id = id; this.id = id;
} }
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 getLastloggedin() { public Date getLastloggedin() {
return lastloggedin; return lastloggedin;
} }
public void setLastloggedin(Date lastloggedin) { public void setLastloggedin(Date lastloggedin) {
this.lastloggedin = lastloggedin; this.lastloggedin = lastloggedin;
} }
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 Short getAuthorization_level() { public Short getAuthorization_level() {
return authorization_level; return authorization_level;
} }
public void setAuthorization_level(Short authorization_level) { public void setAuthorization_level(Short authorization_level) {
this.authorization_level = authorization_level; this.authorization_level = authorization_level;
} }
public Short getUsertype() { public Short getUsertype() {
return usertype; return usertype;
} }
public void setUsertype(Short usertype) { public void setUsertype(Short usertype) {
this.usertype = usertype; this.usertype = usertype;
} }
public Boolean getVerified_email() { public Boolean getVerified_email() {
return verified_email; return verified_email;
} }
public void setVerified_email(Boolean verified_email) { public void setVerified_email(Boolean verified_email) {
this.verified_email = verified_email; this.verified_email = verified_email;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getAdditionalinfo() { public String getAdditionalinfo() {
return additionalinfo; return additionalinfo;
} }
public void setAdditionalinfo(String additionalinfo) { public void setAdditionalinfo(String additionalinfo) {
this.additionalinfo = additionalinfo; this.additionalinfo = additionalinfo;
} }
public Set<Credential> getCredentials() { public Set<Credential> getCredentials() {
return credentials; return credentials;
} }
public void setCredentials(Set<Credential> credentials) { public void setCredentials(Set<Credential> credentials) {
this.credentials = credentials; this.credentials = credentials;
} }
public Set<UserRole> getUserRoles() { public Set<UserRole> getUserRoles() {
return userRoles; return userRoles;
} }
public void setUserRoles(Set<UserRole> userRoles) { public void setUserRoles(Set<UserRole> userRoles) {
this.userRoles = userRoles; this.userRoles = userRoles;
} }
@Override @Override
public void update(UserInfo entity) { public void update(UserInfo entity) {
this.name = entity.getName(); this.name = entity.getName();
this.email = entity.getEmail(); this.email = entity.getEmail();
this.additionalinfo = entity.getAdditionalinfo(); this.additionalinfo = entity.getAdditionalinfo();
this.lastloggedin = entity.getLastloggedin(); this.lastloggedin = entity.getLastloggedin();
this.userRoles = entity.getUserRoles(); this.userRoles = entity.getUserRoles();
} }
@Override @Override
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;
@ -11,50 +13,57 @@ import java.util.UUID;
@Table(name = "\"UserRole\"") @Table(name = "\"UserRole\"")
public class UserRole implements DataEntity<UserRole, UUID> { public class UserRole implements DataEntity<UserRole, UUID> {
@Id @Id
@GeneratedValue @GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") @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;
@Column(name = "\"Role\"", nullable = false) @Column(name = "\"Role\"", nullable = false)
private int role; private int role;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false) @JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo; private UserInfo userInfo;
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 int getRole() { public int getRole() {
return role; return role;
} }
public void setRole(int role) { public void setRole(int role) {
this.role = role; this.role = role;
} }
public UserInfo getUserInfo() { public UserInfo getUserInfo() {
return userInfo; return userInfo;
} }
public void setUserInfo(UserInfo userInfo) { public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo; this.userInfo = userInfo;
} }
@Override @Override
public void update(UserRole entity) { public void update(UserRole entity) {
} }
@Override @Override
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;
@ -11,60 +14,69 @@ import java.util.UUID;
@Table(name = "\"UserToken\"") @Table(name = "\"UserToken\"")
public class UserToken implements DataEntity<UserToken, UUID> { public class UserToken implements DataEntity<UserToken, UUID> {
@Id @Id
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token; private UUID token;
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false) @JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo user; private UserInfo user;
@Column(name = "\"IssuedAt\"", nullable = false) @Column(name = "\"IssuedAt\"", nullable = false)
private Date issuedAt = null; @Convert(converter = DateToUTCConverter.class)
private Date issuedAt = null;
@Column(name = "\"ExpiresAt\"", nullable = false) @Column(name = "\"ExpiresAt\"", nullable = false)
private Date expiresAt = null; @Convert(converter = DateToUTCConverter.class)
private Date expiresAt = null;
public UUID getToken() { public UUID getToken() {
return token; return token;
} }
public void setToken(UUID token) { public void setToken(UUID token) {
this.token = token; this.token = token;
} }
public UserInfo getUser() { public UserInfo getUser() {
return user; return user;
} }
public void setUser(UserInfo user) { public void setUser(UserInfo user) {
this.user = user; this.user = user;
} }
public Date getIssuedAt() { public Date getIssuedAt() {
return issuedAt; return issuedAt;
} }
public void setIssuedAt(Date issuedAt) { public void setIssuedAt(Date issuedAt) {
this.issuedAt = issuedAt; this.issuedAt = issuedAt;
} }
public Date getExpiresAt() { public Date getExpiresAt() {
return expiresAt; return expiresAt;
} }
public void setExpiresAt(Date expiresAt) { public void setExpiresAt(Date expiresAt) {
this.expiresAt = expiresAt; this.expiresAt = expiresAt;
} }
@Override @Override
public void update(UserToken entity) { public void update(UserToken entity) {
} }
@Override @Override
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,24 +5,13 @@ 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> {
@Override
public class ProjectCriteriaRequest extends Query<ProjectCriteria,Project> { public QueryableList<Project> applyCriteria() {
private ProjectCriteriaRequest() { QueryableList<Project> 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() + "%"));
@Override query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
public QueryableList<Project> applyCriteria() { return query;
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;
}
} }

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