use of eu.bcvsolutions.idm.core.api.rest.domain.ResourcePage in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowProcessInstanceService method find.
@Override
public Page<WorkflowProcessInstanceDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
// we must call original method search because is there check flag checkRight
if (pageable != null) {
filter.setPageNumber(pageable.getPageNumber());
filter.setPageSize(pageable.getPageSize());
//
String fieldForSort = null;
boolean ascSort = false;
boolean descSort = false;
if (pageable != null) {
Sort sort = pageable.getSort();
if (sort != null) {
for (Order order : sort) {
if (!StringUtils.isEmpty(order.getProperty())) {
// TODO: now is implemented only one property sort
fieldForSort = order.getProperty();
if (order.getDirection() == Direction.ASC) {
ascSort = true;
} else if (order.getDirection() == Direction.DESC) {
descSort = true;
}
break;
}
}
}
}
filter.setSortAsc(ascSort);
filter.setSortDesc(descSort);
filter.setSortByFields(fieldForSort);
}
ResourcesWrapper<WorkflowProcessInstanceDto> search = this.search(filter);
//
ResourcePage pages = search.getPage();
List<WorkflowProcessInstanceDto> processes = (List<WorkflowProcessInstanceDto>) search.getResources();
//
return new PageImpl<WorkflowProcessInstanceDto>(processes, pageable, pages.getTotalElements());
}
Aggregations