Class EquipmentAdminController

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

@Controller public class EquipmentAdminController extends Object
Defines the behaviour of the API server for the path /admin/equipment.
  • Field Details

  • Constructor Details

  • Method Details

    • getEquipmentTypes

      @GetMapping({"/admin/ausstattung","/en/admin/equipment"}) @NonNull public @NonNull String getEquipmentTypes(@NonNull @NonNull EquipmentTypeDTO equipmentTypeDTO, @NonNull @NonNull org.springframework.ui.Model model)
      Handles GET requests to /admin/equipment.
      Parameters:
      equipmentTypeDTO - An empty EquipmentTypeDTO only used for binding in the Thymeleaf template.
      model - Used to add the existing EquipmentTypes to the form.
      Returns:
      The admins' equipment page.
    • getCreateEquipmentTypeForm

      @GetMapping({"/admin/ausstattung/neu","/en/admin/equipment/new"}) @NonNull public @NonNull String getCreateEquipmentTypeForm(@NonNull @NonNull EquipmentTypeDTO equipmentTypeDTO, @NonNull @NonNull org.springframework.ui.Model model)
      Handles GET requests to /admin/equipment.
      Parameters:
      equipmentTypeDTO - An empty EquipmentTypeDTO only used for binding in the Thymeleaf template.
      model - Used to add the existing EquipmentTypes to the form.
      Returns:
      The admins' equipment page.
    • createEquipmentType

      @PostMapping({"/admin/ausstattung/neu","/en/admin/equipment/new"}) @NonNull public @NonNull String createEquipmentType(@Valid @NonNull @Valid @NonNull EquipmentTypeDTO dto, @NonNull @NonNull org.springframework.validation.BindingResult bindingResult, @NonNull @NonNull org.springframework.ui.Model model, @NonNull @NonNull jakarta.servlet.http.HttpServletResponse response) throws IllegalStateException, InvalidEquipmentException
      Handles POST requests to /admin/equipment/new and adds the given EquipmentTypeDTO as a new EquipmentType to the database.
      Parameters:
      dto - The data-transfer object that represents the new EquipmentType. Must be valid according to the annotations on the class fields
      bindingResult - The result of the DTO validation.
      model - Used to add the existing EquipmentTypes to the form.
      response - The web server's response to the admin's HTTP request.
      Returns:
      In case of success: The equipment page. Otherwise: The form, with the original input preserved and with error messages shown.
      Throws:
      InvalidEquipmentException - If the EquipmentTypeDTO.type is invalid.
      IllegalStateException - If the equipment path is malformed.
    • getDeleteTypeConfirmationPage

      @GetMapping({"/admin/ausstattung/{name}/l\u00f6schen","/en/admin/equipment/{name}/delete"}) @NonNull public @NonNull String getDeleteTypeConfirmationPage(@NonNull @PathVariable @NonNull String name, @NonNull @NonNull org.springframework.ui.Model model) throws NotFoundException, de.gustavblass.commons.exceptions.IllegalArgumentException
      Handles GET requests to /admin/equipment/{name}/delete and asks the user whether they really wish to delete the EquipmentType with the given EquipmentType.name from the database.
      Parameters:
      name - The title of the EquipmentType to be deleted.
      model - Used to display the details of the EquipmentType.
      Returns:
      A confirmation form.
      Throws:
      NotFoundException - If the given EquipmentType does not exist.
      de.gustavblass.commons.exceptions.IllegalArgumentException - See EquipmentTypeMapper.toDto(EquipmentType).
    • deleteEquipmentType

      @PostMapping({"/admin/ausstattung/{name}/l\u00f6schen","/en/admin/equipment/delete"}) @NonNull public @NonNull String deleteEquipmentType(@NonNull @PathVariable @NonNull String name, @NonNull @NonNull Locale locale) throws NotFoundException, IllegalStateException
      Removes the EquipmentType with the given EquipmentType.name from the database if existent. Also removes all RoomEquipment that has the RoomEquipment.type that shall be deleted.
      Parameters:
      name - The title of the EquipmentType to delete.
      locale - The language of the request.
      Returns:
      Redirects to the list of all equipment types.
      Throws:
      NotFoundException - If no EquipmentType with the given name exists.
      IllegalStateException - If the equipment URL is malformed.