Class ApplicantController

java.lang.Object
controller.ApplicantController

public class ApplicantController extends Object
Controller responsible for handling business logic related to actions performed by Applicants. This includes checking project eligibility, viewing project lists, applying for projects, withdrawing applications, and managing personal enquiries (view, create, edit, delete). It operates based on the currently logged-in applicant's ID.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyProject(String projectID, FlatType applyFlat)
    Processes a project application request for the current applicant.
    static FlatType
    Checks if the currently set applicant is eligible to apply for a given project.
    static boolean
    checkQuery(String requestID)
    Checks if the current applicant is allowed to modify (edit/delete) a specific enquiry.
    static void
    deleteQuery(String requestID)
    Deletes an existing enquiry submitted by the current applicant.
    static void
    editQuery(String requestID, String text)
    Edits the text content of an existing enquiry submitted by the current applicant.
    static void
    query(String projectID, String text)
    Submits an enquiry from the current applicant regarding a specific project.
    static void
    Sets the applicant ID for the current session context.
    static void
    Displays a list of projects that the current applicant is eligible to apply for.
    static void
    Displays the current applicant's pending and historical BTO applications and withdrawals.
    static void
    Displays details of the single project the applicant has currently applied to, if any.
    static void
    Displays all enquiries previously submitted by the current applicant.
    static void
    Submits a request for the current applicant to withdraw their application from a specific project.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ApplicantController

      public ApplicantController()
  • Method Details

    • setApplicantID

      public static void setApplicantID(String ID)
      Sets the applicant ID for the current session context. All subsequent operations in this controller will be performed for this applicant.
      Parameters:
      ID - The user ID of the currently logged-in applicant.
    • checkApplicable

      public static FlatType checkApplicable(String projectID)
      Checks if the currently set applicant is eligible to apply for a given project. Eligibility criteria include: - Project visibility is true. - Applicant is not an officer assigned to the project. - Current date is within the project's application open and close dates. - Applicant meets age and marital status requirements for specific flat types: - Age >= 35 and Single: Eligible for TWO_ROOM. - Age >= 21 and Married: Eligible for THREE_ROOM (implicitly includes TWO_ROOM).
      Parameters:
      projectID - The ID of the project to check eligibility for.
      Returns:
      The maximum FlatType the applicant is eligible for (THREE_ROOM implies eligibility for TWO_ROOM as well), or null if the applicant is not eligible for the project based on the criteria.
    • viewApplicableProject

      public static void viewApplicableProject()
      Displays a list of projects that the current applicant is eligible to apply for. The list is first filtered using FilterController. For each eligible project, it indicates the maximum flat type the applicant can apply for.
    • viewAppliedApplication

      public static void viewAppliedApplication()
      Displays the current applicant's pending and historical BTO applications and withdrawals. Separates the display into current pending requests and completed request history.
    • viewAppliedProject

      public static void viewAppliedProject()
      Displays details of the single project the applicant has currently applied to, if any. Includes the current application status for that project.
    • applyProject

      public static void applyProject(String projectID, FlatType applyFlat) throws ProjectNotFoundException
      Processes a project application request for the current applicant. Performs checks: - Applicant hasn't already applied for another project. - Project exists. - Applicant is eligible for the specified project (using checkApplicable(String)). - The requested flat type has available units. If all checks pass, updates the applicant's record (sets project, applied flat type, status to PENDING) and creates a new BTOApplication request in the RequestList.
      Parameters:
      projectID - The ID of the project to apply for.
      applyFlat - The FlatType the applicant wants to apply for.
      Throws:
      ProjectNotFoundException - If the specified projectID does not exist.
    • withdrawApplication

      public static void withdrawApplication(String projectID) throws ProjectNotFoundException
      Submits a request for the current applicant to withdraw their application from a specific project. Performs checks: - Project exists. - Applicant has a pending application for this project. - Applicant has not already submitted a withdrawal request for this project. If checks pass, creates a new BTOWithdrawal request in the RequestList.
      Parameters:
      projectID - The ID of the project from which to withdraw the application.
      Throws:
      ProjectNotFoundException - If the specified projectID does not exist.
    • query

      public static void query(String projectID, String text)
      Submits an enquiry from the current applicant regarding a specific project. Checks if the applicant is generally eligible (relevant) to enquire about the project using checkApplicable(String). If relevant, creates a new Enquiry request in the RequestList.
      Parameters:
      projectID - The ID of the project the enquiry is about.
      text - The text content of the enquiry.
    • viewQuery

      public static void viewQuery()
      Displays all enquiries previously submitted by the current applicant.
    • checkQuery

      public static boolean checkQuery(String requestID)
      Checks if the current applicant is allowed to modify (edit/delete) a specific enquiry. Conditions for modification: - Request ID must exist. - Request must be an Enquiry. - Enquiry status must be PENDING (cannot modify answered enquiries). - Enquiry must belong to the current applicant.
      Parameters:
      requestID - The ID of the enquiry request to check.
      Returns:
      true if the applicant is allowed to modify the enquiry, false otherwise.
    • editQuery

      public static void editQuery(String requestID, String text)
      Edits the text content of an existing enquiry submitted by the current applicant. First performs validation using checkQuery(String). If validation passes, updates the enquiry in the RequestList with the new text.
      Parameters:
      requestID - The ID of the enquiry request to check.
      text - The text content of the enquiry.
    • deleteQuery

      public static void deleteQuery(String requestID)
      Deletes an existing enquiry submitted by the current applicant. First performs validation using checkQuery(String). If validation passes, removes the enquiry from the RequestList.
      Parameters:
      requestID - The ID of the enquiry to delete.