Collection<String> flowNodeIdsWithInactivatedBehavior = new ArrayList<String>(); for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) { if (flowNode.getBehavior() instanceof InactiveActivityBehavior) { flowNodeIdsWithInactivatedBehavior.add(flowNode.getId()); InactiveActivityBehavior inactiveActivityBehavior = ((InactiveActivityBehavior) flowNode.getBehavior()); logger.debug("Found InactiveActivityBehavior instance of class {} that can be executed on activity '{}'", inactiveActivityBehavior.getClass(), flowNode.getId()); inactiveActivityBehavior.executeInactive(inactiveExecution);
public static ActivitiActivityEvent createActivityEvent(ActivitiEventType type, String activityId, String activityName, String executionId, String processInstanceId, String processDefinitionId, FlowElement flowElement) { ActivitiActivityEventImpl newEvent = new ActivitiActivityEventImpl(type); newEvent.setActivityId(activityId); newEvent.setActivityName(activityName); newEvent.setExecutionId(executionId); newEvent.setProcessDefinitionId(processDefinitionId); newEvent.setProcessInstanceId(processInstanceId); if (flowElement instanceof FlowNode) { FlowNode flowNode = (FlowNode) flowElement; newEvent.setActivityType(parseActivityType(flowNode)); Object behaviour = flowNode.getBehavior(); if (behaviour != null) { newEvent.setBehaviorClass(behaviour.getClass().getCanonicalName()); } } return newEvent; }
@Override public void run() { FlowElement currentFlowElement = getCurrentFlowElement(execution); if (currentFlowElement instanceof FlowNode) { ActivityBehavior activityBehavior = (ActivityBehavior) ((FlowNode) currentFlowElement).getBehavior(); if (activityBehavior instanceof TriggerableActivityBehavior) { if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityStart(execution); } ((TriggerableActivityBehavior) activityBehavior).trigger(execution, null, null); if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityEnd(execution, null); } } else { throw new ActivitiException("Invalid behavior: " + activityBehavior + " should implement " + TriggerableActivityBehavior.class.getName()); } } else { throw new ActivitiException("Programmatic error: no current flow element found or invalid type: " + currentFlowElement + ". Halting."); } }
subProcessActivityBehavior = (SubProcessActivityBehavior) superExecutionElement.getBehavior(); try { subProcessActivityBehavior.completing(superExecution,
sourceFlowElement != null ? (String) sourceFlowElement.getName() : null, sourceFlowElement != null ? sourceFlowElement.getClass().getName() : null, sourceFlowElement != null ? ((FlowNode) sourceFlowElement).getBehavior() : null, targetFlowElement != null ? targetFlowElement.getId() : null, targetFlowElement != null ? targetFlowElement.getName() : null, targetFlowElement != null ? targetFlowElement.getClass().getName() : null, targetFlowElement != null ? ((FlowNode) targetFlowElement).getBehavior() : null));
protected void executeMultiInstanceSynchronous(FlowNode flowNode) { // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute any boundary events, sub process boundary events will be executed from the activity behavior if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events List<BoundaryEvent> boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { executeBoundaryEvents(boundaryEvents, execution); } } // Execute the multi instance behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); } else { throw new ActivitiException("Expected an activity behavior in flow node " + flowNode.getId()); } }
protected void executeSynchronous(FlowNode flowNode) { commandContext.getHistoryManager().recordActivityStart(execution); // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute any boundary events, sub process boundary events will be executed from the activity behavior if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events List<BoundaryEvent> boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { executeBoundaryEvents(boundaryEvents, execution); } } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); } else { logger.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId()); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true); } }
ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { logger.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId());
Collection<String> flowNodeIdsWithInactivatedBehavior = new ArrayList<String>(); for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) { if (flowNode.getBehavior() instanceof InactiveActivityBehavior) { flowNodeIdsWithInactivatedBehavior.add(flowNode.getId()); InactiveActivityBehavior inactiveActivityBehavior = ((InactiveActivityBehavior) flowNode.getBehavior()); logger.debug("Found InactiveActivityBehavior instance of class {} that can be executed on activity '{}'", inactiveActivityBehavior.getClass(), flowNode.getId()); inactiveActivityBehavior.executeInactive(inactiveExecution);
public static ActivitiActivityEvent createActivityEvent(ActivitiEventType type, String activityId, String activityName, String executionId, String processInstanceId, String processDefinitionId, FlowElement flowElement) { ActivitiActivityEventImpl newEvent = new ActivitiActivityEventImpl(type); newEvent.setActivityId(activityId); newEvent.setActivityName(activityName); newEvent.setExecutionId(executionId); newEvent.setProcessDefinitionId(processDefinitionId); newEvent.setProcessInstanceId(processInstanceId); if (flowElement instanceof FlowNode) { FlowNode flowNode = (FlowNode) flowElement; newEvent.setActivityType(parseActivityType(flowNode)); Object behaviour = flowNode.getBehavior(); if (behaviour != null) { newEvent.setBehaviorClass(behaviour.getClass().getCanonicalName()); } } return newEvent; }
@Override public void run() { FlowElement currentFlowElement = getCurrentFlowElement(execution); if (currentFlowElement instanceof FlowNode) { ActivityBehavior activityBehavior = (ActivityBehavior) ((FlowNode) currentFlowElement).getBehavior(); if (activityBehavior instanceof TriggerableActivityBehavior) { if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityStart(execution); } ((TriggerableActivityBehavior) activityBehavior).trigger(execution, null, null); if (currentFlowElement instanceof BoundaryEvent) { commandContext.getHistoryManager().recordActivityEnd(execution, null); } } else { throw new ActivitiException("Invalid behavior: " + activityBehavior + " should implement " + TriggerableActivityBehavior.class.getName()); } } else { throw new ActivitiException("Programmatic error: no current flow element found or invalid type: " + currentFlowElement + ". Halting."); } }
subProcessActivityBehavior = (SubProcessActivityBehavior) superExecutionElement.getBehavior(); try { subProcessActivityBehavior.completing(superExecution, processInstanceExecution);
protected void continueThroughSequenceFlow(SequenceFlow sequenceFlow) { // Execution listener. Sequenceflow only 'take' makes sense ... but we've supported all three since the beginning if (CollectionUtil.isNotEmpty(sequenceFlow.getExecutionListeners())) { executeExecutionListeners(sequenceFlow, ExecutionListener.EVENTNAME_START); executeExecutionListeners(sequenceFlow, ExecutionListener.EVENTNAME_TAKE); executeExecutionListeners(sequenceFlow, ExecutionListener.EVENTNAME_END); } // Firing event that transition is being taken if(Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement(); Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createSequenceFlowTakenEvent( (ExecutionEntity) execution, ActivitiEventType.SEQUENCEFLOW_TAKEN, sequenceFlow.getId(), sourceFlowElement != null ? sourceFlowElement.getId() : null, sourceFlowElement != null ? (String) sourceFlowElement.getName() : null, sourceFlowElement != null ? sourceFlowElement.getClass().getName() : null, sourceFlowElement != null ? ((FlowNode) sourceFlowElement).getBehavior(): null, targetFlowElement != null ? targetFlowElement.getId() : null, targetFlowElement != null ? targetFlowElement.getName() : null, targetFlowElement != null ? targetFlowElement.getClass().getName() : null, targetFlowElement != null ? ((FlowNode) targetFlowElement).getBehavior(): null)); } FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement(); execution.setCurrentFlowElement(targetFlowElement); logger.debug("Sequence flow '{}' encountered. Continuing process by following it using execution {}", sequenceFlow.getId(), execution.getId()); Context.getAgenda().planContinueProcessOperation(execution); }
protected void executeMultiInstanceSynchronous(FlowNode flowNode) { // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute any boundary events, sub process boundary events will be executed from the activity behavior if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events List<BoundaryEvent> boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { executeBoundaryEvents(boundaryEvents, execution); } } // Execute the multi instance behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); } else { throw new ActivitiException("Expected an activity behavior in flow node " + flowNode.getId()); } }
protected void executeSynchronous(FlowNode flowNode) { commandContext.getHistoryManager().recordActivityStart(execution); // Execution listener: event 'start' if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) { executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START); } // Execute any boundary events, sub process boundary events will be executed from the activity behavior if (!inCompensation && flowNode instanceof Activity) { // Only activities can have boundary events List<BoundaryEvent> boundaryEvents = ((Activity) flowNode).getBoundaryEvents(); if (CollectionUtil.isNotEmpty(boundaryEvents)) { executeBoundaryEvents(boundaryEvents, execution); } } // Execute actual behavior ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { executeActivityBehavior(activityBehavior, flowNode); } else { logger.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId()); Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true); } }
ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); if (activityBehavior != null) { logger.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId());