use of pro.taskana.TaskQuery in project taskana by Taskana.
the class QueryObjectReferenceAccTest method testFindObjectReferenceByType.
@Test
public void testFindObjectReferenceByType() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery().typeIn("Type2", "Type3").list();
assertNotNull(objectReferenceList);
assertEquals(2, objectReferenceList.size());
}
use of pro.taskana.TaskQuery in project taskana by Taskana.
the class QueryObjectReferenceAccTest method testFindObjectReferenceByCompany.
@Test
public void testFindObjectReferenceByCompany() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery().companyIn("Company1", "Company2").list();
assertNotNull(objectReferenceList);
assertEquals(2, objectReferenceList.size());
}
use of pro.taskana.TaskQuery in project taskana by Taskana.
the class QueryObjectReferenceAccTest method testFindObjectReferenceByValue.
@Test
public void testFindObjectReferenceByValue() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery().valueIn("Value1", "Value3").list();
assertNotNull(objectReferenceList);
assertEquals(2, objectReferenceList.size());
}
use of pro.taskana.TaskQuery 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.TaskQuery in project taskana by Taskana.
the class TaskFilter method inspectParams.
public List<TaskSummary> inspectParams(MultiValueMap<String, String> params) throws NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskService.createTaskQuery();
// apply filters
if (params.containsKey(NAME)) {
String[] names = extractCommaSeperatedFields(params.get(NAME));
taskQuery.nameIn(names);
}
if (params.containsKey(DESCRIPTION)) {
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
}
if (params.containsKey(PRIORITY)) {
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
int[] priorites = extractPriorities(prioritesInString);
taskQuery.priorityIn(priorites);
}
if (params.containsKey(STATE)) {
TaskState[] states = extractStates(params);
taskQuery.stateIn(states);
}
if (params.containsKey(CLASSIFICATION_KEY)) {
String[] classificationKeys = extractCommaSeperatedFields(params.get(CLASSIFICATION_KEY));
taskQuery.classificationKeyIn(classificationKeys);
}
if (params.containsKey(WORKBASKET_ID)) {
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_ID));
taskQuery.workbasketIdIn(workbaskets);
}
if (params.containsKey(OWNER)) {
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
taskQuery.ownerIn(owners);
}
// objectReference
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
if (params.containsKey(POR_COMPANY)) {
String[] companies = extractCommaSeperatedFields(params.get(POR_COMPANY));
taskQuery.primaryObjectReferenceCompanyIn(companies);
}
if (params.containsKey(POR_SYSTEM)) {
String[] systems = extractCommaSeperatedFields(params.get(POR_SYSTEM));
taskQuery.primaryObjectReferenceSystemIn(systems);
}
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
String[] systemInstances = extractCommaSeperatedFields(params.get(POR_SYSTEM_INSTANCE));
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
}
if (params.containsKey(POR_TYPE)) {
String[] types = extractCommaSeperatedFields(params.get(POR_TYPE));
taskQuery.primaryObjectReferenceTypeIn(types);
}
if (params.containsKey(POR_VALUE)) {
String[] values = extractCommaSeperatedFields(params.get(POR_VALUE));
taskQuery.primaryObjectReferenceValueIn(values);
}
}
if (params.containsKey(IS_READ)) {
taskQuery.readEquals(Boolean.getBoolean(params.get(IS_READ).get(0)));
}
if (params.containsKey(IS_TRANSFERRED)) {
taskQuery.transferredEquals(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
}
return taskQuery.list();
}
Aggregations