From 00661483abe61df8d400b96ea9dc26a9733b2412 Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Mon, 10 Jun 2019 14:25:42 +0300 Subject: [PATCH] Adds backend DMP filter on public Dataset listing. --- .../dao/criteria/DatasetPublicCriteria.java | 23 +++++++++++-------- .../dataset/DatasetPublicTableRequest.java | 21 +++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java index d78041eba..c7d9f903e 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DatasetPublicCriteria.java @@ -11,16 +11,16 @@ import java.util.UUID; * Created by ikalyvas on 10/2/2018. */ public class DatasetPublicCriteria extends Criteria{ - public ProjectStateType projectStatus; - public List projects; - public List datasetProfile; - public List dmpOrganisations; - public List tags; + private ProjectStateType projectStatus; + private List projects; + private List datasetProfile; + private List dmpOrganisations; + private List tags; + private List dmpIds; public ProjectStateType getProjectStatus() { return projectStatus; } - public void setProjectStatus(ProjectStateType projectStatus) { this.projectStatus = projectStatus; } @@ -28,7 +28,6 @@ public class DatasetPublicCriteria extends Criteria{ public List getProjects() { return projects; } - public void setProjects(List projects) { this.projects = projects; } @@ -36,7 +35,6 @@ public class DatasetPublicCriteria extends Criteria{ public List getDatasetProfile() { return datasetProfile; } - public void setDatasetProfile(List datasetProfile) { this.datasetProfile = datasetProfile; } @@ -44,7 +42,6 @@ public class DatasetPublicCriteria extends Criteria{ public List getDmpOrganisations() { return dmpOrganisations; } - public void setDmpOrganisations(List dmpOrganisations) { this.dmpOrganisations = dmpOrganisations; } @@ -52,8 +49,14 @@ public class DatasetPublicCriteria extends Criteria{ public List getTags() { return tags; } - public void setTags(List tags) { this.tags = tags; } + + public List getDmpIds() { + return dmpIds; + } + public void setDmpIds(List dmpIds) { + this.dmpIds = dmpIds; + } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java index 41498d65a..cccff303e 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java @@ -29,20 +29,23 @@ public class DatasetPublicTableRequest extends TableQuery 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().projects != null && !this.getCriteria().projects.isEmpty()) - query.where(((builder, root) -> root.get("dmp").get("project").get("id").in(this.getCriteria().projects))); - if (this.getCriteria().projectStatus != null) { - if (this.getCriteria().projectStatus.getValue().equals(ProjectStateType.FINISHED.getValue())) + if (this.getCriteria().getProjects() != null && !this.getCriteria().getProjects().isEmpty()) + query.where(((builder, root) -> root.get("dmp").get("project").get("id").in(this.getCriteria().getProjects()))); + if (this.getCriteria().getProjectStatus() != null) { + if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.FINISHED.getValue())) query.where((builder, root) -> builder.lessThan(root.get("dmp").get("project").get("enddate"), new Date())); - if (this.getCriteria().projectStatus.getValue().equals(ProjectStateType.ONGOING.getValue())) + if (this.getCriteria().getProjectStatus().getValue().equals(ProjectStateType.ONGOING.getValue())) query.where((builder, root) -> builder.or(builder.greaterThan(root.get("dmp").get("project").get("enddate"), new Date()) , builder.isNull(root.get("dmp").get("project").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().dmpOrganisations != null && !this.getCriteria().dmpOrganisations.isEmpty()) query - .where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().dmpOrganisations))); + if (this.getCriteria().getDmpIds() != null) { + 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; }