Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getSuperExecution()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#getSuperExecution() . 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: ExecutionTreeUtil.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public static ExecutionTree buildExecutionTree(DelegateExecution executionEntity) {
  
  // Find highest parent
  ExecutionEntity parentExecution = (ExecutionEntity) executionEntity;
  while (parentExecution.getParentId() != null || parentExecution.getSuperExecutionId() != null) {
    if (parentExecution.getParentId() != null) {
      parentExecution = parentExecution.getParent();
    } else {
      parentExecution = parentExecution.getSuperExecution();
    }
  }
  
  // Collect all child executions now we have the parent
  List<ExecutionEntity> allExecutions = new ArrayList<ExecutionEntity>();
  allExecutions.add(parentExecution);
  collectChildExecutions(parentExecution, allExecutions);
  return buildExecutionTree(allExecutions);
}
 
Example 2
Source File: ActivitiProcessStartedEventImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public ActivitiProcessStartedEventImpl(final Object entity, final Map variables, final boolean localScope) {
  super(entity, variables, localScope, ActivitiEventType.PROCESS_STARTED);
  if (entity instanceof ExecutionEntity) {
    ExecutionEntity executionEntity = (ExecutionEntity) entity;
    if (executionEntity.isProcessInstanceType() == false) {
      executionEntity = executionEntity.getParent();
    }
    
    final ExecutionEntity superExecution = executionEntity.getSuperExecution();
    if (superExecution != null) {
      this.nestedProcessDefinitionId = superExecution.getProcessDefinitionId();
      this.nestedProcessInstanceId = superExecution.getProcessInstanceId();
    } else {
      this.nestedProcessDefinitionId = null;
      this.nestedProcessInstanceId = null;
    }
    
  } else {
    this.nestedProcessDefinitionId = null;
    this.nestedProcessInstanceId = null;
  }
}
 
Example 3
Source File: ErrorPropagation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public static boolean mapException(Exception e, ExecutionEntity execution, List<MapExceptionEntry> exceptionMap) {
  String errorCode = findMatchingExceptionMapping(e, exceptionMap);
  if (errorCode != null) {
    propagateError(errorCode, execution);
    return true;
  } else {
    ExecutionEntity callActivityExecution = null;
    ExecutionEntity parentExecution = execution.getParent();
    while (parentExecution != null && callActivityExecution == null) {
      if (parentExecution.getId().equals(parentExecution.getProcessInstanceId())) {
        if (parentExecution.getSuperExecution() != null) {
          callActivityExecution = parentExecution.getSuperExecution();
        } else {
          parentExecution = null;
        }
      } else {
        parentExecution = parentExecution.getParent();
      }
    }

    if (callActivityExecution != null) {
      CallActivity callActivity = (CallActivity) callActivityExecution.getCurrentFlowElement();
      if (CollectionUtil.isNotEmpty(callActivity.getMapExceptions())) {
        errorCode = findMatchingExceptionMapping(e, callActivity.getMapExceptions());
        if (errorCode != null) {
          propagateError(errorCode, callActivityExecution);
          return true;
        }
      }
    }

    return false;
  }
}
 
Example 4
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ActivityExecution findRootProcessInstanceExecution(ExecutionEntity execution) {
    ExecutionEntity currentExecution = execution;
    while (currentExecution.getParentId() != null || currentExecution.getSuperExecutionId() != null) {
        ExecutionEntity parentExecution = currentExecution.getParent();
        if (parentExecution != null) {
            currentExecution = parentExecution;
        } else if (currentExecution.getSuperExecutionId() != null) {
            currentExecution = currentExecution.getSuperExecution();
        }
    }
    return currentExecution;
}
 
Example 5
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected List<ExecutionEntity> orderExecutionsRootToLeaf(ExecutionEntity execution) {

        // Find root process instance
        ExecutionEntity rootExecution = execution;
        while (rootExecution.getParent() != null || rootExecution.getSuperExecution() != null) {
            rootExecution = rootExecution.getParent() != null ? rootExecution.getParent() : rootExecution.getSuperExecution();
        }

        return orderExecutionsRootToLeaf(rootExecution, new ArrayList<>());
    }
 
Example 6
Source File: ErrorPropagation.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public static void propagateError(String errorCode, DelegateExecution execution) {
  Map<String, List<Event>> eventMap = findCatchingEventsForProcess(execution.getProcessDefinitionId(), errorCode);
  if (eventMap.size() > 0) {
    executeCatch(eventMap, execution, errorCode);
  } else if (!execution.getProcessInstanceId().equals(execution.getRootProcessInstanceId())) { // Call activity

    ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
    ExecutionEntity processInstanceExecution = executionEntityManager.findById(execution.getProcessInstanceId());
    if (processInstanceExecution != null) {

      ExecutionEntity parentExecution = processInstanceExecution.getSuperExecution();

      Set<String> toDeleteProcessInstanceIds = new HashSet<String>();
      toDeleteProcessInstanceIds.add(execution.getProcessInstanceId());

      while (parentExecution != null && eventMap.size() == 0) {
        eventMap = findCatchingEventsForProcess(parentExecution.getProcessDefinitionId(), errorCode);
        if (eventMap.size() > 0) {

          for (String processInstanceId : toDeleteProcessInstanceIds) {
            ExecutionEntity processInstanceEntity = executionEntityManager.findById(processInstanceId);

            // Delete
            executionEntityManager.deleteProcessInstanceExecutionEntity(processInstanceEntity.getId(),
                execution.getCurrentFlowElement() != null ? execution.getCurrentFlowElement().getId() : null,
                "ERROR_EVENT " + errorCode,
                false, false);

            // Event
            if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
              Context.getProcessEngineConfiguration().getEventDispatcher()
                  .dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.PROCESS_COMPLETED_WITH_ERROR_END_EVENT, processInstanceEntity));
            }
          }
          executeCatch(eventMap, parentExecution, errorCode);

        } else {
          toDeleteProcessInstanceIds.add(parentExecution.getProcessInstanceId());
          ExecutionEntity superExecution = parentExecution.getSuperExecution();
          if (superExecution != null) {
            parentExecution = superExecution;
          } else if (!parentExecution.getId().equals(parentExecution.getRootProcessInstanceId())) { // stop at the root
              parentExecution = parentExecution.getProcessInstance();
          } else {
            parentExecution = null;
          }
        }
      }

    }

  }

  if (eventMap.size() == 0) {
    throw new BpmnError(errorCode, "No catching boundary event found for error with errorCode '" + errorCode + "', neither in same process nor in parent process");
  }
}