manager.getContextFromStack().setType(currentType);
}
protected void handleParallelGateway(List<SequenceFlow> outgoing) {
PathContext context = manager.getContextFromStack();
boolean canBeFinished = context.isCanBeFinished();
context.setCanBeFinished(false);
manager.addAllToPath(outgoing, context);
int counter = 0;
for (SequenceFlow seqFlow : outgoing) {
counter++;
FlowElement target = seqFlow.getTargetRef();
if (counter == outgoing.size()) {
context = manager.getContextFromStack();
context.setCanBeFinished(canBeFinished);
}
super.handle(target, manager);
}
// finalize paths if there are any to cover scenario when there was not converging parallel gateway
if (canBeFinished) {
for (SequenceFlow seqFlow : outgoing) {
manager.addToPath(seqFlow, context);
manager.addToPath(seqFlow.getTargetRef(), context);
}
Iterator<PathContext> it = manager.getPaths().iterator();
while (it.hasNext()) {
PathContext pathContext = (PathContext) it.next();
if (pathContext.getType() == Type.ACTIVE) {
pathContext.setCanBeFinishedNoIncrement(canBeFinished);
manager.finalizePath(pathContext);
it.remove();
}
}