Search in sources :

Example 1 with SetVariablesStep

use of com.walmartlabs.concord.runtime.v2.model.SetVariablesStep in project concord by walmartlabs.

the class SetVariablesCommand method execute.

@Override
@SuppressWarnings("unchecked")
protected void execute(Runtime runtime, State state, ThreadId threadId) {
    state.peekFrame(threadId).pop();
    SetVariablesStep step = getStep();
    Context ctx = runtime.getService(Context.class);
    // eval the input
    ExpressionEvaluator ee = runtime.getService(ExpressionEvaluator.class);
    Map<String, Object> vars = ee.evalAsMap(EvalContextFactory.scope(ctx), step.getVars());
    vars.forEach((k, v) -> {
        Object o = ctx.variables().get(k);
        if (o instanceof Map && v instanceof Map) {
            v = deepMerge((Map<String, Object>) o, (Map<String, Object>) v);
        }
        ctx.variables().set(k, v);
    });
}
Also used : Context(com.walmartlabs.concord.runtime.v2.sdk.Context) SetVariablesStep(com.walmartlabs.concord.runtime.v2.model.SetVariablesStep) ExpressionEvaluator(com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator) Map(java.util.Map)

Aggregations

SetVariablesStep (com.walmartlabs.concord.runtime.v2.model.SetVariablesStep)1 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)1 Context (com.walmartlabs.concord.runtime.v2.sdk.Context)1 Map (java.util.Map)1