Search in sources :

Example 11 with HistoricProcessInstanceQuery

use of org.activiti.engine.history.HistoricProcessInstanceQuery in project midpoint by Evolveum.

the class ProcessInstanceManager method getActivitiToMidpoint.

private Map<String, String> getActivitiToMidpoint(Set<String> activeProcessInstances, OperationResult result) {
    Map<String, String> rv = new HashMap<>();
    int processWithoutTaskOidCount = 0;
    HistoricProcessInstanceQuery query = activitiEngine.getHistoryService().createHistoricProcessInstanceQuery().includeProcessVariables().excludeSubprocesses(true);
    List<HistoricProcessInstance> processes = query.list();
    for (HistoricProcessInstance process : processes) {
        String taskOid = (String) process.getProcessVariables().get(CommonProcessVariableNames.VARIABLE_MIDPOINT_TASK_OID);
        rv.put(process.getId(), taskOid);
        if (taskOid == null) {
            processWithoutTaskOidCount++;
        }
        if (process.getEndTime() == null) {
            activeProcessInstances.add(process.getId());
        }
    }
    LOGGER.info("Found {} processes; among these, {} have no task OID. Active processes: {}", rv.size(), processWithoutTaskOidCount, activeProcessInstances.size());
    return rv;
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Aggregations

HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)11 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)9 Deployment (org.activiti.engine.test.Deployment)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 HashMap (java.util.HashMap)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 JobQuery (org.activiti.engine.runtime.JobQuery)1 Test (org.junit.Test)1