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

The following examples show how to use org.activiti.engine.delegate.DelegateExecution#inactivate() . 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: ParallelGatewayActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void execute(DelegateExecution execution) { 
  ActivityExecution activityExecution = (ActivityExecution) execution;
  // Join
  PvmActivity activity = activityExecution.getActivity();
  List<PvmTransition> outgoingTransitions = activityExecution.getActivity().getOutgoingTransitions();
  execution.inactivate();
  lockConcurrentRoot(activityExecution);
  
  List<ActivityExecution> joinedExecutions = activityExecution.findInactiveConcurrentExecutions(activity);
  int nbrOfExecutionsToJoin = activityExecution.getActivity().getIncomingTransitions().size();
  int nbrOfExecutionsJoined = joinedExecutions.size();
  Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
  if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) {
    
    // Fork
    if(log.isDebugEnabled()) {
      log.debug("parallel gateway '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
    }
    activityExecution.takeAll(outgoingTransitions, joinedExecutions);
    
  } else if (log.isDebugEnabled()){
    log.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
  }
}
 
Example 2
Source File: ParallelGateway.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void execute(DelegateExecution execution) {
  ActivityExecution activityExecution = (ActivityExecution) execution;
  PvmActivity activity = activityExecution.getActivity();

  List<PvmTransition> outgoingTransitions = activityExecution.getActivity().getOutgoingTransitions();
  
  execution.inactivate();
  
  List<ActivityExecution> joinedExecutions = activityExecution.findInactiveConcurrentExecutions(activity);
  
  int nbrOfExecutionsToJoin = activityExecution.getActivity().getIncomingTransitions().size();
  int nbrOfExecutionsJoined = joinedExecutions.size();
  
  if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) {
    log.debug("parallel gateway '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
    activityExecution.takeAll(outgoingTransitions, joinedExecutions);
    
  } else if (log.isDebugEnabled()){
    log.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
  }
}
 
Example 3
Source File: InclusiveGatewayActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
  // The join in the inclusive gateway works as follows:
  // When an execution enters it, it is inactivated.
  // All the inactivated executions stay in the inclusive gateway
  // until ALL executions that CAN reach the inclusive gateway have reached it.
  //
  // This check is repeated on execution changes until the inactivated
  // executions leave the gateway.

  execution.inactivate();
  executeInclusiveGatewayLogic((ExecutionEntity) execution);
}
 
Example 4
Source File: ParallelGatewayActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void execute(DelegateExecution execution) {

    // First off all, deactivate the execution
    execution.inactivate();

    // Join
    FlowElement flowElement = execution.getCurrentFlowElement();
    ParallelGateway parallelGateway = null;
    if (flowElement instanceof ParallelGateway) {
      parallelGateway = (ParallelGateway) flowElement;
    } else {
      throw new ActivitiException("Programmatic error: parallel gateway behaviour can only be applied" + " to a ParallelGateway instance, but got an instance of " + flowElement);
    }

    lockFirstParentScope(execution);

    DelegateExecution multiInstanceExecution = null;
    if (hasMultiInstanceParent(parallelGateway)) {
      multiInstanceExecution = findMultiInstanceParentExecution(execution);
    }

    ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
    Collection<ExecutionEntity> joinedExecutions = executionEntityManager.findInactiveExecutionsByActivityIdAndProcessInstanceId(execution.getCurrentActivityId(), execution.getProcessInstanceId());
    if (multiInstanceExecution != null) {
      joinedExecutions = cleanJoinedExecutions(joinedExecutions, multiInstanceExecution);
    }

    int nbrOfExecutionsToJoin = parallelGateway.getIncomingFlows().size();
    int nbrOfExecutionsCurrentlyJoined = joinedExecutions.size();

    // Fork

    // Is needed to set the endTime for all historic activity joins
    Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution, null);

    if (nbrOfExecutionsCurrentlyJoined == nbrOfExecutionsToJoin) {

      // Fork
      if (log.isDebugEnabled()) {
        log.debug("parallel gateway '{}' activates: {} of {} joined", execution.getCurrentActivityId(), nbrOfExecutionsCurrentlyJoined, nbrOfExecutionsToJoin);
      }

      if (parallelGateway.getIncomingFlows().size() > 1) {

        // All (now inactive) children are deleted.
        for (ExecutionEntity joinedExecution : joinedExecutions) {

          // The current execution will be reused and not deleted
          if (!joinedExecution.getId().equals(execution.getId())) {
            executionEntityManager.deleteExecutionAndRelatedData(joinedExecution, null, false);
          }

        }
      }

      // TODO: potential optimization here: reuse more then 1 execution, only 1 currently
      Context.getAgenda().planTakeOutgoingSequenceFlowsOperation((ExecutionEntity) execution, false); // false -> ignoring conditions on parallel gw

    } else if (log.isDebugEnabled()) {
      log.debug("parallel gateway '{}' does not activate: {} of {} joined", execution.getCurrentActivityId(), nbrOfExecutionsCurrentlyJoined, nbrOfExecutionsToJoin);
    }

  }