Search in sources :

Example 1 with VariableContainer

use of io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.VariableContainer in project automatiko-engine by automatiko-io.

the class ProtobufProcessMarshaller method marshallVariablesContainer.

public static VariableContainer marshallVariablesContainer(MarshallerWriteContext context, Map<String, Object> variables) throws IOException {
    AutomatikoMessages.VariableContainer.Builder vcbuilder = AutomatikoMessages.VariableContainer.newBuilder();
    for (String key : variables.keySet()) {
        AutomatikoMessages.Variable.Builder builder = AutomatikoMessages.Variable.newBuilder().setName(key);
        if (variables.get(key) != null) {
            ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategyObject(variables.get(key));
            Integer index = context.getStrategyIndex(strategy);
            builder.setStrategyIndex(index).setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, variables.get(key))));
        }
        vcbuilder.addVariable(builder.build());
    }
    return vcbuilder.build();
}
Also used : Variable(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Variable) VariableContainer(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.VariableContainer) ObjectMarshallingStrategy(io.automatiko.engine.api.marshalling.ObjectMarshallingStrategy) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)1 ObjectMarshallingStrategy (io.automatiko.engine.api.marshalling.ObjectMarshallingStrategy)1 Variable (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Variable)1 VariableContainer (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.VariableContainer)1