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; }
protected void updateTaskInfo(CoreSession session, GraphRoute graph, Task task, String status) { String nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); if (StringUtils.isEmpty(nodeId)) { throw new DocumentRouteException("No nodeId found on task: " + task.getId()); } GraphNode node = graph.getNode(nodeId); NuxeoPrincipal principal = session.getPrincipal(); String actor = principal.getActingUser(); node.updateTaskInfo(task.getId(), true, status, actor, null); }
/** * @param session * @param task * @return GraphNode corresponding to task. */ private GraphNode getGraphNode(CoreSession session, Task task) { final String routeDocId = task.getVariable(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY); final String nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); DocumentModel doc = session.getDocument(new IdRef(routeDocId)); GraphRoute route = doc.getAdapter(GraphRoute.class); GraphNode node = route.getNode(nodeId); return node; }
@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();
@Override public void run() { DocumentModel workflowInstanceDoc = session.getDocument(new IdRef(workflowInstanceId)); workflowInstance = workflowInstanceDoc.getAdapter(GraphRoute.class); node = workflowInstance.getNode(nodeId); workflowInstanceDoc.detach(true); node.getDocument().detach(true); }
/** * @since 5.8 - Define if action reassign task can be displayed. */ public boolean canBeReassign() throws ClientException { if (currentTask == null) { return false; } DocumentModel workflowInstance = documentManager.getDocument(new IdRef( currentTask.getProcessId())); GraphRoute workflow = workflowInstance.getAdapter(GraphRoute.class); if (workflow == null) { return false; } GraphNode node = workflow.getNode(currentTask.getType()); return node.allowTaskReassignment(); } }
GraphNode node = workflow.getNode(task.getType()); for (Button button : buttons) { Action action = new Action(button.getName(),
@Override public void handleEvent(Event event) { if (!DocumentEventTypes.ABOUT_TO_REMOVE.equals(event.getName())) { return; } DocumentEventContext docCtx; if (event.getContext() instanceof DocumentEventContext) { docCtx = (DocumentEventContext) event.getContext(); } else { return; } DocumentModel doc = docCtx.getSourceDocument(); CoreSession session = docCtx.getCoreSession(); if (doc.hasFacet(DocumentRoutingConstants.ROUTING_TASK_FACET_NAME)) { Task task = doc.getAdapter(Task.class); String routeId = task.getProcessId(); IdRef routeIdRef = new IdRef(routeId); if (StringUtils.isNotBlank(routeId) && session.exists(routeIdRef)) { GraphRoute graphRoute = session.getDocument(routeIdRef).getAdapter(GraphRoute.class); String nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); if (StringUtils.isNotBlank(nodeId)) { GraphNode graphNode = graphRoute.getNode(nodeId); graphNode.removeTaskInfo(task.getId()); } } } }
GraphNode node = graph.getNode(nodeId); if (node == null) { throw new DocumentRouteException("Invalid nodeId: " + nodeId);
GraphNode target = graph.getNode(t.target); if (!pendingNodes.contains(target)) { pendingNodes.add(target);
"Invalid routeInstanceId: " + routeId + " referenced by the task " + taskId); GraphNode node = routeInstance.getNode(task.getType()); if (node == null) { throw new DocumentRouteException(
"Invalid routeInstanceId: " + routeId + " referenced by the task " + taskId); GraphNode node = routeInstance.getNode(task.getType()); if (node == null) { throw new DocumentRouteException(