Search in sources :

Example 1 with InstanceCountInfo

use of org.wso2.carbon.bpmn.rest.model.stats.InstanceCountInfo in project carbon-business-process by wso2.

the class ProcessStatisticsService method getProcessInstanceCount.

/**
 * Get the deployed processes count
 *
 * @return a list of deployed processes with their instance count
 */
@GET
@Path("/process-instances/count")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ResponseHolder getProcessInstanceCount() {
    List<ProcessDefinition> processDefinitionList = BPMNOSGIService.getRepositoryService().createProcessDefinitionQuery().processDefinitionTenantId(getTenantIdStr()).list();
    List<Object> bpmnProcessInstancesList = new ArrayList<>();
    ResponseHolder response = new ResponseHolder();
    for (ProcessDefinition processDefinition : processDefinitionList) {
        InstanceCountInfo instanceCountInfo = new InstanceCountInfo();
        instanceCountInfo.setProcessDefinitionId(processDefinition.getId());
        long historicInstanceCount = getCompletedProcessInstanceCount(processDefinition.getId());
        long runningInstanceCount = getActiveProcessInstanceCount(processDefinition.getId());
        long noOfInstances = historicInstanceCount + runningInstanceCount;
        instanceCountInfo.setInstanceCount(noOfInstances);
        bpmnProcessInstancesList.add(instanceCountInfo);
    }
    response.setData(bpmnProcessInstancesList);
    return response;
}
Also used : ResponseHolder(org.wso2.carbon.bpmn.rest.model.stats.ResponseHolder) ArrayList(java.util.ArrayList) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) InstanceCountInfo(org.wso2.carbon.bpmn.rest.model.stats.InstanceCountInfo) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 InstanceCountInfo (org.wso2.carbon.bpmn.rest.model.stats.InstanceCountInfo)1 ResponseHolder (org.wso2.carbon.bpmn.rest.model.stats.ResponseHolder)1