Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue #354
  • Loading branch information
rsoika committed Sep 7, 2024
1 parent eac50d7 commit 9a762a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* <p>
* In case the filter does not match the current element, the Iterator will
* recursive follow the sequence flow until the next matching element was found.
* If the start element is null the Iterator will become empty.
*
*/
public class BPMNFlowIterator<T> implements Iterator<BPMNElementNode> {
Expand All @@ -41,7 +42,8 @@ public class BPMNFlowIterator<T> implements Iterator<BPMNElementNode> {
/**
* Creates a new BPMNFlowIterator with a given filter criteria.
* The method collects all BPMNElements following the given start element and
* matching the given filter
* matching the given filter. If the start element is null the Iterator is
* empty.
*
* @param bpmnElementNode
* @param filter
Expand All @@ -52,13 +54,16 @@ public BPMNFlowIterator(BPMNElementNode bpmnElementNode, Predicate<BPMNElementNo
this.targetNodes = new ArrayList<>();
this.index = 0;
// find all elements
findValidNodes(bpmnElementNode);
if (bpmnElementNode != null) {
findValidNodes(bpmnElementNode);
}
}

/**
* Creates a new BPMNFlowIterator with a given filter criteria.
* The method collects all BPMNElements following the given start element and
* matching the given filter
* matching the given filter. If the start element is null the Iterator is
* empty.
*
* @param bpmnElementNode
* @param filter
Expand All @@ -73,7 +78,9 @@ public BPMNFlowIterator(BPMNElementNode bpmnElementNode, Predicate<BPMNElementNo
this.targetNodes = new ArrayList<>();
this.index = 0;
// find all elements
findValidNodes(bpmnElementNode);
if (bpmnElementNode != null) {
findValidNodes(bpmnElementNode);
}
}

@Override
Expand All @@ -99,6 +106,9 @@ public BPMNElementNode next() {
* @param currentNode
*/
private void findValidNodes(BPMNElementNode currentNode) {
if (currentNode == null) {
return;
}
Set<SequenceFlow> flowSet = currentNode.getOutgoingSequenceFlows();
// Check if the sequence flow has a condition and evaluate it if a
// conditionEvaluator is defined
Expand All @@ -107,12 +117,14 @@ private void findValidNodes(BPMNElementNode currentNode) {
}

for (SequenceFlow flow : flowSet) {
BPMNElementNode node = getTargetNode(flow);// flow.getTargetElement();
if (filter.test(node)) {
targetNodes.add(node);
} else {
// if the node does not match the filter go ahead by a recursive call....
findValidNodes(node);
BPMNElementNode node = getTargetNode(flow);
if (node != null) {
if (filter.test(node)) {
targetNodes.add(node);
} else {
// if the node does not match the filter go ahead by a recursive call....
findValidNodes(node);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BPMNLinkNavigator {
public BPMNElementNode findNext(BPMNElementNode node) {

// is it a throw event?
if (BPMNTypes.THROW_EVENT.equals(node.getType())) {
if (node != null && BPMNTypes.THROW_EVENT.equals(node.getType())) {
String linkName = node.getName();
// now find the corresponding first catch event with the same name
Set<? extends BPMNElementNode> filteredElementList = node.getBpmnProcess()
Expand Down

0 comments on commit 9a762a3

Please sign in to comment.