When counting organizations for the user count only the active ones
This commit is contained in:
parent
4b3468d513
commit
016acaaa0f
|
@ -5,6 +5,7 @@ import eu.eudat.data.entities.Organisation;
|
|||
public class OrganisationCriteria extends Criteria<Organisation> {
|
||||
private String labelLike;
|
||||
private Boolean isPublic;
|
||||
private boolean isActive;
|
||||
|
||||
public String getLabelLike() {
|
||||
return labelLike;
|
||||
|
@ -19,4 +20,12 @@ public class OrganisationCriteria extends Criteria<Organisation> {
|
|||
public void setPublic(Boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,11 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
|||
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if (criteria.isActive()) {
|
||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.getValue())).distinct();
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,9 @@ public class DashBoardManager {
|
|||
|
||||
grantCriteria.setActive(true);
|
||||
|
||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
||||
organisationCriteria.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()
|
||||
|
@ -146,7 +149,7 @@ public class DashBoardManager {
|
|||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||
CompletableFuture grantFuture = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).countAsync()
|
||||
.whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats));
|
||||
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.asQueryable().withHint("organisationRecentActivity"), user).countAsync()
|
||||
CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.getWithCriteria(organisationCriteria).withHint("organisationRecentActivity"), user).countAsync()
|
||||
.whenComplete((organisationStats, throwable) -> statistics.setTotalOrganisationCount(organisationStats));
|
||||
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, grantFuture, orgnanisationFuture).join();
|
||||
|
|
Loading…
Reference in New Issue