Fix various critical issues

This commit is contained in:
George Kalampokis 2021-07-02 14:02:32 +03:00
parent 4e3b98f1ff
commit 244bfa5c54
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());
searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).size(criteria.getSize()); if (criteria.getSize() != null) {
searchSourceBuilder.size(criteria.getSize());
}
sortBuilders.forEach(searchSourceBuilder::sort); sortBuilders.forEach(searchSourceBuilder::sort);
searchRequest.source(searchSourceBuilder); searchRequest.source(searchSourceBuilder);
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT); SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);

View File

@ -1814,7 +1814,7 @@ public class DataManagementPlanManager {
} }
private boolean isUserOwnerOfDmp(DMP dmp, Principal principal) { 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) { if (columnOrderings.getFieldOrderings() != null && columnOrderings.getFieldOrderings().length > 0) {
for (Ordering ordering: columnOrderings.getFieldOrderings()) { for (Ordering ordering: columnOrderings.getFieldOrderings()) {
SortCriteria sortCriteria1 = new SortCriteria(); 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.setColumnType(ordering.getColumnType() != null ? SortCriteria.ColumnType.valueOf(ordering.getColumnType().name()): SortCriteria.ColumnType.COLUMN);
sortCriteria1.setOrderByType(SortCriteria.OrderByType.valueOf(ordering.getOrderByType().name())); sortCriteria1.setOrderByType(SortCriteria.OrderByType.valueOf(ordering.getOrderByType().name()));
sortCriteria.add(sortCriteria1); sortCriteria.add(sortCriteria1);