Package org.camunda.bpm.engine.impl.pvm.delegate

Examples of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution


    fixMiRootActivityInstanceId(execution);

    List<ActivityExecution> concurrentExecutions = new ArrayList<ActivityExecution>();
    for (int loopCounter=0; loopCounter<nrOfInstances; loopCounter++) {
      ActivityExecution concurrentExecution = execution.createExecution(loopCounter != 0);
      concurrentExecution.setActive(true);
      concurrentExecution.setConcurrent(true);
      concurrentExecution.setScope(false);

      // In case of an embedded subprocess, and extra child execution is required
      // Otherwise, all child executions would end up under the same parent,
      // without any differentiation to which embedded subprocess they belong
      if (isExtraScopeNeeded()) {
        ActivityExecution extraScopedExecution = concurrentExecution.createExecution();
        extraScopedExecution.setActive(true);
        extraScopedExecution.setConcurrent(false);
        extraScopedExecution.setScope(true);
        concurrentExecution = extraScopedExecution;
      }

      // create event subscriptions for the concurrent execution
      for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(execution.getActivity())) {
        declaration.createSubscriptionForParallelMultiInstance((ExecutionEntity) concurrentExecution);
      }

      if (ioMapping != null) {
        ioMapping.executeInputParameters((AbstractVariableScope) concurrentExecution);
      }

      // create timer job for the current execution
      List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) concurrentExecution.getActivity().getProperty(BpmnParse.PROPERTYNAME_TIMER_DECLARATION);
      if (timerDeclarations!=null) {
        for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
          timerDeclaration.createTimerInstanceForParallelMultiInstance((ExecutionEntity) concurrentExecution);
        }
      }

      concurrentExecutions.add(concurrentExecution);
      logLoopDetails(concurrentExecution, "initialized", loopCounter, 0, nrOfInstances, nrOfInstances);
    }

    // Before the activities are executed, all executions MUST be created up front
    // Do not try to merge this loop with the previous one, as it will lead to bugs,
    // due to possible child execution pruning.
    for (int loopCounter=0; loopCounter<nrOfInstances; loopCounter++) {
      ActivityExecution concurrentExecution = concurrentExecutions.get(loopCounter);
      // executions can be inactive, if instances are all automatics (no-waitstate)
      // and completionCondition has been met in the meantime
      if (concurrentExecution.isActive() && !concurrentExecution.isEnded()
              && concurrentExecution.getParent().isActive()
              && !concurrentExecution.getParent().isEnded()) {

        setLoopVariable(concurrentExecution, LOOP_COUNTER, loopCounter);
        executeOriginalBehavior(concurrentExecution, loopCounter);
      }
    }
View Full Code Here


    }
  }


  protected void fixMiRootActivityInstanceId(ActivityExecution execution) {
    ActivityExecution miRoot = execution.getParent();
    miRoot.setActivityInstanceId(miRoot.getParentActivityInstanceId());
  }
View Full Code Here

    ActivityExecution miRoot = execution.getParent();
    miRoot.setActivityInstanceId(miRoot.getParentActivityInstanceId());
  }

  protected void resetMiRootActivityInstanceId(ActivityExecution execution) {
    ActivityExecution miEnteringExecution = execution.getParent();
    ActivityExecution miRoot = miEnteringExecution.getParent();
    miRoot.setActivityInstanceId(miEnteringExecution.getActivityInstanceId());
  }
View Full Code Here

   * new, non-concurrent execution leaves activity
   */
  @SuppressWarnings("unchecked")
  public void lastExecutionEnded(ActivityExecution execution) {

    ActivityExecution outgoingExecution = execution.getParent().createExecution();
    outgoingExecution.setConcurrent(false);
    outgoingExecution.setActivity(execution.getActivity());

    // eventscope execution
    execution.setConcurrent(false);
    execution.setActive(false);
    ((PvmExecutionImpl)execution).setEventScope(true);

    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    if(outgoingTransitions.isEmpty()) {
      outgoingExecution.end(true);
    }else {
      outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
    }
  }
View Full Code Here

* @author Joram Barrez
*/
public abstract class GatewayActivityBehavior extends FlowNodeActivityBehavior {
 
