Search in sources :

Example 1 with HistoricActivityInstanceQueryRequest

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

the class BaseHistoricActivitiInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricActivityInstanceQueryRequest queryRequest, Map<String, String> allRequestParams, UriInfo uriInfo) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // Populate query based on request
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getActivityName() != null) {
        query.activityName(queryRequest.getActivityName());
    }
    if (queryRequest.getActivityType() != null) {
        query.activityType(queryRequest.getActivityType());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getFinished() != null) {
        Boolean finished = queryRequest.getFinished();
        if (finished) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    if (queryRequest.getTaskAssignee() != null) {
        query.taskAssignee(queryRequest.getTaskAssignee());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getTenantId() != null) {
        query.activityTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.activityTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.activityWithoutTenantId();
    }
    return new HistoricActivityInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "startTime", allowedSortProperties);
}
Also used : HistoricActivityInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList) HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService)

Example 2 with HistoricActivityInstanceQueryRequest

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

the class BaseHistoricTaskInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricActivityInstanceQueryRequest queryRequest, Map<String, String> allRequestParams) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // Populate query based on request
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getActivityName() != null) {
        query.activityName(queryRequest.getActivityName());
    }
    if (queryRequest.getActivityType() != null) {
        query.activityType(queryRequest.getActivityType());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getFinished() != null) {
        Boolean finished = queryRequest.getFinished();
        if (finished) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    if (queryRequest.getTaskAssignee() != null) {
        query.taskAssignee(queryRequest.getTaskAssignee());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getTenantId() != null) {
        query.activityTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.activityTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.activityWithoutTenantId();
    }
    RestResponseFactory restResponseFactory = new RestResponseFactory();
    return new HistoricActivityInstancePaginateList(restResponseFactory, uriInfo).paginateList(allRequestParams, queryRequest, query, "startTime", allowedSortProperties);
}
Also used : HistoricActivityInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList) HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService)

Example 3 with HistoricActivityInstanceQueryRequest

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

the class HistoricActivitiInstanceService method getHistoricActivityInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricActivityInstances(@Context UriInfo uriInfo) {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    HistoricActivityInstanceQueryRequest query = getHistoricActivityInstanceQueryRequest(uriInfo, allRequestParams);
    DataResponse dataResponse = getQueryResponse(query, allRequestParams, uriInfo);
    return Response.ok().entity(dataResponse).build();
}
Also used : HashMap(java.util.HashMap) HistoricActivityInstanceQueryRequest(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstanceQueryRequest) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with HistoricActivityInstanceQueryRequest

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

the class HistoricActivitiInstanceQueryService method queryActivityInstances.

@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryActivityInstances(HistoricActivityInstanceQueryRequest queryRequest, @Context UriInfo uriInfo) {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, uriInfo);
    return Response.ok().entity(dataResponse).build();
}
Also used : HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

HashMap (java.util.HashMap)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 HistoryService (org.activiti.engine.HistoryService)2 HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)2 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)2 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)2 HistoricActivityInstancePaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList)2 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 HistoricActivityInstanceQueryRequest (org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstanceQueryRequest)1