Hi,
I'm trying to get the node name for a process that at a given moment has a gateway making two tasks active simultaneasly.
The problem is that when I get the NodeInstance collection it seems that it is not iterating correctly, when I use a do/while with a hasNext I enter a infinite loop and only one NodeName is obtained.
Then I changed it for using size, and although the size is correct (in my case size is 2) the getNameName method always returns the same node name as if the iterator was always in the same place.
Can you help me on this?
Here is the code:
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
WorkflowProcessInstance workflowProcessInstance = null;
Collection<NodeInstance> nodes = ((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance).getNodeInstances();
int nodeSize = nodes.size();
System.out.println("Number of nodes - " + nodeSize);
int count = 0;
do {
processTasks = nodes.iterator().next().getNodeName();
System.out.println(processTasks + " - " + count);
count = count + 1;
} while (count < nodes.size());
The result of this code is:
Number of nodes - 2
Digitalize Document - 0
Digitalize Document - 1
Instead of:
Number of nodes - 2
Digitalize Document - 0
Insert data - 1
Thank you