Search in sources :

Example 1 with HistoricProcessInstancePaginateList

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

the class HistoricProcessInstanceQueryService method queryProcessInstances.

@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryProcessInstances(HistoricProcessInstanceQueryRequest queryRequest) {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    org.activiti.engine.history.HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // Populate query based on request
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessInstanceIds() != null && !queryRequest.getProcessInstanceIds().isEmpty()) {
        query.processInstanceIds(new HashSet<>(queryRequest.getProcessInstanceIds()));
    }
    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.getSuperProcessInstanceId() != null) {
        query.superProcessInstanceId(queryRequest.getSuperProcessInstanceId());
    }
    if (queryRequest.getExcludeSubprocesses() != null) {
        query.excludeSubprocesses(queryRequest.getExcludeSubprocesses());
    }
    if (queryRequest.getFinishedAfter() != null) {
        query.finishedAfter(queryRequest.getFinishedAfter());
    }
    if (queryRequest.getFinishedBefore() != null) {
        query.finishedBefore(queryRequest.getFinishedBefore());
    }
    if (queryRequest.getStartedAfter() != null) {
        query.startedAfter(queryRequest.getStartedAfter());
    }
    if (queryRequest.getStartedBefore() != null) {
        query.startedBefore(queryRequest.getStartedBefore());
    }
    if (queryRequest.getStartedBy() != null) {
        query.startedBy(queryRequest.getStartedBy());
    }
    if (queryRequest.getFinished() != null) {
        if (queryRequest.getFinished()) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    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();
    }
    DataResponse dataResponse = new HistoricProcessInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
    return Response.ok().entity(dataResponse).build();
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) HistoryService(org.activiti.engine.HistoryService) HistoricProcessInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricProcessInstancePaginateList) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Example 2 with HistoricProcessInstancePaginateList

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

the class HistoricProcessInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricProcessInstanceQueryRequest queryRequest, Map<String, String> allRequestParams) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // Populate query based on request
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessInstanceIds() != null && !queryRequest.getProcessInstanceIds().isEmpty()) {
        query.processInstanceIds(new HashSet<String>(queryRequest.getProcessInstanceIds()));
    }
    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.getSuperProcessInstanceId() != null) {
        query.superProcessInstanceId(queryRequest.getSuperProcessInstanceId());
    }
    if (queryRequest.getExcludeSubprocesses() != null) {
        query.excludeSubprocesses(queryRequest.getExcludeSubprocesses());
    }
    if (queryRequest.getFinishedAfter() != null) {
        query.finishedAfter(queryRequest.getFinishedAfter());
    }
    if (queryRequest.getFinishedBefore() != null) {
        query.finishedBefore(queryRequest.getFinishedBefore());
    }
    if (queryRequest.getStartedAfter() != null) {
        query.startedAfter(queryRequest.getStartedAfter());
    }
    if (queryRequest.getStartedBefore() != null) {
        query.startedBefore(queryRequest.getStartedBefore());
    }
    if (queryRequest.getStartedBy() != null) {
        query.startedBy(queryRequest.getStartedBy());
    }
    if (queryRequest.getFinished() != null) {
        if (queryRequest.getFinished()) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    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();
    }
    RestResponseFactory restResponseFactory = new RestResponseFactory();
    DataResponse dataResponse = new HistoricProcessInstancePaginateList(restResponseFactory, uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
    return dataResponse;
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) HistoricProcessInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricProcessInstancePaginateList)

Aggregations

RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)2 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)2 HistoricProcessInstancePaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricProcessInstancePaginateList)2 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 HistoryService (org.activiti.engine.HistoryService)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1