Interface BookingService
- All Known Implementing Classes:
TransactionalBookingService
public interface BookingService
This interface provides methods for operating on repositories of the booking application.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves all the clients saved in the database.Retrieves all the reservations saved in the database.findClient
(UUID id) Retrieves the client with the specified id from the database.findClientNamed
(String firstName, String lastName) Retrieves the client with specified name and surname from the database.findReservation
(UUID id) Retrieves the reservation with the specified id from the database.findReservationOn
(LocalDate date) Retrieves the reservation of the specified date from the database.insertNewClient
(Client client) Adds a new client in the database.insertNewReservation
(Reservation reservation) Adds a new reservation in the database.void
removeClient
(UUID id) Deletes the client with the specified id and all his reservation from the database.void
removeClientNamed
(String firstName, String lastName) Deletes the client with specified name and surname and all his reservation from the database.void
Deletes the reservation with the specified id from the database.void
removeReservationOn
(LocalDate date) Deletes the reservation on the specified date from the database.renameClient
(UUID id, String newFirstName, String newLastName) Changes name and surname of the client with the specified id in the database.rescheduleReservation
(UUID id, LocalDate newDate) Changes date of the reservation with the specified id in the database.
-
Method Details
-
findAllClients
Retrieves all the clients saved in the database.- Returns:
- the list of clients found in the database.
- Throws:
DatabaseException
- if a database error occurs.
-
findAllReservations
List<Reservation> findAllReservations()Retrieves all the reservations saved in the database.- Returns:
- the list of reservations found in the database.
- Throws:
DatabaseException
- if a database error occurs.
-
findClient
Retrieves the client with the specified id from the database.- Parameters:
id
- the identifier of the client to find.- Returns:
- the
Client
identified byid
. - Throws:
InstanceNotFoundException
- if there is no client with that id in the database.DatabaseException
- if a database error occurs.
-
findReservation
Retrieves the reservation with the specified id from the database.- Parameters:
id
- the identifier of the reservation to find.- Returns:
- the
Reservation
identified byid
. - Throws:
InstanceNotFoundException
- if there is no reservation with that id in the database.DatabaseException
- if a database error occurs.
-
findClientNamed
Client findClientNamed(String firstName, String lastName) throws InstanceNotFoundException, DatabaseException Retrieves the client with specified name and surname from the database.- Parameters:
firstName
- the name of the client to find.lastName
- the surname of the client to find.- Returns:
- the
Client
namedfirstName
andlastName
. - Throws:
InstanceNotFoundException
- if there is no client with those names in the database.DatabaseException
- if a database error occurs.
-
findReservationOn
Retrieves the reservation of the specified date from the database.- Parameters:
date
- the date of the reservation to find.- Returns:
- the
Reservation
ondate
. - Throws:
InstanceNotFoundException
- if there is no reservation on that date in the database.DatabaseException
- if a database error occurs.
-
insertNewClient
Adds a new client in the database.- Parameters:
client
- the client to insert.- Returns:
- the
Client
inserted. - Throws:
InstanceAlreadyExistsException
- ifclient
is already in the database.DatabaseException
- if a database error occurs.
-
insertNewReservation
Reservation insertNewReservation(Reservation reservation) throws InstanceAlreadyExistsException, InstanceNotFoundException, DatabaseException Adds a new reservation in the database.- Parameters:
reservation
- the reservation to insert.- Returns:
- the
Reservation
inserted. - Throws:
InstanceAlreadyExistsException
- ifreservation
is already in the database.InstanceNotFoundException
- if the associatedclient
doesn't exist in the database.DatabaseException
- if a database error occurs.
-
removeClient
Deletes the client with the specified id and all his reservation from the database.- Parameters:
id
- the identifier of the client to remove.- Throws:
InstanceNotFoundException
- if there is no client with that identifier in the database.DatabaseException
- if a database error occurs.
-
removeReservation
Deletes the reservation with the specified id from the database.- Parameters:
id
- the identifier of the reservation to remove.- Throws:
InstanceNotFoundException
- if there is no reservation with that identifier in the database.DatabaseException
- if a database error occurs.
-
removeClientNamed
void removeClientNamed(String firstName, String lastName) throws InstanceNotFoundException, DatabaseException Deletes the client with specified name and surname and all his reservation from the database.- Parameters:
firstName
- the name of the client to remove.lastName
- the surname of the client to remove.- Throws:
InstanceNotFoundException
- if there is no client with those names in the database.DatabaseException
- if a database error occurs.
-
removeReservationOn
Deletes the reservation on the specified date from the database.- Parameters:
date
- the date of the reservation to remove.- Throws:
InstanceNotFoundException
- if there is no reservation on that date in the database.DatabaseException
- if a database error occurs.
-
renameClient
Client renameClient(UUID id, String newFirstName, String newLastName) throws InstanceNotFoundException, InstanceAlreadyExistsException, DatabaseException Changes name and surname of the client with the specified id in the database.- Parameters:
id
- the identifier of the client to rename.newFirstName
- the new name for the client.newLastName
- the new surname for the client.- Returns:
- the
Client
renamed. - Throws:
InstanceNotFoundException
- if there is noclient
with specified id in the database.InstanceAlreadyExistsException
- if aClient
with those names is already in the database.DatabaseException
- if a database error occurs.
-
rescheduleReservation
Reservation rescheduleReservation(UUID id, LocalDate newDate) throws InstanceNotFoundException, InstanceAlreadyExistsException, DatabaseException Changes date of the reservation with the specified id in the database.- Parameters:
id
- the identifier of the reservation to reschedule.newDate
- the new date for the reservation.- Returns:
- the
Reservation
rescheduled. - Throws:
InstanceNotFoundException
- if there is noreservation
with specified id in the database.InstanceAlreadyExistsException
- if areservation
with that date is already in the database.DatabaseException
- if a database error occurs.
-