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;
}
Aggregations