Interface DocumentRoutingService

    • Method Detail

      • resumeInstance

        void resumeInstance​(String routeId,
                            String nodeId,
                            Map<String,​Object> data,
                            String status,
                            CoreSession session)
        Resumes a route instance on a give node. Any remaining tasks on this node will be cancelled.

        Called by the UI action corresponding to a task button.

        If all attached documents of the workflow instance have been deleted then the workflow is cancelled.

        Parameters:
        routeId - the id of the route instance
        nodeId - the node id to resume on
        data - the data coming from UI form
        status - the status coming from UI form
        session - the session
        Since:
        5.6
      • completeTask

        void completeTask​(String routeId,
                          String taskId,
                          Map<String,​Object> data,
                          String status,
                          CoreSession session)
        Completes a task on a give node. If this is the last task the workflow will continue.

        Called by the UI action corresponding to a task button.

        Parameters:
        routeId - the id of the route instance
        taskId - the id of the task
        data - the data coming from UI form
        status - the status coming from UI form
        session - the session
        Since:
        5.6
      • saveRouteAsNewModel

        DocumentRoute saveRouteAsNewModel​(DocumentRoute route,
                                          CoreSession session)
        Save a route instance as a new model of route.

        The place in which the new instance is persisted and its name depends on DocumentRoutingPersister. The route instance should be in either running, done or ready state. The new route model will be in draft state and won't have any attached documents.

        Parameters:
        route - the instance from which we create a new model.
        Returns:
        the new model in draft state.
      • getOperationChainId

        @Deprecated
        String getOperationChainId​(String documentType)
        Deprecated.
        since 5.9.2 - Use only routes of type 'graph'
        Return the operation chain to run for a documentType. The document type should extend the DocumentRouteStep. Use the chainsToType extension point to contribute new mapping.
        Parameters:
        documentType - The document type
        Returns:
        The operation chain id.
      • getUndoFromRunningOperationChainId

        @Deprecated
        String getUndoFromRunningOperationChainId​(String documentType)
        Deprecated.
        since 5.9.2 - Use only routes of type 'graph'
        Return the operation chain to undo a step when the step is in running state. The document type should extend the DocumentRouteStep. Use the chainsToType extension point to contribute new mapping.
      • getUndoFromDoneOperationChainId

        String getUndoFromDoneOperationChainId​(String documentType)
        Return the operation chain to undo a step when the step is in done state. The document type should extend the DocumentRouteStep. Use the chainsToType extension point to contribute new mapping.
      • unlockDocumentRouteUnrestrictedSession

        DocumentRoute unlockDocumentRouteUnrestrictedSession​(DocumentRoute routeModel,
                                                             CoreSession userSession)
        Unlock the given DocumentRoute model under unrestricted session.
        Returns:
        The unlocked route.
        Since:
        1.9
      • canValidateRoute

        boolean canValidateRoute​(DocumentModel documentRoute,
                                 CoreSession coreSession)
        Checks if the principal that created the client session can validate the route
      • addRouteElementToRoute

        @Deprecated
        void addRouteElementToRoute​(DocumentRef parentDocumentRef,
                                    String sourceName,
                                    DocumentRouteElement routeElement,
                                    CoreSession session)
                             throws DocumentRouteNotLockedException
        Deprecated.
        since 5.9.2 - Use only routes of type 'graph'
        Add a route element in another route element.

        If the parent element is in draft state, the routeElement is kept in draft state. Otherwise, the element is set to 'ready' state.

        Parameters:
        parentDocumentRef - The DocumentRef of the parent document.
        sourceName - the name of the previous document in the container.
        routeElement - the document to add.
        Throws:
        DocumentRouteNotLockedException
      • getOrderedRouteElement

        @Deprecated
        DocumentModelList getOrderedRouteElement​(String routeElementId,
                                                 CoreSession session)
        Deprecated.
        since 5.9.2 - Use only routes of type 'graph'
        Get the children of the given stepFolder ordered by the ecm:pos metadata.
      • isRoutable

        boolean isRoutable​(DocumentModel doc)
        Checks if the given document can be associated to a DocumentRoute.
        Parameters:
        doc - the document
        Returns:
        true if the document can be routed
      • importAllRouteModels

        void importAllRouteModels​(CoreSession session)
        Imports all the route models resource templates.
        Parameters:
        session - the core session to use
        Since:
        7.3
      • importRouteModel

        DocumentRoute importRouteModel​(URL templateResource,
                                       boolean overwrite,
                                       CoreSession session)
        Creates a route model in the root models folder defined by the current persister. The templateResource is a zip tree xml export of a route document and it is imported using the core-io importer.
        Since:
        5.6
      • registerRouteResource

        void registerRouteResource​(RouteModelResourceType resource,
                                   RuntimeContext extensionContext)
        Registers a new route model template to be imported at application startup.
        Parameters:
        resource - the resource
        Since:
        5.6
      • getRouteModelTemplateResources

        List<URL> getRouteModelTemplateResources()
        Returns all the route models resource templates. Use the routeModelImporter extension point to contribute new resources.
        Since:
        5.6
      • getRouteModelDocIdWithId

        String getRouteModelDocIdWithId​(CoreSession session,
                                        String id)
        Returns the doc id of the route model with the given id
        Since:
        5.7
      • makeRoutingTasks

        @Deprecated
        void makeRoutingTasks​(CoreSession session,
                              List<Task> tasks)
        Deprecated.
        The facet RoutingTask is statically attached to the new RoutingTask Document type since 7.1
        Marks the tasks as Routing tasks.

        This allows the related documents to be adapted to RoutingTask.

        Parameters:
        session - the session
        tasks - the tasks
        Since:
        5.6, was on RoutingTaskService before
      • endTask

        void endTask​(CoreSession session,
                     Task task,
                     Map<String,​Object> data,
                     String status)
        Ends a task. If this is the last task the workflow will continue.
        Parameters:
        status - name of the button clicked to submit the task form
        Since:
        5.6, was on RoutingTaskService before
      • grantPermissionToTaskAssignees

        void grantPermissionToTaskAssignees​(CoreSession session,
                                            String permission,
                                            List<DocumentModel> docs,
                                            Task task)
        Grants on these documents the specified assignees permissions for this task.
        Parameters:
        session - the session
        permission - the permission
        docs - the documents
        task - the task
        Since:
        5.6
      • removePermissionFromTaskAssignees

        void removePermissionFromTaskAssignees​(CoreSession session,
                                               List<DocumentModel> docs,
                                               Task task)
        Removes on these documents the specified assignees permissions for this task.
        Parameters:
        session - the session
        docs - the documents
        task - the task
        Since:
        5.6
      • getWorkflowInputDocuments

        List<DocumentModel> getWorkflowInputDocuments​(CoreSession session,
                                                      Task task)
        Gets the documents following the workflow to which the given task belongs
        Since:
        5.6, was on RoutingTaskService before
      • finishTask

        @Deprecated
        void finishTask​(CoreSession session,
                        DocumentRoute route,
                        Task task,
                        boolean delete)
                 throws DocumentRouteException
        Deprecated.
        // will be removed in 5.8, use completeTask instead
        Finishes an open task. All permissions granted to the tasks assignees on the document following the worklflow are removed. Doesn't resume the workflow as the completeTask method. Not executed using an unrestricted session.
        Throws:
        DocumentRouteException
        Since:
        5.7
      • cancelTask

        void cancelTask​(CoreSession session,
                        String taskId)
                 throws DocumentRouteException
        Cancels an open task. If the task was created by an workflow, all permissions granted to the tasks assignees on the document following the worklflow are removed. Doesn't resume the workflow as the completeTask method.
        Throws:
        DocumentRouteException
        Since:
        5.7.3
      • grantPermissionToTaskDelegatedActors

        void grantPermissionToTaskDelegatedActors​(CoreSession session,
                                                  String permission,
                                                  List<DocumentModel> docs,
                                                  Task task)
        Grants on these documents the specified assignees permissions for this task to the tasks delegated actors.
        Parameters:
        session - the session
        permission - the permission
        docs - the documents
        task - the task
        Since:
        5.8
      • removePermissionsForTaskActors

        void removePermissionsForTaskActors​(CoreSession session,
                                            List<DocumentModel> docs,
                                            Task task)
        Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegated
        Parameters:
        session - the session
        docs - the documents
        task - the task
        Since:
        5.8
      • removePermissionsForTaskActors

        void removePermissionsForTaskActors​(CoreSession session,
                                            List<DocumentModel> docs,
                                            String taskId)
        Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegated
        Parameters:
        session - the session
        docs - the documents
        taskId - the taskId
        Since:
        7.4
      • cleanupDoneAndCanceledRouteInstances

        @Deprecated
        void cleanupDoneAndCanceledRouteInstances​(String repositoryName,
                                                  int limit)
        Deprecated.
        since 2023, use #cleanupRouteInstances(String) instead.
        Query for the routes 'done' or 'canceled' and delete them. The max no of the routes that will be deleted is specified by the 'limit' parameter. When the limit is '0' all the completed routes are deleted.
        Since:
        5.8
      • cleanupRouteInstances

        void cleanupRouteInstances​(String repositoryName)
        Remove the routes in state 'done' or 'canceled' of the given repository.

        If 'nuxeo.routing.cleanup.workflow.instances.orphan' framework property is set to true, orphan routes (for which all associated documents have been removed) will also be removed.

        Parameters:
        repositoryName - the repository name to clean up
        Since:
        2023
      • invalidateRouteModelsCache

        void invalidateRouteModelsCache()
        Since:
        5.9.3
      • doCleanupDoneAndCanceledRouteInstances

        @Deprecated
        int doCleanupDoneAndCanceledRouteInstances​(String reprositoryName,
                                                   int limit)
        Deprecated.
        since 2023, use GarbageCollectRoutesAction instead
        Query for the routes 'done' or 'canceled' and delete them. The max no of the routes that will be deleted is specified by the 'limit' parameter. When the limit is '0' all the completed routes are deleted. The routes to be deleted are ordered ascending by their creation date.
        Returns:
        always -1
        Since:
        7.1
      • getTasks

        @Deprecated
        List<Task> getTasks​(DocumentModel document,
                            String actorId,
                            String workflowInstanceId,
                            String workflowModelName,
                            CoreSession session)
        Deprecated.
        since 11.1 this method does not scale as it does not paginate results. Use org.nuxeo.ecm.platform.routing.core.provider.RoutingTaskPageProvider#getCurrentPage() instead.
        Since:
        7.2
      • getRunningWorkflowInstancesLaunchedByCurrentUser

        List<DocumentRoute> getRunningWorkflowInstancesLaunchedByCurrentUser​(CoreSession session)
        Since:
        7.2
      • getRunningWorkflowInstancesLaunchedByCurrentUser

        List<DocumentRoute> getRunningWorkflowInstancesLaunchedByCurrentUser​(CoreSession session,
                                                                             String worflowModelName)
        Since:
        7.2
      • isWorkflowModel

        boolean isWorkflowModel​(DocumentRoute documentRoute)
        Returns true if the document route is a model, false if it is just an instance i.e. a running workflow.
        Since:
        7.2
      • canCreateInstance

        boolean canCreateInstance​(CoreSession session,
                                  List<String> documentIds,
                                  String worflowModelName)
        Returns true if the workflow model can be started on the document list.
        Since:
        11.4
      • getRunnableWorkflows

        List<DocumentRoute> getRunnableWorkflows​(CoreSession session,
                                                 List<String> documentIds)
        Returns a list of runnable document routes for the input document IDs.
        Since:
        11.4
      • purgeDocumentRoute

        boolean purgeDocumentRoute​(CoreSession session,
                                   DocumentRoute route)
        Remove the workflow instance if it is canceled, done or orphan. An orphan instance has all its attached document already removed.
        Returns:
        true if the route has been deleted, false otherwise
        Since:
        2023