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

The following examples show how to use org.camunda.bpm.engine.delegate.DelegateExecution#getVariableTyped() . 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: ArchiveInvoiceService.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {

    Boolean shouldFail = (Boolean) execution.getVariable("shouldFail");
    FileValue invoiceDocumentVar  = execution.getVariableTyped("invoiceDocument");

    if(shouldFail != null && shouldFail) {
      throw new ProcessEngineException("Could not archive invoice...");
    }
    else {
      LOGGER.info("\n\n  ... Now archiving invoice "+execution.getVariable("invoiceNumber")
          +", filename: "+invoiceDocumentVar.getFilename()+" \n\n");
    }

  }
 
Example 2
Source File: UpdateValueDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  TypedValue typedValue = execution.getVariableTyped("listVar");
  List<JsonSerializable> var = (List<JsonSerializable>) typedValue.getValue();
  JsonSerializable newElement = new JsonSerializable();
  newElement.setStringProperty(STRING_PROPERTY);
  // implicit update of the list, so no execution.setVariable call
  var.add(newElement);

}
 
Example 3
Source File: XmlDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
  execution.setVariable("xmlVariable", Variables.untypedValue(xmlValue("<xml />"),true));

  // when
  TypedValue typedValue = execution.getVariableTyped("xmlVariable");

  // then
  assertThat(typedValue.isTransient(), is(true));
}
 
Example 4
Source File: JsonDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
  execution.setVariable("jsonVariable", Variables.untypedValue(jsonValue("{}"),true));

  // when
  TypedValue typedValue = execution.getVariableTyped("jsonVariable");

  // then
  assertThat(typedValue.isTransient(), is(true));
}
 
Example 5
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 6
Source File: TransientVariableTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariable("var", Variables.untypedValue(Variables.objectValue("aString"), true));

  // when
  TypedValue typedValue = execution.getVariableTyped("var");

  // then
  assertThat(typedValue.isTransient()).isTrue();
}
 
Example 7
Source File: CallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  TypedValue typedValue = execution.getVariableTyped("var");
  assertThat(typedValue).isNotNull();
  assertThat(typedValue.getType()).isEqualTo(ValueType.STRING);
  assertThat(typedValue.isTransient()).isTrue();
  assertThat(typedValue.getValue()).isEqualTo("value");
}
 
Example 8
Source File: GetSerializedValueDelegate.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {

    TypedValue typedValue = execution.getVariableTyped("varName", false);
    Assert.assertNotNull(typedValue);

  }