protected void fireEventAfterWorkflowStarted(DocumentRoute route, CoreSession session) { Map<String, Serializable> eventProperties = new HashMap<>(); eventProperties.put(RoutingAuditHelper.WORKFLOW_INITATIOR, route.getInitiator()); eventProperties.put("modelId", route.getModelId()); eventProperties.put("modelName", route.getModelName()); if (route instanceof GraphRoute) { eventProperties.put(RoutingAuditHelper.WORKFLOW_VARIABLES, (Serializable) ((GraphRoute) route).getVariables()); } fireEvent(DocumentRoutingConstants.Events.afterWorkflowStarted.name(), eventProperties, route, session); }
protected void fireWorkflowCompletionEvent(CoreSession session) { EventFirer.fireEvent(session, this, null, DocumentRoutingConstants.Events.afterRouteFinish.name()); Map<String, Serializable> eventProperties = new HashMap<String, Serializable>(); // First compute duration long duration = RoutingAuditHelper.computeDurationSinceWfStarted(getDocument().getId()); if (duration >= 0) { eventProperties.put(RoutingAuditHelper.TIME_SINCE_WF_STARTED, duration); } eventProperties.put(RoutingAuditHelper.WORKFLOW_INITATIOR, this.getInitiator()); // Add common info about workflow if (this instanceof GraphRoute) { eventProperties.put(RoutingAuditHelper.WORKFLOW_VARIABLES, (Serializable) ((GraphRoute) this).getVariables()); } eventProperties.put("modelId", getModelId()); eventProperties.put("modelName", getModelName()); EventFirer.fireEvent(session, this, eventProperties, DocumentRoutingConstants.Events.afterWorkflowFinish.name()); }
@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(); } }
@Override public void run() throws ClientException { DocumentModel doc = session.getDocument(new IdRef(routeDocId)); GraphRoute route = doc.getAdapter(GraphRoute.class); GraphNode node = route.getNode(nodeId); HashMap<String, Serializable> map = new HashMap<String, Serializable>(); if (getFormVariables) { map.putAll(node.getVariables()); map.putAll(route.getVariables()); } res[0] = new TaskInfo(task.getId(), map, node.getTaskLayout(), node.getTaskButtons(), node.allowTaskReassignment(), task.getName()); } }.runUnrestricted();
@SuppressWarnings("unchecked") @OperationMethod public void run() { // first fill context if (ctx.get(Constants.VAR_WORKFLOW) != null) { ((Map<String, Serializable>) ctx.get(Constants.VAR_WORKFLOW)).put(name, (Serializable) value); } // get workflow instance id from context if not in automation parameters if (workflowInstanceId == null) { workflowInstanceId = (String) ctx.get("workflowInstanceId"); } if (workflowInstanceId == null) { return; } // finally save graph variables DocumentModel workflowInstance = session.getDocument(new IdRef(workflowInstanceId)); GraphRoute graph = workflowInstance.getAdapter(GraphRoute.class); Map<String, Serializable> vars = graph.getVariables(); vars.put(name, (Serializable) value); graph.setVariables(vars); } }
eventProperties.put(RoutingAuditHelper.TASK_ACTOR, session.getPrincipal().getActingUser()); eventProperties.put("nodeVariables", (Serializable) node.getVariables()); eventProperties.put("workflowVariables", (Serializable) graph.getVariables());
eventProperties.put("nodeVariables", (Serializable) node.getVariables()); if (routeInstance instanceof GraphRoute) { eventProperties.put("workflowVariables", (Serializable) ((GraphRoute) routeInstance).getVariables());