Search in sources :

Example 1 with TaskQuery

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());
}
Also used : ObjectReference(pro.taskana.impl.ObjectReference) TaskQuery(pro.taskana.TaskQuery) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 2 with TaskQuery

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());
}
Also used : ObjectReference(pro.taskana.impl.ObjectReference) TaskQuery(pro.taskana.TaskQuery) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 3 with TaskQuery

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());
}
Also used : ObjectReference(pro.taskana.impl.ObjectReference) TaskQuery(pro.taskana.TaskQuery) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 4 with TaskQuery

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);
}
Also used : PageMetadata(org.springframework.hateoas.PagedResources.PageMetadata) TaskSummaryResourcesAssembler(pro.taskana.rest.resource.mapper.TaskSummaryResourcesAssembler) TaskSummaryResource(pro.taskana.rest.resource.TaskSummaryResource) ResponseEntity(org.springframework.http.ResponseEntity) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskQuery(pro.taskana.TaskQuery) TaskSummary(pro.taskana.TaskSummary) GetMapping(org.springframework.web.bind.annotation.GetMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with TaskQuery

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();
}
Also used : TaskService(pro.taskana.TaskService) Arrays(java.util.Arrays) List(java.util.List) Component(org.springframework.stereotype.Component) TaskSummary(pro.taskana.TaskSummary) TaskState(pro.taskana.TaskState) Autowired(org.springframework.beans.factory.annotation.Autowired) MultiValueMap(org.springframework.util.MultiValueMap) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) TaskQuery(pro.taskana.TaskQuery) ArrayList(java.util.ArrayList) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskQuery(pro.taskana.TaskQuery) TaskState(pro.taskana.TaskState)

Aggregations

TaskQuery (pro.taskana.TaskQuery)9 AbstractAccTest (acceptance.AbstractAccTest)7 Test (org.junit.Test)7 ObjectReference (pro.taskana.impl.ObjectReference)5 TaskSummary (pro.taskana.TaskSummary)3 TaskService (pro.taskana.TaskService)2 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 PageMetadata (org.springframework.hateoas.PagedResources.PageMetadata)1 ResponseEntity (org.springframework.http.ResponseEntity)1 Component (org.springframework.stereotype.Component)1 Transactional (org.springframework.transaction.annotation.Transactional)1 MultiValueMap (org.springframework.util.MultiValueMap)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 TaskState (pro.taskana.TaskState)1 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)1 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)1