Search in sources :

Example 16 with TypedValue

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);
}
Also used : TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 17 with 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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 18 with TypedValue

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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 19 with TypedValue

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);
        }
    }
}
Also used : TriggerVariableValueDto(org.camunda.bpm.engine.rest.dto.runtime.TriggerVariableValueDto) RestException(org.camunda.bpm.engine.rest.exception.RestException) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 20 with TypedValue

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());
}
Also used : TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Aggregations

TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)81 Test (org.junit.Test)25 Deployment (org.camunda.bpm.engine.test.Deployment)15 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)11 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)7 DmnDataTypeTransformer (org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer)6 BusinessProcess (org.camunda.bpm.engine.cdi.BusinessProcess)6 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)4 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)3 DeclarativeProcessController (org.camunda.bpm.engine.cdi.test.impl.beans.DeclarativeProcessController)3 RestException (org.camunda.bpm.engine.rest.exception.RestException)3 Task (org.camunda.bpm.engine.task.Task)3 ArrayList (java.util.ArrayList)2 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)2 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)2 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2