Interface TaskService

All Known Implementing Classes:
TaskServiceImpl

public interface TaskService
  • Field Details

    • TEXT_SEARCH_WINDOW

      static final int TEXT_SEARCH_WINDOW
      The most hits a text search reads, the most relevant first.
      See Also:
    • TEXT_SEARCH_NO_WORD

      static final String TEXT_SEARCH_NO_WORD
      The code of the refusal of a text search holding no word with letters.
      See Also:
    • USER_TARGET_ACTIONS

      static final List<String> USER_TARGET_ACTIONS
      The change log actions whose target is a user, an assignee or a coworker; the other actions name a status, a project or nothing there (EXO-91902).
  • Method Details

    • createTask

      TaskDto createTask(TaskDto task)
      Create a new task.
      Parameters:
      task - the given task.
      Returns:
      the created task.
    • updateTask

      TaskDto updateTask(TaskDto task)
      Update the task.
      Parameters:
      task - the given task.
      Returns:
      TaskDto the updated task.
    • updateTask

      TaskDto updateTask(long taskId, TaskDto task, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Update 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.
      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.
      IllegalArgumentException - when the given status is not found.
    • moveTasks

      List<TaskDto> moveTasks(List<Long> taskIds, long statusId, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Moves tasks to the given status, all or none: each task is authorized as 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 for updateTask(TaskDto).
      Parameters:
      taskIds - ids of the tasks to move
      statusId - id of the status the tasks take
      identity - 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.
      IllegalArgumentException - when the given status is not found.
    • unassignTasks

      List<TaskDto> unassignTasks(List<Long> taskIds, org.exoplatform.services.security.Identity identity) throws org.exoplatform.commons.exception.ObjectNotFoundException
      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. 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 for updateTask(TaskDto).
      Parameters:
      taskIds - ids of the tasks to remove the user from
      identity - the user to remove
      Returns:
      the updated tasks
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when a task is not found.
      IllegalArgumentException - when the user is neither the assignee nor a coworker of a task.
    • updateTaskOrder

      void updateTaskOrder(long currentTaskId, Status newStatus, long[] orders)
    • removeTask

      void removeTask(long taskId) throws EntityNotFoundException
      Remove the task with given taskId
      Parameters:
      taskId - the given task id.
      Throws:
      EntityNotFoundException - when task is not found.
    • cloneTask

      TaskDto cloneTask(long taskId) throws EntityNotFoundException
      Clone the task from a task with given taskId.
      Parameters:
      taskId - the task Id
      Returns:
      the cloned task.
      Throws:
      EntityNotFoundException - when task is not found.
    • getTask

      TaskDto getTask(long taskId) throws EntityNotFoundException
      Return the task with given taskId.
      Parameters:
      taskId - the task Id
      Returns:
      the given task.
      Throws:
      EntityNotFoundException - when task is not found.
    • getWatchedTasks

      List<TaskDto> getWatchedTasks(String user, int limit)
    • countWatchedTasks

      Long countWatchedTasks(String user)
    • getAssignedTasks

      List<TaskDto> getAssignedTasks(String user, int limit)
    • countAssignedTasks

      Long countAssignedTasks(String user)
    • getCollaboratedTasks

      List<TaskDto> getCollaboratedTasks(String user, int limit)
    • countCollaboratedTasks

      Long countCollaboratedTasks(String user)
    • findTasksByMemberShips

      List<TaskDto> findTasksByMemberShips(String user, List<String> memberships, String query, int limit)
    • findTasks

      List<TaskDto> findTasks(String user, String query, int limit)
    • countTasks

      int countTasks(TaskQuery query) throws Exception
      Throws:
      Exception
    • selectTaskField

      <T> List<T> selectTaskField(TaskQuery query, String fieldName)
    • findTasksByLabel

      List<TaskDto> findTasksByLabel(LabelDto label, List<Long> projectIds, String username, OrderBy orderBy, int offset, int limit) throws Exception
      Throws:
      Exception
    • countTasksByLabel

      int countTasksByLabel(LabelDto label, List<Long> projectIds, String username, OrderBy orderBy) throws Exception
      Throws:
      Exception
    • addTaskLog

      ChangeLogEntry addTaskLog(long taskId, String username, String actionName, String target) throws EntityNotFoundException
      Create a log associated with a task with given taskId.
      Parameters:
      taskId - 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

      List<ChangeLogEntry> getTaskLogs(long taskId, int offset, int limit) throws Exception
      Throws:
      Exception
    • addChangeFilter

      void addChangeFilter(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.
      Parameters:
      query - the query to narrow, already scoped to what the user can see
      filter - the change filter, possibly null
    • getAssignedTasksQuery

      TaskQuery 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).
      Parameters:
      username - the user
      filter - the change filter, possibly null
      Returns:
      the query
    • getTaskChanges

      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.
      Parameters:
      task - the task
      since - the earliest date of the changes, included; required
      includeChangeLog - whether its newest change log entries come too
      Returns:
      its changes
      Throws:
      IllegalArgumentException - when since is null
      Exception - when its change log can't be read
    • getTasksChanges

      Map<Long, List<TaskFieldChange>> getTasksChanges(List<TaskDto> tasks, Date since)
      Rebuilds the changes since a date of several tasks, as 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.
      Parameters:
      tasks - the tasks
      since - 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
      Throws:
      IllegalArgumentException - when since is null
    • findTaskByActivityId

      TaskDto findTaskByActivityId(String activityId)
    • getCoworker

      Set<String> getCoworker(long taskId)
    • getMentionedUsers

      Set<String> getMentionedUsers(long taskId)
    • getUncompletedTasks

      List<TaskDto> getUncompletedTasks(String user, int limit)
    • countUncompletedTasks

      Long countUncompletedTasks(String user)
    • getIncomingTasks

      List<TaskDto> getIncomingTasks(String user, int offset, int limit) throws Exception
      Throws:
      Exception
    • countIncomingTasks

      int countIncomingTasks(String user) throws Exception
      Throws:
      Exception
    • getOverdueTasks

      List<TaskDto> getOverdueTasks(String user, int limit)
    • countOverdueTasks

      Long countOverdueTasks(String user)
    • getWatchersOfTask

      Set<String> getWatchersOfTask(TaskDto task)
    • addWatcherToTask

      void addWatcherToTask(String username, TaskDto task) throws Exception
      Throws:
      Exception
    • deleteWatcherOfTask

      void deleteWatcherOfTask(String username, TaskDto task) throws Exception
      Throws:
      Exception
    • findTasks

      List<TaskDto> findTasks(TaskQuery query, int offset, int limit) throws Exception
      Find tasks assigned to a user using a term to find in title or description of the task
      Parameters:
      query - term to search in title or description
      offset - term to offset results.
      limit - term to limit results.
      Returns:
      List of TaskDto
      Throws:
      Exception - when therer is an exception on get tasks.
    • countTasks

      long countTasks(String user, String query, List<String> memberships) throws Exception
      Count tasks assigned to a user using a search term to find in title or description of the task
      Parameters:
      user - username
      query - term to search in title or description
      Returns:
      tasks count
      Throws:
      Exception
    • countTaskStatusByProject

      List<Object[]> countTaskStatusByProject(long projectId)
    • filterTasks

      TasksList filterTasks(String query, long projectId, String keyword, List<Long> labels, TaskUtil.DUE dueDate, Priority priority, List<String> assignees, List<String> coworkers, 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
      Throws:
      Exception
    • isExternal

      boolean isExternal(String userId)
    • getAllIds

      List<Long> getAllIds(int offset, int limit)
      Retrieves a paginated list of all task IDs.
      Parameters:
      offset - the starting position of the first result
      limit - the maximum number of results to retrieve
      Returns:
      a list of task IDs
    • findTasks

      List<TaskDto> findTasks(TaskSearchFilter taskFilter)
      Find tasks assigned to a user using a term to find in title or description of the task
      Parameters:
      taskFilter - the task search filter
      Returns:
      a list of task IDs
    • searchTasks

      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 as 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.
      Parameters:
      text - the text searched: every word in the title, or every word in the description
      projectId - the project, null for every task the user can view
      includeCompleted - whether the completed tasks are returned, after the open ones
      limit - the most tasks returned, bounded between 1 and 100
      identity - 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 exist
      IllegalAccessException - when the user can't view the project
      IllegalArgumentException - with the code "task.search.noWord" when the text holds no word with letters
    • findLastUpdatedTasks

      List<TaskDto> findLastUpdatedTasks(TaskQuery query, int offset, int limit)
      Find tasks switch last update date computed from Task Logs and Task Comments after applying the TaskQuery filtering
      Parameters:
      query - TaskQuery
      offset - result offset
      limit - result limit
      Returns:
      List of corresponding Tasks