use of pro.taskana.rest.resource.TaskSummaryResource 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);
}
use of pro.taskana.rest.resource.TaskSummaryResource in project taskana by Taskana.
the class TaskSummaryResourceAssembler method toResource.
@Override
public TaskSummaryResource toResource(TaskSummary taskSummary) {
TaskSummaryResource resource = createResourceWithId(taskSummary.getTaskId(), taskSummary);
BeanUtils.copyProperties(taskSummary, resource);
if (taskSummary.getCreated() != null) {
resource.setCreated(taskSummary.getCreated().toString());
}
if (taskSummary.getModified() != null) {
resource.setModified(taskSummary.getModified().toString());
}
if (taskSummary.getClaimed() != null) {
resource.setClaimed(taskSummary.getClaimed().toString());
}
if (taskSummary.getCompleted() != null) {
resource.setCompleted(taskSummary.getCompleted().toString());
}
if (taskSummary.getDue() != null) {
resource.setDue(taskSummary.getDue().toString());
}
resource.setClassificationSummaryResource(classificationAssembler.toResource(taskSummary.getClassificationSummary()));
resource.setWorkbasketSummaryResource(workbasketAssembler.toResource(taskSummary.getWorkbasketSummary()));
return resource;
}
Aggregations