Interface IProjectService

All Known Implementing Classes:
ProjectService

public interface IProjectService
Service interface for project-related operations in the BTO Management System.

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 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 project
      name - The name of the project
      neighborhood - The neighborhood where the project is located
      flatInfoMap - A map of flat types and their details (units, price)
      openDate - The opening date for applications
      closeDate - The closing date for applications
      officerSlots - 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 project
      projectId - The ID of the project to edit
      name - The new name of the project
      neighborhood - The new neighborhood of the project
      openDate - The new opening date for applications
      closeDate - The new closing date for applications
      officerSlots - The new maximum number of officer slots
      Returns:
      true if the project was successfully updated, false otherwise
    • deleteProject

      boolean deleteProject(HDBManager manager, String projectId)
      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 deletion
      projectId - The ID of the project to delete
      Returns:
      true if the project was successfully deleted, false otherwise
    • toggleVisibility

      boolean toggleVisibility(HDBManager manager, String projectId)
      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 change
      projectId - The ID of the project to toggle visibility for
      Returns:
      true if the visibility was successfully toggled, false otherwise
    • getAllProjects

      List<Project> getAllProjects(User user, Map<String,Object> filters)
      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 projects
      filters - A map of optional filters to apply (neighborhood, flat type, visibility)
      Returns:
      A list of projects matching the criteria
    • getProjectsManagedBy

      List<Project> getProjectsManagedBy(String managerNRIC)
      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

      List<Project> getProjectsManagedBy(String managerNRIC, Map<String,Object> filters)
      Retrieves all projects managed by a specific manager with optional filters.
      Parameters:
      managerNRIC - The NRIC of the manager
      filters - 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

      Project findProjectById(String projectId)
      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

      List<Project> getVisibleProjectsForUser(User user)
      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

      List<Project> 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.

      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 projects
      filters - 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

      List<Project> getProjectsAvailableForOfficerRegistration(HDBOfficer officer)
      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