Java Code Examples for org.flowable.engine.impl.persistence.entity.ExecutionEntity#getSuperExecutionId()

The following examples show how to use org.flowable.engine.impl.persistence.entity.ExecutionEntity#getSuperExecutionId() . 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 flowable-engine 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<>();
        allExecutions.add(parentExecution);
        collectChildExecutions(parentExecution, allExecutions);
        return buildExecutionTree(allExecutions);
    }
 
Example 2
Source File: ExecutionTreeUtil.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static ExecutionTree buildExecutionTree(Collection<ExecutionEntity> executions) {
    ExecutionTree executionTree = new ExecutionTree();

    // Map the executions to their parents. Catch and store the root element (process instance execution) while were at it
    Map<String, List<ExecutionEntity>> parentMapping = new HashMap<>();
    for (ExecutionEntity executionEntity : executions) {
        String parentId = executionEntity.getParentId();

        // Support for call activity
        if (parentId == null) {
            parentId = executionEntity.getSuperExecutionId();
        }

        if (parentId != null) {
            if (!parentMapping.containsKey(parentId)) {
                parentMapping.put(parentId, new ArrayList<>());
            }
            parentMapping.get(parentId).add(executionEntity);
        } else if (executionEntity.getSuperExecutionId() == null) {
            executionTree.setRoot(new ExecutionTreeNode(executionEntity));
        }
    }

    fillExecutionTree(executionTree, parentMapping);
    return executionTree;
}
 
Example 3
Source File: EscalationPropagation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static void propagateEscalation(String escalationCode, String escalationName, DelegateExecution execution) {
    Map<String, List<Event>> eventMap = new HashMap<>();
    Set<String> rootProcessDefinitionIds = new HashSet<>();
    if (!execution.getProcessInstanceId().equals(execution.getRootProcessInstanceId())) {
        ExecutionEntity parentExecution = (ExecutionEntity) execution;
        while (parentExecution.getParentId() != null || parentExecution.getSuperExecutionId() != null) {
            if (parentExecution.getParentId() != null) {
                parentExecution = parentExecution.getParent();
            } else {
                parentExecution = parentExecution.getSuperExecution();
                rootProcessDefinitionIds.add(parentExecution.getProcessDefinitionId());
            }
        }
    }
    
    if (rootProcessDefinitionIds.size() > 0) {
        for (String processDefinitionId : rootProcessDefinitionIds) {
            eventMap.putAll(findCatchingEventsForProcess(processDefinitionId, escalationCode));
        }
    }
    
    eventMap.putAll(findCatchingEventsForProcess(execution.getProcessDefinitionId(), escalationCode));
    if (eventMap.size() > 0) {
        executeCatch(eventMap, execution, escalationCode, escalationName);
    }
}
 
Example 4
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void propagateError(String errorCode, DelegateExecution execution) {
    Map<String, List<Event>> eventMap = new HashMap<>();
    Set<String> rootProcessDefinitionIds = new HashSet<>();
    if (!execution.getProcessInstanceId().equals(execution.getRootProcessInstanceId())) {
        ExecutionEntity parentExecution = (ExecutionEntity) execution;
        while (parentExecution.getParentId() != null || parentExecution.getSuperExecutionId() != null) {
            if (parentExecution.getParentId() != null) {
                parentExecution = parentExecution.getParent();
            } else {
                parentExecution = parentExecution.getSuperExecution();
                rootProcessDefinitionIds.add(parentExecution.getProcessDefinitionId());
            }
        }
    }
    
    if (rootProcessDefinitionIds.size() > 0) {
        for (String processDefinitionId : rootProcessDefinitionIds) {
            eventMap.putAll(findCatchingEventsForProcess(processDefinitionId, errorCode));
        }
    }
    
    eventMap.putAll(findCatchingEventsForProcess(execution.getProcessDefinitionId(), errorCode));
    if (eventMap.size() > 0) {
        executeCatch(eventMap, execution, errorCode);
    }

    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");
    }
}
 
Example 5
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void sendProcessInstanceCompletedEvent(ExecutionEntity execution, FlowElement terminateEndEvent) {
    Process process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
    CommandContextUtil.getProcessEngineConfiguration().getListenerNotificationHelper()
        .executeExecutionListeners(process, execution, ExecutionListener.EVENTNAME_END);

    FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration().getEventDispatcher();
    if (eventDispatcher != null && eventDispatcher.isEnabled()) {
        if ((execution.isProcessInstanceType() && execution.getSuperExecutionId() == null) ||
                (execution.getParentId() == null && execution.getSuperExecutionId() != null)) {

            // This event should only be fired if terminate end event is part of the process definition for the process instance execution,
            // otherwise a regular cancel event of the process instance will be fired (see above).
            boolean fireEvent = true;
            if (!terminateAll) {
                Process processForExecution = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
                Process processForTerminateEndEvent = getProcessForTerminateEndEvent(terminateEndEvent);
                fireEvent = processForExecution.getId().equals(processForTerminateEndEvent.getId());
            }
            
            if (fireEvent) {
                eventDispatcher
                    .dispatchEvent(FlowableEventBuilder.createTerminateEvent(execution, terminateEndEvent));
            }
            
        }
    }

}
 
Example 6
Source File: SubProcessInstanceExecutionBySuperExecutionIdMatcher.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRetained(ExecutionEntity executionEntity, Object parameter) {
    return executionEntity.getSuperExecutionId() != null
            && ((String) parameter).equals(executionEntity.getSuperExecutionId());
}