Adds backend DMP filter on public Dataset listing.
This commit is contained in:
parent
014b6158d3
commit
00661483ab
|
@ -11,16 +11,16 @@ import java.util.UUID;
|
|||
* Created by ikalyvas on 10/2/2018.
|
||||
*/
|
||||
public class DatasetPublicCriteria extends Criteria<Dataset>{
|
||||
public ProjectStateType projectStatus;
|
||||
public List<UUID> projects;
|
||||
public List<UUID> datasetProfile;
|
||||
public List<String> dmpOrganisations;
|
||||
public List<Tag> tags;
|
||||
private ProjectStateType projectStatus;
|
||||
private List<UUID> projects;
|
||||
private List<UUID> datasetProfile;
|
||||
private List<String> dmpOrganisations;
|
||||
private List<Tag> tags;
|
||||
private List<UUID> dmpIds;
|
||||
|
||||
public ProjectStateType getProjectStatus() {
|
||||
return projectStatus;
|
||||
}
|
||||
|
||||
public void setProjectStatus(ProjectStateType projectStatus) {
|
||||
this.projectStatus = projectStatus;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
|
|||
public List<UUID> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<UUID> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
@ -36,7 +35,6 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
|
|||
public List<UUID> getDatasetProfile() {
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
public void setDatasetProfile(List<UUID> datasetProfile) {
|
||||
this.datasetProfile = datasetProfile;
|
||||
}
|
||||
|
@ -44,7 +42,6 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
|
|||
public List<String> getDmpOrganisations() {
|
||||
return dmpOrganisations;
|
||||
}
|
||||
|
||||
public void setDmpOrganisations(List<String> dmpOrganisations) {
|
||||
this.dmpOrganisations = dmpOrganisations;
|
||||
}
|
||||
|
@ -52,8 +49,14 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,20 +29,23 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
|
|||
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().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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue