Class TaskServiceImpl
java.lang.Object
org.exoplatform.task.service.impl.TaskServiceImpl
- All Implemented Interfaces:
TaskService
-
Field Summary
Fields inherited from interface TaskService
TEXT_SEARCH_NO_WORD, TEXT_SEARCH_WINDOW, USER_TARGET_ACTIONS -
Constructor Summary
ConstructorsConstructorDescriptionTaskServiceImpl(TaskStorage taskStorage, DAOHandler daoHandler, org.exoplatform.services.listener.ListenerService listenerService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeFilter(TaskQuery query, TaskChangeFilter filter) Narrows a task query with the conditions of a change filter (EXO-91902): the tasks whose status, project, due date, assignee or completion changed since a date, an assignee change counting only on a task created before it; the tasks completed since a date; those assigned to one user; those in one status; the completed tasks left out on demand, unless the completed ones are asked for.addTaskLog(long id, String username, String actionName, String target) Create a log associated with a task with giventaskId.voidaddWatcherToTask(String user, TaskDto task) cloneTask(long id) Clone the task from a task with giventaskId.countAssignedTasks(String user) countCollaboratedTasks(String user) intcountIncomingTasks(String user) countOverdueTasks(String user) longcountTasks(String user, String query, List<String> memberships) Count tasks assigned to a user using a search term to find in title or description of the taskintcountTasks(TaskQuery query) intcountTaskStatusByProject(long projectId) countUncompletedTasks(String user) countWatchedTasks(String user) createTask(TaskDto task) Create a new task.voiddeleteWatcherOfTask(String user, TaskDto task) filterTasks(String query, long projectId, String keyword, List<Long> labels, TaskUtil.DUE dueDate, Priority priority, List<String> assignees, List<String> coworker, List<String> watchers, Long labelId, Long statusId, org.exoplatform.services.security.Identity currIdentity, String dueCategory, String space_group_id, TimeZone userTimezone, boolean isShowCompleted, boolean advanceSearch, boolean noProjPermission, boolean noLblPermission, String orderBy, String groupBy, int offset, int limit) findLastUpdatedTasks(TaskQuery query, int offset, int limit) Find tasks switch last update date computed from Task Logs and Task Comments after applying theTaskQueryfilteringFind tasks assigned to a user using a term to find in title or description of the taskfindTasks(TaskSearchFilter filter) Find tasks assigned to a user using a term to find in title or description of the taskfindTasksByLabel(LabelDto label, List<Long> projectIds, String username, OrderBy orderBy, int offset, int limit) findTasksByMemberShips(String user, List<String> memberships, String query, int limit) getAllIds(int offset, int limit) Retrieves a paginated list of all task IDs.getAssignedTasks(String user, int limit) getAssignedTasksQuery(String username, TaskChangeFilter filter) Builds the query of the tasks a user is assigned to or a coworker of, narrowed by a change filter (EXO-91902).getCollaboratedTasks(String user, int limit) getCoworker(long taskId) getIncomingTasks(String user, int offset, int limit) getMentionedUsers(long taskId) getOverdueTasks(String user, int limit) getTask(long id) Return the task with giventaskId.getTaskChanges(TaskDto task, Date since, boolean includeChangeLog) Rebuilds the changes of a task since a date from its whole change log (EXO-91902), oldest first: its status, project, due date, assignee and completion changes, each with its old and new value when the log tells it.getTaskLogs(long taskId, int offset, int limit) getTasksChanges(List<TaskDto> tasks, Date since) Rebuilds the changes since a date of several tasks, asTaskService.getTaskChanges(TaskDto, Date, boolean)does for one, from a fixed number of queries whatever the number of tasks: their change log entries logged at or after the date, and, for each task, the latest entry before it that tells the status, the project or the assignee the first change since then left.getUncompletedTasks(String user, int limit) getWatchedTasks(String user, int limit) getWatchersOfTask(TaskDto task) booleanisExternal(String userId) Moves tasks to the given status, all or none: each task is authorized asTaskService.updateTask(long, TaskDto, Identity)does, in one transaction, so a task refused after others were written rolls those writes back.protected List<TaskPayload> moveTasksAtomically(List<Long> taskIds, long statusId, org.exoplatform.services.security.Identity identity) One transaction for the whole move: a task refused after others were written rolls those writes back.voidremoveTask(long id) Remove the task with giventaskIdsearchTasks(String text, Long projectId, boolean includeCompleted, int limit, org.exoplatform.services.security.Identity identity) Searches the tasks a user can view by a text in their title or description, ignoring case and accents, through the same index and the same permissions asTaskService.findTasks(TaskSearchFilter): the user and their memberships.<T> List<T> selectTaskField(TaskQuery query, String fieldName) unassignTasks(List<Long> taskIds, org.exoplatform.services.security.Identity identity) Removes a user from tasks, all or none: on each task the user is no longer its assignee nor one of its coworkers, the other coworkers stay.protected List<TaskPayload> unassignTasksAtomically(List<Long> taskIds, org.exoplatform.services.security.Identity identity) One transaction for the whole change, asmoveTasksAtomically(List, long, Identity): the events are left to the caller.updateTask(long taskId, TaskDto task, org.exoplatform.services.security.Identity identity) Update a task on behalf of a user.updateTask(TaskDto task) Update the task.voidupdateTaskOrder(long currentTaskId, Status newStatus, long[] orders)
-
Constructor Details
-
TaskServiceImpl
public TaskServiceImpl(TaskStorage taskStorage, DAOHandler daoHandler, org.exoplatform.services.listener.ListenerService listenerService)
-
-
Method Details
-
createTask
Description copied from interface:TaskServiceCreate a new task.- Specified by:
createTaskin interfaceTaskService- Parameters:
task- the given task.- Returns:
- the created task.
-
updateTask
Description copied from interface:TaskServiceUpdate the task.- Specified by:
updateTaskin interfaceTaskService- Parameters:
task- the given task.- Returns:
- TaskDto the updated task.
-
updateTask
public TaskDto updateTask(long taskId, TaskDto task, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Description copied from interface:TaskServiceUpdate a task on behalf of a user. The permission is checked on the stored task, and the update applies to that task whatever id the given task carries. A given status is loaded by its id, and moving the task to a status of another project requires the user to view that project.- Specified by:
updateTaskin interfaceTaskService- Parameters:
taskId- the id of the task to update.task- the updated task.identity- the user updating the task.- Returns:
- TaskDto the updated task.
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the task is not found.IllegalAccessException- when the user cannot edit the task, or cannot view the project of the given status.
-
moveTasks
public List<TaskDto> moveTasks(List<Long> taskIds, long statusId, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Description copied from interface:TaskServiceMoves tasks to the given status, all or none: each task is authorized asTaskService.updateTask(long, TaskDto, Identity)does, in one transaction, so a task refused after others were written rolls those writes back. The update events are broadcast once the move is committed, when no transaction is active on the caller's thread; called inside one, the move joins it and the events are broadcast before its commit. Each task sends its destination board's modification event with the board as read during the move, so an edit of the board's name, description, colour, due date, managers or participants committed in the meantime can be undone by the event's listener, as forTaskService.updateTask(TaskDto).- Specified by:
moveTasksin interfaceTaskService- Parameters:
taskIds- ids of the tasks to movestatusId- id of the status the tasks takeidentity- the user moving the tasks- Returns:
- the moved tasks
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when a task is not found.IllegalAccessException- when the user cannot edit a task, or cannot view the project of the given status.
-
unassignTasks
public List<TaskDto> unassignTasks(List<Long> taskIds, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:TaskServiceRemoves a user from tasks, all or none: on each task the user is no longer its assignee nor one of its coworkers, the other coworkers stay. A task the user is neither the assignee nor a coworker of is refused, and the change is one transaction, so a task refused after others were written rolls those writes back. The update events are broadcast once the change is committed, when no transaction is active on the caller's thread; called inside one, the change joins it and the events are broadcast before its commit. Each task of a board sends that board's modification event with the board as read during the change, so an edit of the board's name, description, colour, due date, managers or participants committed in the meantime can be undone by the event's listener, as forTaskService.updateTask(TaskDto).- Specified by:
unassignTasksin interfaceTaskService- Parameters:
taskIds- ids of the tasks to remove the user fromidentity- the user to remove- Returns:
- the updated tasks
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when a task is not found.
-
updateTaskOrder
- Specified by:
updateTaskOrderin interfaceTaskService
-
removeTask
Description copied from interface:TaskServiceRemove the task with giventaskId- Specified by:
removeTaskin interfaceTaskService- Parameters:
id- the given task id.- Throws:
EntityNotFoundException- when task is not found.
-
cloneTask
Description copied from interface:TaskServiceClone the task from a task with giventaskId.- Specified by:
cloneTaskin interfaceTaskService- Parameters:
id- the task Id- Returns:
- the cloned task.
- Throws:
EntityNotFoundException- when task is not found.
-
getTask
Description copied from interface:TaskServiceReturn the task with giventaskId.- Specified by:
getTaskin interfaceTaskService- Parameters:
id- the task Id- Returns:
- the given task.
- Throws:
EntityNotFoundException- when task is not found.
-
getMentionedUsers
- Specified by:
getMentionedUsersin interfaceTaskService
-
addTaskLog
public ChangeLogEntry addTaskLog(long id, String username, String actionName, String target) throws EntityNotFoundException Description copied from interface:TaskServiceCreate a log associated with a task with giventaskId.- Specified by:
addTaskLogin interfaceTaskService- Parameters:
id- the given task id.username- the given username.actionName- the given action name.target- the given target.- Returns:
- add task log.
- Throws:
EntityNotFoundException- when task is not found.
-
getTaskLogs
- Specified by:
getTaskLogsin interfaceTaskService- Throws:
Exception
-
addChangeFilter
Narrows a task query with the conditions of a change filter (EXO-91902): the tasks whose status, project, due date, assignee or completion changed since a date, an assignee change counting only on a task created before it; the tasks completed since a date; those assigned to one user; those in one status; the completed tasks left out on demand, unless the completed ones are asked for.- Specified by:
addChangeFilterin interfaceTaskService- Parameters:
query- the query to narrow, already scoped to what the user can seefilter- the change filter, possibly null
-
getAssignedTasksQuery
Builds the query of the tasks a user is assigned to or a coworker of, narrowed by a change filter (EXO-91902).- Specified by:
getAssignedTasksQueryin interfaceTaskService- Parameters:
username- the userfilter- the change filter, possibly null- Returns:
- the query
-
getTaskChanges
public TaskChanges getTaskChanges(TaskDto task, Date since, boolean includeChangeLog) throws Exception Rebuilds the changes of a task since a date from its whole change log (EXO-91902), oldest first: its status, project, due date, assignee and completion changes, each with its old and new value when the log tells it. On demand, also its newest change log entries, at most a hundred. The whole change log is read: the task may have been selected on an entry the newest ones do not hold, and an old value is the new value of an earlier entry.- Specified by:
getTaskChangesin interfaceTaskService- Parameters:
task- the tasksince- the earliest date of the changes, included; requiredincludeChangeLog- whether its newest change log entries come too- Returns:
- its changes
- Throws:
Exception- when its change log can't be read
-
getTasksChanges
Rebuilds the changes since a date of several tasks, asTaskService.getTaskChanges(TaskDto, Date, boolean)does for one, from a fixed number of queries whatever the number of tasks: their change log entries logged at or after the date, and, for each task, the latest entry before it that tells the status, the project or the assignee the first change since then left. The entries before the date that the changes since then read are the latest status, project and assignee entries: the status a task left is that of its latest creation, move or project change, its project that of its latest project change, its assignee that of its latest assignment. A completion or due date change since the date reads only the entries after it.- Specified by:
getTasksChangesin interfaceTaskService- Parameters:
tasks- the taskssince- the earliest date of the changes, included; required- Returns:
- the changes of each task, oldest first, by task id; a task with none maps to an empty list
-
findTasks
Description copied from interface:TaskServiceFind tasks assigned to a user using a term to find in title or description of the task- Specified by:
findTasksin interfaceTaskService- Parameters:
query- term to search in title or descriptionoffset- term to offset results.limit- term to limit results.- Returns:
ListofTaskDto- Throws:
Exception- when therer is an exception on get tasks.
-
findLastUpdatedTasks
Description copied from interface:TaskServiceFind tasks switch last update date computed from Task Logs and Task Comments after applying theTaskQueryfiltering- Specified by:
findLastUpdatedTasksin interfaceTaskService- Parameters:
query-TaskQueryoffset- result offsetlimit- result limit- Returns:
Listof corresponding Tasks
-
countTasks
- Specified by:
countTasksin interfaceTaskService- Throws:
Exception
-
selectTaskField
- Specified by:
selectTaskFieldin interfaceTaskService
-
findTasksByLabel
-
countTasksByLabel
public int countTasksByLabel(LabelDto label, List<Long> projectIds, String username, OrderBy orderBy) throws Exception - Specified by:
countTasksByLabelin interfaceTaskService- Throws:
Exception
-
findTaskByActivityId
- Specified by:
findTaskByActivityIdin interfaceTaskService
-
getCoworker
- Specified by:
getCoworkerin interfaceTaskService
-
getUncompletedTasks
- Specified by:
getUncompletedTasksin interfaceTaskService
-
countUncompletedTasks
- Specified by:
countUncompletedTasksin interfaceTaskService
-
getWatchedTasks
- Specified by:
getWatchedTasksin interfaceTaskService
-
countWatchedTasks
- Specified by:
countWatchedTasksin interfaceTaskService
-
getAssignedTasks
- Specified by:
getAssignedTasksin interfaceTaskService
-
countAssignedTasks
- Specified by:
countAssignedTasksin interfaceTaskService
-
getCollaboratedTasks
- Specified by:
getCollaboratedTasksin interfaceTaskService
-
countCollaboratedTasks
- Specified by:
countCollaboratedTasksin interfaceTaskService
-
findTasksByMemberShips
public List<TaskDto> findTasksByMemberShips(String user, List<String> memberships, String query, int limit) - Specified by:
findTasksByMemberShipsin interfaceTaskService
-
searchTasks
public TaskTextSearchResult searchTasks(String text, Long projectId, boolean includeCompleted, int limit, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Searches the tasks a user can view by a text in their title or description, ignoring case and accents, through the same index and the same permissions asTaskService.findTasks(TaskSearchFilter): the user and their memberships. The text is reduced to its words, lower-cased letters and digits without accents, and must hold a word with letters, since the index does not search numbers. With a project, only the tasks of that project, which the user must be able to view. The open tasks come first, in the order of relevance; the completed ones are left out unless asked for, and then come after every open one. Each hit is checked again against the task's own view permission and, with a project, against the task's project, so a task the index still lists for a user who lost access to it is never returned. The search reads the 100 most relevant hits at most.- Specified by:
searchTasksin interfaceTaskService- Parameters:
text- the text searched: every word in the title, or every word in the descriptionprojectId- the project, null for every task the user can viewincludeCompleted- whether the completed tasks are returned, after the open oneslimit- the most tasks returned, bounded between 1 and 100identity- the user who searches- Returns:
- the tasks found, the limit used, and whether more may match
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the project doesn't existIllegalAccessException- when the user can't view the project
-
findTasks
Description copied from interface:TaskServiceFind tasks assigned to a user using a term to find in title or description of the task- Specified by:
findTasksin interfaceTaskService- Parameters:
filter- the task search filter- Returns:
- a list of task IDs
-
findTasks
-
countTasks
Description copied from interface:TaskServiceCount tasks assigned to a user using a search term to find in title or description of the task- Specified by:
countTasksin interfaceTaskService- Parameters:
user- usernamequery- term to search in title or description- Returns:
- tasks count
-
getIncomingTasks
- Specified by:
getIncomingTasksin interfaceTaskService- Throws:
Exception
-
countIncomingTasks
- Specified by:
countIncomingTasksin interfaceTaskService- Throws:
Exception
-
getOverdueTasks
- Specified by:
getOverdueTasksin interfaceTaskService
-
countOverdueTasks
- Specified by:
countOverdueTasksin interfaceTaskService
-
addWatcherToTask
- Specified by:
addWatcherToTaskin interfaceTaskService- Throws:
Exception
-
deleteWatcherOfTask
- Specified by:
deleteWatcherOfTaskin interfaceTaskService- Throws:
Exception
-
getWatchersOfTask
- Specified by:
getWatchersOfTaskin interfaceTaskService
-
countTaskStatusByProject
- Specified by:
countTaskStatusByProjectin interfaceTaskService
-
filterTasks
public TasksList filterTasks(String query, long projectId, String keyword, List<Long> labels, TaskUtil.DUE dueDate, Priority priority, List<String> assignees, List<String> coworker, List<String> watchers, Long labelId, Long statusId, org.exoplatform.services.security.Identity currIdentity, String dueCategory, String space_group_id, TimeZone userTimezone, boolean isShowCompleted, boolean advanceSearch, boolean noProjPermission, boolean noLblPermission, String orderBy, String groupBy, int offset, int limit) throws Exception - Specified by:
filterTasksin interfaceTaskService- Throws:
Exception
-
isExternal
- Specified by:
isExternalin interfaceTaskService
-
getAllIds
Description copied from interface:TaskServiceRetrieves a paginated list of all task IDs.- Specified by:
getAllIdsin interfaceTaskService- Parameters:
offset- the starting position of the first resultlimit- the maximum number of results to retrieve- Returns:
- a list of task IDs
-
moveTasksAtomically
protected List<TaskPayload> moveTasksAtomically(List<Long> taskIds, long statusId, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException One transaction for the whole move: a task refused after others were written rolls those writes back. The events are left to the caller, which broadcasts them once this method returns: after the commit when it began the transaction, before the outer commit when it joined one (seeTaskService.moveTasks(List, long, Identity)).- Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
unassignTasksAtomically
protected List<TaskPayload> unassignTasksAtomically(List<Long> taskIds, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException One transaction for the whole change, asmoveTasksAtomically(List, long, Identity): the events are left to the caller.- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException
-