Class TaskTemplateService

java.lang.Object
no.ntnu.principes.service.TaskTemplateService

public class TaskTemplateService extends Object
Manages the creation and update of task templates and their assignments. Handles the initial setup of tasks with proper assignments to household members, and updates to task properties and member assignments.
  • Constructor Details

    • TaskTemplateService

      public TaskTemplateService()
      Creates a new TaskTemplateService with the required repositories. Repositories are obtained from the central DatabaseManager.
  • Method Details

    • createTask

      public Task createTask(CreateTaskRequest taskRequest, List<Long> assignToMemberIds, boolean pushEvents)
      Creates a new task with optional assignments to specific members. If no members are specified, creates an unassigned task assignment.
      Parameters:
      taskRequest - The request containing task details
      assignToMemberIds - List of member IDs to assign the task to, or null/empty for unassigned
      pushEvents - Whether to push events after task creation
      Returns:
      The created task
    • createTask

      public Task createTask(CreateTaskRequest taskRequest, List<Long> assignToMemberIds)
      Creates a new task with optional assignments to specific members. If no members are specified, creates an unassigned task assignment.
      Parameters:
      taskRequest - The request containing task details
      assignToMemberIds - List of member IDs to assign the task to, or null/empty for unassigned
      Returns:
      The created task
    • updateTask

      public Task updateTask(Long taskId, CreateTaskRequest taskRequest, List<Long> assignToMemberIds)
      Updates an existing task and its assignments. Handles changes to task properties and member assignments, preserving or updating existing assignments as needed.
      Parameters:
      taskId - The ID of the task to update
      taskRequest - The request containing updated task details
      assignToMemberIds - List of member IDs to assign the task to, or null/empty for unassigned
      Returns:
      The updated task
      Throws:
      IllegalArgumentException - if the task is not found
    • getUnassignedTasks

      public List<Task> getUnassignedTasks()
    • hasCreatedTasks

      public boolean hasCreatedTasks()