Class RoomController
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.controller.RoomController
Defines the behaviour of the web server for the path
/rooms.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumRepresents templates in the resources, allowing one or several Rooms to be rendered as HTML. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRoomController(@NonNull RoomService roomService) Constructs a newRoomController. -
Method Summary
Modifier and TypeMethodDescriptionHandlesGETrequests to/räume/{number}.getRooms(int page, @Max(20L) int size, @NonNull String sortBy, boolean ascending, @NonNull org.springframework.ui.Model model) HandlesGETrequests to/rooms.@NonNull StringgetSchedule(@NonNull String number, @Nullable LocalDate date, @NonNull org.springframework.ui.Model model) HandlesGETrequests to/rooms/{number}/scheduleand returns theRoomSchedulefor theRoomwith the givenRoom.numberon the givenLocalDate.@NonNull StringgetWeekSchedule(@NonNull String number, @Nullable LocalDate date, @NonNull org.springframework.ui.Model model) HandlesGETrequests to/rooms/{number}/schedule/weekand returns the RoomSchedules for each day in the givenLocalDate's week for theRoomwith the givenRoom.numberon the givenLocalDate.
-
Field Details
-
roomService
-
-
Constructor Details
-
RoomController
Constructs a newRoomController.- Parameters:
roomService- TheroomServicefor database access.
-
-
Method Details
-
getRooms
@GetMapping({"/r\u00e4ume","/en/rooms"}) public String getRooms(@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, @NonNull @NonNull org.springframework.ui.Model model) HandlesGETrequests to/rooms. Retrieves a paginated subset of all Rooms 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 Rooms' 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 usingsortBy.model- Will be filled with the data for the Thymeleaf template.- Returns:
- The
reservations.htmlpage with the requested reservations.
-
getRoom
@ExceptionHandler(IllegalStateException.class) @GetMapping({"/r\u00e4ume/{number}","/en/rooms/{number}"}) public String getRoom(@NonNull @PathVariable @NonNull String number, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException HandlesGETrequests to/räume/{number}. Retrieves a specificRoomdenoted by the path parameternumber.- Parameters:
number- The path parameter{number}denoting a specific Room.model- Will be filled with the data for the Thymeleaf template.- Returns:
- The
room.htmltemplate filled with the requested Room. - Throws:
NotFoundException- If no Room with the given number exists.
-
getSchedule
@GetMapping({"/r\u00e4ume/{number}/plan","/en/rooms/{number}/schedule"}) @NonNull public @NonNull String getSchedule(@NonNull @PathVariable @NonNull String number, @Nullable @Nullable LocalDate date, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException HandlesGETrequests to/rooms/{number}/scheduleand returns theRoomSchedulefor theRoomwith the givenRoom.numberon the givenLocalDate.- Parameters:
number- The number of the Room whose schedule shall be returned.date- The day for which the Room's schedule shall be built.model- Will be filled with the data for the Thymeleaf template.- Returns:
- The
RoomController.Template.SCHEDULEpage. - Throws:
NotFoundException- If the given Room number does not belong to any Room.
-
getWeekSchedule
@GetMapping({"/r\u00e4ume/{number}/plan/woche","/en/rooms/{number}/schedule/week"}) @NonNull public @NonNull String getWeekSchedule(@NonNull @PathVariable @NonNull String number, @Nullable @Nullable LocalDate date, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException HandlesGETrequests to/rooms/{number}/schedule/weekand returns the RoomSchedules for each day in the givenLocalDate's week for theRoomwith the givenRoom.numberon the givenLocalDate.- Parameters:
number- The number of the Room whose schedule shall be returned.date- The Room's schedule will be built for the week that contains this date.model- Will be filled with the data for the Thymeleaf template.- Returns:
- The
RoomController.Template.SCHEDULEpage. - Throws:
NotFoundException- If the given Room number does not belong to any Room.
-