-
1. Re: How can i get the human task id defined in bpmn files?
roxy1987 May 16, 2013 11:12 AM (in response to jayzhang)1 of 1 people found this helpfulI believe you have the process instance ID. So you can find the process definition id using the instance id first.
Using the process def id, you will need to find the Process object to get the node related information.
Here is what you can do,
String strProcessDefId = JPAProcessInstanceDbLog.findProcessInstance(intProcessInstId).getProcessId(); // Get process def id. readKnowledgeBase(); // Get the knowledge base by feeding it the process name. Process objProcess = objKBase.getProcess(strProcessDefId); // Process object. for (Node objNode : ((WorkflowProcessImpl) objProcess).getNodes()) { Map<String, Object> hshMetaData = objNode.getMetaData(); System.out.println(hshMetaData.get("UniqueId")); }
Regards.
-
2. Re: How can i get the human task id defined in bpmn files?
jayzhang May 16, 2013 8:26 PM (in response to roxy1987)Thank you!
I solve the problem in this way:
//get session
StatefulKnowledgeSession sess = this.jbpm5helper.buildJbpmSession(0);
//get processInstance by processInstanceId
RuleFlowProcessInstance processInstance=(RuleFlowProcessInstance)sess.getProcessInstance(processInstanceId);
//get the id of node To be executed
List<NodeInstance> nodeList=(List<NodeInstance>)processInstance.getNodeInstances();
int currentNodeId=(int)nodeList.get(0).getNodeId();
-
3. Re: How can i get the human task id defined in bpmn files?
imphilippesimo Jun 14, 2016 9:38 PM (in response to jayzhang)hi, may be its too late but i hope this could be helpful for someone else
try this method
List<Long> getHumanTaskNodes(String processIdAsString, RuntimeEnvironment environment) {
List<Long> nodeIds = new ArrayList<Long>();
WorkflowProcess workflowProcess = (WorkflowProcess) environment
.getKieBase().getProcess(processIdAsString);
for (Node node : workflowProcess.getNodes()) {
if (node instanceof CompositeContextNode) {
for (Node inNode : ((CompositeContextNode) node).getNodes())
if (inNode instanceof HumanTaskNode)
nodeIds.add(inNode.getId());
} else if (node instanceof HumanTaskNode)
nodeIds.add(node.getId());
}
return nodeIds;
}
Here you have all your humanTasks ids