private ExecutionImpl createExecution(Object owner) { ExecutionImpl execution = new ExecutionImpl(); execution.setProcessDefinition(getProcessDefinition(owner)); return execution; }
private List<ProcessInstanceRef> adoptProcessInstances(List<ProcessInstance> processInstances, ProcessDefinition processDefinition) { List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>(); for (Execution processInstance : processInstances) { if (processInstance.isEnded()) { continue; // JBPM-2055: Execution is already ended. Should not show up in query } if (processInstance.getIsProcessInstance()) { // parent execution ((ExecutionImpl) processInstance).setProcessDefinition((ProcessDefinitionImpl) processDefinition); results.add(ModelAdaptor.adoptExecution(processInstance)); } } return results; }
public static ProcessInstanceRef adoptExecution(Execution execution) { ProcessInstanceRef ref = new ProcessInstanceRef(); ref.setId(execution.getId()); ref.setKey(execution.getKey()); ref.setDefinitionId(execution.getProcessDefinitionId()); // Start date is only available through historyService HistoryService historyService = ProcessEngineUtil.retrieveProcessEngine().getHistoryService(); Date startDate = historyService.createHistoryProcessInstanceQuery() .processInstanceId(execution.getId()) .uniqueResult().getStartTime(); ref.setStartDate(startDate); ExecutionImpl processInstance = (ExecutionImpl) execution.getProcessInstance(); ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition(); TokenReference tok = execution2TokenReference(processInstance); Collection<? extends Execution> childExecutions = processInstance.getExecutions(); if (childExecutions != null) { for (Execution child : childExecutions) { ExecutionImpl childExecution = (ExecutionImpl) child; // set process definition on child execution from process instance childExecution.setProcessDefinition(processDefinition); TokenReference childTok = execution2TokenReference(childExecution); tok.getChildren().add(childTok); } } ref.setRootToken(tok); return ref; }