ProcessEngine pe = this.getProcessEngine();
RepositoryService repo = pe.getRepositoryService();
RuntimeService rt = pe.getRuntimeService();
HistoryService hs = pe.getHistoryService();
ProcessInstance pi = rt.createProcessInstanceQuery().processInstanceId(pid).singleResult();
HistoricProcessInstance hpi = hs.createHistoricProcessInstanceQuery().processInstanceId(pid)
.singleResult();
if (pi == null && hpi == null) {
// both null means. no process with that id.
out().printf("No process details found with process id %s \n", pid);
return;
}
String pdId = null;
if (pi != null) {
pdId = pi.getProcessDefinitionId();
} else if (hpi != null) {
pdId = hpi.getProcessDefinitionId();
}
ProcessDefinition pd = repo.createProcessDefinitionQuery().processDefinitionId(pdId).singleResult();