  protected void lockConcurrentRoot(ActivityExecution execution) {
    ActivityExecution concurrentRoot = null;
    if (execution.isConcurrent()) {
      concurrentRoot = execution.getParent();
    } else {
      concurrentRoot = execution;
    }
View Full Code Here

    // TODO: merge two approaches (super process / regular process approach)
    if(eventHandlerId != null) {
      executeCatch(eventHandlerId, execution);
    }else {
      ActivityExecution superExecution = getSuperExecution(execution);
      if (superExecution != null) {
        executeCatchInSuperProcess(errorCode, origException, superExecution);
      } else {
        if (origException==null) {
          LOG.info(execution.getActivity().getId() + " throws error event with errorCode '"
View Full Code Here

  private static void executeCatchInSuperProcess(String errorCode, Exception origException, ActivityExecution superExecution) throws Exception {
    String errorHandlerId = findLocalErrorEventHandler(superExecution, errorCode, origException);
    if (errorHandlerId != null) {
      executeCatch(errorHandlerId, superExecution);
    } else { // no matching catch found, going one level up in process hierarchy
      ActivityExecution superSuperExecution = getSuperExecution(superExecution);
      if (superSuperExecution != null) {
        executeCatchInSuperProcess(errorCode, origException, superSuperExecution);
      } else {
        if (origException == null) {
          throw new BpmnError(errorCode, "No catching boundary event found for error with errorCode '"
View Full Code Here

    ProcessDefinitionImpl processDefinition = ((ExecutionEntity) execution).getProcessDefinition();
    ActivityImpl errorHandler = processDefinition.findActivity(errorHandlerId);
    ensureNotNull(errorHandlerId + " not found in process definition", "errorHandler", errorHandler);

    boolean matchingParentFound = false;
    ActivityExecution leavingExecution = execution;
    ActivityImpl currentActivity = (ActivityImpl) execution.getActivity();

    ScopeImpl catchingScope = errorHandler.getParent();
    if (catchingScope instanceof ActivityImpl) {
      ActivityImpl catchingScopeActivity = (ActivityImpl) catchingScope;
      if (!catchingScopeActivity.isScope()) { // event subprocesses
        catchingScope = catchingScopeActivity.getParent();
      }
    }

    if (catchingScope instanceof PvmProcessDefinition) {
      executeEventHandler(errorHandler, ((ExecutionEntity) execution).getProcessInstance());

    } else {
      if (currentActivity.getId().equals(catchingScope.getId())) {
        matchingParentFound = true;
      } else {
        // boundary events are always defined on scopes, so we have to
        // find the next parent activity that is a scope
        currentActivity = currentActivity.getParentScopeActivity();

        // Traverse parents until one is found that is a scope
        // and matches the activity the boundary event is defined on.
        //
        // This loop attempts attempts to find the execution that matches
        // currentActivity and then checks whether this is the scope that
        // is responsible for catching the error (i.e. currentActivity == catchingScope).
        // If not, search is continued in the parent activities and executions.
        while (!matchingParentFound && leavingExecution != null && currentActivity != null) {
          if (!leavingExecution.isConcurrent() && currentActivity.getId().equals(catchingScope.getId())) {
            matchingParentFound = true;
          } else if (leavingExecution.isConcurrent()) {
            leavingExecution = leavingExecution.getParent();

          } else {
            currentActivity = currentActivity.getParentScopeActivity();
            leavingExecution = leavingExecution.getParent();
          }
        }

        // Follow parents up until matching scope can't be found anymore (needed to support for multi-instance)
        while (leavingExecution != null
          && leavingExecution.getParent() != null
          && leavingExecution.getParent().getActivity() != null
          && leavingExecution.getParent().getActivity().getId().equals(catchingScope.getId())) {
          leavingExecution = leavingExecution.getParent();
        }
      }

      if (matchingParentFound && leavingExecution != null) {
        executeEventHandler(errorHandler, leavingExecution);
View Full Code Here

    // have compensated

    // join compensating executions
    if(execution.getExecutions().isEmpty()) {
      if(execution.getParent() != null) {
        ActivityExecution parent = execution.getParent();
        execution.remove();
        parent.signal("compensationDone", signalData);
      }
    } else {
      ((ExecutionEntity)execution).forceUpdate();
    }
View Full Code Here

    execution.setVariableLocal(variableName, value);
  }

  protected Integer getLoopVariable(ActivityExecution execution, String variableName) {
    Object value = execution.getVariableLocal(variableName);
    ActivityExecution parent = execution.getParent();
    while (value == null && parent != null) {
      value = parent.getVariableLocal(variableName);
      parent = parent.getParent();
    }

    ensureNotNull("The variable \"" + variableName + "\" could not be found in execution with id " + execution.getId(), "value", value);

    return (Integer) value;
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.