Class TaskServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.platform.task.core.service.TaskServiceImpl
-
- All Implemented Interfaces:
Serializable
,TaskProvider
,TaskService
,Adaptable
,Component
,Extensible
,TimestampedService
public class TaskServiceImpl extends DefaultComponent implements TaskService
- Since:
- 5.5
- Author:
- Laurent Doguin
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TaskServiceImpl.GetTaskRootParentPathUnrestricted
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.platform.task.TaskService
TaskService.VariableName
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_TASK_PROVIDER
static ComponentName
NAME
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Fields inherited from interface org.nuxeo.ecm.platform.task.TaskService
TASK_INSTANCE_EVENT_PROPERTIES_KEY
-
-
Constructor Summary
Constructors Constructor Description TaskServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
acceptTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment)
Ends the task using event nameTaskEventNames.WORKFLOW_TASK_COMPLETED
and marking the task as validated.void
activate(ComponentContext context)
Activates the component.boolean
canEndTask(NuxeoPrincipal principal, Task task)
Returns true if user is an administrator, the initiator of the task, or an actor of the task.protected boolean
checkPermissions(NuxeoPrincipal principal, Task task)
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)
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)
Creates a task of the given document type and starts it.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.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)
Creates a task and starts it.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.void
deactivate(ComponentContext context)
Deactivates the component.void
delegateTask(CoreSession session, String taskId, List<String> delegatedActors, String comment, Map<String,Serializable> eventInfo)
void
deleteTask(CoreSession coreSession, String taskId)
Remove the documentTask identified by the given taskId if coreSession's principal has the Remove permission.String
endTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment, String eventName, boolean isValidated)
Use the task provider held by theTask.TASK_PROVIDER_KEY
task variable to end thetask
.List<Task>
getAllCurrentTaskInstances(CoreSession coreSession, List<SortInfo> sortInfos)
Returns the list of task instances associated assigned to the current user.List<Task>
getAllTaskInstances(String processId, String nodeId, CoreSession session)
Returns all the tasks instances for the givenprocessId
originating from the givennodeId
.List<Task>
getAllTaskInstances(String processId, List<String> actors, CoreSession session)
Returns all the tasks instances for the givenprocessId
which assigned to one of the actor in the list or its pool.List<Task>
getAllTaskInstances(String processId, CoreSession session)
Returns all the tasks instances for the givenprocessId
.List<Task>
getAllTaskInstances(String processId, NuxeoPrincipal user, CoreSession session)
Returns all the tasks instances for the givenprocessId
and where the user is the actor or belongs to the pooled actor list.List<Task>
getCurrentTaskInstances(List<String> actors, CoreSession coreSession)
Returns a list of task instances assigned to one of the actors in the list or to its pool.List<Task>
getCurrentTaskInstances(List<String> actors, CoreSession coreSession, List<SortInfo> sortInfos)
Provide @param sortInfo to handle sort page-provider contributions (seegetCurrentTaskInstances(org.nuxeo.ecm.core.api.CoreSession)
)List<Task>
getCurrentTaskInstances(CoreSession coreSession)
List<Task>
getCurrentTaskInstances(CoreSession coreSession, List<SortInfo> sortInfos)
Provide @param sortInfo to handle sort page-provider contributions (seegetCurrentTaskInstances(org.nuxeo.ecm.core.api.CoreSession)
)DocumentModel
getTargetDocumentModel(Task task, CoreSession coreSession)
Task
getTask(CoreSession coreSession, String taskId)
List<Task>
getTaskInstances(DocumentModel dm, List<String> actors, boolean includeDelegatedTasks, CoreSession session)
Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool.List<Task>
getTaskInstances(DocumentModel dm, List<String> actors, CoreSession coreSession)
Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool.List<Task>
getTaskInstances(DocumentModel dm, NuxeoPrincipal user, CoreSession coreSession)
Returns the list of task instances associated with this document for which the user is the actor or belongs to the pooled actor list.String
getTaskRootParentPath(CoreSession coreSession)
Default value is /task-rootprotected boolean
isTaskActive(Task task)
protected boolean
isTaskAssignedToUser(Task task, NuxeoPrincipal user, boolean checkDelegatedActors)
protected void
notifyEvent(CoreSession session, Task task, List<DocumentModel> docs, String event, Map<String,Serializable> eventInfo, String comment, NuxeoPrincipal principal, List<String> actorIds)
void
reassignTask(CoreSession session, String taskId, List<String> newActors, String comment, Map<String,Serializable> eventInfo)
void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
String
rejectTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment)
Ends the task using event nameTaskEventNames.WORKFLOW_TASK_REJECTED
and marking the task as not validated.void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
Methods inherited from interface org.nuxeo.ecm.platform.task.TaskService
delegateTask, reassignTask
-
-
-
-
Field Detail
-
NAME
public static final ComponentName NAME
-
DEFAULT_TASK_PROVIDER
public static final String DEFAULT_TASK_PROVIDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
activate
public void activate(ComponentContext context)
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
createTask
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)
Description copied from interface:TaskService
Creates a task and starts it. Notifies events with namesTaskEventNames.WORKFLOW_TASK_ASSIGNED
andTaskEventNames.WORKFLOW_TASK_ASSIGNED
, passing the task in the event properties using keyTaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY
- Specified by:
createTask
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifyingprincipal
- the principal marked as initiator of the task and used when notifying.document
- the document to attach to the task.taskName
- the task name.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 commentdueDate
- the due date, set on the task instancetaskVariables
- additional task variablesparentPath
- /task-root if null
-
createTask
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)
Description copied from interface:TaskService
Creates a task of the given document type and starts it. Notifies events with namesTaskEventNames.WORKFLOW_TASK_ASSIGNED
andTaskEventNames.WORKFLOW_TASK_ASSIGNED
, passing the task in the event properties using keyTaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY
Also the map eventInfo is passed in the event properties- Specified by:
createTask
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifyingprincipal
- the principal marked as initiator of the task and used when notifying.document
- the document to attach to the task.taskDocumentType
- the task document typetaskName
- the task name.taskType
- the task type.processId
- the process ID 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 commentdueDate
- the due date, set on the task instancetaskVariables
- additional task variablesparentPath
- /task-root if null- Since:
- 5.6
-
createTask
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)
Description copied from interface:TaskService
Creates a task and starts it. Notifies events with namesTaskEventNames.WORKFLOW_TASK_ASSIGNED
andTaskEventNames.WORKFLOW_TASK_ASSIGNED
, passing the task in the event properties using keyTaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY
- Specified by:
createTask
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifyingprincipal
- 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 commentdueDate
- the due date, set on the task instancetaskVariables
- additional task variablesparentPath
- /task-root if null- Since:
- 5.6
-
acceptTask
public String acceptTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment)
Description copied from interface:TaskService
Ends the task using event nameTaskEventNames.WORKFLOW_TASK_COMPLETED
and marking the task as validated.- Specified by:
acceptTask
in interfaceTaskService
- Returns:
- the name of the Seam event to raise
- See Also:
TaskService.endTask(CoreSession, NuxeoPrincipal, Task, String, String, boolean)
-
rejectTask
public String rejectTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment)
Description copied from interface:TaskService
Ends the task using event nameTaskEventNames.WORKFLOW_TASK_REJECTED
and marking the task as not validated.- Specified by:
rejectTask
in interfaceTaskService
- Returns:
- the name of the Seam event to raise
- See Also:
TaskService.endTask(CoreSession, NuxeoPrincipal, Task, String, String, boolean)
-
endTask
public String endTask(CoreSession coreSession, NuxeoPrincipal principal, Task task, String comment, String eventName, boolean isValidated)
Use the task provider held by theTask.TASK_PROVIDER_KEY
task variable to end thetask
. If null use theDEFAULT_TASK_PROVIDER
.- Specified by:
endTask
in interfaceTaskProvider
- Specified by:
endTask
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifying and resolving of referenced document for notification.principal
- principal used when notifyingtask
- the instance to endcomment
- string added to the task comments and used as a notification commenteventName
- the core event name to use when notifyingisValidated
- boolean marker to state if the task was validated or rejected- Returns:
- the name of the Seam event to raise
-
canEndTask
public boolean canEndTask(NuxeoPrincipal principal, Task task)
Description copied from interface:TaskService
Returns true if user is an administrator, the initiator of the task, or an actor of the task.- Specified by:
canEndTask
in interfaceTaskService
-
checkPermissions
protected boolean checkPermissions(NuxeoPrincipal principal, Task task)
-
isTaskActive
protected boolean isTaskActive(Task task)
-
isTaskAssignedToUser
protected boolean isTaskAssignedToUser(Task task, NuxeoPrincipal user, boolean checkDelegatedActors)
-
getTask
public Task getTask(CoreSession coreSession, String taskId)
- Specified by:
getTask
in interfaceTaskService
- Returns:
- the taskDocument with the given taskId
-
deleteTask
public void deleteTask(CoreSession coreSession, String taskId)
Description copied from interface:TaskService
Remove the documentTask identified by the given taskId if coreSession's principal has the Remove permission.- Specified by:
deleteTask
in interfaceTaskService
-
getTargetDocumentModel
public DocumentModel getTargetDocumentModel(Task task, CoreSession coreSession)
- Specified by:
getTargetDocumentModel
in interfaceTaskService
- Parameters:
task
- the task- Returns:
- the task's target document
-
getCurrentTaskInstances
public List<Task> getCurrentTaskInstances(CoreSession coreSession)
- Specified by:
getCurrentTaskInstances
in interfaceTaskProvider
- Returns:
- A list of task instances where the current user is an actor. Doesn't take into account tasks that were delegated to this user.
-
getCurrentTaskInstances
public List<Task> getCurrentTaskInstances(CoreSession coreSession, List<SortInfo> sortInfos)
Provide @param sortInfo to handle sort page-provider contributions (seegetCurrentTaskInstances(org.nuxeo.ecm.core.api.CoreSession)
)- Specified by:
getCurrentTaskInstances
in interfaceTaskProvider
- Since:
- 5.9.3
-
getAllCurrentTaskInstances
public List<Task> getAllCurrentTaskInstances(CoreSession coreSession, List<SortInfo> sortInfos)
Description copied from interface:TaskProvider
Returns the list of task instances associated assigned to the current user. Takes into account tasks that were delegated to this user. The query is done in unrestricted mode and so the documents linked to the tasks are detached.- Specified by:
getAllCurrentTaskInstances
in interfaceTaskProvider
-
getCurrentTaskInstances
public List<Task> getCurrentTaskInstances(List<String> actors, CoreSession coreSession)
Returns a list of task instances assigned to one of the actors in the list or to its pool.- Specified by:
getCurrentTaskInstances
in interfaceTaskProvider
- Parameters:
actors
- a list used as actorId to retrieve the tasks.
-
getCurrentTaskInstances
public List<Task> getCurrentTaskInstances(List<String> actors, CoreSession coreSession, List<SortInfo> sortInfos)
Provide @param sortInfo to handle sort page-provider contributions (seegetCurrentTaskInstances(org.nuxeo.ecm.core.api.CoreSession)
)- Specified by:
getCurrentTaskInstances
in interfaceTaskProvider
- Since:
- 5.9.3
-
getTaskInstances
public List<Task> getTaskInstances(DocumentModel dm, NuxeoPrincipal user, CoreSession coreSession)
Description copied from interface:TaskProvider
Returns the list of task instances associated with this document for which the user is the actor or belongs to the pooled actor list. Doesn't take into account tasks that were delegated to this user.If the user is null, then it returns all task instances for the document. The query is done in unrestricted mode and so the documents linked to the tasks are detached.
- Specified by:
getTaskInstances
in interfaceTaskProvider
- Parameters:
dm
- the document.
-
getTaskInstances
public List<Task> getTaskInstances(DocumentModel dm, List<String> actors, CoreSession coreSession)
Description copied from interface:TaskProvider
Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool. Doesn't take into account tasks that were delegated to these users. The query is done in unrestricted mode and so the documents linked to the tasks are detached.- Specified by:
getTaskInstances
in interfaceTaskProvider
-
getAllTaskInstances
public List<Task> getAllTaskInstances(String processId, CoreSession session)
Description copied from interface:TaskProvider
Returns all the tasks instances for the givenprocessId
.The query is done in unrestricted mode and so the documents linked to the tasks are detached.
- Specified by:
getAllTaskInstances
in interfaceTaskProvider
-
getAllTaskInstances
public List<Task> getAllTaskInstances(String processId, NuxeoPrincipal user, CoreSession session)
Description copied from interface:TaskProvider
Returns all the tasks instances for the givenprocessId
and where the user is the actor or belongs to the pooled actor list. Doesn't take into account tasks that were delegated to this user.The query is done in unrestricted mode and so the documents linked to the tasks are detached.
- Specified by:
getAllTaskInstances
in interfaceTaskProvider
-
getAllTaskInstances
public List<Task> getAllTaskInstances(String processId, List<String> actors, CoreSession session)
Description copied from interface:TaskProvider
Returns all the tasks instances for the givenprocessId
which assigned to one of the actor in the list or its pool. Doesn't take into account tasks that were delegated to these users.The query is done in unrestricted mode and so the documents linked to the tasks are detached.
- Specified by:
getAllTaskInstances
in interfaceTaskProvider
-
getTaskRootParentPath
public String getTaskRootParentPath(CoreSession coreSession)
Description copied from interface:TaskService
Default value is /task-root- Specified by:
getTaskRootParentPath
in interfaceTaskService
- Returns:
- the path registered in the taskPersister extension point.
-
getAllTaskInstances
public List<Task> getAllTaskInstances(String processId, String nodeId, CoreSession session)
Description copied from interface:TaskProvider
Returns all the tasks instances for the givenprocessId
originating from the givennodeId
.The query is done in unrestricted mode and so the documents linked to the tasks are detached.
- Specified by:
getAllTaskInstances
in interfaceTaskProvider
-
reassignTask
public void reassignTask(CoreSession session, String taskId, List<String> newActors, String comment, Map<String,Serializable> eventInfo)
- Specified by:
reassignTask
in interfaceTaskService
- See Also:
TaskService.reassignTask(CoreSession, String, List, String)
-
delegateTask
public void delegateTask(CoreSession session, String taskId, List<String> delegatedActors, String comment, Map<String,Serializable> eventInfo)
- Specified by:
delegateTask
in interfaceTaskService
- See Also:
TaskService.delegateTask(CoreSession, String, List, String)
-
notifyEvent
protected void notifyEvent(CoreSession session, Task task, List<DocumentModel> docs, String event, Map<String,Serializable> eventInfo, String comment, NuxeoPrincipal principal, List<String> actorIds)
-
getTaskInstances
public List<Task> getTaskInstances(DocumentModel dm, List<String> actors, boolean includeDelegatedTasks, CoreSession session)
Description copied from interface:TaskProvider
Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool. If the parameterincludeDelegatedTasks
is true, takes into account tasks that were delegated to these users. The query is done in unrestricted mode and so the documents linked to the tasks are detached.- Specified by:
getTaskInstances
in interfaceTaskProvider
-
createTask
@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)
Deprecated.Description copied from interface:TaskService
Creates a task of the given documents type and starts it. Notifies events with namesTaskEventNames.WORKFLOW_TASK_ASSIGNED
andTaskEventNames.WORKFLOW_TASK_ASSIGNED
, passing the task in the event properties using keyTaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY
Also the map eventInfo is passed in the event properties- Specified by:
createTask
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifyingprincipal
- the principal marked as initiator of the task and used when notifying.documents
- the documents to attach to the task.taskDocumentType
- the task document typetaskName
- the task name.taskType
- the task type.processId
- the process ID 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 commentdueDate
- the due date, set on the task instancetaskVariables
- additional task variablesparentPath
- /task-root if null- Since:
- 5.8
-
createTaskForProcess
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)
Description copied from interface:TaskService
Creates a task of the given documents type and starts it. Notifies events with namesTaskEventNames.WORKFLOW_TASK_ASSIGNED
andTaskEventNames.WORKFLOW_TASK_ASSIGNED
, passing the task in the event properties using keyTaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY
Also the map eventInfo is passed in the event properties. The process name can also be specified if any.- Specified by:
createTaskForProcess
in interfaceTaskService
- Parameters:
coreSession
- the session to use when notifyingprincipal
- the principal marked as initiator of the task and used when notifying.documents
- the documents to attach to the task.taskDocumentType
- the task document typetaskName
- 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 commentdueDate
- the due date, set on the task instancetaskVariables
- additional task variablesparentPath
- /task-root if null- Since:
- 7.4
-
-