@Override public void run() { DocumentRoutingEngineService routingEngine = Framework.getService(DocumentRoutingEngineService.class); DocumentModel routeDoc = session.getDocument(new IdRef(routeId)); DocumentRoute routeInstance = routeDoc.getAdapter(DocumentRoute.class); routingEngine.resume(routeInstance, nodeId, task != null ? task.getId() : null, data, status, session); // If task is null, it means we are resuming the workflow and about to cancel pending tasks. // Do not notify if (task != null) { String comment = data != null ? (String) data.get(GraphNode.NODE_VARIABLE_COMMENT) : null; final Map<String, Serializable> extraEventProperties = new HashMap<>(); extraEventProperties.put(DocumentRoutingConstants.WORKFLOW_TASK_COMPLETION_ACTION_KEY, status); TaskEventNotificationHelper.notifyTaskEnded(session, session.getPrincipal(), task, comment, TaskEventNames.WORKFLOW_TASK_COMPLETED, extraEventProperties); } }
@Override public String endTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment, String eventName, boolean isValidated) { // put user comment on the task if (!StringUtils.isEmpty(comment)) { task.addComment(principal.getName(), comment); } // end the task, adding boolean marker that task was validated or // rejected task.setVariable(TaskService.VariableName.validated.name(), String.valueOf(isValidated)); task.end(coreSession); // make sure taskDoc is attached to prevent sending event with null session DocumentModel taskDocument = task.getDocument(); if (taskDocument.getSessionId() == null) { taskDocument.attach(coreSession.getSessionId()); } coreSession.saveDocument(taskDocument); if (StringUtils.isNotBlank(eventName)) { TaskEventNotificationHelper.notifyTaskEnded(coreSession, principal, task, comment, eventName, null); } return isValidated ? TaskEventNames.WORKFLOW_TASK_COMPLETED : TaskEventNames.WORKFLOW_TASK_REJECTED; }