use of org.jbpm.marshalling.impl.JBPMMessages.Variable in project jbpm by kiegroup.
the class ContentMarshallerHelper method fallbackParse.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Object fallbackParse(MarshallerReaderContext context, Header header, ExtensionRegistry registry) throws Exception {
Variable parseFrom = JBPMMessages.Variable.parseFrom(header.getPayload(), registry);
Object value = ProtobufProcessMarshaller.unmarshallVariableValue(context, parseFrom);
if (value instanceof Map) {
Map result = new HashMap();
Map<String, Variable> variablesMap = (Map<String, Variable>) value;
for (String key : variablesMap.keySet()) {
result.put(key, ProtobufProcessMarshaller.unmarshallVariableValue(context, variablesMap.get(key)));
}
return result;
}
return value;
}
use of org.jbpm.marshalling.impl.JBPMMessages.Variable in project jbpm by kiegroup.
the class ProtobufProcessMarshaller method marshallVariable.
public static Variable marshallVariable(MarshallerWriteContext context, String name, Object value) throws IOException {
JBPMMessages.Variable.Builder builder = JBPMMessages.Variable.newBuilder().setName(name);
if (value != null) {
ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategyObject(value);
Integer index = context.getStrategyIndex(strategy);
builder.setStrategyIndex(index).setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, value)));
}
return builder.build();
}
use of org.jbpm.marshalling.impl.JBPMMessages.Variable in project jbpm by kiegroup.
the class ProtobufProcessMarshaller method marshallVariablesMap.
public static Variable marshallVariablesMap(MarshallerWriteContext context, Map<String, Object> variables) throws IOException {
Map<String, Variable> marshalledVariables = new HashMap<String, Variable>();
for (String key : variables.keySet()) {
JBPMMessages.Variable.Builder builder = JBPMMessages.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))));
}
marshalledVariables.put(key, builder.build());
}
return marshallVariable(context, "variablesMap", marshalledVariables);
}
use of org.jbpm.marshalling.impl.JBPMMessages.Variable in project jbpm by kiegroup.
the class ProtobufProcessMarshaller method unmarshallVariableContainerValue.
public static Map<String, Object> unmarshallVariableContainerValue(MarshallerReaderContext context, JBPMMessages.VariableContainer _variableContiner) throws IOException, ClassNotFoundException {
Map<String, Object> variables = new HashMap<String, Object>();
if (_variableContiner.getVariableCount() == 0) {
return variables;
}
for (Variable _variable : _variableContiner.getVariableList()) {
Object value = ProtobufProcessMarshaller.unmarshallVariableValue(context, _variable);
variables.put(_variable.getName(), value);
}
return variables;
}
Aggregations