Java Code Examples for org.activiti.engine.delegate.DelegateExecution#setScope()

The following examples show how to use org.activiti.engine.delegate.DelegateExecution#setScope() . 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
public void execute(DelegateExecution execution) {
  StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
  EventSubProcess eventSubProcess = (EventSubProcess) startEvent.getSubProcess();
  execution.setCurrentFlowElement(eventSubProcess);
  execution.setScope(true);

  // initialize the template-defined data objects as variables
  Map<String, Object> dataObjectVars = processDataObjects(eventSubProcess.getDataObjects());
  if (dataObjectVars != null) {
    execution.setVariablesLocal(dataObjectVars);
  }

  ExecutionEntity startSubProcessExecution = Context.getCommandContext()
      .getExecutionEntityManager().createChildExecution((ExecutionEntity) execution);
  startSubProcessExecution.setCurrentFlowElement(startEvent);
  Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(startSubProcessExecution, true);
}
 
Example 2
public void execute(DelegateExecution execution) {
  SubProcess subProcess = getSubProcessFromExecution(execution);
  execution.setScope(true);

  // initialize the template-defined data objects as variables
  Map<String, Object> dataObjectVars = processDataObjects(subProcess.getDataObjects());
  if (dataObjectVars != null) {
    execution.setVariablesLocal(dataObjectVars);
  }
}
 
Example 3
public void execute(DelegateExecution execution) {
  StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
  EventSubProcess eventSubProcess = (EventSubProcess) startEvent.getSubProcess();

  execution.setScope(true);

  // initialize the template-defined data objects as variables
  Map<String, Object> dataObjectVars = processDataObjects(eventSubProcess.getDataObjects());
  if (dataObjectVars != null) {
    execution.setVariablesLocal(dataObjectVars);
  }
}
 
Example 4
/**
 * Called when the wrapped {@link ActivityBehavior} calls the {@link AbstractBpmnActivityBehavior#leave(ActivityExecution)} method. Handles the completion of one instance, and executes the logic for
 * the sequential behavior.
 */
public void leave(DelegateExecution childExecution) {
  DelegateExecution multiInstanceRootExecution = getMultiInstanceRootExecution(childExecution);
  int nrOfInstances = getLoopVariable(multiInstanceRootExecution, NUMBER_OF_INSTANCES);
  int loopCounter = getLoopVariable(childExecution, getCollectionElementIndexVariable()) + 1;
  int nrOfCompletedInstances = getLoopVariable(multiInstanceRootExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1;
  int nrOfActiveInstances = getLoopVariable(multiInstanceRootExecution, NUMBER_OF_ACTIVE_INSTANCES);

  setLoopVariable(multiInstanceRootExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
  setLoopVariable(childExecution, getCollectionElementIndexVariable(), loopCounter);
  logLoopDetails(childExecution, "instance completed", loopCounter, nrOfCompletedInstances, nrOfActiveInstances, nrOfInstances);
  
  Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) childExecution, null);
  callActivityEndListeners(childExecution);
  
  //executeCompensationBoundaryEvents(execution.getCurrentFlowElement(), execution);

  if (loopCounter >= nrOfInstances || completionConditionSatisfied(multiInstanceRootExecution)) {
    removeLocalLoopVariable(childExecution, getCollectionElementIndexVariable());
    multiInstanceRootExecution.setMultiInstanceRoot(false);
    multiInstanceRootExecution.setScope(false);
    multiInstanceRootExecution.setCurrentFlowElement(childExecution.getCurrentFlowElement());
    Context.getCommandContext().getExecutionEntityManager().deleteChildExecutions((ExecutionEntity) multiInstanceRootExecution, "MI_END", false);
    super.leave(multiInstanceRootExecution);
    
  } else {
    try {
      
      if (childExecution.getCurrentFlowElement() instanceof SubProcess) {
        ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
        ExecutionEntity executionToContinue = executionEntityManager.createChildExecution((ExecutionEntity) multiInstanceRootExecution);
        executionToContinue.setCurrentFlowElement(childExecution.getCurrentFlowElement());
        executionToContinue.setScope(true);
        setLoopVariable(executionToContinue, getCollectionElementIndexVariable(), loopCounter);
        executeOriginalBehavior(executionToContinue, loopCounter);
      } else {
        executeOriginalBehavior(childExecution, loopCounter);
      }
      
    } catch (BpmnError error) {
      // re-throw business fault so that it can be caught by an Error
      // Intermediate Event or Error Event Sub-Process in the process
      throw error;
    } catch (Exception e) {
      throw new ActivitiException("Could not execute inner activity behavior of multi instance behavior", e);
    }
  }
}