Examples of PvmExecutionImpl


Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  public PvmProcessInstance createProcessInstance(String businessKey) {
    return createProcessInstance(businessKey, null);
  }

  public PvmProcessInstance createProcessInstance(String businessKey, String caseInstanceId) {
    PvmExecutionImpl processInstance = (PvmExecutionImpl) createProcessInstanceForInitial(initial);

    processInstance.setBusinessKey(businessKey);
    processInstance.setCaseInstanceId(caseInstanceId);

    return processInstance;
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  /** creates a process instance using the provided activity as initial */
  public PvmProcessInstance createProcessInstanceForInitial(ActivityImpl initial) {
    ensureNotNull("Cannot start process instance, initial activity where the process instance should start is null", "initial", initial);

    PvmExecutionImpl processInstance = newProcessInstance(initial);

    processInstance.setProcessDefinition(this);
    processInstance.setProcessInstance(processInstance);

    processInstance.initialize();

    PvmExecutionImpl scopeInstance = processInstance;

    List<ActivityImpl> initialActivityStack = getInitialActivityStack(initial);

    for (ActivityImpl initialActivity: initialActivityStack) {
      if (initialActivity.isScope()) {
        scopeInstance = scopeInstance.createExecution();
        scopeInstance.setActivity(initialActivity);
        if (initialActivity.isScope()) {
          scopeInstance.initialize();
        }
      }
    }

    scopeInstance.setActivity(initial);

    return processInstance;
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  private static Logger log = Logger.getLogger(EventCollector.class.getName());

  public List<String> events = new ArrayList<String>();

  public void notify(DelegateExecution execution) throws Exception {
    PvmExecutionImpl executionImpl = (PvmExecutionImpl) execution;
    log.fine("collecting event: "+execution.getEventName()+" on "+executionImpl.getEventSource());
    events.add(execution.getEventName()+" on "+executionImpl.getEventSource());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

    ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();

    ProcessInstanceStartContext processInstanceStartContext = execution.getProcessInstanceStartContext();
    if (processInstanceStartContext==null) {
      // The ProcessInstanceStartContext is set on the process instance / parent execution - grab it from there:
      PvmExecutionImpl executionToUse = execution;
      while (processInstanceStartContext==null) {
        executionToUse = execution.getParent();
        processInstanceStartContext = executionToUse.getProcessInstanceStartContext();
      }
    }

    if (activity== processInstanceStartContext.getInitial()) {

      processInstanceStartContext.initialStarted(execution);

      execution.disposeProcessInstanceStartContext();
      execution.performOperation(ACTIVITY_EXECUTE);

    } else {
      List<ActivityImpl> initialActivityStack = processDefinition.getInitialActivityStack(processInstanceStartContext.getInitial());
      int index = initialActivityStack.indexOf(activity);
      // starting the next one
      activity = initialActivityStack.get(index+1);

      // and search for the correct execution to set the Activity to
      PvmExecutionImpl executionToUse = execution;
      if (executionToUse.getActivity().isScope()) {
        executionToUse.setActive(false); // Deactivate since we jump to a node further down the hierarchy
        executionToUse = executionToUse.getExecutions().get(0);
      }
      executionToUse.setActivity(activity);
      executionToUse.performOperation(PROCESS_START_INITIAL);
    }
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  public void execute(PvmExecutionImpl execution) {
    ActivityImpl activity = getCancellingActivity(execution);

    // find scope execution:
    PvmExecutionImpl scopeExecution = execution.isScope() ? execution : execution.getParent();

    ScopeImpl scope = activity.getScope();
    if (scope != activity.getParent()) {

      if (activity.getParent() instanceof ActivityImpl) {
        ActivityImpl parent = (ActivityImpl) activity.getParent();

        if (parent.isScope()) {
          scopeExecution = scopeExecution.getParent();
        }
      }
    }

    // cancel the current scope (removes all child executions)
    scopeExecution.cancelScope("Cancel scope activity " + activity + " executed.");

    // set new activity
    scopeExecution.setActivity(activity);
    scopeExecution.setActive(true);

    scopeCancelled(scopeExecution);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

    ActivityImpl activity = execution.getActivity();

    if (activity!=null) {
      return activity;
    } else {
      PvmExecutionImpl parent = execution.getParent();
      if (parent != null) {
        return getScope(execution.getParent());
      }
      return execution.getProcessDefinition();
    }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

      }

      execution.remove();

      if (!execution.isDeleteRoot()) {
        PvmExecutionImpl parent = execution.getParent();
        if (parent!=null) {
          // set activity on parent in case the parent is an inactive scope execution and activity has been set to 'null'.
          if(parent.getActivity() == null && activity != null && activity.getParentActivity() != null) {
            parent.setActivity(activity.getParentActivity());
          }
          parent.performOperation(DELETE_CASCADE);
        }
      }
    }
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  protected PvmExecutionImpl eventNotificationsStarted(PvmExecutionImpl execution) {

    // hack around execution tree structure not being in sync with activity instance concept:
    // if we end a scope activity, take remembered activity instance from parent and set on
    // execution before calling END listeners.
    PvmExecutionImpl parent = execution.getParent();
    ActivityImpl activity = execution.getActivity();
    if (parent != null && execution.isScope() &&
        activity != null && activity.isScope() &&
        (activity.getActivityBehavior() instanceof CompositeActivityBehavior)) {

      if(log.isLoggable(Level.FINE)) {
        log.fine("[LEAVE] "+ execution + ": "+execution.getActivityInstanceId() );
      }

      // use remembered activity instance id from parent
      execution.setActivityInstanceId(parent.getActivityInstanceId());
      // make parent go one scope up.
      parent.leaveActivityInstance();

    }

    return execution;
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

  @Override
  protected void eventNotificationsCompleted(PvmExecutionImpl execution) {

    super.eventNotificationsCompleted(execution);

    PvmExecutionImpl superExecution = execution.getSuperExecution();
    CmmnActivityExecution superCaseExecution = execution.getSuperCaseExecution();

    SubProcessActivityBehavior subProcessActivityBehavior = null;
    TransferVariablesActivityBehavior transferVariablesBehavior = null;

    // copy variables before destroying the ended sub process instance
    if (superExecution!=null) {
      ActivityImpl activity = superExecution.getActivity();
      subProcessActivityBehavior = (SubProcessActivityBehavior) activity.getActivityBehavior();
      try {
        subProcessActivityBehavior.completing(superExecution, execution);
      } catch (RuntimeException e) {
          log.log(Level.SEVERE, "Error while completing sub process of execution " + execution, e);
          throw e;
      } catch (Exception e) {
          log.log(Level.SEVERE, "Error while completing sub process of execution " + execution, e);
          throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
      }
    } else if (superCaseExecution != null) {
      CmmnActivity activity = superCaseExecution.getActivity();
      transferVariablesBehavior = (TransferVariablesActivityBehavior) activity.getActivityBehavior();
      try {
        transferVariablesBehavior.transferVariables(execution, superCaseExecution);
      } catch (RuntimeException e) {
          log.log(Level.SEVERE, "Error while completing sub process of execution " + execution, e);
          throw e;
      } catch (Exception e) {
          log.log(Level.SEVERE, "Error while completing sub process of execution " + execution, e);
          throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
      }
    }

    execution.destroy();
    execution.remove();

    // and trigger execution afterwards
    if (superExecution!=null) {
      superExecution.setSubProcessInstance(null);
      try {
          subProcessActivityBehavior.completed(superExecution);
      } catch (RuntimeException e) {
          log.log(Level.SEVERE, "Error while completing sub process of execution " + execution, e);
          throw e;
View Full Code Here

Examples of org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl

public abstract class PvmAtomicOperationCreateConcurrentExecution implements PvmAtomicOperation {

  public void execute(PvmExecutionImpl execution) {

    // the execution which will continue
    PvmExecutionImpl propagatingExecution = execution;

    // the activity which is to be executed concurrently
    ActivityImpl concurrentActivity = execution.getNextActivity();
    ScopeImpl concurrencyScope = concurrentActivity.getScope();

    if(isLeaf(execution)) {

      if(execution.getActivity() != null
         && execution.isScope()
         && !(execution.getActivity()).isScope()
         && concurrencyScope == execution.getActivity().getParent()
         ) {

        // Expand tree (1):
        //
        //        ...                        ...
        //         |                          |
        //      +------+                  +-------+   s=tt
        //      |  e   |       =>         |   e   |   cc=ff
        //      +------+                  +-------+
        //          s=tt                      ^
        //         cc=ff                     / \
        //                                  /   \
        //                                 /     \          Both:
        //                          +-------+   +--------+    s=ff
        //                          | CCE-1 |   | PPE    |   cc=tt
        //                          +-------+   +--------+
        //

        // 1) create new concurrent execution (CCE-1) replacing the the active scope execution (e)
        PvmExecutionImpl replacingExecution = execution.createExecution();
        replacingExecution.replace(execution); // only copy tasks(?)
        replacingExecution.setActivity(execution.getActivity());
        replacingExecution.setActive(execution.isActive());
        replacingExecution.setScope(false);
        replacingExecution.setConcurrent(true);

        execution.setActive(false);
        execution.setActivity(null);

        // 2) create new concurrent execution (PPE) for new activity instance
        propagatingExecution = createConcurrentExecution(execution, concurrentActivity);

      } else {

        // Case (1): Expand tree and set execution to concurrent:
        //
        //        ...                         ...
        //         |                           |
        //      +------+ s=tt              +-------+ s=tt
        //      |  p   | cc=ff     =>      |   p   | cc=ff
        //      +------+                   +-------+
        //         |                           ^
        //         |                          / \
        //         |                         /   \
        //         |                        /     \          Both:
        //      +------+ s=tt        +-------+   +--------+    s=ff
        //      |  e   | cc=ff       |   e   |   |  PPE   |   cc=tt
        //      +------+             +-------+   +--------+
        //
        // Case (2): Add to existing concurrency tree rooting at parent of parent
        //
        //
        //                 ...                                 ...
        //                  |                                   |
        //              +-------+   s=tt                    +--------+  s=tt
        //              |   pp  |   cc=ff                   |   pp   |  cc=ff
        //              +-------+                           +--------+
        //                  ^                                   ^    ^
        //                 / \                   =>            / \    \
        //                /   \                               /   \    \
        //               /     \     all:                    /     \    \           all:
        //        +--------+   ....   s=ff            +--------+   ....  +-------+  s=ff
        //        | parent |          cc=tt           | parent |         |  PPE  |  cc=tt
        //        +--------+                          +--------+         +-------+
        //             |                                  |
        //        +-------+ s=tt                      +-------+ s=tt
        //        | e     | cc=ff                     | e     | cc=ff
        //        +-------+                           +-------+
        //



        // Case (1)
        PvmExecutionImpl parent = execution.getParent();

        if (!parent.isConcurrent()) {
          // mark execution (e) concurrent
          execution.setConcurrent(true);

        } else {
          // Case (2)
          parent = parent.getParent();
        }

        propagatingExecution = createConcurrentExecution(parent, concurrentActivity);

      }

    } else {

      List<? extends PvmExecutionImpl> childExecutions = execution.getExecutions();

      if(childExecutions.size() == 1
        && execution.getActivity() == null
        && !execution.isActive()) {

      // Add new child execution and set concurrent flag to true
      // for already existing child execution
      //
      //        ...                         ...
      //         |                           |
      //      +------+ s=tt              +-------+ s=tt
      //      |  e   | cc=ff     =>      |   e   | cc=ff
      //      +------+                   +-------+
      //         |                           ^
      //         |                          / \
      //         |                         /   \
      //         |                        /     \          Both:
      //      +------+ s=tt        +-------+   +--------+    s=ff
      //      |child | cc=ff       | child |   |  PPE   |   cc=tt
      //      +------+             +-------+   +--------+
      //

      // 1) mark existing child concurrent
      PvmExecutionImpl existingChild = childExecutions.get(0);
      existingChild.setConcurrent(true);

      // 2) create new concurrent execution (PPE) for new activity instance
      propagatingExecution = createConcurrentExecution(execution, concurrentActivity);



      } else { /* execution.getExecutions().size() > 1 */

        // Add to existing concurrency tree:
        //
        // Case (1)
        //              +-------+ s=tt                   +-------+ s=tt
        //              |   e   | cc=ff                  |   e   | cc=ff
        //              +-------+                        +-------+
        //                  ^                                ^   ^
        //                 / \                =>            / \   \
        //                /   \                            /   \   \
        //               /     \     all:                 /     \   \
        //        +-------+   ....     s=?          +-------+   ...  +-------+ s=ff
        //        |       |            cc=tt        |       |        |  PPE  | cc=tt
        //        +-------+                         +-------+        +-------+
        //
        // Case (2)
        //
        //                 ...                              ...
        //                  |                                |     s=tt
        //              +-------+ s=tt                   +-------+ cc=ff
        //              | parent| cc=ff                  | parent|<------------+
        //              +-------+                        +-------+             |
        //                  |                                |                 |
        //              +-------+ s=tt                   +-------+ s=tt     +-------+ s=ff
        //              |   e   | cc=?                   |   e   | cc=tt    |  PPE  | cc=tt
        //              +-------+                        +-------+          +-------+
        //                  ^                                ^
        //                 / \                =>            / \
        //                /   \                            /   \
        //               /     \     all:                 /     \    all:
        //        +-------+   ....     s=?          +-------+   ...    s=?
        //        |       |            cc=tt        |       |          cc=tt
        //        +-------+                         +-------+
        //
        // Case (3)
        //
        //                 ...                                   ...
        //                  |     s=tt                            |     s=tt
        //              +-------+ cc=?                        +-------+ cc=?
        //              |   pp  |<-----------+                |  pp   |<---------------------------+
        //              +-------+            |                +-------+            |               |
        //                  |                |  all:              |                |  all:         |
        //                  |     s=tt       |   s=?              |     s=tt       |   s=?         |
        //              +-------+ cc=tt     ...  cc=tt        +-------+ cc=tt     ...  cc=tt   +-------+ s=ff
        //              | parent|                             | parent|                        |  PPE  | cc=tt
        //              +-------+                             +-------+                        +-------+
        //                  |                                     |
        //              +-------+ s=tt                        +-------+ s=tt
        //              |   e   | cc=?                        |   e   | cc=?
        //              +-------+                             +-------+
        //                  ^                                     ^
        //                 / \                   =>              / \
        //                /   \                                 /   \
        //               /     \     all:                      /     \    all:
        //        +-------+   ....     s=?                +-------+   ...    s=?
        //        |       |            cc=tt              |       |          cc=tt
        //        +-------+                               +-------+
        //
        //


        // Case (1)
        PvmExecutionImpl concurrentRoot = execution;

        ScopeImpl parentScope = concurrentActivity.getParent();
        if(parentScope instanceof ActivityImpl) {
          ActivityImpl parentActivity = (ActivityImpl) parentScope;
          if (execution.getActivity() != null || execution.isActive()) {
            if(parentActivity.isScope()) {
              // Case (2)
              concurrentRoot = execution.getParent();
              if (!concurrentRoot.isConcurrent()) {
                execution.setConcurrent(true);

              } else {
                // Case (3)
                concurrentRoot = concurrentRoot.getParent();
              }
            }
          }
        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.