Class BookingService

java.lang.Object
com.ntu.fdae.group1.bto.services.booking.BookingService
All Implemented Interfaces:
IBookingService

public class BookingService extends Object implements IBookingService
Implementation of the IBookingService interface that provides booking functionality for the BTO Management System.

This service is responsible for managing the booking process, including creating new bookings, retrieving booking information, and handling booking cancellations. It implements all the business logic related to the booking process.

  • Constructor Details

    • BookingService

      public BookingService(IApplicationRepository appRepo, IProjectRepository projRepo, IBookingRepository bookingRepo, IUserRepository userRepo)
      Constructs a new BookingService with the specified repositories.
      Parameters:
      appRepo - Repository for Application entities
      projRepo - Repository for Project entities
      bookingRepo - Repository for Booking entities
      userRepo - Repository for User entities
  • Method Details

    • performBooking

      public Booking performBooking(HDBOfficer officer, String applicantNRIC, FlatType flatType) throws BookingException
      Performs a booking operation for an applicant by an HDB officer.

      This method handles the complete booking process including: 1. Validating the officer's authorization to perform bookings 2. Checking the applicant's eligibility for the specified flat type 3. Creating and persisting the booking record

      Implementation details: - Validates that the officer has permission to create bookings - Validates the applicant exists and has an application for the project - Checks if the flat type requested is available - Creates and saves a booking record

      Specified by:
      performBooking in interface IBookingService
      Parameters:
      officer - The HDB officer performing the booking operation
      applicantNRIC - The NRIC of the applicant for whom the booking is being made
      flatType - The type of flat being booked
      Returns:
      The newly created Booking object
      Throws:
      BookingException - If there is an issue with the booking process
    • getBookingsByProject

      public List<Booking> getBookingsByProject(String projectId) throws BookingException
      Retrieves all bookings associated with a specific project.

      This method allows for retrieving and analyzing all bookings that have been made for a particular HDB project.

      Specified by:
      getBookingsByProject in interface IBookingService
      Parameters:
      projectId - The unique identifier of the project
      Returns:
      A list of Booking objects associated with the specified project
      Throws:
      BookingException - If there is an error retrieving the bookings