Project filter on "Public DMPs" now exposes only the ones associated with public DMPs (Ticket #79)

This commit is contained in:
gkolokythas 2019-05-14 16:08:49 +03:00
parent 09d85f1485
commit 62d681d022
4 changed files with 14 additions and 5 deletions

View File

@ -10,11 +10,11 @@ public class ProjectCriteria extends Criteria<Project> {
private Date periodEnd;
private String reference;
private Integer projectStateType;
private boolean isPublic;
public Date getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Date periodStart) {
this.periodStart = periodStart;
}
@ -22,7 +22,6 @@ public class ProjectCriteria extends Criteria<Project> {
public Date getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd;
}
@ -30,7 +29,6 @@ public class ProjectCriteria extends Criteria<Project> {
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
@ -38,8 +36,14 @@ public class ProjectCriteria extends Criteria<Project> {
public Integer getProjectStateType() {
return projectStateType;
}
public void setProjectStateType(Integer projectStateType) {
this.projectStateType = projectStateType;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
}

View File

@ -69,7 +69,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
}
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creator").get("id"), principal), builder.equal(root.join("users", JoinType.LEFT).get("id"), principal)));
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user").get("id"), principal));
return query;
}

View File

@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
@ -45,6 +46,9 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
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();
}
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query;
}

View File

@ -90,6 +90,7 @@ public class ProjectManager {
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPublicPaged(ProjectTableRequest projectTableRequest) throws Exception {
ProjectDao projectRepository = databaseRepository.getProjectDao();
projectTableRequest.getCriteria().setPublic(true);
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(items, projectTableRequest);
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();