Search in sources :

Example 1 with TaskPaginateList

use of org.wso2.carbon.bpmn.rest.model.runtime.TaskPaginateList in project carbon-business-process by wso2.

the class BaseTaskService method getTasksFromQueryRequest.

protected DataResponse getTasksFromQueryRequest(TaskQueryRequest request, UriInfo uriInfo, Map<String, String> requestParams) {
    if (requestParams == null) {
        requestParams = new HashMap<>();
        for (String property : allPropertiesList) {
            String value = uriInfo.getQueryParameters().getFirst(property);
            if (value != null) {
                requestParams.put(property, value);
            }
        }
    }
    TaskService taskService = BPMNOSGIService.getTaskService();
    TaskQuery taskQuery = taskService.createTaskQuery();
    if (request.getName() != null) {
        taskQuery.taskName(request.getName());
    }
    if (request.getNameLike() != null) {
        taskQuery.taskNameLike(request.getNameLike());
    }
    if (request.getDescription() != null) {
        taskQuery.taskDescription(request.getDescription());
    }
    if (request.getDescriptionLike() != null) {
        taskQuery.taskDescriptionLike(request.getDescriptionLike());
    }
    if (request.getPriority() != null) {
        taskQuery.taskPriority(request.getPriority());
    }
    if (request.getMinimumPriority() != null) {
        taskQuery.taskMinPriority(request.getMinimumPriority());
    }
    if (request.getMaximumPriority() != null) {
        taskQuery.taskMaxPriority(request.getMaximumPriority());
    }
    if (request.getAssignee() != null) {
        taskQuery.taskAssignee(request.getAssignee());
    }
    if (request.getAssigneeLike() != null) {
        taskQuery.taskAssigneeLike(request.getAssigneeLike());
    }
    if (request.getOwner() != null) {
        taskQuery.taskOwner(request.getOwner());
    }
    if (request.getOwnerLike() != null) {
        taskQuery.taskOwnerLike(request.getOwnerLike());
    }
    if (request.getUnassigned() != null) {
        taskQuery.taskUnassigned();
    }
    if (request.getDelegationState() != null) {
        DelegationState state = getDelegationState(request.getDelegationState());
        if (state != null) {
            taskQuery.taskDelegationState(state);
        }
    }
    if (request.getCandidateUser() != null) {
        taskQuery.taskCandidateUser(request.getCandidateUser());
    }
    if (request.getInvolvedUser() != null) {
        taskQuery.taskInvolvedUser(request.getInvolvedUser());
    }
    if (request.getCandidateGroup() != null) {
        taskQuery.taskCandidateGroup(request.getCandidateGroup());
    }
    if (request.getCandidateGroupIn() != null) {
        taskQuery.taskCandidateGroupIn(request.getCandidateGroupIn());
    }
    if (request.getProcessInstanceId() != null) {
        taskQuery.processInstanceId(request.getProcessInstanceId());
    }
    if (request.getProcessInstanceBusinessKey() != null) {
        taskQuery.processInstanceBusinessKey(request.getProcessInstanceBusinessKey());
    }
    if (request.getExecutionId() != null) {
        taskQuery.executionId(request.getExecutionId());
    }
    if (request.getCreatedOn() != null) {
        taskQuery.taskCreatedOn(request.getCreatedOn());
    }
    if (request.getCreatedBefore() != null) {
        taskQuery.taskCreatedBefore(request.getCreatedBefore());
    }
    if (request.getCreatedAfter() != null) {
        taskQuery.taskCreatedAfter(request.getCreatedAfter());
    }
    if (request.getExcludeSubTasks() != null) {
        if (request.getExcludeSubTasks()) {
            taskQuery.excludeSubtasks();
        }
    }
    if (request.getTaskDefinitionKey() != null) {
        taskQuery.taskDefinitionKey(request.getTaskDefinitionKey());
    }
    if (request.getTaskDefinitionKeyLike() != null) {
        taskQuery.taskDefinitionKeyLike(request.getTaskDefinitionKeyLike());
    }
    if (request.getDueDate() != null) {
        taskQuery.taskDueDate(request.getDueDate());
    }
    if (request.getDueBefore() != null) {
        taskQuery.taskDueBefore(request.getDueBefore());
    }
    if (request.getDueAfter() != null) {
        taskQuery.taskDueAfter(request.getDueAfter());
    }
    if (request.getWithoutDueDate() != null && request.getWithoutDueDate()) {
        taskQuery.withoutTaskDueDate();
    }
    if (request.getActive() != null) {
        if (request.getActive().booleanValue()) {
            taskQuery.active();
        } else {
            taskQuery.suspended();
        }
    }
    if (request.getIncludeTaskLocalVariables() != null) {
        if (request.getIncludeTaskLocalVariables()) {
            taskQuery.includeTaskLocalVariables();
        }
    }
    if (request.getIncludeProcessVariables() != null) {
        if (request.getIncludeProcessVariables()) {
            taskQuery.includeProcessVariables();
        }
    }
    if (request.getProcessInstanceBusinessKeyLike() != null) {
        taskQuery.processInstanceBusinessKeyLike(request.getProcessInstanceBusinessKeyLike());
    }
    if (request.getProcessDefinitionKey() != null) {
        taskQuery.processDefinitionKey(request.getProcessDefinitionKey());
    }
    if (request.getProcessDefinitionKeyLike() != null) {
        taskQuery.processDefinitionKeyLike(request.getProcessDefinitionKeyLike());
    }
    if (request.getProcessDefinitionName() != null) {
        taskQuery.processDefinitionName(request.getProcessDefinitionName());
    }
    if (request.getProcessDefinitionNameLike() != null) {
        taskQuery.processDefinitionNameLike(request.getProcessDefinitionNameLike());
    }
    if (request.getTaskVariables() != null) {
        addTaskvariables(taskQuery, request.getTaskVariables());
    }
    if (request.getProcessInstanceVariables() != null) {
        addProcessvariables(taskQuery, request.getProcessInstanceVariables());
    }
    if (request.getTenantId() != null) {
        taskQuery.taskTenantId(request.getTenantId());
    }
    if (request.getTenantIdLike() != null) {
        taskQuery.taskTenantIdLike(request.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(request.getWithoutTenantId())) {
        taskQuery.taskWithoutTenantId();
    }
    if (request.getCandidateOrAssigned() != null) {
        taskQuery.taskCandidateOrAssigned(request.getCandidateOrAssigned());
    }
    DataResponse dataResponse = new TaskPaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, request, taskQuery, "id", properties);
    return dataResponse;
// return Response.ok().entity(dataResponse).build();
}
Also used : DelegationState(org.activiti.engine.task.DelegationState) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) TaskQuery(org.activiti.engine.task.TaskQuery) TaskPaginateList(org.wso2.carbon.bpmn.rest.model.runtime.TaskPaginateList)

Aggregations

DelegationState (org.activiti.engine.task.DelegationState)1 TaskQuery (org.activiti.engine.task.TaskQuery)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)1 TaskPaginateList (org.wso2.carbon.bpmn.rest.model.runtime.TaskPaginateList)1