Java Code Examples for org.camunda.bpm.engine.RuntimeService#setVariable()

The following examples show how to use org.camunda.bpm.engine.RuntimeService#setVariable() . 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: TimeoutTaskListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  RuntimeService runtimeService = delegateTask.getProcessEngine().getRuntimeService();
  int triggerCount = 1;
  Integer triggerCountVariable = (Integer) runtimeService.getVariable(delegateTask.getExecutionId(), "triggerCount");
  if (triggerCountVariable != null) {
    triggerCount += triggerCountVariable;
  }
  runtimeService.setVariable(delegateTask.getExecutionId(), "timeout-status", "fired" + (triggerCount == 1 ? "" : triggerCount));
  runtimeService.setVariable(delegateTask.getExecutionId(), "triggerCount", triggerCount);
}
 
Example 2
Source File: SetVariablesScenario.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@DescribesScenario("setVariablesScenario")
public static ScenarioSetup createUserOperationLogEntries() {
  return new ScenarioSetup() {
    @Override
    public void execute(ProcessEngine engine, String scenarioName) {
      RuntimeService runtimeService = engine.getRuntimeService();
      ProcessInstance processInstanceWithInitialVariables = runtimeService.createProcessInstanceQuery()
          .processDefinitionKey("asyncBeforeStartProcess_712")
          .processInstanceBusinessKey("712_ProcessIntanceExecuted")
          .singleResult();
      ManagementService managementService = engine.getManagementService();
      Job firstJob = managementService.createJobQuery()
          .processDefinitionKey("asyncBeforeStartProcess_712")
          .processInstanceId(processInstanceWithInitialVariables.getId())
          .singleResult();
      try {
        managementService.executeJob(firstJob.getId());
      } catch (Exception e) {
        // ignore
      }

      ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
          .processDefinitionKey("asyncBeforeStartProcess_712")
          .processInstanceBusinessKey("7120_ProcessIntanceWithoutExecute")
          .singleResult();
      runtimeService.setVariable(processInstance.getId(), "foo", "value");
      runtimeService.setVariableLocal(processInstance.getId(), "local", "foo1");
    }
  };
}
 
Example 3
Source File: RuntimeServiceDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();

  ObjectValue jsonSerializeable = Variables
      .objectValue(createJsonSerializable())
      .serializationDataFormat(SerializationDataFormats.JSON)
      .create();

  // this should be executed in the context of the current process application
  runtimeService.setVariable(execution.getProcessInstanceId(), VARIABLE_NAME, jsonSerializeable);

}
 
Example 4
Source File: ExecuteRuntimeServiceOperationTaskListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  ProcessEngineServices services = delegateTask.getProcessEngineServices();
  RuntimeService runtimeService = services.getRuntimeService();
  runtimeService.setVariable(delegateTask.getExecutionId(), "taskListenerCalled", true);
}
 
Example 5
Source File: ExecuteRuntimeServiceOperationDelegate.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  ProcessEngineServices services = execution.getProcessEngineServices();
  RuntimeService runtimeService = services.getRuntimeService();
  runtimeService.setVariable(execution.getId(), "serviceTaskCalled", true);
}