Class ReservationAdminRestController

java.lang.Object
de.gustavblass.fsu.fmi.roombooking.controller.admin.ReservationAdminRestController

@RestController public class ReservationAdminRestController extends Object
Defines the behaviour of the API server for the path /api/v1/admin/reservations.
  • Field Details

  • Constructor Details

  • Method Details

    • getReservations

      public org.springframework.hateoas.PagedModel<org.springframework.hateoas.EntityModel<ReservationSummaryDTO>> getReservations(@RequestParam(name="page",defaultValue="0") int page, @Max(20L) @RequestParam(name="size",defaultValue="5") @Max(20L) int size, @NonNull @RequestParam(name="sortBy",defaultValue="id") @NonNull String sortBy, @RequestParam(name="ascending",defaultValue="true") boolean ascending)
      Retrieves a paginated subset of all Reservations according to the URL parameters given.
      Parameters:
      page - The index of the page requested.
      size - How many Reservation items each page in the pagination has.
      sortBy - Which of the Reservations' fields shall be used to sort the items. Determines the order of the items and thereby also which items are present on the requested page.
      ascending - Whether to count from the start or from the end of the list sorted using sortBy.
      Returns:
      The specified subset of all Reservations as summarised data-transfer objects.
      Implementation Note:
      Does not handle HTTP requests, but serves as a fallback for getReservations(int, int, String, boolean, FilterReservationsDTO).
    • getReservations

      @GetMapping("/api/v1/admin/reservations") public org.springframework.hateoas.CollectionModel<org.springframework.hateoas.EntityModel<ReservationSummaryDTO>> getReservations(@RequestParam(name="page",defaultValue="0") int page, @Max(20L) @RequestParam(name="size",defaultValue="5") @Max(20L) int size, @NonNull @RequestParam(name="sortBy",defaultValue="id") @NonNull String sortBy, @RequestParam(name="ascending",defaultValue="true") boolean ascending, @Nullable @Nullable FilterReservationsDTO filterReservationsDTO) throws NotFoundException, de.gustavblass.commons.exceptions.IllegalArgumentException

      Handles GET requests to /api/v1/admin/reservations. Retrieves a paginated or filtered subset of all Reservations according to the URL parameters given.

      The paging parameters page, size, sortBy and ascending are ignored if any of the filtering parameters is set (roomNumber, dateString, startTimeString, endTimeString).

      Parameters:
      page - The index of the page requested.
      size - How many Reservation items each page in the pagination has.
      sortBy - Which of the Reservations' fields shall be used to sort the items. Determines the order of the items and thereby also which items are present on the requested page.
      ascending - Whether to count from the start or from the end of the list sorted using sortBy.
      filterReservationsDTO - Filtering parameters indicating what criteria the requested Reservations must fulfil.
      Returns:
      The specified subset of all Reservations as summarised data-transfer objects.
      Throws:
      NotFoundException - When the user requests the Reservations for an inexistent Room.number.
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the start time is not before the end time.
    • getReservation

      @GetMapping("/api/v1/admin/reservations/{id}") @NonNull public @NonNull org.springframework.hateoas.EntityModel<ReservationDTO> getReservation(@NonNull @PathVariable @NonNull Long id) throws NotFoundException
      Handles GET requests to /api/v1/admin/reservations/{id} and fetches the Reservation with the specified Reservation.id from the database, converts it to an ReservationDTO object and returns that.
      Parameters:
      id - The ID of the Reservation that shall be returned.
      Returns:
      The requested Reservation, represented as a data-transfer object.
      Throws:
      NotFoundException - If there is no Reservation with the given ID.
    • deleteReservation

      @DeleteMapping("/api/v1/admin/reservations/{id}") @NonNull public @NonNull org.springframework.http.ResponseEntity<Void> deleteReservation(@Min(0L) @PathVariable @Min(0L) Long id) throws NotFoundException
      Handles DELETE requests to /api/v1/admin/reservations/{id} and removes the Reservation with the given Reservation.id from the database.
      Parameters:
      id - The identifier whose corresponding Reservation shall no longer be present in the system.
      Returns:
      Empty response. Only the status code indicates success.
      Throws:
      NotFoundException - If no Reservation with the given ID exists.
    • deleteReservation

      @DeleteMapping("/api/v1/admin/reservations") @NonNull public @NonNull org.springframework.http.ResponseEntity<Void> deleteReservation(@NonNull @RequestParam(name="id") @NonNull ArrayList<Long> ids) throws NotFoundException
      Handles DELETE requests to /api/v1/admin/reservations and mass-removes all Reservations with the given IDs from the database.
      Parameters:
      ids - The identifiers of the Reservations that shall no longer be stored.
      Returns:
      Empty response. Only the status code indicates success.
      Throws:
      NotFoundException - If at least one ID does not exist. Then, no Reservation is deleted.