diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DmpRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DmpRepository.java index 124c7cc55..9121a0027 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DmpRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DmpRepository.java @@ -170,8 +170,10 @@ public class DmpRepository extends ElasticRepository { }); } - - searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).size(criteria.getSize()); + searchSourceBuilder.query(boolQuery).from(criteria.getOffset()); + if (criteria.getSize() != null) { + searchSourceBuilder.size(criteria.getSize()); + } sortBuilders.forEach(searchSourceBuilder::sort); searchRequest.source(searchSourceBuilder); SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2ef9a576b..23b39d6b0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1814,7 +1814,7 @@ public class DataManagementPlanManager { } private boolean isUserOwnerOfDmp(DMP dmp, Principal principal) { - return (dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getId()).equals(principal.getId()); + return (dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(userDMP -> userDMP.getUser().getId())).collect(Collectors.toList()).contains(principal.getId()); } /* diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/criteria/DmpCriteriaMapper.java b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/criteria/DmpCriteriaMapper.java index 1e7bae4b7..0fbf92ce8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/criteria/DmpCriteriaMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/criteria/DmpCriteriaMapper.java @@ -48,7 +48,7 @@ public class DmpCriteriaMapper { if (columnOrderings.getFieldOrderings() != null && columnOrderings.getFieldOrderings().length > 0) { for (Ordering ordering: columnOrderings.getFieldOrderings()) { SortCriteria sortCriteria1 = new SortCriteria(); - sortCriteria1.setFieldName(ordering.getFieldName() + ".keyword"); + sortCriteria1.setFieldName(ordering.getFieldName() + (ordering.getFieldName().contains("label") ?".keyword" : "")); sortCriteria1.setColumnType(ordering.getColumnType() != null ? SortCriteria.ColumnType.valueOf(ordering.getColumnType().name()): SortCriteria.ColumnType.COLUMN); sortCriteria1.setOrderByType(SortCriteria.OrderByType.valueOf(ordering.getOrderByType().name())); sortCriteria.add(sortCriteria1);