Java Code Examples for org.camunda.bpm.engine.delegate.DelegateExecution#setVariableLocal()

The following examples show how to use org.camunda.bpm.engine.delegate.DelegateExecution#setVariableLocal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssertVariableInstancesDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {

    // validate integer variable
    Integer expectedIntValue = 1234;
    assertEquals(expectedIntValue, execution.getVariable("anIntegerVariable"));
    assertEquals(expectedIntValue, execution.getVariableTyped("anIntegerVariable").getValue());
    assertEquals(ValueType.INTEGER, execution.getVariableTyped("anIntegerVariable").getType());
    assertNull(execution.getVariableLocal("anIntegerVariable"));
    assertNull(execution.getVariableLocalTyped("anIntegerVariable"));

    // set an additional local variable
    execution.setVariableLocal("aStringVariable", "aStringValue");

    String expectedStringValue = "aStringValue";
    assertEquals(expectedStringValue, execution.getVariable("aStringVariable"));
    assertEquals(expectedStringValue, execution.getVariableTyped("aStringVariable").getValue());
    assertEquals(ValueType.STRING, execution.getVariableTyped("aStringVariable").getType());
    assertEquals(expectedStringValue, execution.getVariableLocal("aStringVariable"));
    assertEquals(expectedStringValue, execution.getVariableLocalTyped("aStringVariable").getValue());
    assertEquals(ValueType.STRING, execution.getVariableLocalTyped("aStringVariable").getType());

    SimpleSerializableBean objectValue = (SimpleSerializableBean) execution.getVariable("anObjectValue");
    assertNotNull(objectValue);
    assertEquals(10, objectValue.getIntProperty());
    ObjectValue variableTyped = execution.getVariableTyped("anObjectValue");
    assertEquals(10, variableTyped.getValue(SimpleSerializableBean.class).getIntProperty());
    assertEquals(Variables.SerializationDataFormats.JAVA.getName(), variableTyped.getSerializationDataFormat());

    objectValue = (SimpleSerializableBean) execution.getVariable("anUntypedObjectValue");
    assertNotNull(objectValue);
    assertEquals(30, objectValue.getIntProperty());
    variableTyped = execution.getVariableTyped("anUntypedObjectValue");
    assertEquals(30, variableTyped.getValue(SimpleSerializableBean.class).getIntProperty());
    assertEquals(Context.getProcessEngineConfiguration().getDefaultSerializationFormat(), variableTyped.getSerializationDataFormat());

  }
 
Example 2
Source File: SetLocalVariableTask.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariableLocal("test", "test2");
}
 
Example 3
Source File: ExecutionEntityTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {
  // given (see #testRemoveExecutionSequence)
  execution.setVariableLocal("localVar", "localVarVal");
}
 
Example 4
Source File: SetLocalVariableTask.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariableLocal("test", "test2");
}
 
Example 5
Source File: TerminateEndEventTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  serviceTaskInvokedCount++;

  // leave only 3 out of n subprocesses
  execution.setVariableLocal("terminate", serviceTaskInvokedCount > 3);
}
 
Example 6
Source File: SetVariableOnConcurrentExecutionDelegate.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  Task task = execution.getProcessEngineServices().getTaskService().createTaskQuery().taskName(TASK_WITH_CONDITION).singleResult();
  ((TaskEntity) task).getExecution().setVariableLocal(VARIABLE_NAME, 1);
  execution.setVariableLocal(VARIABLE_NAME+1, 1);
}
 
Example 7
Source File: SetLocalVariableListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {
  execution.setVariableLocal(variableName, variableValue);
}
 
Example 8
Source File: SetVariableLocalService.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariableLocal("testVar", "testValue");
}
 
Example 9
Source File: ChangeVariablePropertyDelegate.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {

    execution.setVariableLocal("var", new SimpleSerializableBean());

    SimpleSerializableBean variable = (SimpleSerializableBean) execution.getVariable("var");
    variable.setIntProperty(variable.getIntProperty() + 1);

    boolean shouldExplicitlyUpdateVariable = (Boolean) execution.getVariable("shouldExplicitlyUpdateVariable");

    if (shouldExplicitlyUpdateVariable) {
      execution.setVariableLocal("var", variable);
    }

  }
 
Example 10
Source File: SetVariablesDelegate.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {

    String variableName = (String) variable.getValue(execution);
    String value = values.iterator().next();

    execution.setVariableLocal(variableName, value);

    values.remove(value);
  }