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

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


    log.info("SubProcess END:  {},  {}, {}",
            execution.getCurrentActivityName(), execution.getCurrentActivityId(),  
            execution.getProcessBusinessKey());
    
    logServiceNodeEnd(execution);
    
    String retCodeVarName = String.format("retCode_%s_ice1", execution.getCurrentActivityId());
    Object retCodeVarObj = execution.getVariable(retCodeVarName);
    String subProcVarName = String.format("subProcRetCode_%s", execution.getCurrentActivityId());
    if(retCodeVarObj != null && retCodeVarObj instanceof String){
        String retCode = (String)retCodeVarObj;
        execution.setVariable(subProcVarName, retCode);
        log.debug("set variable:{}, {}", subProcVarName, retCode);
    }

}
 
Example 2
Source File: PaymentRestHacksControllerV4b.java    From flowing-retail with Apache License 2.0 6 votes vote down vote up
@FailingOnLastRetry    
public void execute(DelegateExecution ctx) throws Exception {
  CreateChargeRequest request = new CreateChargeRequest();
  request.amount = (long) ctx.getVariable("amount");

  CreateChargeResponse response = new HystrixCommand<CreateChargeResponse>(HystrixCommandGroupKey.Factory.asKey("stripe")) {
    protected CreateChargeResponse run() throws Exception {
      return rest.postForObject( //
          stripeChargeUrl, //
          request, //
          CreateChargeResponse.class);
    }
  }.execute();
  
  ctx.setVariable("paymentTransactionId", response.transactionId);
}
 
Example 3
Source File: MessageCorrelationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  Integer a = (Integer) execution.getVariable("a");
  Integer b = (Integer) execution.getVariable("b");
  execution.setVariable("sum", a + b);
  execution.setVariable("a", "foo");
}
 
Example 4
Source File: PlaceOrderActivity.java    From Hands-On-RESTful-API-Design-Patterns-and-Best-Practices with MIT License 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
	LOG.info("execute {} - {}", ProcessConstants.SERVICE_NAME_ORDER, SERVICE_ACTION);
	BusinessEntity sc = (BusinessEntity) execution.getVariable(ProcessConstants.VAR_SC);
	ServiceResponse response = rpcClient.invokeService(
			ProcessUtil.buildServiceRequest(sc, ProcessConstants.SERVICE_NAME_ORDER, SERVICE_ACTION));
	ProcessUtil.processResponse(execution, response);
	execution.setVariable(ProcessConstants.VAR_ORDER_PLACED, true);
}
 
Example 5
Source File: RemoteSingletonBeanClientDelegateBean.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  BusinessInterface businessInterface = (BusinessInterface) new InitialContext().lookup("java:global/" +
      TestConstants.getAppName() +
      "service/" +
      "RemoteSingletonBean!org.camunda.bpm.integrationtest.functional.ejb.remote.bean.BusinessInterface");

  execution.setVariable("result", businessInterface.doBusiness());
}
 
Example 6
Source File: RetrievePaymentAdapter.java    From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution ctx) throws Exception {
  CreateChargeRequest request = new CreateChargeRequest();
  request.amount = (int) ctx.getVariable(ProcessConstants.VAR_NAME_amount);
  
  CreateChargeResponse response = rest.postForObject( //
      restEndpoint(), //
      request, //
      CreateChargeResponse.class);
  
  ctx.setVariable(ProcessConstants.VARIABLE_paymentTransactionId, response.transactionId);
}
 
Example 7
Source File: InvocationCounterDelegateBean.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  InvocationCounterService invocationCounterService = (InvocationCounterService) new InitialContext().lookup("java:global/" +
      TestConstants.getAppName() +
      "service/" +
      "InvocationCounterServiceBean!org.camunda.bpm.integrationtest.functional.ejb.request.beans.InvocationCounterService");

  execution.setVariable("invocationCounter", invocationCounterService.getNumOfInvocations());
}
 
Example 8
Source File: ActivityStartListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateExecution execution) throws Exception {
  Integer counter = (Integer) execution.getVariable("executionListenerCounter");
  if (counter == null) {
    counter = 0;
  }
  execution.setVariable("executionListenerCounter", ++counter);
}
 
Example 9
Source File: UpdateAndReplaceValueDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  List<String> list = (List<String>) execution.getVariable("listVar");

  // implicitly update the previous list, should update the variable value
  list.add(NEW_ELEMENT);

  // replace the list by another object
  execution.setVariable("listVar", new ArrayList<String>());

  // note that this is the condensed form of more realistic scenarios like
  // an implicit update in task 1 and an explicit update in the following task 2,
  // both in the same transaction.
}
 
Example 10
Source File: ExampleFieldInjectedExecutionListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateExecution execution) throws Exception {
  execution.setVariable("var", fixedValue.getValue(execution).toString() + dynamicValue.getValue(execution).toString());
}
 
Example 11
Source File: ExampleExecutionListenerOne.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateExecution execution) throws Exception {
  execution.setVariable("variableSetInExecutionListener", "firstValue");
  execution.setVariable("eventNameReceived", execution.getEventName());
  execution.setVariable("businessKeyInExecution", execution.getProcessBusinessKey());
}
 
Example 12
Source File: DelegateVarMapping.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void mapOutputVariables(DelegateExecution execution, VariableScope subInstance) {
  execution.setVariable("TestOutputVar", "outValue");
}
 
Example 13
Source File: IncreaseCurrentTimeServiceTask.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  Date currentTime = (Date)execution.getVariable("currentTime");
  currentTime = DateUtils.addSeconds(currentTime, 1);
  ClockUtil.setCurrentTime(currentTime);
  execution.setVariable("currentTime", currentTime);
}
 
Example 14
Source File: RestartProcessInstanceSyncTest.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.setVariable("var", "foo");
}
 
Example 15
Source File: VariableUpdateDelegate.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariable("zzz", 123456789L);
}
 
Example 16
Source File: SetVariableMappingDelegate.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void mapOutputVariables(DelegateExecution superExecution, VariableScope subInstance) {
  superExecution.setVariable("targetOrderId",subInstance.getVariable("orderId"),"SubProcess_1");
}
 
Example 17
Source File: NamedCdiBean.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariable("a", "b");
}
 
Example 18
Source File: InvokeStartProcessDelegateSLSB.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariable("result", businessInterface.doStartProcess());
}
 
Example 19
Source File: SetVariableDelegate.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  
  SerializableVariable serializableVariable = new SerializableVariable();
  serializableVariable.setValue("camunda BPM");
  
  execution.setVariable("var1", serializableVariable);
  
}
 
Example 20
Source File: ExampleDelegate.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
public void execute(DelegateExecution execution) throws Exception {
  execution.setVariable("executed", true);

}