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

The following examples show how to use org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#setActive() . 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: EventScopeCreatingSubprocess.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void complete(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.leaveActivityViaTransitions(outgoingTransitions, Collections.EMPTY_LIST);
    }
  }
 
Example 2
Source File: MultiInstanceActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void performInstance(ActivityExecution execution, PvmActivity activity, int loopCounter) {
  setLoopVariable(execution, LOOP_COUNTER, loopCounter);
  evaluateCollectionVariable(execution, loopCounter);
  execution.setEnded(false);
  execution.setActive(true);
  execution.executeActivity(activity);
}
 
Example 3
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);
  }
}