コード例 #1
0
  protected void fireSentries(List<String> satisfiedSentries) {
    if (satisfiedSentries != null && !satisfiedSentries.isEmpty()) {
      // if there are satisfied sentries, trigger the associated
      // case executions

      // 1. propagate to all child case executions ///////////////////////////////////////////

      // collect the execution tree.
      ArrayList<CmmnExecution> children = new ArrayList<CmmnExecution>();
      collectCaseExecutionsInExecutionTree(children);

      for (CmmnExecution currentChild : children) {

        // check and fire first exitCriteria
        currentChild.checkAndFireExitCriteria(satisfiedSentries);

        // then trigger entryCriteria
        currentChild.checkAndFireEntryCriteria(satisfiedSentries);
      }

      // 2. check exit criteria of the case instance //////////////////////////////////////////

      if (isCaseInstanceExecution() && isActive()) {
        checkAndFireExitCriteria(satisfiedSentries);
      }
    }
  }
コード例 #2
0
 protected Map<String, List<CmmnSentryPart>> collectAllSentries() {
   Map<String, List<CmmnSentryPart>> sentries = new HashMap<String, List<CmmnSentryPart>>();
   List<? extends CmmnExecution> caseExecutions = getCaseExecutions();
   for (CmmnExecution caseExecution : caseExecutions) {
     sentries.putAll(caseExecution.collectAllSentries());
   }
   sentries.putAll(getSentries());
   return sentries;
 }
コード例 #3
0
 public CmmnExecution findCaseExecution(String activityId) {
   if ((getActivity() != null) && (getActivity().getId().equals(activityId))) {
     return this;
   }
   for (CmmnExecution nestedExecution : getCaseExecutions()) {
     CmmnExecution result = nestedExecution.findCaseExecution(activityId);
     if (result != null) {
       return result;
     }
   }
   return null;
 }
コード例 #4
0
  protected boolean containsIfPartAndExecutionActive(
      String sentryId, Map<String, List<CmmnSentryPart>> sentries) {
    List<? extends CmmnSentryPart> sentryParts = sentries.get(sentryId);

    for (CmmnSentryPart part : sentryParts) {
      CmmnExecution caseExecution = part.getCaseExecution();
      if (IF_PART.equals(part.getType()) && caseExecution != null && caseExecution.isActive()) {
        return true;
      }
    }

    return false;
  }
コード例 #5
0
 protected boolean hasVariableWithSameNameInParent(CmmnExecution execution, String variableName) {
   while (execution != null) {
     if (execution.getId().equals(getId())) {
       return false;
     }
     TypedValue variableTypedValue = execution.getVariableLocalTyped(variableName);
     if (variableTypedValue != null) {
       return true;
     }
     execution = execution.getParent();
   }
   return false;
 }
コード例 #6
0
  public void triggerChildExecutionsLifecycle(List<CmmnExecution> children) {
    // then notify create listener for each created
    // child case execution
    for (CmmnExecution child : children) {

      if (isActive()) {
        if (child.isNew()) {
          child.performOperation(CASE_EXECUTION_CREATE);
        }
      } else {
        // if this case execution is not active anymore,
        // then stop notifying create listener and executing
        // of each child case execution
        break;
      }
    }
  }
コード例 #7
0
  protected List<String> collectAffectedSentries(CmmnExecution child, String transition) {
    List<? extends CmmnSentryPart> sentryParts = getCaseSentryParts();

    List<String> affectedSentries = new ArrayList<String>();

    for (CmmnSentryPart sentryPart : sentryParts) {

      // necessary for backward compatibility
      String sourceCaseExecutionId = sentryPart.getSourceCaseExecutionId();
      String sourceRef = sentryPart.getSource();
      if (child.getActivityId().equals(sourceRef) || child.getId().equals(sourceCaseExecutionId)) {

        String standardEvent = sentryPart.getStandardEvent();
        if (transition.equals(standardEvent)) {
          addIdIfNotSatisfied(affectedSentries, sentryPart);
        }
      }
    }

    return affectedSentries;
  }
コード例 #8
0
  public void createChildExecutions(List<CmmnActivity> activities) {
    List<CmmnExecution> children = new ArrayList<CmmnExecution>();

    // first create new child case executions
    for (CmmnActivity currentActivity : activities) {
      CmmnExecution child = createCaseExecution(currentActivity);
      children.add(child);
    }

    // then notify create listener for each created
    // child case execution
    for (CmmnExecution child : children) {

      if (isActive()) {
        child.performOperation(CASE_EXECUTION_CREATE);
      } else {
        // if this case execution is not active anymore,
        // then stop notifying create listener and executing
        // of each child case execution
        break;
      }
    }
  }
コード例 #9
0
  protected void invokeVariableListeners(boolean includeCustomerListeners) {
    Queue<VariableEvent> variableEventsQueue = getVariableEventQueue();

    while (!variableEventsQueue.isEmpty()) {
      // do not remove the event yet, as otherwise new events will immediately be dispatched
      VariableEvent nextEvent = variableEventsQueue.peek();

      CmmnExecution sourceExecution = (CmmnExecution) nextEvent.getSourceScope();

      DelegateCaseVariableInstanceImpl delegateVariable =
          DelegateCaseVariableInstanceImpl.fromVariableInstance(nextEvent.getVariableInstance());
      delegateVariable.setEventName(nextEvent.getEventName());
      delegateVariable.setSourceExecution(sourceExecution);

      Map<String, List<VariableListener<?>>> listenersByActivity =
          sourceExecution
              .getActivity()
              .getVariableListeners(delegateVariable.getEventName(), includeCustomerListeners);

      CmmnExecution currentExecution = sourceExecution;
      while (currentExecution != null) {

        if (currentExecution.getActivityId() != null) {
          List<VariableListener<?>> listeners =
              listenersByActivity.get(currentExecution.getActivityId());

          if (listeners != null) {
            delegateVariable.setScopeExecution(currentExecution);

            for (VariableListener<?> listener : listeners) {
              try {
                CaseVariableListener caseVariableListener = (CaseVariableListener) listener;
                CaseVariableListenerInvocation invocation =
                    new CaseVariableListenerInvocation(
                        caseVariableListener, delegateVariable, currentExecution);
                Context.getProcessEngineConfiguration()
                    .getDelegateInterceptor()
                    .handleInvocation(invocation);
              } catch (Exception e) {
                throw LOG.invokeVariableListenerException(e);
              }
            }
          }
        }

        currentExecution = currentExecution.getParent();
      }

      // finally remove the event from the queue
      variableEventsQueue.remove();
    }
  }
コード例 #10
0
 public void remove() {
   CmmnExecution parent = getParent();
   if (parent != null) {
     parent.getCaseExecutionsInternal().remove(this);
   }
 }
コード例 #11
0
 protected void collectCaseExecutionsInExecutionTree(List<CmmnExecution> children) {
   for (CmmnExecution child : getCaseExecutions()) {
     child.collectCaseExecutionsInExecutionTree(children);
   }
   children.addAll(getCaseExecutions());
 }