Class ManagerProjectController

java.lang.Object
controller.ManagerProjectController

public class ManagerProjectController extends Object
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 Details

    • ManagerProjectController

      public ManagerProjectController()
  • Method Details

    • setManagerID

      public static void setManagerID(String ID)
      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 the ProjectList and updates the manager's record in ManagerList to 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 each FlatType.
      price - A map defining the price for each FlatType.
      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

      public static void editProject(String projectID, Project project)
      Updates an existing project's details in the ProjectList. Replaces the project with the given projectID with the data from the provided project object.
      Parameters:
      projectID - The ID of the project to update.
      project - The Project object containing the updated details.
    • deleteProject

      public static void deleteProject(String projectID) throws ProjectNotFoundException
      Deletes a project and handles cascading updates/cleanups. Actions performed: 1. Removes the project from ProjectList. 2. Removes the project ID from the list of projects managed by the associated manager in ManagerList. 3. Deletes all related requests (applications, withdrawals, enquiries) from RequestList. 4. Unlinks the project from any applicants who applied (sets their project to null) and updates their application status to UNSUCCESSFUL in ApplicantList. 5. Removes the project ID from the list of projects officers are registered for and updates their registration status to REJECTED in OfficerList.
      Parameters:
      projectID - The ID of the project to delete.
      Throws:
      ProjectNotFoundException - If no project with the given ID exists.
    • toggleVisibility

      public static void toggleVisibility(String projectID) throws ProjectNotFoundException
      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 all OfficerRegistration requests found in the RequestList. This allows the manager to view pending officer applications for projects.
    • viewProjectList

      public static void viewProjectList(String managerID) throws ProjectNotFoundException
      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 using FilterController, 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 the ApplicantList based on these criteria using Java Streams and displays the matching applicants.