Interface IProjectService
- All Known Implementing Classes:
ProjectService
This interface defines the contract for all project management operations, including: - Creating, editing, and deleting projects - Managing project visibility - Retrieving projects based on various filters and user roles - Checking project eligibility for different users
The service layer sits between controllers and repositories, implementing business rules and orchestrating multiple data operations to fulfill use cases related to BTO projects.
-
Method Summary
Modifier and TypeMethodDescriptioncreateProject
(HDBManager manager, String name, String neighborhood, Map<String, ProjectFlatInfo> flatInfoMap, LocalDate openDate, LocalDate closeDate, int officerSlots) Creates a new BTO project with the specified details.boolean
deleteProject
(HDBManager manager, String projectId) Deletes a project from the system.boolean
editCoreProjectDetails
(HDBManager manager, String projectId, String name, String neighborhood, LocalDate openDate, LocalDate closeDate, int officerSlots) Edits the core details of an existing project.findProjectById
(String projectId) Retrieves a project by its unique identifier.getAllProjects
(User user, Map<String, Object> filters) Retrieves all projects accessible to a specific user, with optional filters.Retrieves all projects available for an HDB Officer to register for.getProjectsManagedBy
(String managerNRIC) Retrieves all projects managed by a specific manager.getProjectsManagedBy
(String managerNRIC, Map<String, Object> filters) Retrieves all projects managed by a specific manager with optional filters.Retrieves all currently visible projects for which the user is eligible to apply.getVisibleProjectsForUser
(User user, Map<String, Object> filters) Retrieves all currently visible projects for which the user is eligible to apply, filtered by the provided criteria.boolean
toggleVisibility
(HDBManager manager, String projectId) Toggles the visibility of a project between visible and hidden states.
-
Method Details
-
createProject
Project createProject(HDBManager manager, String name, String neighborhood, Map<String, ProjectFlatInfo> flatInfoMap, LocalDate openDate, LocalDate closeDate, int officerSlots) Creates a new BTO project with the specified details.Validates project parameters and performs business rule checks, including: - Valid date range (opening date before closing date) - Manager's eligibility (not managing other projects during the same period) - Officer slots within permitted range - At least one flat type offered
If validation passes, a new project is created with a unique ID.
- Parameters:
manager
- The HDB manager creating the projectname
- The name of the projectneighborhood
- The neighborhood where the project is locatedflatInfoMap
- A map of flat types and their details (units, price)openDate
- The opening date for applicationscloseDate
- The closing date for applicationsofficerSlots
- The maximum number of officer slots for the project- Returns:
- The newly created Project object, or null if creation fails
-
editCoreProjectDetails
boolean editCoreProjectDetails(HDBManager manager, String projectId, String name, String neighborhood, LocalDate openDate, LocalDate closeDate, int officerSlots) Edits the core details of an existing project.Validates the changes against business rules, including: - Valid date range - Manager's eligibility and authorization - Officer slots within permitted range and not less than current approved count
- Parameters:
manager
- The HDB manager editing the projectprojectId
- The ID of the project to editname
- The new name of the projectneighborhood
- The new neighborhood of the projectopenDate
- The new opening date for applicationscloseDate
- The new closing date for applicationsofficerSlots
- The new maximum number of officer slots- Returns:
- true if the project was successfully updated, false otherwise
-
deleteProject
Deletes a project from the system.Deletion is only allowed if: - The project exists - The manager is authorized (is the project manager) - The project has no active applications
- Parameters:
manager
- The HDB manager requesting the deletionprojectId
- The ID of the project to delete- Returns:
- true if the project was successfully deleted, false otherwise
-
toggleVisibility
Toggles the visibility of a project between visible and hidden states.Only the project manager can toggle visibility. Hidden projects are not visible to applicants but remain accessible to staff.
- Parameters:
manager
- The HDB manager requesting the visibility changeprojectId
- The ID of the project to toggle visibility for- Returns:
- true if the visibility was successfully toggled, false otherwise
-
getAllProjects
Retrieves all projects accessible to a specific user, with optional filters.Staff can view all projects, while applicants can only view visible projects for which they are eligible. Filters can include criteria such as neighborhood, flat type, and visibility.
- Parameters:
user
- The user requesting the projectsfilters
- A map of optional filters to apply (neighborhood, flat type, visibility)- Returns:
- A list of projects matching the criteria
-
getProjectsManagedBy
Retrieves all projects managed by a specific manager.- Parameters:
managerNRIC
- The NRIC of the manager- Returns:
- A list of projects managed by the specified manager
-
getProjectsManagedBy
Retrieves all projects managed by a specific manager with optional filters.- Parameters:
managerNRIC
- The NRIC of the managerfilters
- A map of optional filters to apply (neighborhood, flat type, visibility)- Returns:
- A list of projects managed by the manager that match the filter criteria
-
findProjectById
Retrieves a project by its unique identifier.- Parameters:
projectId
- The ID of the project to retrieve- Returns:
- The Project object, or null if not found
-
getVisibleProjectsForUser
Retrieves all currently visible projects for which the user is eligible to apply.This is a convenience overload that calls getVisibleProjectsForUser with an empty filter map.
- Parameters:
user
- The user for whom to filter the projects- Returns:
- A list of visible projects for which the user is eligible
-
getVisibleProjectsForUser
Retrieves all currently visible projects for which the user is eligible to apply, filtered by the provided criteria.Project visibility and application closing date are checked, along with user-specific eligibility based on age, marital status, and flat types offered.
- Parameters:
user
- The user for whom to filter the projectsfilters
- A map of optional filters to apply (neighborhood, flat type)- Returns:
- A list of visible projects for which the user is eligible that match the filters
-
getProjectsAvailableForOfficerRegistration
Retrieves all projects available for an HDB Officer to register for.An officer can register for a project if: - They have not applied for the project as an applicant - They are not already registered for the project - They are not registered for another project with an overlapping application period
- Parameters:
officer
- The HDB Officer for whom to find available projects- Returns:
- A list of projects available for officer registration
-