use of pro.taskana.rest.resource.mapper.TaskSummaryResourcesAssembler in project taskana by Taskana.
the class TaskController method getTasks.
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException, NotAuthorizedException {
TaskQuery query = taskService.createTaskQuery();
query = applyFilterParams(query, params);
query = applySortingParams(query, params);
PageMetadata pageMetadata = null;
List<TaskSummary> taskSummaries = null;
String page = params.getFirst(PAGING_PAGE);
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
if (page != null && pageSize != null) {
// paging
long totalElements = query.count();
pageMetadata = initPageMetadata(pageSize, page, totalElements);
taskSummaries = query.listPage((int) pageMetadata.getNumber(), (int) pageMetadata.getSize());
} else if (page == null && pageSize == null) {
// not paging
taskSummaries = query.list();
} else {
throw new InvalidArgumentException("Paging information is incomplete.");
}
TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler();
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries, pageMetadata);
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
}
Aggregations