protected boolean isCreatedFromCreateTaskOperation() { return Boolean.parseBoolean(getTask().getVariable("createdFromCreateTaskOperation")); }
/** * @since 5.6 */ public DocumentModel getRouteInstanceFor(Task task) throws ClientException { final String routeDocId = task.getVariable(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY); if (routeDocId == null) { return null; } final DocumentModel[] res = new DocumentModel[1]; new UnrestrictedSessionRunner(documentManager) { @Override public void run() throws ClientException { DocumentModel doc = session.getDocument(new IdRef(routeDocId)); doc.detach(true); res[0] = doc; } }.runUnrestricted(); return res[0]; }
/** * @param task * @return workflow document model of task. */ public DocumentModel getCurrentWfModel(Task task) { String routeInstanceDocId = task.getVariable("routeInstanceDocId"); return documentManager.getDocument(new IdRef(routeInstanceDocId)); }
/** * @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; }
protected boolean needi18n() { if (isCreatedFromCreateTaskOperation()) { return false; } return Boolean.parseBoolean(getTask().getVariable(Task.TaskVariableName.needi18n.name())); }
public static void notifyEvent(CoreSession coreSession, DocumentModel document, NuxeoPrincipal principal, Task task, String eventId, Map<String, Serializable> properties, String comment, String category) { // Default category if (category == null) { category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY; } if (properties == null) { properties = new HashMap<>(); } EventContext eventContext; if (document != null) { properties.put(CoreEventConstants.REPOSITORY_NAME, document.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, coreSession.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, document.getCurrentLifeCycleState()); eventContext = new DocumentEventContext(coreSession, principal, document); } else { eventContext = new EventContextImpl(coreSession, principal); } properties.put(DocumentEventContext.COMMENT_PROPERTY_KEY, comment); properties.put(DocumentEventContext.CATEGORY_PROPERTY_KEY, category); properties.put(TaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY, task); String disableNotif = task.getVariable(TaskEventNames.DISABLE_NOTIFICATION_SERVICE); if (disableNotif != null && Boolean.TRUE.equals(Boolean.valueOf(disableNotif))) { properties.put(TaskEventNames.DISABLE_NOTIFICATION_SERVICE, Boolean.TRUE); } eventContext.setProperties(properties); Event event = eventContext.newEvent(eventId); getEventProducer().fireEvent(event); }
/** * Use the task provider held by the {@link Task#TASK_PROVIDER_KEY} task variable to end the {@code task}. If null * use the {@link #DEFAULT_TASK_PROVIDER}. */ @Override public String endTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment, String eventName, boolean isValidated) { if (!canEndTask(principal, task)) { throw new NuxeoException(String.format("User with id '%s' cannot end this task", principal.getName())); } String taskProviderId = task.getVariable(Task.TASK_PROVIDER_KEY); if (taskProviderId == null) { taskProviderId = DEFAULT_TASK_PROVIDER; } TaskProvider taskProvider = tasksProviders.get(taskProviderId); if (taskProvider == null) { throw new NuxeoException(String.format( "No task provider registered, cannot end task. Please contribute at least the default task provider: %s.", DEFAULT_TASK_PROVIDER)); } return taskProvider.endTask(coreSession, principal, task, comment, eventName, isValidated); }
return tasksInfoCache.get(task.getId()); final String routeDocId = task.getVariable(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY); final String nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); if (routeDocId == null) { throw new ClientException(
docIds.addAll(task.getTargetDocumentsIds()); String docIdVar = task.getVariable(TaskService.VariableName.documentId.name()); if (!docIds.contains(docIdVar)) { docIds.add(docIdVar); String docRepo = task.getVariable(TaskService.VariableName.documentRepositoryName.name()); List<DocumentModel> documents = new ArrayList<>(); if (coreSession.getRepositoryName().equals(docRepo)) {
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); }
Boolean validated = Boolean.valueOf(task.getVariable(TaskService.VariableName.validated.name())); chain = task.getVariable(OperationTaskVariableName.acceptOperationChain.name()); } else { chain = task.getVariable(OperationTaskVariableName.rejectOperationChain.name());
GraphNode node = null; String workflowInstanceId = item.getProcessId(); final String nodeId = item.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); try (SessionWrapper wrapper = ctx.getSession(item.getDocument())) { if (StringUtils.isNotBlank(workflowInstanceId)) { jg.writeStringField("created", DateParser.formatW3CDateTime(item.getCreated())); jg.writeStringField("dueDate", DateParser.formatW3CDateTime(item.getDueDate())); jg.writeStringField("nodeName", item.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY));
protected void endTask(DocumentModel document, NuxeoPrincipal currentUser, CoreSession session, String comment, PublishingEvent event) { List<Task> tis = getTaskService().getTaskInstances(document, currentUser, session); String initiator = null; for (Task task : tis) { if (task.getName().equals(TASK_NAME)) { initiator = (String) task.getVariable(TaskService.VariableName.initiator.name()); task.end(session); // make sure taskDoc is attached to prevent sending event with null session DocumentModel taskDocument = task.getDocument(); if (taskDocument.getSessionId() == null) { taskDocument.attach(coreSession.getSessionId()); } session.saveDocument(taskDocument); break; } } DocumentModel liveDoc = getLiveDocument(session, document); Map<String, Serializable> properties = new HashMap<String, Serializable>(); if (initiator != null) { properties.put(NotificationConstants.RECIPIENTS_KEY, new String[] { initiator }); } notifyEvent(event.name(), properties, comment, null, liveDoc, session); }
nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY); if (StringUtils.isEmpty(nodeId)) { throw new DocumentRouteException("No nodeId found on task: " + taskId);
String routeId = task.getVariable(DocumentRoutingConstants.TASK_ROUTE_INSTANCE_DOCUMENT_ID_KEY); String nodeId = task.getVariable(DocumentRoutingConstants.TASK_NODE_ID_KEY);
@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()); } } } }