Class ManagerProjectController
java.lang.Object
controller.ManagerProjectController
Controller responsible for handling project-related operations initiated by a Manager.
This includes creating, editing, deleting projects, toggling project visibility,
viewing projects associated with a manager, viewing officer registration requests,
and generating applicant reports based on various criteria.
It operates using the context of the currently logged-in manager's ID.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateProject(String projectID, String name, List<String> neighbourhood, Map<FlatType, Integer> availableUnit, Map<FlatType, Integer> price, LocalDate openDate, LocalDate closeDate, int availableOfficer) Creates a new project and associates it with the current manager.static voiddeleteProject(String projectID) Deletes a project and handles cascading updates/cleanups.static voideditProject(String projectID, Project project) Updates an existing project's details in theProjectList.static voidGenerates and displays a report of applicants for a specific project based on criteria provided by the user.static voidsetManagerID(String ID) Sets the manager ID for the current session context.static voidtoggleVisibility(String projectID) Toggles the visibility status of the specified project.static voidDisplays allOfficerRegistrationrequests found in theRequestList.static voidviewProjectList(String managerID) Displays a list of projects managed by the specified manager ID, after applying current filters.
-
Constructor Details
-
ManagerProjectController
public ManagerProjectController()
-
-
Method Details
-
setManagerID
Sets the manager ID for the current session context. All subsequent manager-specific operations in this controller will be performed for this manager.- Parameters:
ID- The user ID of the currently logged-in manager.
-
createProject
public static void createProject(String projectID, String name, List<String> neighbourhood, Map<FlatType, Integer> availableUnit, Map<FlatType, Integer> price, LocalDate openDate, LocalDate closeDate, int availableOfficer) Creates a new project and associates it with the current manager. Performs pre-checks: - Ensures the project name is unique across all existing projects. - Ensures the manager does not already have another active project with overlapping dates. If checks pass, adds the project to theProjectListand updates the manager's record inManagerListto include the new project ID.- Parameters:
projectID- The unique ID generated for the new project.name- The name of the new project.neighbourhood- A list of neighbourhood names associated with the project.availableUnit- A map defining the number of available units for eachFlatType.price- A map defining the price for eachFlatType.openDate- The date when project applications open.closeDate- The date when project applications close.availableOfficer- The number of officer slots available for this project.
-
editProject
Updates an existing project's details in theProjectList. Replaces the project with the givenprojectIDwith the data from the providedprojectobject.- Parameters:
projectID- The ID of the project to update.project- TheProjectobject containing the updated details.
-
deleteProject
Deletes a project and handles cascading updates/cleanups. Actions performed: 1. Removes the project fromProjectList. 2. Removes the project ID from the list of projects managed by the associated manager inManagerList. 3. Deletes all related requests (applications, withdrawals, enquiries) fromRequestList. 4. Unlinks the project from any applicants who applied (sets their project to null) and updates their application status to UNSUCCESSFUL inApplicantList. 5. Removes the project ID from the list of projects officers are registered for and updates their registration status to REJECTED inOfficerList.- Parameters:
projectID- The ID of the project to delete.- Throws:
ProjectNotFoundException- If no project with the given ID exists.
-
toggleVisibility
Toggles the visibility status of the specified project. If the project is currently visible, it becomes not visible, and vice versa.- Parameters:
projectID- The ID of the project whose visibility to toggle.- Throws:
ProjectNotFoundException- If no project with the given ID exists.
-
viewOfficerRegistrationStatus
public static void viewOfficerRegistrationStatus()Displays allOfficerRegistrationrequests found in theRequestList. This allows the manager to view pending officer applications for projects. -
viewProjectList
Displays a list of projects managed by the specified manager ID, after applying current filters. Retrieves the list of project IDs associated with the manager, gets the corresponding Project objects, applies filters usingFilterController, and displays the resulting projects.- Parameters:
managerID- The ID of the manager whose projects are to be viewed.- Throws:
ProjectNotFoundException- If the manager manages no projects, or if after filtering, no projects remain.
-
generateReport
public static void generateReport()Generates and displays a report of applicants for a specific project based on criteria provided by the user. Prompts the user for Project ID, age range, marital status, and applied flat type. Filters theApplicantListbased on these criteria using Java Streams and displays the matching applicants.
-