Hide grants without any active dmp

This commit is contained in:
George Kalampokis 2021-05-10 17:17:08 +03:00
parent 95f8eb15c9
commit b76a787972
3 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,7 @@ public class GrantCriteria extends Criteria<Grant> {
private String funderId;
private String funderReference;
private String exactReference;
private boolean isActive;
public Date getPeriodStart() {
return periodStart;
@ -71,4 +72,12 @@ public class GrantCriteria extends Criteria<Grant> {
public void setExactReference(String exactReference) {
this.exactReference = exactReference;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean active) {
isActive = active;
}
}

View File

@ -52,6 +52,10 @@ public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
if (criteria.isPublic()) {
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DMP.DMPStatus.FINALISED.getValue())).distinct();
}
if (criteria.isActive()) {
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.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())));
if (criteria.getFunderReference() != null && !criteria.getFunderReference().isEmpty())

View File

@ -135,6 +135,8 @@ public class DashBoardManager {
dataManagementPlanCriteria.setAllVersions(false);
GrantCriteria grantCriteria = new GrantCriteria();
grantCriteria.setActive(true);
List<Integer> roles = new LinkedList<>();
List<Dmp> finalDmps = dmps;
CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated((dmps != null && !dmps.isEmpty()) ? dataManagementPlanRepository.asQueryable().where((builder, root) -> root.get("id").in(finalDmps.stream().map(Dmp::getId).collect(Collectors.toList()))) : dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).distinct().countAsync()