visitedElements.add(sourceElement.getId()); if (sourceElement.getId().equals(targetElement.getId())) { return true; visitedElements.add(sourceElement.getId()); String targetRef = sequenceFlow.getTargetRef(); FlowNode sequenceFlowTarget = (FlowNode) process.getFlowElement(targetRef, true); if (sequenceFlowTarget != null && !visitedElements.contains(sequenceFlowTarget.getId())) { boolean reachable = isReachable(process, sequenceFlowTarget, targetElement, visitedElements);
protected boolean hasMultiInstanceRootExecution(ExecutionEntity execution, FlowNode flowNode) { ExecutionEntity currentExecution = execution.getParent(); while (currentExecution != null) { if (currentExecution.isMultiInstanceRoot() && flowNode.getId().equals(currentExecution.getActivityId())) { return true; } currentExecution = currentExecution.getParent(); } return false; }
for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) { if (flowNode.getBehavior() instanceof InactiveActivityBehavior) { flowNodeIdsWithInactivatedBehavior.add(flowNode.getId()); LOGGER.debug("Found InactiveActivityBehavior instance of class {} that can be executed on activity '{}'", inactiveActivityBehavior.getClass(), flowNode.getId()); inactiveActivityBehavior.executeInactive(inactiveExecution);
protected void leaveFlowNode(FlowNode flowNode) { flowNode.getClass(), flowNode.getId(), flowNode.getOutgoingFlows().size()); LOGGER.debug("No outgoing sequence flow found for flow node '{}'.", flowNode.getId()); agenda.planEndExecutionOperation(execution); throw new FlowableException("No outgoing sequence flow of element '" + flowNode.getId() + "' could be selected for continuing the process");
protected void executeActivityBehavior(ActivityBehavior activityBehavior, FlowNode flowNode) { LOGGER.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId()); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); if (processEngineConfiguration != null && processEngineConfiguration.getEventDispatcher().isEnabled()) { if (flowNode instanceof Activity && ((Activity) flowNode).hasMultiInstanceLoopCharacteristics()) { processEngineConfiguration.getEventDispatcher().dispatchEvent( FlowableEventBuilder.createMultiInstanceActivityEvent(FlowableEngineEventType.MULTI_INSTANCE_ACTIVITY_STARTED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } else { processEngineConfiguration.getEventDispatcher().dispatchEvent( FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_STARTED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } } try { activityBehavior.execute(execution); } catch (RuntimeException e) { if (LogMDC.isMDCEnabled()) { LogMDC.putMDCExecution(execution); } throw e; } }
if (messageFlow.getSourceRef().equals(flowNode.getId())) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId())); if (artifact instanceof Association){ Association association= (Association) artifact; if (association.getSourceRef().equals(flowNode.getId())){ outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(artifact.getId()));
protected void executeSynchronous(FlowNode flowNode) { CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(execution); // Execution listener if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); LOGGER.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId()); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); if (processEngineConfiguration != null && processEngineConfiguration.getEventDispatcher().isEnabled()) { processEngineConfiguration.getEventDispatcher().dispatchEvent( FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_STARTED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } try { activityBehavior.execute(execution); } 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 ErrorPropagation.propagateError(error, execution); } catch (RuntimeException e) { if (LogMDC.isMDCEnabled()) { LogMDC.putMDCExecution(execution); } throw e; } }
protected void executeSynchronous(FlowNode flowNode) { CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(execution); // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Create any boundary events, sub process boundary events will be created from the activity behavior List<ExecutionEntity> boundaryEventExecutions = null; List<BoundaryEvent> boundaryEvents = null; if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { boundaryEventExecutions = createBoundaryEvents(boundaryEvents, execution); } } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); } else { executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); LOGGER.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId()); CommandContextUtil.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true); } }
protected void executeMultiInstanceSynchronous(FlowNode flowNode) { // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } if (!hasMultiInstanceRootExecution(execution, flowNode)) { execution = createMultiInstanceRootExecution(execution); } // Create any boundary events, sub process boundary events will be created from the activity behavior List<ExecutionEntity> boundaryEventExecutions = null; List<BoundaryEvent> boundaryEvents = null; if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { boundaryEventExecutions = createBoundaryEvents(boundaryEvents, execution); } } // Execute the multi instance behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); executeBoundaryEvents(boundaryEvents, boundaryEventExecutions); } else { throw new FlowableException("Expected an activity behavior in flow node " + flowNode.getId()); } }
protected void handleActivityEnd(FlowNode flowNode) { // a process instance execution can never leave a flow node, but it can pass here whilst cleaning up // hence the check for NOT being a process instance if (!execution.isProcessInstanceType()) { if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_END); } if (execution.isActive() && !flowNode.getOutgoingFlows().isEmpty() && !(flowNode instanceof ParallelGateway) // Parallel gw takes care of its own history && !(flowNode instanceof InclusiveGateway) // Inclusive gw takes care of its own history && !(flowNode instanceof SubProcess) // Subprocess handling creates and destroys scoped execution. The execution taking the seq flow is different from the one entering && (!(flowNode instanceof Activity) || ((Activity) flowNode).getLoopCharacteristics() == null) // Multi instance root execution leaving the node isn't stored in history ) { // If no sequence flow: will be handled by the deletion of executions CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityEnd(execution, null); } if (!(execution.getCurrentFlowElement() instanceof SubProcess) && !(flowNode instanceof Activity && ((Activity) flowNode).hasMultiInstanceLoopCharacteristics())) { CommandContextUtil.getEventDispatcher(commandContext).dispatchEvent( FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_COMPLETED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode)); } } }