Java Code Examples for org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#getVariable()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#getVariable() . 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: While.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void execute(ActivityExecution execution) throws Exception {
  PvmTransition more = execution.getActivity().findOutgoingTransition("more");
  PvmTransition done = execution.getActivity().findOutgoingTransition("done");

  Integer value = (Integer) execution.getVariable(variableName);

  if (value==null) {
    execution.setVariable(variableName, from);
    execution.leaveActivityViaTransition(more);

  } else {
    value = value+1;

    if (value<to) {
      execution.setVariable(variableName, value);
      execution.leaveActivityViaTransition(more);

    } else {
      execution.leaveActivityViaTransition(done);
    }
  }
}
 
Example 2
Source File: RetrievePaymentAdapter.java    From flowing-retail-old with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {
  Order order = OrderRepository.instance.getOrder((String)execution.getVariable("orderId")); 
  String transactionId = (String)execution.getVariable("transactionId");    

  // create event payload and send message
  JsonObjectBuilder payload = eventProducer.createPayloadJson("Command", "RetrievePayment", transactionId)
      .add("refId", order.getId()) //
      .add("reason", "CustomerOrder") //
      .add("amount", order.getTotalSum());
  eventProducer.send(payload);

  addMessageSubscription(execution, "PaymentReceived");
}
 
Example 3
Source File: FetchGoodsAdapter.java    From flowing-retail-old with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {
  OrderEventProducer eventProducer = new OrderEventProducer();
  
  Order order = orderRepository.getOrder((String)execution.getVariable("orderId"));
  String transactionId = (String)execution.getVariable("transactionId");
  
  addMessageSubscription(execution, "GoodsFetched");    
  
  eventProducer.publishCommandFetchGoods(transactionId, order);   
}
 
Example 4
Source File: ShipGoodsAdapter.java    From flowing-retail-old with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {
  OrderEventProducer eventProducer = new OrderEventProducer();
  
  Order order = orderRepository.getOrder((String)execution.getVariable("orderId"));    
  String pickId = (String)execution.getVariable("pickId");
  String transactionId = (String)execution.getVariable("transactionId");

  addMessageSubscription(execution, "GoodsShipped");

  eventProducer.publishCommandShipGoods(transactionId, order, pickId);    
}
 
Example 5
Source File: ReserveGoodsAdapter.java    From flowing-retail-old with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {
  OrderEventProducer eventProducer = new OrderEventProducer();

  Order order = orderRepository.getOrder((String)execution.getVariable("orderId")); 
  String transactionId = (String)execution.getVariable("transactionId");

  addMessageSubscription(execution, "GoodsReserved");    

  eventProducer.publishCommandReserveGoods(transactionId, order);    
}
 
Example 6
Source File: MultiInstanceActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void evaluateCollectionVariable(ActivityExecution execution, int loopCounter) {
  if (usesCollection() && collectionElementVariable != null) {
    Collection<?> collection = null;
    if (collectionExpression != null) {
      collection = (Collection<?>) collectionExpression.getValue(execution);
    } else if (collectionVariable != null) {
      collection = (Collection<?>) execution.getVariable(collectionVariable);
    }

    Object value = getElementAtIndex(loopCounter, collection);
    setLoopVariable(execution, collectionElementVariable, value);
  }
}
 
Example 7
Source File: Decision.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(ActivityExecution execution) throws Exception {
  PvmTransition transition = null;
  String creditRating = (String) execution.getVariable("creditRating");
  if (creditRating.equals("AAA+")) {
    transition = execution.getActivity().findOutgoingTransition("wow");
  } else if (creditRating.equals("Aaa-")) {
    transition = execution.getActivity().findOutgoingTransition("nice");
  } else {
    transition = execution.getActivity().findOutgoingTransition("default");
  }

  execution.leaveActivityViaTransition(transition);
}
 
Example 8
Source File: ThrowErrorDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void handle(ActivityExecution execution, String action) throws Exception {
  execution.setVariable(action, true);
  String type = (String) execution.getVariable("type");
  if ("error".equalsIgnoreCase(type)) {
    throw new BpmnError("MyError");
  }
  else if ("exception".equalsIgnoreCase(type)) {
    throw new MyBusinessException("MyException");
  }
  else if ("leave".equalsIgnoreCase(type)) {
    execution.setVariable("type", null);
    leave(execution);
  }
}
 
Example 9
Source File: WaitStateUndoService.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(ActivityExecution execution) throws Exception {
  String variableName = (String) counterName.getValue(execution);
  Object variable = execution.getVariable(variableName);
  if(variable == null) {
    execution.setVariable(variableName, (Integer) 1);
  }
  else  {
    execution.setVariable(variableName, ((Integer)variable)+1);
  }
}
 
Example 10
Source File: ThrowsExceptionBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void execute(ActivityExecution execution) throws Exception {
  String var = (String) execution.getVariable("var");

  PvmTransition transition = null;
  try {
    executeLogic(var);
    transition = execution.getActivity().findOutgoingTransition("no-exception");
  } catch (Exception e) {
    transition = execution.getActivity().findOutgoingTransition("exception");
  }
  execution.leaveActivityViaTransition(transition);
}
 
Example 11
Source File: ThrowErrorDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void handle(ActivityExecution execution, String action) throws Exception {
  execution.setVariable(action, true);
  String type = (String) execution.getVariable("type");
  if ("error".equalsIgnoreCase(type)) {
    throw new BpmnError("MyError");
  }
  else if ("exception".equalsIgnoreCase(type)) {
    throw new MyBusinessException("MyException");
  }
  else if ("leave".equalsIgnoreCase(type)) {
    execution.setVariable("type", null);
    leave(execution);
  }
}