use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class SingleQueryVariableValueCondition method initializeValue.
public void initializeValue(VariableSerializers serializers) {
TypedValue typedValue = wrappedQueryValue.getTypedValue();
initializeValue(serializers, typedValue);
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class JsonSerializationTest method testSetUntypedNullForExistingVariable.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// initially the variable has a value
JsonSerializable object = new JsonSerializable();
runtimeService.setVariable(instance.getId(), "varName", objectValue(object).serializationDataFormat(JSON_FORMAT_NAME).create());
// get value via untyped api
assertEquals(object, 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 XmlSerializationTest method testSetUntypedNullForExistingVariable.
@Deployment(resources = ONE_TASK_PROCESS)
public void testSetUntypedNullForExistingVariable() throws Exception {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// initially the variable has a value
XmlSerializable object = new XmlSerializable();
runtimeService.setVariable(instance.getId(), "varName", objectValue(object).serializationDataFormat(XML_FORMAT_NAME).create());
// get value via untyped api
assertEquals(object, 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 CaseExecutionResourceImpl method initializeCommandWithVariables.
protected void initializeCommandWithVariables(CaseExecutionCommandBuilder commandBuilder, Map<String, TriggerVariableValueDto> variables, String transition) {
for (String variableName : variables.keySet()) {
try {
TriggerVariableValueDto variableValue = variables.get(variableName);
TypedValue typedValue = variableValue.toTypedValue(engine, objectMapper);
if (variableValue.isLocal()) {
commandBuilder.setVariableLocal(variableName, typedValue);
} else {
commandBuilder.setVariable(variableName, typedValue);
}
} catch (RestException e) {
String errorMessage = String.format("Cannot %s case execution %s due to invalid variable %s: %s", transition, caseExecutionId, variableName, e.getMessage());
throw new RestException(e.getStatus(), e, errorMessage);
}
}
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class AbstractVariableScope method setVariable.
public void setVariable(String variableName, Object value) {
TypedValue typedValue = Variables.untypedValue(value);
setVariable(variableName, typedValue, getSourceActivityVariableScope());
}
Aggregations