Fixes bug on DMPdao.

This commit is contained in:
gkolokythas 2019-05-30 11:31:08 +03:00
parent 2f045e6a52
commit 56ff4f3fb9
2 changed files with 2 additions and 3 deletions

View File

@ -57,9 +57,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
} }
if (criteria.getRole() != null) { if (criteria.getRole() != null) {
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())){ if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())){
query.where((builder, root) -> builder.equal(root.join("users").get("role"), UserDMP.UserDMPRoles.OWNER.getValue())); query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())){ } else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())){
query.where((builder, root) -> builder.equal(root.join("users").get("role"), UserDMP.UserDMPRoles.USER.getValue())); query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
} }
} }
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) { if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {

View File

@ -88,7 +88,6 @@ public class DataManagementPlanManager {
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
UUID principalID = principal.getId(); UUID principalID = principal.getId();
dataManagementPlanTableRequest.getCriteria().setUserId(principalID);
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)); QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class));
QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID); QueryableList<DMP> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalID);
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest); QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);