Class OfficerRegistrationService

java.lang.Object
com.ntu.fdae.group1.bto.services.project.OfficerRegistrationService
All Implemented Interfaces:
IOfficerRegistrationService

public class OfficerRegistrationService extends Object implements IOfficerRegistrationService
Service that manages the registration of HDB Officers to projects in the BTO Management System.

This service implements the business logic for creating, retrieving, and managing officer registrations to projects. It acts as an intermediary between controllers and the data access layer, applying domain-specific rules and managing the workflow of officer registrations.

The service handles:
  • Creating new registration requests from officers
  • Processing approval/rejection of registrations
  • Checking registration status for authorization
  • Retrieving registration information for specific officers or projects
  • Constructor Details

    • OfficerRegistrationService

      public OfficerRegistrationService(IOfficerRegistrationRepository registrationRepo, IProjectRepository projectRepo, IApplicationRepository applicationRepo, IEligibilityService eligibilityService)
      Constructs a new OfficerRegistrationService with the specified repositories and services.

      Uses dependency injection to receive the required repositories and services, and performs null checks to ensure valid dependencies.

      Parameters:
      registrationRepo - The repository for officer registration data
      projectRepo - The repository for project data
      applicationRepo - The repository for application data
      eligibilityService - The service for checking officer eligibility
      Throws:
      NullPointerException - if any of the repositories or services are null
  • Method Details

    • requestProjectRegistration

      public OfficerRegistration requestProjectRegistration(HDBOfficer officer, String projectId) throws RegistrationException
      Requests registration of an HDB officer to a project.

      This is the first step in the registration process, where an officer requests to be associated with a project. The registration starts in PENDING status and requires manager approval.

      Creates a new registration request for an officer to be assigned to a project. The registration is initially created with PENDING status and requires approval from a manager before the officer can perform actions on the project.

      Specified by:
      requestProjectRegistration in interface IOfficerRegistrationService
      Parameters:
      officer - The HDB officer requesting registration
      projectId - The ID of the project the officer wants to register for
      Returns:
      The created registration record
      Throws:
      RegistrationException - if the registration request fails (e.g., officer is not eligible)
    • reviewRegistration

      public boolean reviewRegistration(HDBManager manager, String registrationId, boolean approve) throws RegistrationException
      Reviews (approves or rejects) an officer's registration request.

      This method allows a project manager to decide whether to approve or reject an officer's request to be associated with their project.

      Updates the status of a registration request, typically used by managers to approve or reject officers' requests to work on projects.

      When a registration is approved or rejected, a response date is automatically captured in the registration record.

      Specified by:
      reviewRegistration in interface IOfficerRegistrationService
      Parameters:
      manager - The manager reviewing the registration request
      registrationId - The ID of the registration to review
      approve - True to approve, false to reject
      Returns:
      True if the review was successful
      Throws:
      RegistrationException - if the review fails (e.g., unauthorized manager)
    • getRegistrationStatus

      public OfficerRegStatus getRegistrationStatus(HDBOfficer officer, String projectId) throws DataAccessException
      Gets the current registration status for a specific officer and project.
      Specified by:
      getRegistrationStatus in interface IOfficerRegistrationService
      Parameters:
      officer - The HDBOfficer whose registration status is needed.
      projectId - The ID of the project in question.
      Returns:
      The OfficerRegStatus if a registration exists, otherwise null.
      Throws:
      DataAccessException - if an error occurs during data retrieval.
    • getPendingRegistrations

      public List<OfficerRegistration> getPendingRegistrations()
      Gets all pending registration requests across all projects.

      This method is typically used by managers to view all pending registration requests that need their attention.

      Retrieves all registration requests that are currently pending approval. This method is typically used by managers to view and process pending registration requests.

      Specified by:
      getPendingRegistrations in interface IOfficerRegistrationService
      Returns:
      A list of all pending registration requests
    • getPendingRegistrationsForProject

      public List<OfficerRegistration> getPendingRegistrationsForProject(String projectId)
      Gets all pending registration requests for a specific project.

      This method allows project managers to view registration requests specifically for their projects.

      Retrieves all registration requests for a specific project that are currently pending approval. This method is typically used by managers to view and process pending registration requests for their projects.

      Specified by:
      getPendingRegistrationsForProject in interface IOfficerRegistrationService
      Parameters:
      projectId - The ID of the project to check
      Returns:
      A list of pending registration requests for the specified project
    • getPendingRegistrationCountForProject

      public int getPendingRegistrationCountForProject(String projectId)
      Gets the count of pending registration requests for a specific project.

      This method provides a quick way to check how many pending registration requests exist for a project without retrieving the full details.

      Retrieves the count of registration requests for a specific project that are currently pending approval. This method is typically used by managers to quickly get the number of pending registration requests for their projects.

      Specified by:
      getPendingRegistrationCountForProject in interface IOfficerRegistrationService
      Parameters:
      projectId - The ID of the project to check
      Returns:
      The number of pending registration requests for the project
    • getRegistrationsByProject

      public List<OfficerRegistration> getRegistrationsByProject(String projectId)
      Gets all registration records for a specific project.

      This method retrieves all officer registrations associated with a project, regardless of their status.

      Retrieves all registration requests associated with a specific project, regardless of their status. This method enables project managers to view and manage all officers requesting access to or already assigned to a project.

      Specified by:
      getRegistrationsByProject in interface IOfficerRegistrationService
      Parameters:
      projectId - The ID of the project
      Returns:
      A list of all registration records for the project
    • getRegistrationsByOfficer

      public List<OfficerRegistration> getRegistrationsByOfficer(String officerNric)
      Gets all registration records for a specific officer.

      This method retrieves all project registrations associated with an officer, regardless of their status.

      Retrieves all registration requests submitted by a specific officer, regardless of their status. This method enables officers to track the status of their project registration requests.

      Specified by:
      getRegistrationsByOfficer in interface IOfficerRegistrationService
      Parameters:
      officerNric - The NRIC of the officer
      Returns:
      A list of all registration records for the officer