use of io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Variable in project automatiko-engine by automatiko-io.
the class ProtobufProcessMarshaller method marshallVariablesMap.
public static Variable marshallVariablesMap(MarshallerWriteContext context, Map<String, Object> variables, boolean extractFiles) throws IOException {
Map<String, Variable> marshalledVariables = new HashMap<String, Variable>();
for (String key : variables.keySet()) {
AutomatikoMessages.Variable.Builder builder = AutomatikoMessages.Variable.newBuilder().setName(key);
Object variable = variables.get(key);
if (variable != null) {
ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategyObject(variable);
Integer index = context.getStrategyIndex(strategy);
builder.setStrategyIndex(index).setDataType(strategy.getType(variable.getClass())).setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, variable)));
}
marshalledVariables.put(key, builder.build());
}
return marshallVariable(context, "variablesMap", marshalledVariables, extractFiles);
}
use of io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Variable in project automatiko-engine by automatiko-io.
the class ProtobufProcessMarshaller method marshallVariable.
public static Variable marshallVariable(MarshallerWriteContext context, String name, Object value, boolean extractFiles) throws IOException {
AutomatikoMessages.Variable.Builder builder = AutomatikoMessages.Variable.newBuilder().setName(name);
if (value != null) {
if (extractFiles && (boolean) context.env.getOrDefault("_export_", false)) {
if (value instanceof ByteArrayFile) {
ByteArrayFile file = ((ByteArrayFile) value);
value = new ByteArrayFile(file.name(), file.content(), file.attributes());
}
}
ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategyObject(value);
Integer index = context.getStrategyIndex(strategy);
builder.setStrategyIndex(index).setDataType(strategy.getType(value.getClass())).setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, value)));
}
return builder.build();
}
Aggregations