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

The following examples show how to use org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#getActivityInstanceId() . 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: AbstractBpmnActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Takes an {@link ActivityExecution} and an {@link Callable} and wraps
 * the call to the Callable with the proper error propagation. This method
 * also makes sure that exceptions not caught by following activities in the
 * process will be thrown and not propagated.
 *
 * @param execution
 * @param toExecute
 * @throws Exception
 */
protected void executeWithErrorPropagation(ActivityExecution execution, Callable<Void> toExecute) throws Exception {
  String activityInstanceId = execution.getActivityInstanceId();
  try {
    toExecute.call();
  } catch (Exception ex) {
    if (activityInstanceId.equals(execution.getActivityInstanceId())) {

      try {
        BpmnExceptionHandler.propagateException(execution, ex);
      }
      catch (ErrorPropagationException e) {
        // exception has been logged by thrower
        // re-throw the original exception so that it is logged
        // and set as cause of the failure
        throw ex;
      }

    }
    else {
      throw ex;
    }
  }
}
 
Example 2
Source File: ActivityInstanceVerification.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void addActivityInstanceId(ActivityExecution execution, Map<String, List<ActivityInstance>> instanceMap) {

    String actId = execution.getActivity().getId();
    String actInstanceId = execution.getActivityInstanceId();
    String parentActInstanceId = execution.getParentActivityInstanceId();
    String executionId = String.valueOf(System.identityHashCode(execution));

    // add to instance map
    List<ActivityInstance> instancesForThisAct = instanceMap.get(actId);
    if(instancesForThisAct == null) {
      instancesForThisAct = new ArrayList<ActivityInstance>();
      instanceMap.put(actId, instancesForThisAct);
    }
    ActivityInstance activityInstance = new ActivityInstance(executionId, actInstanceId, parentActInstanceId, execution.isCompleteScope());
    instancesForThisAct.add(activityInstance);
  }
 
Example 3
Source File: ActivityInstanceVerification.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateExecution e) throws Exception {

    final ActivityExecution execution = (ActivityExecution) e;

    if(execution.getActivityInstanceId() == null) {
      return;
    }

    if(execution.getEventName().equals(EVENTNAME_START)) {
      addActivityInstanceId(execution, startedActivityInstances);

    } else if(execution.getEventName().equals(EVENTNAME_END)) {
      addActivityInstanceId(execution, endedActivityInstances);
    }

  }
 
Example 4
Source File: TaskActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * The method which will be called before the execution is performed.
 *
 * @param execution the execution which is used during execution
 * @throws Exception
 */
protected void preExecution(ActivityExecution execution) throws Exception {
  activityInstanceId = execution.getActivityInstanceId();
}