SequenceFlow newFlow(String from, String to) { if (primed) { primed = false; String id = name; if (id == null) { id = seq.nextFlowId(from, to); } return new SequenceFlow(id, from, to, expression); } return new SequenceFlow(seq.nextFlowId(from, to), from, to); } }
private static List<AbstractElement> link(IdGenerator idGenerator, List<Container> containers) { if (containers.isEmpty()) { return Collections.emptyList(); } List<AbstractElement> l = new ArrayList<>(); Collection<AbstractElement> last = null; for (Container c : containers) { if (last != null) { for (AbstractElement e : last) { l.add(new SequenceFlow(idGenerator.nextId(), e.getId(), c.first.getId())); } } l.add(c.first); if (c.rest != null) { l.addAll(c.rest); } l.addAll(c.last); last = c.last; } return l; }
private static List<AbstractElement> addEntryPoint(IdGenerator idGenerator, List<AbstractElement> elements) throws ParserException { if (elements.size() < 1) { throw new ParserException("Can't add an entry point to a empty block"); } List<AbstractElement> l = new ArrayList<>(elements); AbstractElement first = l.get(0); AbstractElement last = l.get(l.size() - 1); String startId = idGenerator.nextId(); String endId = idGenerator.nextId(); l.add(0, new StartEvent(startId)); l.add(1, new SequenceFlow(idGenerator.nextId(), startId, first.getId())); l.add(new SequenceFlow(idGenerator.nextId(), last.getId(), endId)); l.add(new EndEvent(endId)); return l; }
public List<AbstractElement> wrapAsProcess(Chunk c) { List<AbstractElement> l = new ArrayList<>(); String startId = nextId(); l.add(new StartEvent(startId)); if (c.isEmpty()) { String endId = nextId(); l.add(new SequenceFlow(nextId(), startId, endId)); l.add(new EndEvent(endId)); return l; } l.add(new SequenceFlow(nextId(), startId, c.firstElement().getId())); l.addAll(c.getElements()); if (!c.getOutputs().isEmpty()) { String endId = nextId(); for (String src : c.getOutputs()) { l.add(new SequenceFlow(nextId(), src, endId)); } l.add(new EndEvent(endId)); } return l; }
SequenceFlow f = new SequenceFlow(idGenerator.nextId(), gw.getId(), toId, (String) expr); elements.add(f); elements.addAll(es);
result.add(new SequenceFlow(idGenerator.nextId(), evId, callId)); result.add(a.first); if (a.last != null) { for (AbstractElement l : a.last) { result.add(new SequenceFlow(idGenerator.nextId(), l.getId(), endId));
SequenceFlow sf = new SequenceFlow(id, sourceRef, targetRef, expr, l); sf.setName(name); children.add(sf);
private void connect(Chunk c, Chunk a, Chunk b) { String dst = b.firstElement().getId(); for (String src : a.getOutputs()) { c.addElement(new SequenceFlow(nextId(), src, dst)); } } }
result.addElement(new SequenceFlow(ctx.nextId(), startId, initId)); result.addElement(new SequenceFlow(ctx.nextId(), initId, nextItemTaskId)); result.addElement(new SequenceFlow(ctx.nextId(), nextItemTaskId, hasNextGwId)); result.addElement(new SequenceFlow(ctx.nextId(), processOutVarsTask, nextItemTaskId)); result.addElement(new SequenceFlow(ctx.nextId(), hasNextGwId, c.firstElement().getId(), "${__withItemsUtils.hasNext(execution)}")); result.addElement(new SequenceFlow(ctx.nextId(), hasNextGwId, cleanupTaskId)); c.getOutputs().forEach(o -> { result.addElement(new SequenceFlow(ctx.nextId(), o, processOutVarsTask)); });
c.addElement(new SequenceFlow(ctx.nextId(), originalTaskEvId, incCounterId)); c.addElement(new ServiceTask(incCounterId, ExpressionType.SIMPLE, "${__retryUtils.inc(execution, '__retryCount')}", null, null, true)); c.addElement(new SequenceFlow(ctx.nextId(), incCounterId, retryCountGwId)); c.addElement(new ExclusiveGateway(retryCountGwId)); c.addElement(new SequenceFlow(ctx.nextId(), retryCountGwId, retryDelayId, "${__retryCount <= " + retryParams.get("times") + "}")); c.addElement(new ServiceTask(retryDelayId, ExpressionType.SIMPLE, "${__retryUtils.sleep(" + getRetryDelay(retryParams) + ")}", null, null, true)); c.addElement(new SequenceFlow(ctx.nextId(), retryDelayId, retryTaskId)); c.addElement(new ServiceTask(retryTaskId, ExpressionType.DELEGATE, "${" + s.getKey() + "}", c.addElement(new SequenceFlow(ctx.nextId(), retryTaskEventId, incCounterId)); String expr = "${__retryUtils.throwLastError(execution)}"; c.addElement(new ServiceTask(throwTaskId, ExpressionType.DELEGATE, expr, null, null, true)); c.addElement(new SequenceFlow(ctx.nextId(), retryCountGwId, throwTaskId)); c.addElement(new SequenceFlow(ctx.nextId(),throwTaskId, endId));
@SuppressWarnings("unchecked") default void applyErrorBlock(ConverterContext ctx, Chunk c, String attachedRef, Map<String, Object> opts) throws YamlConverterException { if (opts == null) { return; } Seq<YamlStep> errorSteps = (Seq<YamlStep>) opts.get("error"); if (errorSteps == null) { return; } String evId = ctx.nextId(); c.addElement(new BoundaryEvent(evId, attachedRef, null)); Chunk err = ctx.convert(errorSteps); // connect the boundary event to the error block's steps String dst = err.firstElement().getId(); c.addElement(new SequenceFlow(ctx.nextId(), evId, dst)); c.addElements(err.getElements()); c.addOutputs(err.getOutputs()); // keep the source map of the error block's steps c.addSourceMaps(err.getSourceMap()); }
private static void applyDefaultBlock(ConverterContext ctx, Chunk c, String gwId, Seq<YamlStep> steps) throws YamlConverterException { Chunk defaultChunk = steps != null ? ctx.convert(steps) : null; if (defaultChunk == null || defaultChunk.isEmpty()) { c.addOutput(gwId); return; } String dst = defaultChunk.firstElement().getId(); c.addElement(new SequenceFlow(ctx.nextId(), gwId, dst)); c.addElements(defaultChunk.getElements()); // output of the "default" case c.addOutputs(defaultChunk.getOutputs()); c.addSourceMaps(defaultChunk.getSourceMap()); } }
private static void applyElseBlock(ConverterContext ctx, Chunk c, String gwId, Seq<YamlStep> steps) throws YamlConverterException { Chunk elseChunk = steps != null ? ctx.convert(steps) : null; if (elseChunk == null || elseChunk.isEmpty()) { c.addOutput(gwId); return; } // connect "else" steps with the gateway String elseDst = elseChunk.firstElement().getId(); c.addElement(new SequenceFlow(ctx.nextId(), gwId, elseDst)); c.addElements(elseChunk.getElements()); // output of the "else" branch c.addOutputs(elseChunk.getOutputs()); c.addSourceMaps(elseChunk.getSourceMap()); } }
c.addElement(new SequenceFlow(ctx.nextId(), id, gwId)); c.addSourceMap(gwId, toSourceMap(s, "Switch: " + s.getExpr())); c.addElement(new SequenceFlow(ctx.nextId(), gwId, dst, buildCaseExpression(caseKey, switchExprResultVarName))); c.addElements(caseChunk.getElements()); c.addOutputs(caseChunk.getOutputs());
@Override public Chunk convert(ConverterContext ctx, YamlIfExpr s) throws YamlConverterException { Chunk c = new Chunk(); String gwId = ctx.nextId(); c.addElement(new ExclusiveGateway(gwId)); c.addSourceMap(gwId, toSourceMap(s, "Check: " + s.getExpr())); // "then" branch Chunk thenChunk = ctx.convert(s.getThenSteps()); // connect "then" steps with the gateway String thenDst = thenChunk.firstElement().getId(); c.addElement(new SequenceFlow(ctx.nextId(), gwId, thenDst, s.getExpr())); c.addElements(thenChunk.getElements()); c.addOutputs(thenChunk.getOutputs()); c.addSourceMaps(thenChunk.getSourceMap()); // "else" branch applyElseBlock(ctx, c, gwId, s.getElseSteps()); return c; }