Class OfficerProjectController
java.lang.Object
controller.OfficerProjectController
Controller responsible for handling project-related operations performed by an Officer.
This includes viewing projects available for registration, viewing applicant statuses within assigned projects,
booking flats for successful applicants, and generating receipts/reports related to booked flats.
It operates using the context of the currently logged-in officer's ID.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidBooks a flat for a specified applicant.static booleancheckValidProject(List<String> projectId) Helper method to check if the officer is associated with any projects.static voidGenerates a 'receipt' by displaying details of all applicants who have successfully BOOKED a flat across all projects the current officer is registered for.static voidgenerateReceiptByApplicant(String applicantID) Generates a 'receipt' for a specific applicant ID.static voidgenerateReceiptByProject(String projectID) Generates a 'receipt' by displaying details of all applicants who have successfully BOOKED a flat for a specific project ID, provided the current officer is registered for that project.static voidsetOfficerID(String ID) Sets the officer ID for the current session context.static voidDisplays the application status for all applicants across all projects the current officer is registered for.static voidDisplays applicants with a specificApplicationStatusacross all projects the current officer is registered for.static voidviewApplicantApplicationStatus(String projectID) Displays the application status for all applicants associated with a specific project ID.static voidviewApplicantApplicationStatus(String projectID, ApplicationStatus status) Displays applicants with a specificApplicationStatusfor a specific project ID.static voidDisplays a list of projects that the current officer may be eligible to register for.
-
Constructor Details
-
OfficerProjectController
public OfficerProjectController()
-
-
Method Details
-
setOfficerID
Sets the officer ID for the current session context. Subsequent officer-specific operations in this controller will use this ID.- Parameters:
ID- The user ID of the currently logged-in officer.
-
viewRegistrableProject
public static void viewRegistrableProject()Displays a list of projects that the current officer may be eligible to register for. Filters the global project list usingFilterController. Further filters based on: - Project visibility. - Officer is not already an applicant for the project. - The project's dates do not overlap with any project the officer is already registered for. -
viewApplicantApplicationStatus
public static void viewApplicantApplicationStatus()Displays the application status for all applicants across all projects the current officer is registered for. Checks if the officer is registered for any projects before proceeding. -
viewApplicantApplicationStatus
Displays the application status for all applicants associated with a specific project ID. Note: This method does not explicitly check if the current officer is assigned to this project.- Parameters:
projectID- The ID of the project for which to view applicant statuses.
-
viewApplicantApplicationStatus
Displays applicants with a specificApplicationStatusacross all projects the current officer is registered for.- Parameters:
status- The specificApplicationStatusto filter by.
-
viewApplicantApplicationStatus
Displays applicants with a specificApplicationStatusfor a specific project ID. Note: This method does not explicitly check if the current officer is assigned to this project.- Parameters:
projectID- The ID of the project to filter by.status- The specificApplicationStatusto filter by.
-
bookFlat
Books a flat for a specified applicant. Performs checks: - Applicant ID is valid and corresponds to an Applicant (not Manager/Officer). - Applicant has applied to a project. - The current officer is registered for the applicant's project. - Applicant's status is SUCCESSFUL (not already BOOKED or PENDING/UNSUCCESSFUL). - The flat type applied for has available units. If checks pass, updates the project's available units, adds the applicant to the project's booked list, and updates the applicant's status to BOOKED.- Parameters:
applicantID- The ID of the applicant for whom to book the flat.
-
generateReceipt
public static void generateReceipt()Generates a 'receipt' by displaying details of all applicants who have successfully BOOKED a flat across all projects the current officer is registered for. Also displays the project details for context. -
generateReceiptByApplicant
Generates a 'receipt' for a specific applicant ID. Displays details if the applicant has BOOKED status and is associated with a project the current officer is registered for.- Parameters:
applicantID- The ID of the applicant for whom to generate the receipt.
-
generateReceiptByProject
Generates a 'receipt' by displaying details of all applicants who have successfully BOOKED a flat for a specific project ID, provided the current officer is registered for that project.- Parameters:
projectID- The ID of the project for which to generate receipts.
-
checkValidProject
Helper method to check if the officer is associated with any projects. Prints a message to the console if the officer is not registered for any projects. Suggestion: Could be made private if only used within this class.- Parameters:
projectId- The list of project IDs the officer is registered for.- Returns:
- true if the list is not null and not empty, false otherwise.
-