Class TaskService

java.lang.Object
com.homannsoftware.tasks.task.TaskService

@Service @Transactional(readOnly=true) public class TaskService extends Object
Coordinates task use cases within service-level transaction boundaries. Write methods override the default read-only transaction configuration.
  • Constructor Details

    • TaskService

      public TaskService(TaskRepository tasks)
      Receives the repository through constructor injection.
      Parameters:
      tasks - repository used for task persistence
  • Method Details

    • create

      @Transactional public TaskView create(String title)
      Creates and stores an incomplete task.
      Parameters:
      title - raw title to validate and normalize
      Returns:
      representation containing the assigned identity
      Throws:
      IllegalArgumentException - if the title is null, blank or too long
    • list

      public List<TaskView> list()
      Reads the entire tutorial dataset in ascending identity order.
      Returns:
      all tasks, or an empty list; this operation is not paginated
    • get

      public TaskView get(long id)
      Reads one task.
      Parameters:
      id - task identity to find
      Returns:
      current task representation
      Throws:
      TaskNotFound - if the identity does not exist
    • complete

      @Transactional public TaskView complete(long id)
      Sets completion without changing the title; repeating this is idempotent. JPA persists the managed entity change when the transaction commits.
      Parameters:
      id - task identity to complete
      Returns:
      representation with completion set to true
      Throws:
      TaskNotFound - if the identity does not exist
    • delete

      @Transactional public void delete(long id)
      Deletes an existing task.
      Parameters:
      id - task identity to remove
      Throws:
      TaskNotFound - if the identity does not exist