@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();
taskVariables.put(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY, routeInstance.getDocument().getId()); taskVariables.put(DocumentRoutingConstants.TASK_NODE_ID_KEY, node.getId()); taskVariables.put(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY, node.getDocument().getId()); String taskNotiftemplate = node.getTaskNotificationTemplate(); if (!StringUtils.isEmpty(taskNotiftemplate)) { taskVariables.put(DocumentRoutingConstants.TASK_ASSIGNED_NOTIFICATION_TEMPLATE, taskNotiftemplate); actors.addAll(node.evaluateTaskAssignees()); actors.addAll(node.getTaskAssignees()); Date dueDate = node.computeTaskDueDate(); DocumentModelList docs = graph.getAttachedDocumentModels(); TaskService taskService = Framework.getService(TaskService.class); node.getTaskDocType(), node.getDocument().getTitle(), node.getId(), routeInstance.getDocument().getId(), new ArrayList<>(actors), node.hasMultipleTasks(), node.getTaskDirective(), null, dueDate, taskVariables, null, node.getWorkflowContextualInfo(session, true)); Map<String, Serializable> eventProperties = new HashMap<>(); eventProperties.put(DocumentEventContext.CATEGORY_PROPERTY_KEY, DocumentRoutingConstants.ROUTING_CATEGORY); eventProperties.put("taskName", node.getDocument().getTitle()); eventProperties.put("actors", actors); eventProperties.put("modelId", graph.getModelId()); eventProperties.put(RoutingAuditHelper.WORKFLOW_INITATIOR, graph.getInitiator()); eventProperties.put(RoutingAuditHelper.TASK_ACTOR, session.getPrincipal().getOriginatingUser()); eventProperties.put("nodeVariables", (Serializable) node.getVariables()); if (routeInstance instanceof GraphRoute) {
switch (node.getState()) { case READY: log.debug("Doing node " + node); if (node.isMerge()) { jump = State.WAITING; } else { if (node.canMerge()) { recursiveCancelInput(graph, node, pendingNodes); jump = State.RUNNING_INPUT; node.starting(); node.executeChain(node.getInputChain()); if (node.hasTask() || node.hasMultipleTasks()) { node.setState(State.SUSPENDED); if (node.hasSubRoute()) { if (!pendingSubRoutes.contains(node)) { pendingSubRoutes.add(node); node.setState(State.SUSPENDED); if (node.getState() != State.SUSPENDED) { jump = State.RUNNING_OUTPUT; node.setLastActor(actor); node.executeChain(node.getOutputChain());
while (!todo.isEmpty()) { GraphNode node = todo.pop(); done.add(node.getId()); for (Transition t : node.getInputTransitions()) { if (t.loop) { if (done.contains(source.getId())) { source.setCanceled(); State state = source.getState(); source.setState(State.READY); pendingNodes.remove(node); if (state == State.SUSPENDED) { source.cancelTasks(); } else {
&& (Boolean) varData.get(DocumentRoutingConstants.WORKFLOW_FORCE_RESUME)); if (forceResume && node.getState() != State.SUSPENDED && node.getState() != State.WAITING) { throw new DocumentRouteException("Cannot force resume on non-suspended or non-waiting node: " + node); if (!forceResume && node.getState() != State.SUSPENDED) { throw new DocumentRouteException("Cannot resume on non-suspended node: " + node); node.setAllVariables(varData, false); if (StringUtils.isNotEmpty(status)) { node.setButton(status); eventProperties.put(RoutingAuditHelper.WORKFLOW_INITATIOR, graph.getInitiator()); eventProperties.put(RoutingAuditHelper.TASK_ACTOR, session.getPrincipal().getActingUser()); eventProperties.put("nodeVariables", (Serializable) node.getVariables()); eventProperties.put("workflowVariables", (Serializable) graph.getVariables()); node.cancelTasks(); if (node.hasOpenTasks()) { log.info("Node " + node.getId() + "has open tasks, the workflow can not be resumed for now."); && ((Map<String, Serializable>) varData.get(Constants.VAR_WORKFLOW_NODE)).containsKey( GraphNode.NODE_VARIABLE_COMMENT)) { node.setVariable(GraphNode.NODE_VARIABLE_COMMENT, "");
jg.writeFieldName("taskInfo"); jg.writeStartObject(); jg.writeBooleanField("allowTaskReassignment", node.allowTaskReassignment()); for (Button button : node.getTaskButtons()) { if (StringUtils.isBlank(button.getFilter()) || actionManager.checkFilter(button.getFilter(), createActionContext(wrapper.getSession()))) { jg.writeStringField("name", node.getTaskLayout()); jg.writeStringField("url", ctx.getBaseUrl() + "site/layout-manager/layouts/?layoutName=" + node.getTaskLayout()); jg.writeEndObject(); for (String schema : node.getDocument().getSchemas()) {
+ "' can not be adapted to a GraphNode"); List<EscalationRule> rules = node.getEscalationRules(); EscalationRule rule = null; for (EscalationRule escalationRule : rules) { context.putAll(node.getWorkflowContextualInfo(session, true)); context.setInput(context.get("documents")); log.trace("Rule " + rule.getId() + "on node " + node.getId() + " already executed"); return; node.executeChain(rule.getChain());
"Invalid node " + routeId + " referenced by the task " + taskId); if (!node.allowTaskReassignment()) { throw new DocumentRouteException("Task " + taskId + " can not be reassigned. Node " + node.getId() + " doesn't allow reassignment."); grantPermissionToTaskAssignees(session, node.getTaskAssigneesPermission(), docs, task);
@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(); } }
/** * @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(); } }
if (node != null) { Map<String, Object> workflowContextualInfo = new HashMap<String, Object>(); workflowContextualInfo.putAll(node.getWorkflowContextualInfo( documentManager, true)); actionContext.putAllLocalVariables(workflowContextualInfo);