Class OfficerRegistrationService
- All Implemented Interfaces:
IOfficerRegistrationService
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 Summary
ConstructorsConstructorDescriptionOfficerRegistrationService
(IOfficerRegistrationRepository registrationRepo, IProjectRepository projectRepo, IApplicationRepository applicationRepo, IEligibilityService eligibilityService) Constructs a new OfficerRegistrationService with the specified repositories and services. -
Method Summary
Modifier and TypeMethodDescriptionint
getPendingRegistrationCountForProject
(String projectId) Gets the count of pending registration requests for a specific project.Gets all pending registration requests across all projects.getPendingRegistrationsForProject
(String projectId) Gets all pending registration requests for a specific project.getRegistrationsByOfficer
(String officerNric) Gets all registration records for a specific officer.getRegistrationsByProject
(String projectId) Gets all registration records for a specific project.getRegistrationStatus
(HDBOfficer officer, String projectId) Gets the current registration status for a specific officer and project.requestProjectRegistration
(HDBOfficer officer, String projectId) Requests registration of an HDB officer to a project.boolean
reviewRegistration
(HDBManager manager, String registrationId, boolean approve) Reviews (approves or rejects) an officer's registration request.
-
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 dataprojectRepo
- The repository for project dataapplicationRepo
- The repository for application dataeligibilityService
- 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 interfaceIOfficerRegistrationService
- Parameters:
officer
- The HDB officer requesting registrationprojectId
- 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 interfaceIOfficerRegistrationService
- Parameters:
manager
- The manager reviewing the registration requestregistrationId
- The ID of the registration to reviewapprove
- 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 interfaceIOfficerRegistrationService
- 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
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 interfaceIOfficerRegistrationService
- Returns:
- A list of all pending registration requests
-
getPendingRegistrationsForProject
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 interfaceIOfficerRegistrationService
- Parameters:
projectId
- The ID of the project to check- Returns:
- A list of pending registration requests for the specified project
-
getPendingRegistrationCountForProject
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 interfaceIOfficerRegistrationService
- Parameters:
projectId
- The ID of the project to check- Returns:
- The number of pending registration requests for the project
-
getRegistrationsByProject
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 interfaceIOfficerRegistrationService
- Parameters:
projectId
- The ID of the project- Returns:
- A list of all registration records for the project
-
getRegistrationsByOfficer
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 interfaceIOfficerRegistrationService
- Parameters:
officerNric
- The NRIC of the officer- Returns:
- A list of all registration records for the officer
-