当前位置: 首页>>代码示例>>Java>>正文


Java HistoricProcessInstanceQuery.count方法代码示例

本文整理汇总了Java中org.activiti.engine.history.HistoricProcessInstanceQuery.count方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricProcessInstanceQuery.count方法的具体用法?Java HistoricProcessInstanceQuery.count怎么用?Java HistoricProcessInstanceQuery.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.history.HistoricProcessInstanceQuery的用法示例。


在下文中一共展示了HistoricProcessInstanceQuery.count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPaginatedHistoryInstances

import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
 * Get paginated history instances
 *
 * @param start
 * @param size
 * @return list of BPMNInstances
 */
public BPMNInstance[] getPaginatedHistoryInstances(int start, int size){
    BPMNInstance bpmnInstance;
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    List<BPMNInstance> bpmnInstances = new ArrayList<>();
    HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
    HistoricProcessInstanceQuery query =
            historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
                    .finished().includeProcessVariables();
    historyInstanceCount = (int) query.count();
    List<HistoricProcessInstance> historicProcessInstances = query.listPage(start, size);
    for(HistoricProcessInstance instance: historicProcessInstances){
        bpmnInstance = new BPMNInstance();
        bpmnInstance.setInstanceId(instance.getId());
        bpmnInstance.setProcessId(instance.getProcessDefinitionId());
        bpmnInstance.setStartTime(instance.getStartTime());
        bpmnInstance.setEndTime(instance.getEndTime());
        bpmnInstance.setVariables(formatVariables(instance.getProcessVariables()));
        bpmnInstances.add(bpmnInstance);
    }
    return bpmnInstances.toArray(new BPMNInstance[bpmnInstances.size()]);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:29,代码来源:BPMNInstanceService.java

示例2: getHistoryInstanceCount

import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
 * Get total history instance count
 *
 * @return count int
 * @throws BPSFault
 */
public int getHistoryInstanceCount() throws BPSFault {
    if(historyInstanceCount == -1){
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
        HistoricProcessInstanceQuery query =
                historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).finished();
        historyInstanceCount = (int) query.count();
    }
    return historyInstanceCount;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:17,代码来源:BPMNInstanceService.java

示例3: constructBPMNInstancesByProcessID

import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
private boolean constructBPMNInstancesByProcessID(BPMNDeletableInstances bpmnDeletableInstances, String processId, Integer
        tenantId, ProcessEngine processEngine){

    //first going to get the instances list of unfinished instances
    HistoricProcessInstanceQuery runtimeQuery = processEngine.getHistoryService()
            .createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
            .includeProcessVariables().unfinished().processDefinitionId(processId);
    int processInstanceCount = (int) runtimeQuery.count();
    bpmnDeletableInstances.setActiveInstanceCount(processInstanceCount);

    if(bpmnDeletableInstances.getActiveInstanceCount() > maximumDeleteCount){
        return false;
    }
    if(log.isDebugEnabled()){
        log.debug("Process ID has un completed instances count : " + processInstanceCount);
    }
    if(processInstanceCount > 0){
        List<HistoricProcessInstance> instances = runtimeQuery.listPage(0, processInstanceCount + 1);
        bpmnDeletableInstances.setActiveProcessInstance(instances);
    }

    //next get the count of finished instance for the same process id
    runtimeQuery =  processEngine.getHistoryService()
            .createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
            .includeProcessVariables().finished().processDefinitionId(processId);
    int completedProcessInstanceCount = (int) runtimeQuery.count();

    if((completedProcessInstanceCount + bpmnDeletableInstances.getActiveInstanceCount()) > maximumDeleteCount){
        return false;
    }

    bpmnDeletableInstances.setCompletedInstanceCount(completedProcessInstanceCount);
    bpmnDeletableInstances.addCompletedProcessDefinitionIds(processId);

    if(log.isDebugEnabled()){
        log.debug("Process ID has completed instances count : " + completedProcessInstanceCount);
    }
    return true;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:40,代码来源:BPMNDeploymentService.java

示例4: getAvgTimeDurationForCompletedProcesses

import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
 * Get the average time duration of completed processes
 *
 * @return list with the completed processes and the average time duration taken for each process
 */
@GET
@Path("/process-instances/duration/average")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseHolder getAvgTimeDurationForCompletedProcesses() {

    ResponseHolder response = new ResponseHolder();
    List<Object> list = new ArrayList<>();

    HistoryService historyService = BPMNOSGIService.getHistoryService();
    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    List<ProcessDefinition> deployedProcessList = repositoryService.
            createProcessDefinitionQuery().processDefinitionTenantId(getTenantIdStr()).list();

    for (ProcessDefinition instance : deployedProcessList) {
        ProcessInstanceAverageInfo bpmnProcessInstance = new ProcessInstanceAverageInfo();
        bpmnProcessInstance.setProcessDefinitionId(instance.getId());
        double totalTime = 0;
        double averageTime;
        String processDefinitionID = instance.getId();

        HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.
                createHistoricProcessInstanceQuery().processInstanceTenantId(getTenantIdStr()).
                    processDefinitionId(processDefinitionID).finished();
        long instanceCount = historicProcessInstanceQuery.count();

        if (instanceCount != 0) {
            List<HistoricProcessInstance> instanceList = historicProcessInstanceQuery.list();

            for (HistoricProcessInstance completedProcess : instanceList) {
                double timeDurationOfTask = completedProcess.getDurationInMillis();
                double timeInMins = timeDurationOfTask / (1000 * 60);
                totalTime += timeInMins;
            }
            averageTime = totalTime / instanceCount;
            bpmnProcessInstance.setAverageTimeForCompletion(averageTime);
            list.add(bpmnProcessInstance);
        }
    }
    response.setData(list);
    return response;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:47,代码来源:ProcessStatisticsService.java

示例5: avgTaskTimeDurationForCompletedProcesses

import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
 * Average task duration for completed processes
 *
 * @param pId processDefintionId of the process selected to view the average time duration for each task
 * @return list of completed tasks with the average time duration for the selected process
 */
@GET
@Path("/task-instances/duration/avarage/{pid}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseHolder avgTaskTimeDurationForCompletedProcesses(@PathParam("pid") String pId) {

    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    HistoryService historyService = BPMNOSGIService.getHistoryService();

    long processCount = repositoryService.createProcessDefinitionQuery().
            processDefinitionTenantId(getTenantIdStr()).processDefinitionId(pId).count();

    if (processCount == 0) {
        throw new ActivitiObjectNotFoundException("Count not find a matching process with PID '" +
                pId + "'.");
    }

    ResponseHolder response = new ResponseHolder();
    List<Object> taskListForProcess = new ArrayList<>();
    HashMap<String, Long> map = new HashMap<>();

    //Get the number of completed/finished process instance for each process definition
    HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService
            .createHistoricProcessInstanceQuery().processInstanceTenantId(getTenantIdStr())
            .processDefinitionId(pId).finished();
    //Get the count of the complete process instances
    long noOfHistoricInstances = historicProcessInstanceQuery.count();

    //If the deployed process does not have any completed process instances --> Ignore
    if (noOfHistoricInstances == 0) {
        response.setData(taskListForProcess);
    }
    //If the deployed process has completed process instances --> then
    else {

        TaskInstanceAverageInfo tInstance;
        //Get the list of completed tasks/activities in the completed process instance by passing the
        //process definition id of the process
        List<HistoricTaskInstance> taskList = BPMNOSGIService.getHistoryService().
                createHistoricTaskInstanceQuery().taskTenantId(getTenantIdStr()).processDefinitionId(pId)
                .processFinished().list();
        //Iterate through each completed task/activity and get the task name and duration
        for (HistoricTaskInstance taskInstance : taskList) {
            //Get the task name
            String taskKey = taskInstance.getTaskDefinitionKey();
            //Get the time duration taken for the task to be completed
            long taskDuration = taskInstance.getDurationInMillis();

            if (map.containsKey(taskKey)) {
                long tt = map.get(taskKey);
                map.put(taskKey, taskDuration + tt);
            } else {
                map.put(taskKey, taskDuration);
            }
            //Iterating Task List finished
        }
        Iterator iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            String key = iterator.next().toString();
            double value = map.get(key) / noOfHistoricInstances;
            tInstance = new TaskInstanceAverageInfo();
            tInstance.setTaskDefinitionKey(key);
            tInstance.setAverageTimeForCompletion(value);
            taskListForProcess.add(tInstance);
        }

        response.setData(taskListForProcess);
    }
    return response;
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:76,代码来源:ProcessStatisticsService.java


注:本文中的org.activiti.engine.history.HistoricProcessInstanceQuery.count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。