How to get all childelements (JavaDelegate, Camunda BPM Reactor)

Hi Paul,

#getChildElementsByType returns all child elements in the XML sense, so it doesn’t help you. You can access all nodes that follow a certain node as follows:

UserTask userTask = modelInstance.getModelElementById("foo");
Collection<SequenceFlow> outgoingSequenceFlows = userTask.getOutgoing();

outgoingSequenceFlows.forEach(f -> {
  FlowNode nextFlowNode = f.getTarget();

  if (nextFlowNode instanceof UserTask)
  {
    // do something
  }
});

You can do this repeatedly to traverse the process graph. Just be aware that you may have to watch out for infinite loops in your process model.

Cheers,
Thorben