Class ProjectController
java.lang.Object
com.ntu.fdae.group1.bto.controllers.project.ProjectController
Controller for project-related operations
-
Constructor Summary
ConstructorsConstructorDescriptionProjectController
(IProjectService projectService) Constructs a new ProjectController -
Method Summary
Modifier and TypeMethodDescriptioncreateProject
(HDBManager manager, String name, String neighborhood, Map<String, ProjectFlatInfo> flatInfoMap, LocalDate openDate, LocalDate closeDate, int officerSlots) Creates a new projectboolean
deleteProject
(HDBManager manager, String projectId) Deletes a projectboolean
editProject
(HDBManager manager, String projectId, String name, String neighborhood, LocalDate openDate, LocalDate closeDate, int officerSlots) Edits an existing projectfindProjectById
(String projectId) Finds a project by its IDgetAllProjects
(User user, Map<String, Object> filter) Retrieves all projects in the system, with optional filtering.Gets projects potentially available for the given officer to register for handling.getProjectsManagedBy
(HDBManager manager) Gets projects managed by a specific HDB Manager object.getProjectsManagedBy
(HDBManager manager, Map<String, Object> filters) Retrieves projects managed by a specific HDB manager, with optional filtering.Gets projects visible to a user (without additional filters).getVisibleProjectsForUser
(User user, Map<String, Object> filters) Retrieves projects that are visible to a specific user, with optional filtering.boolean
toggleProjectVisibility
(HDBManager manager, String projectId) Toggles the visibility of a project
-
Constructor Details
-
ProjectController
Constructs a new ProjectController- Parameters:
projectService
- The project service to use
-
-
Method Details
-
createProject
public Project createProject(HDBManager manager, String name, String neighborhood, Map<String, ProjectFlatInfo> flatInfoMap, LocalDate openDate, LocalDate closeDate, int officerSlots) Creates a new project- Parameters:
manager
- The manager creating the projectname
- Project nameneighborhood
- Project locationflatInfoMap
- Information about flat typesopenDate
- Opening date for applicationscloseDate
- Closing date for applicationsofficerSlots
- Number of slots for officers- Returns:
- The created project
-
editProject
public boolean editProject(HDBManager manager, String projectId, String name, String neighborhood, LocalDate openDate, LocalDate closeDate, int officerSlots) Edits an existing project- Parameters:
manager
- The manager editing the projectprojectId
- ID of the project to editname
- New nameneighborhood
- New locationopenDate
- New opening datecloseDate
- New closing dateofficerSlots
- New number of officer slots- Returns:
- true if edit was successful, false otherwise
-
deleteProject
Deletes a project- Parameters:
manager
- The manager deleting the projectprojectId
- ID of the project to delete- Returns:
- true if deletion was successful, false otherwise
-
toggleProjectVisibility
Toggles the visibility of a project- Parameters:
manager
- The manager toggling visibilityprojectId
- ID of the project to toggle- Returns:
- true if toggle was successful, false otherwise
-
getVisibleProjectsForUser
Gets projects visible to a user (without additional filters).- Parameters:
user
- The user to get visible projects for- Returns:
- List of visible projects
-
getVisibleProjectsForUser
Retrieves projects that are visible to a specific user, with optional filtering.- Parameters:
user
- The user for whom to retrieve visible projectsfilters
- Optional filters to apply to the results (e.g., neighborhood, flat types)- Returns:
- A list of projects visible to the user, filtered as specified
-
getAllProjects
public List<Project> getAllProjects(User user, Map<String, Object> filter) throws AuthorizationExceptionRetrieves all projects in the system, with optional filtering.This method is restricted to HDB staff members and will throw an exception if accessed by regular applicants.
- Parameters:
user
- The user requesting the projects (must be HDB staff)filter
- Optional filters to apply to the results (e.g., neighborhood, flat types)- Returns:
- A list of all projects, filtered as specified
- Throws:
AuthorizationException
- If the user is not authorized to view all projects
-
getProjectsManagedBy
Gets projects managed by a specific HDB Manager object.- Parameters:
manager
- The HDBManager object.- Returns:
- List of projects managed by the manager.
-
getProjectsManagedBy
Retrieves projects managed by a specific HDB manager, with optional filtering.- Parameters:
manager
- The HDB manager whose projects to retrievefilters
- Optional filters to apply to the results (e.g., neighborhood, flat types)- Returns:
- A list of projects managed by the specified manager, filtered as specified
-
findProjectById
Finds a project by its ID- Parameters:
projectId
- ID of the project to find- Returns:
- The project, or null if not found
-
getProjectsAvailableForRegistration
Gets projects potentially available for the given officer to register for handling. Delegates filtering logic (e.g., excluding projects already applied for or registered for) to the ProjectService.- Parameters:
officer
- The HDBOfficer requesting the list. Must not be null.- Returns:
- A List of Project objects available for registration, sorted by name.
- Throws:
IllegalArgumentException
- if officer is null.RuntimeException
- if an unexpected error occurs during retrieval.
-