Fix various critical issues

(cherry picked from commit 244bfa5c54)
This commit is contained in:
George Kalampokis 2021-07-02 14:02:32 +03:00 committed by Diamantis Tziotzios
parent c1adbe283a
commit 2537923dc0
3 changed files with 6 additions and 4 deletions

View File

@ -170,8 +170,10 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
});
}
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);

View File

@ -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());
}
/*

View File

@ -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);