Search in sources :

Example 1 with HistoricTaskInstanceQueryRequest

use of org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstanceQueryRequest in project carbon-business-process by wso2.

the class HistoricTaskInstanceService method getHistoricProcessInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricProcessInstances() {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    // Populate query based on request
    HistoricTaskInstanceQueryRequest queryRequest = new HistoricTaskInstanceQueryRequest();
    if (allRequestParams.get("taskId") != null) {
        queryRequest.setTaskId(allRequestParams.get("taskId"));
    }
    if (allRequestParams.get("processInstanceId") != null) {
        queryRequest.setProcessInstanceId(allRequestParams.get("processInstanceId"));
    }
    if (allRequestParams.get("processBusinessKey") != null) {
        queryRequest.setProcessBusinessKey(allRequestParams.get("processBusinessKey"));
    }
    if (allRequestParams.get("processDefinitionKey") != null) {
        queryRequest.setProcessDefinitionKey(allRequestParams.get("processDefinitionKey"));
    }
    if (allRequestParams.get("processDefinitionId") != null) {
        queryRequest.setProcessDefinitionId(allRequestParams.get("processDefinitionId"));
    }
    if (allRequestParams.get("processDefinitionName") != null) {
        queryRequest.setProcessDefinitionName(allRequestParams.get("processDefinitionName"));
    }
    if (allRequestParams.get("executionId") != null) {
        queryRequest.setExecutionId(allRequestParams.get("executionId"));
    }
    if (allRequestParams.get("taskName") != null) {
        queryRequest.setTaskName(allRequestParams.get("taskName"));
    }
    if (allRequestParams.get("taskNameLike") != null) {
        queryRequest.setTaskNameLike(allRequestParams.get("taskNameLike"));
    }
    if (allRequestParams.get("taskDescription") != null) {
        queryRequest.setTaskDescription(allRequestParams.get("taskDescription"));
    }
    if (allRequestParams.get("taskDescriptionLike") != null) {
        queryRequest.setTaskDescriptionLike(allRequestParams.get("taskDescriptionLike"));
    }
    if (allRequestParams.get("taskDefinitionKey") != null) {
        queryRequest.setTaskDefinitionKey(allRequestParams.get("taskDefinitionKey"));
    }
    if (allRequestParams.get("taskDeleteReason") != null) {
        queryRequest.setTaskDeleteReason(allRequestParams.get("taskDeleteReason"));
    }
    if (allRequestParams.get("taskDeleteReasonLike") != null) {
        queryRequest.setTaskDeleteReasonLike(allRequestParams.get("taskDeleteReasonLike"));
    }
    if (allRequestParams.get("taskAssignee") != null) {
        queryRequest.setTaskAssignee(allRequestParams.get("taskAssignee"));
    }
    if (allRequestParams.get("taskAssigneeLike") != null) {
        queryRequest.setTaskAssigneeLike(allRequestParams.get("taskAssigneeLike"));
    }
    if (allRequestParams.get("taskOwner") != null) {
        queryRequest.setTaskOwner(allRequestParams.get("taskOwner"));
    }
    if (allRequestParams.get("taskOwnerLike") != null) {
        queryRequest.setTaskOwnerLike(allRequestParams.get("taskOwnerLike"));
    }
    if (allRequestParams.get("taskInvolvedUser") != null) {
        queryRequest.setTaskInvolvedUser(allRequestParams.get("taskInvolvedUser"));
    }
    if (allRequestParams.get("taskPriority") != null) {
        queryRequest.setTaskPriority(Integer.valueOf(allRequestParams.get("taskPriority")));
    }
    if (allRequestParams.get("finished") != null) {
        queryRequest.setFinished(Boolean.valueOf(allRequestParams.get("finished")));
    }
    if (allRequestParams.get("processFinished") != null) {
        queryRequest.setProcessFinished(Boolean.valueOf(allRequestParams.get("processFinished")));
    }
    if (allRequestParams.get("parentTaskId") != null) {
        queryRequest.setParentTaskId(allRequestParams.get("parentTaskId"));
    }
    if (allRequestParams.get("dueDate") != null) {
        queryRequest.setDueDate(RequestUtil.getDate(allRequestParams, "dueDate"));
    }
    if (allRequestParams.get("dueDateAfter") != null) {
        queryRequest.setDueDateAfter(RequestUtil.getDate(allRequestParams, "dueDateAfter"));
    }
    if (allRequestParams.get("dueDateBefore") != null) {
        queryRequest.setDueDateBefore(RequestUtil.getDate(allRequestParams, "dueDateBefore"));
    }
    if (allRequestParams.get("taskCreatedOn") != null) {
        queryRequest.setTaskCreatedOn(RequestUtil.getDate(allRequestParams, "taskCreatedOn"));
    }
    if (allRequestParams.get("taskCreatedBefore") != null) {
        queryRequest.setTaskCreatedBefore(RequestUtil.getDate(allRequestParams, "taskCreatedBefore"));
    }
    if (allRequestParams.get("taskCreatedAfter") != null) {
        queryRequest.setTaskCreatedAfter(RequestUtil.getDate(allRequestParams, "taskCreatedAfter"));
    }
    if (allRequestParams.get("taskCompletedOn") != null) {
        queryRequest.setTaskCompletedOn(RequestUtil.getDate(allRequestParams, "taskCompletedOn"));
    }
    if (allRequestParams.get("taskCompletedBefore") != null) {
        queryRequest.setTaskCompletedBefore(RequestUtil.getDate(allRequestParams, "taskCompletedBefore"));
    }
    if (allRequestParams.get("taskCompletedAfter") != null) {
        queryRequest.setTaskCompletedAfter(RequestUtil.getDate(allRequestParams, "taskCompletedAfter"));
    }
    if (allRequestParams.get("includeTaskLocalVariables") != null) {
        queryRequest.setIncludeTaskLocalVariables(Boolean.valueOf(allRequestParams.get("includeTaskLocalVariables")));
    }
    if (allRequestParams.get("includeProcessVariables") != null) {
        queryRequest.setIncludeProcessVariables(Boolean.valueOf(allRequestParams.get("includeProcessVariables")));
    }
    if (allRequestParams.get("tenantId") != null) {
        queryRequest.setTenantId(allRequestParams.get("tenantId"));
    }
    if (allRequestParams.get("tenantIdLike") != null) {
        queryRequest.setTenantIdLike(allRequestParams.get("tenantIdLike"));
    }
    if (allRequestParams.get("withoutTenantId") != null) {
        queryRequest.setWithoutTenantId(Boolean.valueOf(allRequestParams.get("withoutTenantId")));
    }
    if (allRequestParams.get("taskCandidateGroup") != null) {
        queryRequest.setTaskCandidateGroup(allRequestParams.get("taskCandidateGroup"));
    }
    String serverRootUrl = uriInfo.getBaseUri().toString().replace("/history/historic-task-instances", "");
    DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, serverRootUrl);
    return Response.ok().entity(dataResponse).build();
}
Also used : HistoricTaskInstanceQueryRequest(org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstanceQueryRequest) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse)

