Java Code Examples for org.flowable.engine.impl.persistence.entity.ExecutionEntity#getSuperExecution()
The following examples show how to use
org.flowable.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 flowable-engine with Apache License 2.0 | 6 votes |
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: FlowableProcessStartedEventImpl.java From flowable-engine with Apache License 2.0 | 6 votes |
public FlowableProcessStartedEventImpl(final Object entity, final Map variables, final boolean localScope) { super(entity, variables, localScope, FlowableEngineEventType.PROCESS_STARTED); if (entity instanceof ExecutionEntity) { ExecutionEntity executionEntity = (ExecutionEntity) entity; if (!executionEntity.isProcessInstanceType()) { 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: EscalationPropagation.java From flowable-engine with Apache License 2.0 | 6 votes |
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: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 6 votes |
protected MoveExecutionEntityContainer createMoveExecutionEntityContainer(MoveActivityIdContainer activityContainer, List<ExecutionEntity> executions, CommandContext commandContext) { MoveExecutionEntityContainer moveExecutionEntityContainer = new MoveExecutionEntityContainer(executions, activityContainer.getMoveToActivityIds()); activityContainer.getNewAssigneeId().ifPresent(moveExecutionEntityContainer::setNewAssigneeId); if (activityContainer.isMoveToParentProcess()) { ExecutionEntity processInstanceExecution = executions.get(0).getProcessInstance(); ExecutionEntity superExecution = processInstanceExecution.getSuperExecution(); if (superExecution == null) { throw new FlowableException("No parent process found for execution with activity id " + executions.get(0).getCurrentActivityId()); } moveExecutionEntityContainer.setMoveToParentProcess(true); moveExecutionEntityContainer.setSuperExecution(superExecution); } else if (activityContainer.isMoveToSubProcessInstance()) { moveExecutionEntityContainer.setMoveToSubProcessInstance(true); moveExecutionEntityContainer.setCallActivityId(activityContainer.getCallActivityId()); moveExecutionEntityContainer.setCallActivitySubProcessVersion(activityContainer.getCallActivitySubProcessVersion()); } return moveExecutionEntityContainer; }
Example 5
Source File: ErrorPropagation.java From flowable-engine with Apache License 2.0 | 5 votes |
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 6
Source File: ErrorPropagation.java From flowable-engine with Apache License 2.0 | 5 votes |
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 7
Source File: EscalationPropagation.java From flowable-engine with Apache License 2.0 | 4 votes |
protected static void executeCatch(Map<String, List<Event>> eventMap, DelegateExecution delegateExecution, String escalationCode, String escalationName) { Set<String> toDeleteProcessInstanceIds = new HashSet<>(); Event matchingEvent = null; ExecutionEntity currentExecution = (ExecutionEntity) delegateExecution; ExecutionEntity parentExecution = null; if (eventMap.containsKey(currentExecution.getActivityId() + "#" + currentExecution.getProcessDefinitionId())) { // Check for multi instance if (currentExecution.getParentId() != null && currentExecution.getParent().isMultiInstanceRoot()) { parentExecution = currentExecution.getParent(); } else { parentExecution = currentExecution; } matchingEvent = getCatchEventFromList(eventMap.get(currentExecution.getActivityId() + "#" + currentExecution.getProcessDefinitionId()), parentExecution); } else { parentExecution = currentExecution.getParent(); // Traverse parents until one is found that is a scope and matches the activity the boundary event is defined on while (matchingEvent == null && parentExecution != null) { FlowElementsContainer currentContainer = null; if (parentExecution.getCurrentFlowElement() instanceof FlowElementsContainer) { currentContainer = (FlowElementsContainer) parentExecution.getCurrentFlowElement(); } else if (parentExecution.getId().equals(parentExecution.getProcessInstanceId())) { currentContainer = ProcessDefinitionUtil.getProcess(parentExecution.getProcessDefinitionId()); } if (currentContainer != null) { for (String refId : eventMap.keySet()) { List<Event> events = eventMap.get(refId); if (CollectionUtil.isNotEmpty(events) && events.get(0) instanceof StartEvent) { String refActivityId = refId.substring(0, refId.indexOf('#')); String refProcessDefinitionId = refId.substring(refId.indexOf('#') + 1); if (parentExecution.getProcessDefinitionId().equals(refProcessDefinitionId) && currentContainer.getFlowElement(refActivityId) != null) { matchingEvent = getCatchEventFromList(events, parentExecution); EscalationEventDefinition escalationEventDef = getEscalationEventDefinition(matchingEvent); if (StringUtils.isNotEmpty(escalationEventDef.getEscalationCode())) { break; } } } } } if (matchingEvent == null) { if (eventMap.containsKey(parentExecution.getActivityId() + "#" + parentExecution.getProcessDefinitionId())) { // Check for multi instance if (parentExecution.getParentId() != null && parentExecution.getParent().isMultiInstanceRoot()) { parentExecution = parentExecution.getParent(); } matchingEvent = getCatchEventFromList(eventMap.get(parentExecution.getActivityId() + "#" + parentExecution.getProcessDefinitionId()), parentExecution); } else if (StringUtils.isNotEmpty(parentExecution.getParentId())) { parentExecution = parentExecution.getParent(); } else { if (parentExecution.getProcessInstanceId().equals(parentExecution.getRootProcessInstanceId()) == false) { toDeleteProcessInstanceIds.add(parentExecution.getProcessInstanceId()); parentExecution = parentExecution.getSuperExecution(); } else { parentExecution = null; } } } } } if (matchingEvent != null && parentExecution != null) { for (String processInstanceId : toDeleteProcessInstanceIds) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(); ExecutionEntity processInstanceEntity = executionEntityManager.findById(processInstanceId); // Event ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); FlowableEventDispatcher eventDispatcher = null; if (processEngineConfiguration != null) { eventDispatcher = processEngineConfiguration.getEventDispatcher(); } if (eventDispatcher != null && eventDispatcher.isEnabled()) { processEngineConfiguration.getEventDispatcher() .dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.PROCESS_COMPLETED_WITH_ESCALATION_END_EVENT, processInstanceEntity)); } } executeEventHandler(matchingEvent, parentExecution, currentExecution, escalationCode, escalationName); } }