Commit 2537923d authored by George Kalampokis's avatar George Kalampokis Committed by Diamantis Tziotzios
Browse files

Fix various critical issues

(cherry picked from commit 244bfa5c)
parent c1adbe28
......@@ -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);
......
......@@ -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());
}
/*
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment