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

The following examples show how to use org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#forceUpdate() . 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: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static boolean eventSubprocessConcurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) {
  boolean performLegacyBehavior = isLegacyBehaviorRequired(endedExecution);

  if(performLegacyBehavior) {
    LOG.endConcurrentExecutionInEventSubprocess();
    // notify the grandparent flow scope in a similar way PvmAtomicOperationAcitivtyEnd does
    ScopeImpl flowScope = endedExecution.getActivity().getFlowScope();
    if (flowScope != null) {
      flowScope = flowScope.getFlowScope();

      if (flowScope != null) {
        if (flowScope == endedExecution.getActivity().getProcessDefinition()) {
          endedExecution.remove();
          scopeExecution.tryPruneLastConcurrentChild();
          scopeExecution.forceUpdate();
        }
        else {
          PvmActivity flowScopeActivity = (PvmActivity) flowScope;

          ActivityBehavior activityBehavior = flowScopeActivity.getActivityBehavior();
          if (activityBehavior instanceof CompositeActivityBehavior) {
            ((CompositeActivityBehavior) activityBehavior).concurrentChildExecutionEnded(scopeExecution, endedExecution);
          }
        }
      }
    }
  }

  return performLegacyBehavior;
}
 
Example 2
Source File: SubProcessActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) {
  // join
  endedExecution.remove();
  scopeExecution.tryPruneLastConcurrentChild();
  scopeExecution.forceUpdate();
}
 
Example 3
Source File: ParallelMultiInstanceActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ActivityExecution createConcurrentExecution(ActivityExecution scopeExecution) {
  ActivityExecution concurrentChild = scopeExecution.createExecution();
  scopeExecution.forceUpdate();
  concurrentChild.setConcurrent(true);
  concurrentChild.setScope(false);
  return concurrentChild;
}
 
Example 4
Source File: ParallelMultiInstanceActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) {

  int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1;
  setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
  int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) - 1;
  setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances);

  // inactivate the concurrent execution
  endedExecution.inactivate();
  endedExecution.setActivityInstanceId(null);

  // join
  scopeExecution.forceUpdate();
  // TODO: should the completion condition be evaluated on the scopeExecution or on the endedExecution?
  if(completionConditionSatisfied(endedExecution) ||
      allExecutionsEnded(scopeExecution, endedExecution)) {

    ArrayList<ActivityExecution> childExecutions = new ArrayList<ActivityExecution>(((PvmExecutionImpl) scopeExecution).getNonEventScopeExecutions());
    for (ActivityExecution childExecution : childExecutions) {
      // delete all not-ended instances; these are either active (for non-scope tasks) or inactive but have no activity id (for subprocesses, etc.)
      if (childExecution.isActive() || childExecution.getActivity() == null) {
        ((PvmExecutionImpl)childExecution).deleteCascade("Multi instance completion condition satisfied.");
      }
      else {
        childExecution.remove();
      }
    }

    scopeExecution.setActivity((PvmActivity) endedExecution.getActivity().getFlowScope());
    scopeExecution.setActive(true);
    leave(scopeExecution);
  } else {
    ((ExecutionEntity) scopeExecution).dispatchDelayedEventsAndPerformOperation((Callback<PvmExecutionImpl, Void>) null);
  }
}
 
Example 5
Source File: ParallelMultiInstanceActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void destroyInnerInstance(ActivityExecution concurrentExecution) {

  ActivityExecution scopeExecution = concurrentExecution.getParent();
  concurrentExecution.remove();
  scopeExecution.forceUpdate();

  int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES);
  setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances - 1);

}