Class OfficerProjectController

java.lang.Object
controller.OfficerProjectController

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

    • OfficerProjectController

      public OfficerProjectController()
  • Method Details

    • setOfficerID

      public static void setOfficerID(String ID)
      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 using FilterController. 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

      public static void viewApplicantApplicationStatus(String projectID)
      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

      public static void viewApplicantApplicationStatus(ApplicationStatus status)
      Displays applicants with a specific ApplicationStatus across all projects the current officer is registered for.
      Parameters:
      status - The specific ApplicationStatus to filter by.
    • viewApplicantApplicationStatus

      public static void viewApplicantApplicationStatus(String projectID, ApplicationStatus status)
      Displays applicants with a specific ApplicationStatus for 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 specific ApplicationStatus to filter by.
    • bookFlat

      public static void bookFlat(String applicantID)
      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

      public static void generateReceiptByApplicant(String applicantID)
      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

      public static void generateReceiptByProject(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.
      Parameters:
      projectID - The ID of the project for which to generate receipts.
    • checkValidProject

      public static boolean checkValidProject(List<String> projectId)
      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.