Class AssignmentService

java.lang.Object
com.nicholasalfonso.lato.service.AssignmentService

@Service public class AssignmentService extends Object
Service for retrieving and mutating user-owned assignments.
  • Constructor Details

    • AssignmentService

      public AssignmentService(AssignmentRepository assignmentRepository, NoteRepository noteRepository, AssignmentMapper assignmentMapper, CourseService courseService)
      Creates the assignment service with required repositories and mappers.
      Parameters:
      assignmentRepository - repository for assignment persistence
      noteRepository - repository for note persistence
      assignmentMapper - mapper for assignment response DTOs
      courseService - service used to resolve owning courses
  • Method Details

    • getAssignment

      public Assignment getAssignment(User user, Long assignmentId)
      Loads an assignment owned by the given user.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      Returns:
      the assignment entity
      Throws:
      org.springframework.web.server.ResponseStatusException - if the assignment is not found
    • getDetailedAssignment

      public AssignmentDetailResponse getDetailedAssignment(User user, Long assignmentId)
      Returns detailed assignment information including note content.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      Returns:
      detailed assignment response
    • getArchivedAssignments

      public List<AssignmentDetailResponse> getArchivedAssignments(User user)
      Returns all archived assignments for the given user.
      Parameters:
      user - the owning user
      Returns:
      archived assignment detail responses
    • createAssignment

      @Transactional public AssignmentResponse createAssignment(User user, CreateAssignmentRequest request)
      Creates a new manually entered assignment for the user.
      Parameters:
      user - the owning user
      request - assignment creation details
      Returns:
      summary response for the created assignment
    • updateAssignment

      @Transactional public AssignmentDetailResponse updateAssignment(User user, Long assignmentId, UpdateAssignmentRequest request)
      Updates editable assignment fields and optional note content.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      request - update details
      Returns:
      updated detailed assignment response
    • getDisplayTitle

      public String getDisplayTitle(Assignment assignment)
      Returns the resolved display title for an assignment.
      Parameters:
      assignment - the assignment entity
      Returns:
      custom title when present, otherwise synced title
    • getDisplayDescription

      public String getDisplayDescription(Assignment assignment)
      Returns the resolved display description for an assignment.
      Parameters:
      assignment - the assignment entity
      Returns:
      custom description when present, otherwise synced description
    • getDisplayDueDate

      public LocalDate getDisplayDueDate(Assignment assignment)
      Returns the resolved display due date for an assignment.
      Parameters:
      assignment - the assignment entity
      Returns:
      custom due date when present, otherwise synced due date
    • getDisplayDueTime

      public LocalTime getDisplayDueTime(Assignment assignment)
      Returns the resolved display due time for an assignment.
      Parameters:
      assignment - the assignment entity
      Returns:
      custom due time when present, otherwise synced due time
    • markCompleted

      @Transactional public AssignmentResponse markCompleted(User user, Long assignmentId, boolean completed)
      Marks an assignment complete or incomplete.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      completed - desired completion state
      Returns:
      updated summary assignment response
      Throws:
      org.springframework.web.server.ResponseStatusException - if the assignment is already in the requested state
    • archiveAssignment

      @Transactional public AssignmentResponse archiveAssignment(User user, Long assignmentId, boolean archived)
      Archives or unarchives an assignment.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      archived - desired archival state
      Returns:
      updated summary assignment response
      Throws:
      org.springframework.web.server.ResponseStatusException - if the assignment is already in the requested state
    • deleteAssignment

      @Transactional public MessageResponse deleteAssignment(User user, Long assignmentId)
      Permanently deletes an archived assignment.
      Parameters:
      user - the owning user
      assignmentId - the assignment ID
      Returns:
      confirmation message
      Throws:
      org.springframework.web.server.ResponseStatusException - if the assignment is not archived