java.lang.Object
no.ntnu.principes.repository.AbstractRepository<Task,Long>
no.ntnu.principes.repository.TaskRepository
- All Implemented Interfaces:
BaseRepository<Task,Long>
Repository for managing household tasks.
Handles task creation, updates, and queries with support for recurring tasks,
difficulty weighting, and time estimates.
-
Field Summary
Fields inherited from class no.ntnu.principes.repository.AbstractRepository
dataSource, tableName -
Constructor Summary
ConstructorsConstructorDescriptionTaskRepository(DataSource dataSource) Creates a new TaskRepository with the specified data source. -
Method Summary
Modifier and TypeMethodDescriptionintcount()voiddeleteById(Long id) Deletes a task by its ID.findAll()Retrieves all tasks.Finds a task by its ID.Finds tasks by multiple IDs in a single query.Finds all recurring tasks.findTasksByMember(Long memberId) Finds all tasks assigned to a specific member.protected TaskMaps a database result set row to a Task object.Saves a task, creating a new record or updating an existing one.Methods inherited from class no.ntnu.principes.repository.AbstractRepository
executeInsert, executeUpdate, queryList, queryListRaw, queryListRaw, queryOne, queryOneRaw, queryOneRaw
-
Constructor Details
-
TaskRepository
Creates a new TaskRepository with the specified data source.- Parameters:
dataSource- The JDBC data source for database connections
-
-
Method Details
-
findById
Finds a task by its ID.- Parameters:
id- The task ID- Returns:
- An Optional containing the found task or empty if not found
-
findAll
Retrieves all tasks.- Returns:
- A list of all tasks
-
save
Saves a task, creating a new record or updating an existing one. Converts enum values (WorkWeight, TimeWeight) to their numeric representations.- Parameters:
task- The task to save- Returns:
- The saved task with ID populated
-
deleteById
Deletes a task by its ID.- Parameters:
id- The ID of the task to delete
-
mapRow
Maps a database result set row to a Task object. Converts numeric weight values to their enum representations.- Specified by:
mapRowin classAbstractRepository<Task,Long> - Parameters:
rs- The result set positioned at the row to map- Returns:
- The mapped Task object
- Throws:
SQLException- If a database error occurs during mapping
-
findTasksByMember
Finds all tasks assigned to a specific member.- Parameters:
memberId- The ID of the member to find tasks for- Returns:
- A list of tasks assigned to the member
-
findRecurringTasks
Finds all recurring tasks.- Returns:
- A list of tasks with recurring flag set to true
-
findByIds
Finds tasks by multiple IDs in a single query.- Parameters:
list- A list of task IDs to find- Returns:
- A list of tasks matching the provided IDs
-
findUnassignedTasks
-
count
public int count()
-