Search in sources :

Example 1 with Command

use of com.walmartlabs.concord.svm.Command in project concord by walmartlabs.

the class IfCompiler method compile.

@Override
public Command compile(CompilerContext context, IfStep step) {
    Command thenCommand = compile(context, step.getThenSteps());
    Command elseCommand = compile(context, step.getElseSteps());
    return new IfCommand(step, thenCommand, elseCommand);
}
Also used : BlockCommand(com.walmartlabs.concord.runtime.v2.runner.vm.BlockCommand) IfCommand(com.walmartlabs.concord.runtime.v2.runner.vm.IfCommand) Command(com.walmartlabs.concord.svm.Command) IfCommand(com.walmartlabs.concord.runtime.v2.runner.vm.IfCommand)

Example 2 with Command

use of com.walmartlabs.concord.svm.Command in project concord by walmartlabs.

the class SwitchCompiler method compile.

@Override
public Command compile(CompilerContext context, SwitchStep step) {
    List<Map.Entry<String, Command>> caseCommands = new ArrayList<>();
    for (Map.Entry<String, List<Step>> kv : step.getCaseSteps()) {
        caseCommands.add(new AbstractMap.SimpleEntry<>(kv.getKey(), compile(context, kv.getValue())));
    }
    Command defaultCommand = compile(context, step.getDefaultSteps());
    return new SwitchCommand(step, caseCommands, defaultCommand);
}
Also used : AbstractMap(java.util.AbstractMap) SwitchCommand(com.walmartlabs.concord.runtime.v2.runner.vm.SwitchCommand) SwitchCommand(com.walmartlabs.concord.runtime.v2.runner.vm.SwitchCommand) BlockCommand(com.walmartlabs.concord.runtime.v2.runner.vm.BlockCommand) Command(com.walmartlabs.concord.svm.Command) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 3 with Command

use of com.walmartlabs.concord.svm.Command in project concord by walmartlabs.

the class ScriptCallCompiler method compile.

@Override
public Command compile(CompilerContext context, ScriptCall step) {
    Command cmd = new ScriptCallCommand(step);
    ScriptCallOptions options = Objects.requireNonNull(step.getOptions());
    Retry retry = options.retry();
    if (retry != null) {
        cmd = new RetryWrapper(cmd, retry);
    }
    WithItems withItems = options.withItems();
    if (withItems != null) {
        cmd = WithItemsWrapper.of(cmd, withItems, Collections.emptyList(), Collections.emptyMap());
    }
    Loop loop = options.loop();
    if (loop != null) {
        cmd = LoopWrapper.of(context, cmd, loop, Collections.emptyList(), Collections.emptyMap());
    }
    List<Step> errorSteps = options.errorSteps();
    if (!errorSteps.isEmpty()) {
        cmd = new ErrorWrapper(cmd, CompilerUtils.compile(context, errorSteps));
    }
    return cmd;
}
Also used : Command(com.walmartlabs.concord.svm.Command)

Example 4 with Command

use of com.walmartlabs.concord.svm.Command in project concord by walmartlabs.

the class TaskCallCompiler method compile.

@Override
public Command compile(CompilerContext context, TaskCall step) {
    Command cmd = new TaskCallCommand(step);
    TaskCallOptions options = Objects.requireNonNull(step.getOptions());
    Retry retry = options.retry();
    if (retry != null) {
        cmd = new RetryWrapper(cmd, retry);
    }
    WithItems withItems = options.withItems();
    if (withItems != null) {
        Collection<String> out = Collections.emptyList();
        if (options.out() != null) {
            out = Collections.singletonList(options.out());
        }
        cmd = WithItemsWrapper.of(cmd, withItems, out, options.outExpr());
    }
    Loop loop = options.loop();
    if (loop != null) {
        Collection<String> out = Collections.emptyList();
        if (options.out() != null) {
            out = Collections.singletonList(options.out());
        }
        cmd = LoopWrapper.of(context, cmd, loop, out, options.outExpr());
    }
    List<Step> errorSteps = options.errorSteps();
    if (!errorSteps.isEmpty()) {
        cmd = new ErrorWrapper(cmd, CompilerUtils.compile(context, errorSteps));
    }
    return cmd;
}
Also used : Command(com.walmartlabs.concord.svm.Command)

Example 5 with Command

use of com.walmartlabs.concord.svm.Command in project concord by walmartlabs.

the class FlowCallCompiler method compile.

@Override
public Command compile(CompilerContext context, FlowCall step) {
    Command cmd = new FlowCallCommand(step);
    FlowCallOptions options = Objects.requireNonNull(step.getOptions());
    Retry retry = options.retry();
    if (retry != null) {
        cmd = new RetryWrapper(cmd, retry);
    }
    WithItems withItems = options.withItems();
    if (withItems != null) {
        cmd = WithItemsWrapper.of(cmd, withItems, options.out(), options.outExpr());
    }
    Loop loop = options.loop();
    if (loop != null) {
        cmd = LoopWrapper.of(context, cmd, loop, options.out(), options.outExpr());
    }
    List<Step> errorSteps = options.errorSteps();
    if (!errorSteps.isEmpty()) {
        cmd = new ErrorWrapper(cmd, CompilerUtils.compile(context, errorSteps));
    }
    return cmd;
}
Also used : Command(com.walmartlabs.concord.svm.Command)

Aggregations

Command (com.walmartlabs.concord.svm.Command)6 BlockCommand (com.walmartlabs.concord.runtime.v2.runner.vm.BlockCommand)3 ErrorWrapper (com.walmartlabs.concord.runtime.v2.runner.vm.ErrorWrapper)1 IfCommand (com.walmartlabs.concord.runtime.v2.runner.vm.IfCommand)1 SwitchCommand (com.walmartlabs.concord.runtime.v2.runner.vm.SwitchCommand)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1