Search in sources :

Example 1 with ProcessInstancePaginateList

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

the class BaseProcessInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(ProcessInstanceQueryRequest queryRequest, Map<String, String> requestParams, UriInfo uriInfo) {
    RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // Populate query based on request
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionKey() != null) {
        query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getProcessBusinessKey() != null) {
        query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
    }
    if (queryRequest.getInvolvedUser() != null) {
        query.involvedUser(queryRequest.getInvolvedUser());
    }
    if (queryRequest.getSuspended() != null) {
        if (queryRequest.getSuspended()) {
            query.suspended();
        } else {
            query.active();
        }
    }
    if (queryRequest.getSubProcessInstanceId() != null) {
        query.subProcessInstanceId(queryRequest.getSubProcessInstanceId());
    }
    if (queryRequest.getSuperProcessInstanceId() != null) {
        query.superProcessInstanceId(queryRequest.getSuperProcessInstanceId());
    }
    if (queryRequest.getExcludeSubprocesses() != null) {
        query.excludeSubprocesses(queryRequest.getExcludeSubprocesses());
    }
    if (queryRequest.getIncludeProcessVariables() != null) {
        if (queryRequest.getIncludeProcessVariables()) {
            query.includeProcessVariables();
        }
    }
    if (queryRequest.getVariables() != null) {
        addVariables(query, queryRequest.getVariables());
    }
    if (queryRequest.getTenantId() != null) {
        query.processInstanceTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.processInstanceTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.processInstanceWithoutTenantId();
    }
    return new ProcessInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, queryRequest, query, "id", allowedSortProperties);
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) RuntimeService(org.activiti.engine.RuntimeService) ProcessInstancePaginateList(org.wso2.carbon.bpmn.rest.model.runtime.ProcessInstancePaginateList)

Aggregations

RuntimeService (org.activiti.engine.RuntimeService)1 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 ProcessInstancePaginateList (org.wso2.carbon.bpmn.rest.model.runtime.ProcessInstancePaginateList)1