use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class JavaSerializationTest method testSetUntypedNullForExistingVariable.
@Test
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// initially the variable has a value
JavaSerializable javaSerializable = new JavaSerializable("foo");
runtimeService.setVariable(instance.getId(), "varName", objectValue(javaSerializable).serializationDataFormat(JAVA_DATA_FORMAT).create());
// get value via untyped api
assertEquals(javaSerializable, runtimeService.getVariable(instance.getId(), "varName"));
// set the variable to null via untyped Api
runtimeService.setVariable(instance.getId(), "varName", null);
// variable is now untyped null
TypedValue nullValue = runtimeService.getVariableTyped(instance.getId(), "varName");
assertUntypedNullValue(nullValue);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class PrimitiveTypeValueSerializationTest method shouldGetTypedVariable.
@Test
public void shouldGetTypedVariable() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);
runtimeService.setVariable(instance.getId(), VARIABLE_NAME, typedValue);
TypedValue typedVariableValue = runtimeService.getVariableTyped(instance.getId(), VARIABLE_NAME);
assertEquals(typedValue.getType(), typedVariableValue.getType());
assertEquals(typedValue.getValue(), typedVariableValue.getValue());
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class AbstractVariableScope method setVariableLocal.
public void setVariableLocal(String variableName, Object value) {
TypedValue typedValue = Variables.untypedValue(value);
setVariableLocal(variableName, typedValue, getSourceActivityVariableScope());
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class AbstractVariableScope method setVariableLocalTransient.
/**
* Sets a variable in the local scope. In contrast to
* {@link #setVariableLocal(String, Object)}, the variable is transient that
* means it will not be stored in the data base. For example, a transient
* variable can be used for a result variable that is only available for
* output mapping.
*/
public void setVariableLocalTransient(String variableName, Object value) {
TypedValue typedValue = Variables.untypedValue(value);
checkJavaSerialization(variableName, typedValue);
CoreVariableInstance coreVariableInstance = getVariableInstanceFactory().build(variableName, typedValue, true);
getVariableStore().addVariable(coreVariableInstance);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class AbstractVariableScope method initializeVariableStore.
public void initializeVariableStore(Map<String, Object> variables) {
for (String variableName : variables.keySet()) {
TypedValue value = Variables.untypedValue(variables.get(variableName));
CoreVariableInstance variableValue = getVariableInstanceFactory().build(variableName, value, false);
getVariableStore().addVariable(variableValue);
}
}
Aggregations