Class ReservationAdminController

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

@Controller public class ReservationAdminController extends Object
Defines the behaviour of the web server for the path /admin/reservations.
  • Field Details

  • Constructor Details

  • Method Details

    • getReservations

      @GetMapping({"/admin/reservierungen","/en/admin/reservations"}) @PreAuthorize("hasRole('FACULTY_ADMINISTRATION')") @NonNull public @NonNull String getReservations(@RequestParam(name="page",defaultValue="0") int page, @Max(20L) @RequestParam(name="size",defaultValue="2") @Max(20L) int size, @NonNull @RequestParam(name="sortBy",defaultValue="id") @NonNull String sortBy, @RequestParam(name="ascending",defaultValue="true") boolean ascending, @Nullable @Nullable FilterReservationsDTO filterReservationsDTO, @NonNull @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull @NonNull org.springframework.ui.Model model, org.springframework.validation.BindingResult bindingResult) throws NotFoundException

      Handles GET requests to /admin/reservations. Retrieves a paginated 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.
      response - The web server's response to the admin's HTTP request.
      model - Will be filled with the data for the Thymeleaf template.
      bindingResult - The result of the DTO validation.
      Returns:
      The reservations.html page with the requested reservations.
      Throws:
      NotFoundException - When the user requests the Reservations for an inexistent Room.number.
    • getReservation

      @GetMapping({"/admin/reservierungen/{id}","/en/admin/reservations/{id}"}) public String getReservation(@NonNull @PathVariable @NonNull Long id, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException
      Handles GET requests to /admin/reservations/{id}. Retrieves a specific Reservation denoted by the path parameter id.
      Parameters:
      id - The path parameter id denoting a specific Reservation.
      model - Will be filled with the data for the Thymeleaf template.
      Returns:
      The reservation.html template filled with the requested Reservation.
      Throws:
      NotFoundException - If no Reservation with the given ID exists.
    • getDeletionPage

      @GetMapping({"/admin/reservierungen/{id}/l\u00f6schen","/en/admin/reservations/{id}/delete"}) @NonNull public @NonNull String getDeletionPage(@NonNull @PathVariable @NonNull Long id, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException
      Shows a confirmation page asking the user whether they are sure they wish to permanently remove the Reservation with the given Reservation.id from the database.
      Parameters:
      id - The identifier of the Reservation that the user perhaps wishes to delete.
      model - Will be filled with the Reservation to be deleted, for the Thymeleaf template.
      Returns:
      The ReservationAdminController.Template.DELETE filled with the Reservation to be deleted.
      Throws:
      NotFoundException - If no Reservation with the given ID exists.
    • deleteReservation

      @PostMapping({"/admin/reservierungen/{id}/l\u00f6schen","/en/admin/reservations/{id}/delete"}) @NonNull public @NonNull String deleteReservation(@NonNull @PathVariable @NonNull Long id, @NonNull @NonNull Locale locale) throws NotFoundException, IllegalStateException
      Handles POST requests to /admin/reservations/{id}/delete and permanently removes the Reservation with the given Reservation.id from the database.
      Parameters:
      id - The identifier of the Reservation that shall no longer be stored in the system.
      locale - The language that this page is being shown in.
      Returns:
      Redirects to the list of all reservations.
      Throws:
      NotFoundException - If no Reservation with the given ID exists.
      IllegalStateException - If the reservations' path is malformed.
    • performMultiAction

      @PostMapping({"/admin/reservierungen/multi-aktion","/en/admin/reservations/multi-action"}) @NonNull public @NonNull String performMultiAction(@NonNull @NonNull ReservationMultiActionRequest requestDto, @NonNull @NonNull org.springframework.ui.Model model) throws de.gustavblass.commons.exceptions.IllegalArgumentException
      Handles POST requests to /admin/reservations/multi-action and performs the appropriate operation according to the given ReservationMultiActionRequest.action.
      Parameters:
      requestDto - The data-transfer object that represents the actual request.
      model - Used to indicate to the template that this is an admin page.
      Returns:
      A confirmation page where the user states once again that they intend to perform the operation specified.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the given action is not supported.
    • massDelete

      @PostMapping({"/admin/reservierungen/l\u00f6schen","/en/admin/reservations/delete"}) @NonNull public @NonNull String massDelete(@NonNull @NonNull ReservationMultiActionRequest requestDto, @NonNull @NonNull org.springframework.ui.Model model) throws de.gustavblass.commons.exceptions.IllegalArgumentException, NotFoundException
      Handles POST requests to /admin/reservations/delete and mass deletes the Reservations with the identifiers that are specified in the given data-transfer object.
      Parameters:
      requestDto - The data-transfer object representing the actual request.
      model - Used to indicate to the template that it is not an administrator page.
      Returns:
      A confirmation page telling the user that the deletion succeeded.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the user did not confirm the operation.
      NotFoundException - If at least one of the given IDs does not exist in the database. Then, no Reservation is deleted.