Interface TaskService

  • All Superinterfaces:
    Serializable, TaskProvider
    All Known Implementing Classes:
    TaskServiceImpl

    public interface TaskService
    extends Serializable, TaskProvider
    The task service handle document based Tasks. You can create, search, accept, end or reject tasks. An event is launched when a task is ended, hence giving you the possibility to execute specific code.
    Since:
    5.5
    Author:
    Laurent Doguin
    • Field Detail

      • TASK_INSTANCE_EVENT_PROPERTIES_KEY

        static final String TASK_INSTANCE_EVENT_PROPERTIES_KEY
        Property used to pass task in the notified events properties
        See Also:
        Constant Field Values
    • Method Detail

      • createTask

        List<Task> createTask​(CoreSession coreSession,
                              NuxeoPrincipal principal,
                              DocumentModel document,
                              String taskName,
                              List<String> prefixedActorIds,
                              boolean createOneTaskPerActor,
                              String directive,
                              String comment,
                              Date dueDate,
                              Map<String,​String> taskVariables,
                              String parentPath)
        Creates a task and starts it. Notifies events with names TaskEventNames.WORKFLOW_TASK_ASSIGNED and TaskEventNames.WORKFLOW_TASK_ASSIGNED, passing the task in the event properties using key TASK_INSTANCE_EVENT_PROPERTIES_KEY
        Parameters:
        coreSession - the session to use when notifying
        principal - the principal marked as initiator of the task and used when notifying.
        document - the document to attach to the task.
        taskName - the task name.
        prefixedActorIds - the list of actor ids, prefixed with 'user:' or 'group:'.
        createOneTaskPerActor - if true, one task will be created per actor, else a single task will be assigned to all actors.
        directive - the directive, put in the task variables.
        comment - string added to the task comments and used as a notification comment
        dueDate - the due date, set on the task instance
        taskVariables - additional task variables
        parentPath - /task-root if null
      • createTask

        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)
        Creates a task and starts it. Notifies events with names TaskEventNames.WORKFLOW_TASK_ASSIGNED and TaskEventNames.WORKFLOW_TASK_ASSIGNED, passing the task in the event properties using key TASK_INSTANCE_EVENT_PROPERTIES_KEY
        Parameters:
        coreSession - the session to use when notifying
        principal - the principal marked as initiator of the task and used when notifying.
        document - the document to attach to the task.
        taskName - the task name.
        taskType - the task type.
        processId - the process ID linked to this task if any.
        prefixedActorIds - the list of actor ids, prefixed with 'user:' or 'group:'.
        createOneTaskPerActor - if true, one task will be created per actor, else a single task will be assigned to all actors.
        directive - the directive, put in the task variables.
        comment - string added to the task comments and used as a notification comment
        dueDate - the due date, set on the task instance
        taskVariables - additional task variables
        parentPath - /task-root if null
        Since:
        5.6
      • createTask

        List<Task> createTask​(CoreSession coreSession,
                              NuxeoPrincipal principal,
                              DocumentModel document,
                              String taskDocumentType,
                              String taskName,
                              String taskType,
                              String processId,
                              List<String> prefixedActorIds,
                              boolean createOneTaskPerActor,
                              String directive,
                              String comment,
                              Date dueDate,
                              Map<String,​String> taskVariables,
                              String parentPath,
                              Map<String,​Serializable> eventInfo)
        Creates a task of the given document type and starts it. Notifies events with names TaskEventNames.WORKFLOW_TASK_ASSIGNED and TaskEventNames.WORKFLOW_TASK_ASSIGNED, passing the task in the event properties using key TASK_INSTANCE_EVENT_PROPERTIES_KEY Also the map eventInfo is passed in the event properties
        Parameters:
        coreSession - the session to use when notifying
        principal - the principal marked as initiator of the task and used when notifying.
        document - the document to attach to the task.
        taskDocumentType - the task document type
        taskName - the task name.
        taskType - the task type.
        processId - the process ID linked to this task if any.
        prefixedActorIds - the list of actor ids, prefixed with 'user:' or 'group:'.
        createOneTaskPerActor - if true, one task will be created per actor, else a single task will be assigned to all actors.
        directive - the directive, put in the task variables.
        comment - string added to the task comments and used as a notification comment
        dueDate - the due date, set on the task instance
        taskVariables - additional task variables
        parentPath - /task-root if null
        Since:
        5.6
      • createTaskForProcess

        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)
        Creates a task of the given documents type and starts it. Notifies events with names TaskEventNames.WORKFLOW_TASK_ASSIGNED and TaskEventNames.WORKFLOW_TASK_ASSIGNED, passing the task in the event properties using key TASK_INSTANCE_EVENT_PROPERTIES_KEY Also the map eventInfo is passed in the event properties. The process name can also be specified if any.
        Parameters:
        coreSession - the session to use when notifying
        principal - the principal marked as initiator of the task and used when notifying.
        documents - the documents to attach to the task.
        taskDocumentType - the task document type
        taskName - the task name.
        taskType - the task type.
        processId - the process ID linked to this task if any.
        processName - the process Name linked to this task if any.
        actorIds - the list of actor ids, prefixed with 'user:' or 'group:'.
        createOneTaskPerActor - if true, one task will be created per actor, else a single task will be assigned to all actors.
        directive - the directive, put in the task variables.
        comment - string added to the task comments and used as a notification comment
        dueDate - the due date, set on the task instance
        taskVariables - additional task variables
        parentPath - /task-root if null
        Since:
        7.4
      • canEndTask

        boolean canEndTask​(NuxeoPrincipal principal,
                           Task task)
        Returns true if user is an administrator, the initiator of the task, or an actor of the task.
      • endTask

        String endTask​(CoreSession coreSession,
                       NuxeoPrincipal principal,
                       Task task,
                       String comment,
                       String eventName,
                       boolean isValidated)
        Ends the task
        Specified by:
        endTask in interface TaskProvider
        Parameters:
        coreSession - the session to use when notifying and resolving of referenced document for notification.
        principal - principal used when notifying
        task - the instance to end
        comment - string added to the task comments and used as a notification comment
        eventName - the core event name to use when notifying
        isValidated - boolean marker to state if the task was validated or rejected
        Returns:
        the name of the Seam event to raise
        Throws:
        NuxeoException - when trying to end a task without being granted the right to do so (see canEndTask(NuxeoPrincipal, Task)), or when any other error occurs
      • deleteTask

        void deleteTask​(CoreSession coreSession,
                        String taskId)
        Remove the documentTask identified by the given taskId if coreSession's principal has the Remove permission.
        Since:
        5.5
      • getTargetDocumentModel

        DocumentModel getTargetDocumentModel​(Task ti,
                                             CoreSession coreSession)
        Parameters:
        ti - the task
        Returns:
        the task's target document
      • getTask

        Task getTask​(CoreSession coreSession,
                     String taskId)
        Returns:
        the taskDocument with the given taskId
      • getTaskRootParentPath

        String getTaskRootParentPath​(CoreSession coreSession)
        Default value is /task-root
        Returns:
        the path registered in the taskPersister extension point.
      • reassignTask

        default void reassignTask​(CoreSession session,
                                  String taskId,
                                  List<String> actors,
                                  String comment)
        Reassign the given task to the list of actors. The ACLs set for current assignees and task initiator are removed and new actors are granted 'Manage everything' on the task document. The 'workflowTaskReassigned' event is triggered.
        Since:
        5.7.3
      • delegateTask

        default void delegateTask​(CoreSession session,
                                  String taskId,
                                  List<String> actors,
                                  String comment)
        Delegates the given task to the list of actors. The new actors are granted 'Manage everything' on the task document. The 'workflowTaskDelegated' event is triggered.
        Since:
        5.8