Class ApplicantController
java.lang.Object
controller.ApplicantController
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyProject(String projectID, FlatType applyFlat) Processes a project application request for the current applicant.static FlatTypecheckApplicable(String projectID) Checks if the currently set applicant is eligible to apply for a given project.static booleancheckQuery(String requestID) Checks if the current applicant is allowed to modify (edit/delete) a specific enquiry.static voiddeleteQuery(String requestID) Deletes an existing enquiry submitted by the current applicant.static voidEdits the text content of an existing enquiry submitted by the current applicant.static voidSubmits an enquiry from the current applicant regarding a specific project.static voidsetApplicantID(String ID) Sets the applicant ID for the current session context.static voidDisplays a list of projects that the current applicant is eligible to apply for.static voidDisplays the current applicant's pending and historical BTO applications and withdrawals.static voidDisplays details of the single project the applicant has currently applied to, if any.static voidDisplays all enquiries previously submitted by the current applicant.static voidwithdrawApplication(String projectID) Submits a request for the current applicant to withdraw their application from a specific project.
-
Constructor Details
-
ApplicantController
public ApplicantController()
-
-
Method Details
-
setApplicantID
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
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
FlatTypethe 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 usingFilterController. 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 (usingcheckApplicable(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 newBTOApplicationrequest in the RequestList.- Parameters:
projectID- The ID of the project to apply for.applyFlat- TheFlatTypethe applicant wants to apply for.- Throws:
ProjectNotFoundException- If the specified projectID does not exist.
-
withdrawApplication
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 newBTOWithdrawalrequest 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
Submits an enquiry from the current applicant regarding a specific project. Checks if the applicant is generally eligible (relevant) to enquire about the project usingcheckApplicable(String). If relevant, creates a newEnquiryrequest 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
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
Edits the text content of an existing enquiry submitted by the current applicant. First performs validation usingcheckQuery(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
Deletes an existing enquiry submitted by the current applicant. First performs validation usingcheckQuery(String). If validation passes, removes the enquiry from the RequestList.- Parameters:
requestID- The ID of the enquiry to delete.
-