Class BookingService
- All Implemented Interfaces:
IBookingService
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 Summary
ConstructorsConstructorDescriptionBookingService
(IApplicationRepository appRepo, IProjectRepository projRepo, IBookingRepository bookingRepo, IUserRepository userRepo) Constructs a new BookingService with the specified repositories. -
Method Summary
Modifier and TypeMethodDescriptiongetBookingsByProject
(String projectId) Retrieves all bookings associated with a specific project.performBooking
(HDBOfficer officer, String applicantNRIC, FlatType flatType) Performs a booking operation for an applicant by an HDB officer.
-
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 entitiesprojRepo
- Repository for Project entitiesbookingRepo
- Repository for Booking entitiesuserRepo
- 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 interfaceIBookingService
- Parameters:
officer
- The HDB officer performing the booking operationapplicantNRIC
- The NRIC of the applicant for whom the booking is being madeflatType
- The type of flat being booked- Returns:
- The newly created Booking object
- Throws:
BookingException
- If there is an issue with the booking process
-
getBookingsByProject
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 interfaceIBookingService
- 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
-