Example 2 with HistoricTaskInstanceQueryRequest

use of org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstanceQueryRequest in project carbon-business-process by wso2.

the class BaseHistoricTaskInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricTaskInstanceQueryRequest queryRequest, Map<String, String> allRequestParams, String serverRootUrl) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    // Populate query based on request
    if (queryRequest.getTaskId() != null) {
        query.taskId(queryRequest.getTaskId());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessBusinessKey() != null) {
        query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
    }
    if (queryRequest.getProcessBusinessKeyLike() != null) {
        query.processInstanceBusinessKeyLike(queryRequest.getProcessBusinessKeyLike());
    }
    if (queryRequest.getProcessDefinitionKey() != null) {
        query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
    }
    if (queryRequest.getProcessDefinitionKeyLike() != null) {
        query.processDefinitionKeyLike(queryRequest.getProcessDefinitionKeyLike());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getProcessDefinitionName() != null) {
        query.processDefinitionName(queryRequest.getProcessDefinitionName());
    }
    if (queryRequest.getProcessDefinitionNameLike() != null) {
        query.processDefinitionNameLike(queryRequest.getProcessDefinitionNameLike());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getTaskName() != null) {
        query.taskName(queryRequest.getTaskName());
    }
    if (queryRequest.getTaskNameLike() != null) {
        query.taskNameLike(queryRequest.getTaskNameLike());
    }
    if (queryRequest.getTaskDescription() != null) {
        query.taskDescription(queryRequest.getTaskDescription());
    }
    if (queryRequest.getTaskDescriptionLike() != null) {
        query.taskDescriptionLike(queryRequest.getTaskDescriptionLike());
    }
    if (queryRequest.getTaskDefinitionKey() != null) {
        query.taskDefinitionKey(queryRequest.getTaskDefinitionKey());
    }
    if (queryRequest.getTaskDefinitionKeyLike() != null) {
        query.taskDefinitionKeyLike(queryRequest.getTaskDefinitionKeyLike());
    }
    if (queryRequest.getTaskDeleteReason() != null) {
        query.taskDeleteReason(queryRequest.getTaskDeleteReason());
    }
    if (queryRequest.getTaskDeleteReasonLike() != null) {
        query.taskDeleteReasonLike(queryRequest.getTaskDeleteReasonLike());
    }
    if (queryRequest.getTaskAssignee() != null) {
        query.taskAssignee(queryRequest.getTaskAssignee());
    }
    if (queryRequest.getTaskAssigneeLike() != null) {
        query.taskAssigneeLike(queryRequest.getTaskAssigneeLike());
    }
    if (queryRequest.getTaskOwner() != null) {
        query.taskOwner(queryRequest.getTaskOwner());
    }
    if (queryRequest.getTaskOwnerLike() != null) {
        query.taskOwnerLike(queryRequest.getTaskOwnerLike());
    }
    if (queryRequest.getTaskInvolvedUser() != null) {
        query.taskInvolvedUser(queryRequest.getTaskInvolvedUser());
    }
    if (queryRequest.getTaskPriority() != null) {
        query.taskPriority(queryRequest.getTaskPriority());
    }
    if (queryRequest.getTaskMinPriority() != null) {
        query.taskMinPriority(queryRequest.getTaskMinPriority());
    }
    if (queryRequest.getTaskMaxPriority() != null) {
        query.taskMaxPriority(queryRequest.getTaskMaxPriority());
    }
    if (queryRequest.getTaskPriority() != null) {
        query.taskPriority(queryRequest.getTaskPriority());
    }
    if (queryRequest.getFinished() != null) {
        if (queryRequest.getFinished()) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    if (queryRequest.getProcessFinished() != null) {
        if (queryRequest.getProcessFinished()) {
            query.processFinished();
        } else {
            query.processUnfinished();
        }
    }
    if (queryRequest.getParentTaskId() != null) {
        query.taskParentTaskId(queryRequest.getParentTaskId());
    }
    if (queryRequest.getDueDate() != null) {
        query.taskDueDate(queryRequest.getDueDate());
    }
    if (queryRequest.getDueDateAfter() != null) {
        query.taskDueAfter(queryRequest.getDueDateAfter());
    }
    if (queryRequest.getDueDateBefore() != null) {
        query.taskDueBefore(queryRequest.getDueDateBefore());
    }
    if (queryRequest.getWithoutDueDate() != null && queryRequest.getWithoutDueDate()) {
        query.withoutTaskDueDate();
    }
    if (queryRequest.getTaskCreatedOn() != null) {
        query.taskCreatedOn(queryRequest.getTaskCreatedOn());
    }
    if (queryRequest.getTaskCreatedBefore() != null) {
        query.taskCreatedBefore(queryRequest.getTaskCreatedBefore());
    }
    if (queryRequest.getTaskCreatedAfter() != null) {
        query.taskCreatedAfter(queryRequest.getTaskCreatedAfter());
    }
    if (queryRequest.getTaskCreatedOn() != null) {
        query.taskCreatedOn(queryRequest.getTaskCreatedOn());
    }
    if (queryRequest.getTaskCreatedBefore() != null) {
        query.taskCreatedBefore(queryRequest.getTaskCreatedBefore());
    }
    if (queryRequest.getTaskCreatedAfter() != null) {
        query.taskCreatedAfter(queryRequest.getTaskCreatedAfter());
    }
    if (queryRequest.getTaskCompletedOn() != null) {
        query.taskCompletedOn(queryRequest.getTaskCompletedOn());
    }
    if (queryRequest.getTaskCompletedBefore() != null) {
        query.taskCompletedBefore(queryRequest.getTaskCompletedBefore());
    }
    if (queryRequest.getTaskCompletedAfter() != null) {
        query.taskCompletedAfter(queryRequest.getTaskCompletedAfter());
    }
    if (queryRequest.getIncludeTaskLocalVariables() != null) {
        if (queryRequest.getIncludeTaskLocalVariables()) {
            query.includeTaskLocalVariables();
        }
    }
    if (queryRequest.getIncludeProcessVariables() != null) {
        if (queryRequest.getIncludeProcessVariables()) {
            query.includeProcessVariables();
        }
    }
    if (queryRequest.getTaskVariables() != null) {
        addTaskVariables(query, queryRequest.getTaskVariables());
    }
    if (queryRequest.getProcessVariables() != null) {
        addProcessVariables(query, queryRequest.getProcessVariables());
    }
    if (queryRequest.getTenantId() != null) {
        query.taskTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.taskTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.taskWithoutTenantId();
    }
    if (queryRequest.getTaskCandidateGroup() != null) {
        query.taskCandidateGroup(queryRequest.getTaskCandidateGroup());
    }
    RestResponseFactory restResponseFactory = new RestResponseFactory();
    return new HistoricTaskInstancePaginateList(restResponseFactory, uriInfo, serverRootUrl).paginateList(allRequestParams, queryRequest, query, "taskInstanceId", allowedSortProperties);
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoricTaskInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstancePaginateList) HistoryService(org.activiti.engine.HistoryService) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery)

Aggregations

HashMap (java.util.HashMap)1 HistoryService (org.activiti.engine.HistoryService)1 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)1 HistoricTaskInstancePaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstancePaginateList)1 HistoricTaskInstanceQueryRequest (org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstanceQueryRequest)1