/** * @since 5.6 */ @Override public List<Task> createTask(CoreSession coreSession, NuxeoPrincipal principal, DocumentModel document, String taskName, String taskType, String processId, List<String> prefixedActorIds, boolean createOneTaskPerActor, String directive, String comment, Date dueDate, Map<String, String> taskVariables, String parentPath) { return createTask(coreSession, principal, document, TaskConstants.TASK_TYPE_NAME, taskName, taskType, processId, prefixedActorIds, createOneTaskPerActor, directive, comment, dueDate, taskVariables, parentPath, null); }
/** * @since 5.8 * @deprecated since 7.4 use * {@link #createTaskForProcess(CoreSession, NuxeoPrincipal, List, String, String, String, String, String, List, boolean, String, String, Date, Map, String, Map)} * instead */ @Override @Deprecated public List<Task> createTask(CoreSession coreSession, NuxeoPrincipal principal, List<DocumentModel> documents, String taskDocumentType, String taskName, String taskType, String processId, List<String> actorIds, boolean createOneTaskPerActor, String directive, String comment, Date dueDate, Map<String, String> taskVariables, String parentPath, Map<String, Serializable> eventInfo) { return createTaskForProcess(coreSession, principal, documents, taskDocumentType, taskName, taskType, processId, null, actorIds, createOneTaskPerActor, directive, comment, dueDate, taskVariables, parentPath, eventInfo); }
@Override public String rejectTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment) { return endTask(coreSession, principal, task, comment, TaskEventNames.WORKFLOW_TASK_REJECTED, false); }
/** * @since 7.4 */ @Override public List<Task> createTaskForProcess(CoreSession coreSession, NuxeoPrincipal principal, List<DocumentModel> documents, String taskDocumentType, String taskName, String taskType, String processId, String processName, List<String> actorIds, boolean createOneTaskPerActor, String directive, String comment, Date dueDate, Map<String, String> taskVariables, String parentPath, Map<String, Serializable> eventInfo) { if (StringUtils.isBlank(parentPath)) { parentPath = getTaskRootParentPath(coreSession); } CreateTaskUnrestricted runner = new CreateTaskUnrestricted(coreSession, principal, documents, taskDocumentType, taskName, taskType, processId, processName, actorIds, createOneTaskPerActor, directive, comment, dueDate, taskVariables, parentPath); runner.runUnrestricted(); List<Task> tasks = runner.getTasks(); for (Task task : tasks) { // notify notifyEvent(coreSession, task, documents, TaskEventNames.WORKFLOW_TASK_ASSIGNED, eventInfo, comment, principal, task.getActors()); } return tasks; } }
notifyEvent(session, task, docs, TaskEventNames.WORKFLOW_TASK_DELEGATED, new HashMap<>(), String.format("Task delegated by '%s' to '%s'", currentUser, StringUtils.join(actorIds, ",")) + (!StringUtils.isEmpty(comment) ? " with the following comment: " + comment : ""),
@Override public boolean canEndTask(NuxeoPrincipal principal, Task task) { if (task != null && (!task.isCancelled() && !task.hasEnded())) { return principal.isAdministrator() || principal.getName().equals(task.getInitiator()) || isTaskAssignedToUser(task, principal, true); } return false; }
/** * 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); }
notifyEvent(session, task, docs, TaskEventNames.WORKFLOW_TASK_REASSIGNED, new HashMap<>(), comment, session.getPrincipal(), actorIds);
@Override public List<Task> createTask(CoreSession coreSession, NuxeoPrincipal principal, DocumentModel document, String taskName, List<String> actorIds, boolean createOneTaskPerActor, String directive, String comment, Date dueDate, Map<String, String> taskVariables, String parentPath) { return createTask(coreSession, principal, document, taskName, null, null, actorIds, createOneTaskPerActor, directive, comment, dueDate, taskVariables, parentPath); }
/** * @since 5.6 */ @Override public List<Task> createTask(CoreSession coreSession, NuxeoPrincipal principal, DocumentModel document, String taskDocumentType, String taskName, String taskType, String processId, List<String> actorIds, boolean createOneTaskPerActor, String directive, String comment, Date dueDate, Map<String, String> taskVariables, String parentPath, Map<String, Serializable> eventInfo) { List<DocumentModel> docs = new ArrayList<>(); docs.add(document); return createTaskForProcess(coreSession, principal, docs, taskDocumentType, taskName, taskType, processId, null, actorIds, createOneTaskPerActor, directive, comment, dueDate, taskVariables, parentPath, eventInfo); }
@Override public String acceptTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment) { return endTask(coreSession, principal, task, comment, TaskEventNames.WORKFLOW_TASK_COMPLETED, true); }