Package com.homannsoftware.tasks.task
Class TaskService
java.lang.Object
com.homannsoftware.tasks.task.TaskService
Coordinates task use cases within service-level transaction boundaries.
Write methods override the default read-only transaction configuration.
-
Constructor Summary
ConstructorsConstructorDescriptionTaskService(TaskRepository tasks) Receives the repository through constructor injection. -
Method Summary
Modifier and TypeMethodDescriptioncomplete(long id) Sets completion without changing the title; repeating this is idempotent.Creates and stores an incomplete task.voiddelete(long id) Deletes an existing task.get(long id) Reads one task.list()Reads the entire tutorial dataset in ascending identity order.
-
Constructor Details
-
TaskService
Receives the repository through constructor injection.- Parameters:
tasks- repository used for task persistence
-
-
Method Details
-
create
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
Reads the entire tutorial dataset in ascending identity order.- Returns:
- all tasks, or an empty list; this operation is not paginated
-
get
Reads one task.- Parameters:
id- task identity to find- Returns:
- current task representation
- Throws:
TaskNotFound- if the identity does not exist
-
complete
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
-