default T task(ExpressionType expType, String expr, Set<VariableMapping> in, Set<VariableMapping> out, boolean copyAllVariables) { return add(new ServiceTask(nextStepId(), expType, expr, in, out, copyAllVariables)); }
@Override public String toString() { return "ServiceTask (" + getId() + ") {" + "name='" + name + '\'' + ", expression='" + expression + '\'' + ", type=" + type + ", in=" + in + ", out=" + out + ", copyAllVariables=" + copyAllVariables + '}'; } }
ServiceTask st = new ServiceTask(id, type, expr); st.setName(name); children.add(st); break;
ServiceTask t = (ServiceTask) ProcessDefinitionUtils.findElement(pd, cmd.getElementId()); ExpressionType type = t.getType(); String expr = t.getExpression(); actions.add(new EvalExpressionAction.Builder(cmd.getDefinitionId(), t.getId(), t.getType(), t.getExpression(), defaultCommand) .withTimeouts(timeouts) .withDefaultError(defaultError) .withErrors(errors) .withInVariables(notEmpty(t.getIn())) .withOutVariables(notEmpty(t.getOut())) .withCopyAllVariables(t.isCopyAllVariables()) .build());
private static Container toElements(IdGenerator idGenerator, Map<String, Object> m) throws ParserException { if (m.containsKey(SUBPROCESS_KEY)) { return toSubProcess(idGenerator, m); } if (m.containsKey(EXPR_KEY)) { ServiceTask t = new ServiceTask(idGenerator.nextId(), ExpressionType.SIMPLE, m.get("expr").toString()); return new Container(t, t); } if (m.containsKey(END_KEY)) { String errorRef = (String) m.get(END_KEY); EndEvent e = new EndEvent(idGenerator.nextId(), errorRef); return new Container(e, e); } if (m.containsKey(CALL_KEY)) { return toCallActivity(idGenerator, m); } if (m.containsKey(SWITCH_KEY)) { return toSwitch(idGenerator, m); } throw new ParserException("Unsupported element type: " + m); }
@Override public Chunk convert(ConverterContext ctx, YamlCheckpoint s) throws YamlConverterException { Chunk c = new Chunk(); String id = ctx.nextId(); String checkpoint = s.getKey(); Set<VariableMapping> inVars = new HashSet<>(); inVars.add(new VariableMapping(null, null, checkpoint, "checkpointName", true)); Set<VariableMapping> outVars = new HashSet<>(); outVars.add(new VariableMapping("checkpointId", null, null, "checkpointId", true)); outVars.add(new VariableMapping("checkpointName", null, null, "checkpointName", true)); c.addElement(new ServiceTask(id, ExpressionType.DELEGATE, "${checkpoint}", inVars, outVars, true)); c.addSourceMap(id, toSourceMap(s, "Checkpoint: " + s.getKey())); c.addOutput(id); return c; } }
@Override public Chunk convert(ConverterContext ctx, YamlDockerStep s) throws YamlConverterException { Chunk c = new Chunk(); String id = ctx.nextId(); Map<String, Object> args = new HashMap<>(); args.put("image", s.getImage()); args.put("forcePull", s.isForcePull()); args.put("debug", s.isDebug()); args.put("cmd", s.getCmd()); args.put("env", s.getEnv()); args.put("envFile", s.getEnvFile()); args.put("options", s.getOptions()); args.put("stdout", s.getStdout()); ELCall call = createELCall("docker", args); c.addElement(new ServiceTask(id, ExpressionType.SIMPLE, call.getExpression(), call.getArgs(), null, true)); c.addOutput(id); c.addSourceMap(id, toSourceMap(s, "Docker: " + s.getImage())); return c; } }
@Override public Chunk convert(ConverterContext ctx, YamlSetVariablesStep s) throws YamlConverterException { Chunk c = new Chunk(); String id = ctx.nextId(); String expression = "${vars.set(execution, __0)}"; Object vars = StepConverter.deepConvert(s.getVariables()); Set<VariableMapping> inVars = Collections.singleton(new VariableMapping(null, null, vars, "__0", true)); c.addElement(new ServiceTask(id, ExpressionType.SIMPLE, expression, inVars, null, true)); c.addOutput(id); c.addSourceMap(id, toSourceMap(s, "Set variables")); return c; } }
@Override public Chunk convert(ConverterContext ctx, YamlExpressionStep s) throws YamlConverterException { Chunk c = new Chunk(); Set<VariableMapping> outVars = null; Map<String, Object> opts = s.getOptions(); if (opts != null) { String out = (String) opts.get("out"); if (out != null) { outVars = Collections.singleton(new VariableMapping(ServiceTask.EXPRESSION_RESULT_VAR, null, out)); } } String id = ctx.nextId(); c.addElement(new ServiceTask(id, ExpressionType.SIMPLE, s.getExpr(), null, outVars, true)); c.addOutput(id); c.addSourceMap(id, toSourceMap(s, "Expression: " + s.getExpr())); applyErrorBlock(ctx, c, id, s.getOptions()); return c; } }
String cleanupTaskId = ctx.nextId(); result.addElement(new ServiceTask(initId, ExpressionType.SIMPLE, "${__withItemsUtils.init(execution)}", Collections.singleton(taskVars), null, true)); result.addElement(new ServiceTask(nextItemTaskId, ExpressionType.SIMPLE, "${__withItemsUtils.nextItem(execution)}", Collections.singleton(taskVars), null, true)); result.addElement(new ServiceTask(processOutVarsTask, ExpressionType.SIMPLE, "${__withItemsUtils.processOutVars(execution, __0)}", Collections.singleton(outVarsMapping), null, true)); result.addElement(new ExclusiveGateway(hasNextGwId)); result.addElement(new ServiceTask(cleanupTaskId, ExpressionType.SIMPLE, "${__withItemsUtils.cleanup(execution, __0)}", Collections.singleton(outVarsMapping), null, true));
@Override public Chunk convert(ConverterContext ctx, YamlTaskShortStep s) throws YamlConverterException { Chunk c = new Chunk(); ELCall call = createELCall(s.getKey(), s.getArg()); String id = ctx.nextId(); c.addElement(new ServiceTask(id, ExpressionType.SIMPLE, call.getExpression(), call.getArgs(), null, true)); c.addOutput(id); c.addSourceMap(id, toSourceMap(s, "Task: " + s.getKey())); return c; } }
@Override public Chunk convert(ConverterContext ctx, YamlTaskStep s) throws YamlConverterException { Chunk c = new Chunk(); Set<VariableMapping> inVars = getVarMap(s.getOptions(), "in"); Set<VariableMapping> outVars = getVarMap(s.getOptions(), "out"); String id = ctx.nextId(); String expr = "${" + s.getKey() + "}"; c.addElement(new ServiceTask(id, ExpressionType.DELEGATE, expr, inVars, outVars, true)); c.addOutput(id); c.addSourceMap(id, toSourceMap(s, "Task: " + s.getKey())); Map<String, Object> opts = s.getOptions(); if (opts != null && opts.get("error") != null && opts.get("retry") != null) { throw new YamlConverterException("'error' and 'retry' options are mutually exclusive"); } applyErrorBlock(ctx, c, id, s.getOptions()); applyRetryBlock(ctx, c, id, s); return applyWithItems(ctx, c, s.getOptions()); }
c.addElement(new ServiceTask(incCounterId, ExpressionType.SIMPLE, "${__retryUtils.inc(execution, '__retryCount')}", null, null, true)); c.addElement(new ServiceTask(retryDelayId, ExpressionType.SIMPLE, "${__retryUtils.sleep(" + getRetryDelay(retryParams) + ")}", null, null, true)); c.addElement(new ServiceTask(retryTaskId, ExpressionType.DELEGATE, "${" + s.getKey() + "}", getInVars(opts, retryParams), getVarMap(opts, "out"), true)); c.addElement(new ServiceTask(throwTaskId, ExpressionType.DELEGATE, expr, null, null, true)); c.addElement(new SequenceFlow(ctx.nextId(), retryCountGwId, throwTaskId));
String switchExprResultVarName = "__switch_expr_result_" + id; Set<VariableMapping> outVars = Collections.singleton(new VariableMapping(ServiceTask.EXPRESSION_RESULT_VAR, null, switchExprResultVarName)); c.addElement(new ServiceTask(id, ExpressionType.SIMPLE, s.getExpr(), null, outVars, true)); c.addSourceMap(id, toSourceMap(s, "Switch expression: " + s.getExpr()));