Package pro.taskana.task.api
Interface TaskService
-
- All Known Implementing Classes:
TaskServiceImpl
public interface TaskServiceThe Task Service manages all operations on tasks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TaskcancelClaim(String taskId)Cancel the claim of an existing task if it was claimed by the current user before.TaskcancelTask(String taskId)Cancels a task.Taskclaim(String taskId)Claim an existing task for the current user.TaskcompleteTask(String taskId)Complete a claimed Task as owner/admin and update State and Timestamps.BulkOperationResults<String,TaskanaException>completeTasks(List<String> taskIds)Completes a list of tasks.TaskcreateTask(Task taskToCreate)Persists a not persisted Task which does not exist already.TaskCommentcreateTaskComment(TaskComment taskComment)Create a task comment.TaskQuerycreateTaskQuery()This method provides a query builder for quering the database.voiddeleteTask(String taskId)Deletes the task with the given Id.voiddeleteTaskComment(String taskCommentId)Deletes the task comment with the given Id.BulkOperationResults<String,TaskanaException>deleteTasks(List<String> tasks)Deletes a list of tasks.TaskforceCancelClaim(String taskId)Cancel the claim of an existing task even if it was claimed by another user.TaskforceClaim(String taskId)Claim an existing task for the current user even if it is already claimed by someone else.TaskforceCompleteTask(String taskId)Complete a Task and update State and Timestamps in every case if the Task exists.BulkOperationResults<String,TaskanaException>forceCompleteTasks(List<String> taskIds)Completes a list of tasks.voidforceDeleteTask(String taskId)Deletes the task with the given Id even if it is not completed.TaskgetTask(String taskId)Get the details of a task by Id without checking permissions.TaskCommentgetTaskComment(String taskCommentId)Retrieves a task comment for a given taskCommentId.List<TaskComment>getTaskComments(String taskId)Retrieves a list of task comments for a given taskId.AttachmentnewAttachment()Returns a not persisted instance ofAttachment.TasknewTask()Returns a not persisted instance ofTask.TasknewTask(String workbasketId)Returns a not persisted instance ofTask.TasknewTask(String workbasketKey, String domain)Returns a not persisted instance ofTask.TaskCommentnewTaskComment(String taskId)Returns a not persisted instance ofTaskComment.TaskselectAndClaim(TaskQuery taskQuery)Selects and claims the first task which is returned by the task query.BulkOperationResults<String,TaskanaException>setCallbackStateForTasks(List<String> externalIds, CallbackState state)Sets the callback state on a list of tasks.BulkOperationResults<String,TaskanaException>setOwnerOfTasks(String owner, List<String> taskIds)Sets the owner on a list of tasks.BulkOperationResults<String,TaskanaException>setPlannedPropertyOfTasks(Instant planned, List<String> taskIds)Sets the planned property on a list of tasks.TasksetTaskRead(String taskId, boolean isRead)Marks a task as read.TaskterminateTask(String taskId)Terminates a task.Tasktransfer(String taskId, String destinationWorkbasketId)Transfer a task to another work basket.Tasktransfer(String taskId, String workbasketKey, String domain)Transfer a task to another work basket.BulkOperationResults<String,TaskanaException>transferTasks(String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds)Transfers a list of tasks to an other workbasket.BulkOperationResults<String,TaskanaException>transferTasks(String destinationWorkbasketId, List<String> taskIds)Transfers a list of tasks to an other workbasket.TaskupdateTask(Task task)Update a task.TaskCommentupdateTaskComment(TaskComment taskComment)Update a task comment.List<String>updateTasks(List<String> taskIds, Map<TaskCustomField,String> customFieldsToUpdate)Updates tasks with matching taskIds.List<String>updateTasks(ObjectReference selectionCriteria, Map<TaskCustomField,String> customFieldsToUpdate)Updates tasks with a matchingObjectReference.
-
-
-
Method Detail
-
claim
Task claim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException
Claim an existing task for the current user.- Parameters:
taskId- the id of the task to be claimed- Returns:
- claimed Task
- Throws:
TaskNotFoundException- if the task with taskId was not foundInvalidStateException- if the state of the task with taskId is not READYInvalidOwnerException- if the task with taskId is claimed by some elseNotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
forceClaim
Task forceClaim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException
Claim an existing task for the current user even if it is already claimed by someone else.- Parameters:
taskId- the id of the task to be claimed- Returns:
- claimed Task
- Throws:
TaskNotFoundException- if the task with taskId was not foundInvalidStateException- if the state of the task with taskId is not READYInvalidOwnerException- if the task with taskId is claimed by someone elseNotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
cancelClaim
Task cancelClaim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException
Cancel the claim of an existing task if it was claimed by the current user before.- Parameters:
taskId- id of the task which should be unclaimed.- Returns:
- updated unclaimed task
- Throws:
TaskNotFoundException- if the task can´t be found or does not existInvalidStateException- when the task is already completed.InvalidOwnerException- when the task is claimed by another user.NotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
forceCancelClaim
Task forceCancelClaim(String taskId) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException
Cancel the claim of an existing task even if it was claimed by another user.- Parameters:
taskId- id of the task which should be unclaimed.- Returns:
- updated unclaimed task
- Throws:
TaskNotFoundException- if the task can´t be found or does not existInvalidStateException- when the task is already completed.InvalidOwnerException- when forceCancel is false and the task is claimed by another user.NotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
completeTask
Task completeTask(String taskId) throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException
Complete a claimed Task as owner/admin and update State and Timestamps. If task is already completed, the task is returned as itself.- Parameters:
taskId- - Id of the Task which should be completed.- Returns:
- Task - updated task after completion.
- Throws:
InvalidStateException- when Task wasn´t claimed before.TaskNotFoundException- if the given Task can´t be found in DB.InvalidOwnerException- if current user is not the task-owner or administrator.NotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
forceCompleteTask
Task forceCompleteTask(String taskId) throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException
Complete a Task and update State and Timestamps in every case if the Task exists. If task is already completed, the task is returned as itself.- Parameters:
taskId- - Id of the Task which should be completed.- Returns:
- Task - updated task after completion.
- Throws:
InvalidStateException- when Task wasn´t claimed before.TaskNotFoundException- if the given Task can´t be found in DB.InvalidOwnerException- if current user is not the task-owner or administrator.NotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
createTask
Task createTask(Task taskToCreate) throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException
Persists a not persisted Task which does not exist already.- Parameters:
taskToCreate- the transient task object to be persisted- Returns:
- the created and persisted task
- Throws:
TaskAlreadyExistException- when the Task does already exist.NotAuthorizedException- thrown if the current user is not authorized to create that taskWorkbasketNotFoundException- thrown if the work basket referenced by the task is not foundClassificationNotFoundException- thrown if theClassificationreferenced by the task is not foundInvalidArgumentException- thrown if the primary ObjectReference is invalid
-
getTask
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException
Get the details of a task by Id without checking permissions.- Parameters:
taskId- the id of the task- Returns:
- the Task
- Throws:
TaskNotFoundException- thrown of theTaskwith taskId is not foundNotAuthorizedException- if the current user has no READ permission for the workbasket the task is in.
-
transfer
Task transfer(String taskId, String destinationWorkbasketId) throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException
Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.- Parameters:
taskId- The id of theTaskto be transferreddestinationWorkbasketId- The Id of the target work basket- Returns:
- the transferred task
- Throws:
TaskNotFoundException- Thrown if theTaskwith taskId was not found.WorkbasketNotFoundException- Thrown if the target work basket was not found.NotAuthorizedException- Thrown if the current user is not authorized to transfer thisTaskto the target work basketInvalidStateException- Thrown if the task is in a state which does not allow transferring
-
transfer
Task transfer(String taskId, String workbasketKey, String domain) throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException
Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.- Parameters:
taskId- The id of theTaskto be transferredworkbasketKey- The key of the target work basketdomain- The domain of the target work basket- Returns:
- the transferred task
- Throws:
TaskNotFoundException- Thrown if theTaskwith taskId was not found.WorkbasketNotFoundException- Thrown if the target work basket was not found.NotAuthorizedException- Thrown if the current user is not authorized to transfer thisTaskto the target work basketInvalidStateException- Thrown if the task is in a state which does not allow transferring
-
setTaskRead
Task setTaskRead(String taskId, boolean isRead) throws TaskNotFoundException, NotAuthorizedException
Marks a task as read.- Parameters:
taskId- the id of the task to be updatedisRead- the new status of the read flag.- Returns:
- the updated Task
- Throws:
TaskNotFoundException- Thrown if theTaskwith taskId was not foundNotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
createTaskQuery
TaskQuery createTaskQuery()
This method provides a query builder for quering the database.- Returns:
- a
TaskQuery
-
newTask
Task newTask()
Returns a not persisted instance ofTask. The returned task has no workbasket Id set. When createTask() is invoked for this task, TaskService will call the TaskRouting SPI to determine a workbasket for the task. If the TaskRouting API is not active, e.g. because no TaskRouter is registered, or the TaskRouter(s) don't find a workbasket, the task will not be persisted.- Returns:
- an empty new Task
-
newTask
Task newTask(String workbasketId)
Returns a not persisted instance ofTask.- Parameters:
workbasketId- the id of the workbasket to which the task belongs- Returns:
- an empty new Task
-
newTask
Task newTask(String workbasketKey, String domain)
Returns a not persisted instance ofTask.- Parameters:
workbasketKey- the key of the workbasket to which the task belongsdomain- the domain of the workbasket to which the task belongs- Returns:
- an empty new Task
-
newTaskComment
TaskComment newTaskComment(String taskId)
Returns a not persisted instance ofTaskComment.- Parameters:
taskId- The id of the task to which the task comment belongs- Returns:
- an empty new TaskComment
-
newAttachment
Attachment newAttachment()
Returns a not persisted instance ofAttachment.- Returns:
- an empty new Attachment
-
updateTask
Task updateTask(Task task) throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException, InvalidStateException
Update a task.- Parameters:
task- the task to be updated in the database- Returns:
- the updated task
- Throws:
InvalidArgumentException- if the task to be updated contains invalid properties like e.g. invalid object referencesTaskNotFoundException- if the id of the task is not found in the databaseConcurrencyException- if the task has already been updated by another userClassificationNotFoundException- if the updated task refers to a classification that cannot be foundNotAuthorizedException- if the current user is not authorized to update the taskAttachmentPersistenceException- if an Attachment with ID will be added multiple times without using the task-methodsInvalidStateException- if an attempt is made to change the owner of the task and the task is not in state READY .
-
transferTasks
BulkOperationResults<String,TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException
Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.- Parameters:
destinationWorkbasketId- target workbasket idtaskIds- source task which will be moved- Returns:
- Bulkresult with ID and Error in it for failed transactions.
- Throws:
NotAuthorizedException- if the caller hasn´t permissions on tarket WB.InvalidArgumentException- if the method paramesters are EMPTY or NULL.WorkbasketNotFoundException- if the target WB can´t be found.
-
transferTasks
BulkOperationResults<String,TaskanaException> transferTasks(String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException
Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.- Parameters:
destinationWorkbasketKey- target workbasket keydestinationWorkbasketDomain- target workbasket domaintaskIds- source task which will be moved- Returns:
- Bulkresult with ID and Error in it for failed transactions.
- Throws:
NotAuthorizedException- if the caller hasn´t permissions on tarket WB.InvalidArgumentException- if the method paramesters are EMPTY or NULL.WorkbasketNotFoundException- if the target WB can´t be found.
-
deleteTask
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException
Deletes the task with the given Id.- Parameters:
taskId- The Id of the task to delete.- Throws:
TaskNotFoundException- If the given Id does not refer to an existing task.InvalidStateException- If the state of the referenced task is not Completed.NotAuthorizedException- if the current user is not member of role ADMIN
-
forceDeleteTask
void forceDeleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException
Deletes the task with the given Id even if it is not completed.- Parameters:
taskId- The Id of the task to delete.- Throws:
TaskNotFoundException- If the given Id does not refer to an existing task.InvalidStateException- If the state of the referenced task is not Completed and forceDelet is false.NotAuthorizedException- if the current user is not member of role ADMIN
-
selectAndClaim
Task selectAndClaim(TaskQuery taskQuery) throws NotAuthorizedException, InvalidOwnerException
Selects and claims the first task which is returned by the task query.- Parameters:
taskQuery- the task query.- Returns:
- the task that got selected and claimed
- Throws:
InvalidOwnerException- if the task is claimed by someone elseNotAuthorizedException- if the current user has no read permission for the workbasket the task is in
-
deleteTasks
BulkOperationResults<String,TaskanaException> deleteTasks(List<String> tasks) throws InvalidArgumentException, NotAuthorizedException
Deletes a list of tasks.- Parameters:
tasks- the ids of the tasks to delete.- Returns:
- the result of the operations with Id and Exception for each failed task deletion.
- Throws:
InvalidArgumentException- if the TaskIds parameter is NULLNotAuthorizedException- if the current user is not member of role ADMIN
-
completeTasks
BulkOperationResults<String,TaskanaException> completeTasks(List<String> taskIds) throws InvalidArgumentException
Completes a list of tasks.- Parameters:
taskIds- of the tasks which should be completed.- Returns:
- the result of the operations with Id and Exception for each failed task completion.
- Throws:
InvalidArgumentException- If the taskId parameter is NULL.
-
forceCompleteTasks
BulkOperationResults<String,TaskanaException> forceCompleteTasks(List<String> taskIds) throws InvalidArgumentException
Completes a list of tasks.- Parameters:
taskIds- of the tasks which should be completed.- Returns:
- the result of the operations with Id and Exception for each failed task completion.
- Throws:
InvalidArgumentException- If the taskId parameter is NULL.- See Also:
forceCompleteTask(java.lang.String)
-
updateTasks
List<String> updateTasks(ObjectReference selectionCriteria, Map<TaskCustomField,String> customFieldsToUpdate) throws InvalidArgumentException
Updates tasks with a matchingObjectReference.- Parameters:
selectionCriteria- theObjectReferencethat is used to select the tasks.customFieldsToUpdate- aMapthat contains as key the identification of the custom field and as value the corresponding new value of that custom field.- Returns:
- a list of the Ids of all modified tasks
- Throws:
InvalidArgumentException- if the given selectionCriteria is invalid or the given customFieldsToUpdate are null or empty.
-
updateTasks
List<String> updateTasks(List<String> taskIds, Map<TaskCustomField,String> customFieldsToUpdate) throws InvalidArgumentException
Updates tasks with matching taskIds.- Parameters:
taskIds- the taskIds that are used to select the tasks.customFieldsToUpdate- aMapthat contains as key the identification of the custom field and as value the corresponding new value of that custom field.- Returns:
- a list of the Ids of all modified tasks
- Throws:
InvalidArgumentException- if the given customFieldsToUpdate are null or empty.
-
createTaskComment
TaskComment createTaskComment(TaskComment taskComment) throws NotAuthorizedException, TaskNotFoundException, InvalidArgumentException
Create a task comment.- Parameters:
taskComment- the task comment to be created.- Returns:
- the created task comment.
- Throws:
NotAuthorizedException- If the current user has no authorization to create a task comment for the given taskId in the TaskComment or is not authorized to access the task.TaskNotFoundException- If the given taskId in the TaskComment does not refer to an existing task.InvalidArgumentException- If the given taskCommentId from the provided task comment is not null or empty
-
updateTaskComment
TaskComment updateTaskComment(TaskComment taskComment) throws NotAuthorizedException, ConcurrencyException, TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException
Update a task comment.- Parameters:
taskComment- the task comment to be updated in the database.- Returns:
- the updated task comment.
- Throws:
NotAuthorizedException- If the current user has no authorization to update a task comment or is not authorized to access the task.ConcurrencyException- if an attempt is made to update the task comment and another user. updated it already.TaskCommentNotFoundException- If the given taskCommentId in the TaskComment does not refer to an existing taskComment.TaskNotFoundException- If the given taskId in the TaskComment does not refer to an existing task.InvalidArgumentException- If the given taskCommentId from the provided task comment is null or empty
-
deleteTaskComment
void deleteTaskComment(String taskCommentId) throws NotAuthorizedException, TaskCommentNotFoundException, TaskNotFoundException, InvalidArgumentException
Deletes the task comment with the given Id.- Parameters:
taskCommentId- The id of the task comment to delete.- Throws:
NotAuthorizedException- If the current user has no authorization to delete a task comment or is not authorized to access the task.InvalidArgumentException- If the taskCommentId is null/emptyTaskCommentNotFoundException- If the given taskCommentId in the TaskComment does not refer to an existing taskComment.TaskNotFoundException- If the given taskId in the TaskComment does not refer to an existing task.InvalidArgumentException- If the given taskCommentId is null or empty
-
getTaskComment
TaskComment getTaskComment(String taskCommentId) throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException, InvalidArgumentException
Retrieves a task comment for a given taskCommentId.- Parameters:
taskCommentId- The id of the task comment which should be retrieved- Returns:
- the task comment identified by taskCommentId
- Throws:
TaskCommentNotFoundException- If the given taskCommentId in the TaskComment does not refer to an existing taskComment.NotAuthorizedException- If the current user has no authorization to retrieve a taskComment from a certain task or is not authorized to access the task.TaskNotFoundException- If the given taskId in the TaskComment does not refer to an existing task.InvalidArgumentException- If the given taskCommentId is null or empty
-
getTaskComments
List<TaskComment> getTaskComments(String taskId) throws NotAuthorizedException, TaskNotFoundException
Retrieves a list of task comments for a given taskId.- Parameters:
taskId- The id of the task for which all task comments should be retrieved- Returns:
- the list of task comments attached to task with id taskId
- Throws:
NotAuthorizedException- If the current user has no authorization to retrieve a taskComment from a certain task or is not authorized to access the task.TaskNotFoundException- If the given taskId in the TaskComment does not refer to an existing task.
-
setCallbackStateForTasks
BulkOperationResults<String,TaskanaException> setCallbackStateForTasks(List<String> externalIds, CallbackState state)
Sets the callback state on a list of tasks. Note: this method is primarily intended to be used by the TaskanaAdapter- Parameters:
externalIds- the EXTERNAL_IDs of the tasks on which the callback state is set.state- the callback state that is to be set on the tasks- Returns:
- the result of the operations with Id and Exception for each failed task deletion.
-
setOwnerOfTasks
BulkOperationResults<String,TaskanaException> setOwnerOfTasks(String owner, List<String> taskIds)
Sets the owner on a list of tasks. The owner will only be set on tasks that are in state READY.- Parameters:
owner- the new owner of the taskstaskIds- the IDs of the tasks on which the owner is to be set.- Returns:
- the result of the operations with Id and Exception for each failed task update.
-
setPlannedPropertyOfTasks
BulkOperationResults<String,TaskanaException> setPlannedPropertyOfTasks(Instant planned, List<String> taskIds)
Sets the planned property on a list of tasks. Only tasks in state READY and CLAIMED will be affected by this method. On each task, the corresponding due date is set according to the shortest service level in the classifications of the task and the task's attachments.- Parameters:
planned- the new 'PLANNED" property of the taskstaskIds- the IDs of the tasks on which the new planned property is to be set.- Returns:
- the result of the operations with Id and Exception for each failed task update.
-
cancelTask
Task cancelTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException
Cancels a task. Cancellation means a task is obsolete from a business perspective an does not need to be completed anymore.- Parameters:
taskId- the id of the task to cancel.- Returns:
- the updated task.
- Throws:
TaskNotFoundException- if the Task with Id TaskId is not foundInvalidStateException- if the task is not in state READY or CLAIMEDNotAuthorizedException- if the current user is not authorized to see the task
-
terminateTask
Task terminateTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException
Terminates a task. Termination is a administrative action to complete a task. This is typically done by an administration to correct any technical issue.- Parameters:
taskId- the id of the task to cancel.- Returns:
- the updated task.
- Throws:
TaskNotFoundException- if the Task with Id TaskId is not foundInvalidStateException- if the task is not in state READY or CLAIMEDNotAuthorizedException- if the current user is not authorized to see the task
-
-