public static Map<String, Object> getGraphElementsAsMap(GraphRoute route, Locale locale) { Map<String, Object> graph = new HashMap<String, Object>(); List<NodeView> nodeViews = new ArrayList<NodeView>(); List<TransitionView> tranViews = new ArrayList<TransitionView>(); for (GraphNode node : route.getNodes()) { nodeViews.add(new NodeView(node, locale)); List<Transition> transitions = node.getOutputTransitions(); for (Transition transition : transitions) { GraphNode targetNode = route.getNode(transition.getTarget()); tranViews.add(new TransitionView(node.getId(), targetNode.getId(), transition, locale)); } } graph.put("nodes", nodeViews); graph.put("transitions", tranViews); return graph; }
@Override public void cancel(CoreSession session, DocumentRouteElement element) { GraphRoute graph = element instanceof GraphRoute ? (GraphRoute) element : null; Map<String, Serializable> eventProperties = new HashMap<>(); if (graph != null) { eventProperties.put("modelId", graph.getModelId()); eventProperties.put("modelName", graph.getModelName()); eventProperties.put(RoutingAuditHelper.WORKFLOW_VARIABLES, (Serializable) graph.getVariables()); eventProperties.put(RoutingAuditHelper.WORKFLOW_INITATIOR, graph.getInitiator()); // Get the list of pending node List<String> pendingNodeNames = new ArrayList<>(); for (GraphNode suspendedNode : graph.getSuspendedNodes()) { pendingNodeNames.add(suspendedNode.getId()); } eventProperties.put("pendingNodes", (Serializable) pendingNodeNames); } EventFirer.fireEvent(session, element, eventProperties, DocumentRoutingConstants.Events.beforeWorkflowCanceled.name()); super.cancel(session, element); if (graph == null) { return; } // also cancel tasks // also cancel sub-workflows for (GraphNode node : graph.getNodes()) { node.cancelTasks(); node.cancelSubRoute(); } }