private List<HistoryActivityInstanceRef> getProcessInstanceHistory(String processInstanceId) { org.jbpm.api.HistoryService historyService = this.processEngine.getHistoryService(); List<HistoryActivityInstance> his = historyService.createHistoryActivityInstanceQuery().processInstanceId(processInstanceId).list(); List<HistoryActivityInstanceRef> results = new ArrayList<HistoryActivityInstanceRef>(); for (HistoryActivityInstance t0 : his) { results.add(ModelAdaptor.adoptHistoryActivity(t0)); } return results; }
private List<HistoryProcessInstanceRef> getFinishedProcessInstances(String definitionId) { org.jbpm.api.HistoryService historyService = this.processEngine.getHistoryService(); List<HistoryProcessInstanceRef> results = new ArrayList<HistoryProcessInstanceRef>(); List<HistoryProcessInstance> his = historyService.createHistoryProcessInstanceQuery().processDefinitionId(definitionId).list(); for (HistoryProcessInstance t0 : his) { // all only finished elements if (t0.getEndTime() != null) { results.add(ModelAdaptor.adoptHistoryProcessInstance(t0)); } } 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; }