if (executionList.isEmpty()) {
return null;
}
ExecutionEntity processInstance = null;
// find process instance && index executions by parentActivityInstanceId
Map<String, List<ExecutionEntity>> executionsByParentActIds = new HashMap<String, List<ExecutionEntity>>();
for (ExecutionEntity executionEntity : executionList) {
if (executionEntity.isProcessInstanceExecution()) {
processInstance = executionEntity;
}
String parentActivityInstanceId = executionEntity.getParentActivityInstanceId();
List<ExecutionEntity> exeForThisParentActInst = executionsByParentActIds.get(parentActivityInstanceId);
if (exeForThisParentActInst == null) {
exeForThisParentActInst = new ArrayList<ExecutionEntity>();
executionsByParentActIds.put(parentActivityInstanceId, exeForThisParentActInst);
}
exeForThisParentActInst.add(executionEntity);
}
// create act instance for process instance
ActivityInstanceImpl processActInst = new ActivityInstanceImpl();
processActInst.setId(processInstanceId);
processActInst.setParentActivityInstanceId(null);
processActInst.setProcessInstanceId(processInstanceId);
processActInst.setProcessDefinitionId(processInstance.getProcessDefinitionId());
processActInst.setExecutionIds(new String[]{processInstanceId});
processActInst.setBusinessKey(processInstance.getBusinessKey());
processActInst.setActivityId(processInstance.getProcessDefinitionId());
processActInst.setActivityName(processInstance.getProcessDefinition().getName());
processActInst.setBusinessKey(processInstance.getBusinessKey());
processActInst.setActivityType("processDefinition");
initActivityInstanceTree(processActInst, executionsByParentActIds);
return processActInst;