Class AdminController

java.lang.Object
balu.pizza.webapp.controllers.AdminController

@Controller @PreAuthorize("hasRole(\'ADMIN\')") @RequestMapping("/admin") public class AdminController extends Object
Administrator controller

This functionality is only available to administrators

  • Constructor Summary

    Constructors
    Constructor
    Description
    AdminController(UserUtil userUtil, TypeService typeService, IngredientService ingredientService, BaseService baseService, PizzaService pizzaService, CafeService cafeService, IngredientValidator ingredientValidator, TypeValidator typeValidator, BaseValidator baseValidator, PizzaValidator pizzaValidator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addBase(Base base, org.springframework.ui.Model model)
    Creating a new type of ingredient
    addCafe(Cafe cafe, org.springframework.ui.Model model)
    Creating a new cafe
    addIngredient(org.springframework.ui.Model model, Ingredient ingredient, TypeIngredient typeIngredient)
    Add ingredient page
    addPizza(Pizza pizza, Base base, Ingredient ingredient, org.springframework.ui.Model model)
    Creating a new pizza
    addTypeIngredient(TypeIngredient type, org.springframework.ui.Model model)
    Creating a new type of ingredient
    choiceBase(Base base, org.springframework.ui.Model model)
    generating a page for selecting the base to be edited
    choiceIngredient(org.springframework.ui.Model model)
    Generating a page for selecting the ingredient to be edited
    choiceTypeForEdit(TypeIngredient type, org.springframework.ui.Model model)
    generating a page for selecting the type of ingredient to be edited
    createBase(@Valid Base base, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
    Validating and writing to the database of the created base
    createCafe(@Valid Cafe cafe, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
    Validating and writing to the database of the created cafe
    createIngredient(@Valid Ingredient ingredient, org.springframework.validation.BindingResult bindingResult, TypeIngredient typeIngredient, org.springframework.ui.Model model)
    Validating and writing to the database of the created ingredient
    createType(@Valid TypeIngredient type, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
    Validating and writing to the database of the created type ingredient
    creatPizza(@Valid Pizza pizza, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
    Validating and writing to the database of the created pizza
    editBase(Base base, org.springframework.ui.Model model)
    Page with base edit form
    editCafePage(int cafeId, org.springframework.ui.Model model, Cafe cafe)
    Page with cafe edit form
    editIngredient(int ingrId, org.springframework.ui.Model model)
    Page with pizza edit form
    editPizza(int pizzaId, org.springframework.ui.Model model)
    Page with pizza edit form
    editType(TypeIngredient type, org.springframework.ui.Model model)
    Page with type edit form
    indexAdmin(org.springframework.ui.Model model)
    Admin Panel
    selectCafeForEdit(org.springframework.ui.Model model)
    Generating a page for selecting the cafe to be edited
    selectPizzaForEdit(org.springframework.ui.Model model)
    Generating a page for selecting the pizza to be edited
    updateBase(@Valid Base base, org.springframework.validation.BindingResult bindingResult, int baseId, org.springframework.ui.Model model)
    Validating and writing to the database of the updated base
    updateCafe(@Valid Cafe cafe, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, int cafeId)
    Validating and writing to the database of the updated cafe
    updateIngredient(@Valid Ingredient ingredient, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, int ingrId)
    Validating and writing to the database of the updated ingredient
    updatePizza(@Valid Pizza pizza, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, int pizzaId)
    Validating and writing to the database of the updated pizza
    updateType(@Valid TypeIngredient type, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, int typeId)
    Validating and writing to the database of the updated type

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AdminController

      @Autowired public AdminController(UserUtil userUtil, TypeService typeService, IngredientService ingredientService, BaseService baseService, PizzaService pizzaService, CafeService cafeService, IngredientValidator ingredientValidator, TypeValidator typeValidator, BaseValidator baseValidator, PizzaValidator pizzaValidator)
      Parameters:
      userUtil - Set of utilities
      typeService - Ingredient type service
      ingredientService - Ingredient service
      baseService - Base of pizza service
      pizzaService - Pizza service
      cafeService - Cafe service
      ingredientValidator - Validator for ingredient data entry
      typeValidator - Validator for type ingredient data entry
      baseValidator - Validator for base data entry
      pizzaValidator - Validator for pizza data entry
  • Method Details

    • indexAdmin

      @GetMapping public String indexAdmin(org.springframework.ui.Model model)
      Admin Panel

      admin panel

      Parameters:
      model -
      Returns:
      generates a page for the route /admin
    • addIngredient

      @GetMapping("/add/ingredient") public String addIngredient(org.springframework.ui.Model model, @ModelAttribute("ingredient") Ingredient ingredient, @ModelAttribute("type") TypeIngredient typeIngredient)
      Add ingredient page

      admin panel

      Parameters:
      model -
      ingredient -
      typeIngredient -
      Returns:
      generates a page for the route /admin/add/ingredient
    • createIngredient

      @PostMapping("/add/ingredient") public String createIngredient(@ModelAttribute("ingredient") @Valid @Valid Ingredient ingredient, org.springframework.validation.BindingResult bindingResult, @ModelAttribute("type") TypeIngredient typeIngredient, org.springframework.ui.Model model)
      Validating and writing to the database of the created ingredient
      Parameters:
      ingredient -
      bindingResult -
      typeIngredient -
      model -
      Returns:
      redirect to the admin panel page
    • addTypeIngredient

      @GetMapping("/add/type_ingredient") public String addTypeIngredient(@ModelAttribute("type") TypeIngredient type, org.springframework.ui.Model model)
      Creating a new type of ingredient

      admin panel

      Parameters:
      type -
      model -
      Returns:
      generates a page for the route /admin/add/type_ingredient
    • createType

      @PostMapping("/add/type_ingredient") public String createType(@ModelAttribute("type") @Valid @Valid TypeIngredient type, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
      Validating and writing to the database of the created type ingredient
      Parameters:
      type -
      bindingResult -
      model -
      Returns:
      redirect to the admin panel page
    • addBase

      @GetMapping("/add/base") public String addBase(@ModelAttribute("base") Base base, org.springframework.ui.Model model)
      Creating a new type of ingredient

      admin panel

      Parameters:
      base -
      model -
      Returns:
      generates a page for the route /admin/add/base
    • createBase

      @PostMapping("add/base") public String createBase(@ModelAttribute("base") @Valid @Valid Base base, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
      Validating and writing to the database of the created base
      Parameters:
      base -
      bindingResult -
      model -
      Returns:
      redirect to the admin panel page
    • choiceTypeForEdit

      @GetMapping("edit/type") public String choiceTypeForEdit(@ModelAttribute("type") TypeIngredient type, org.springframework.ui.Model model)
      generating a page for selecting the type of ingredient to be edited

      admin panel

      Parameters:
      type -
      model -
      Returns:
      generates a page for the route /admin/edit/type
    • editType

      @PostMapping("edit/type") public String editType(@ModelAttribute("type") TypeIngredient type, org.springframework.ui.Model model)
      Page with type edit form
      Parameters:
      type -
      model -
      Returns:
      sends a request to change the data
    • updateType

      @PatchMapping("edit/type/{id}") public String updateType(@ModelAttribute("type") @Valid @Valid TypeIngredient type, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, @PathVariable("id") int typeId)
      Validating and writing to the database of the updated type
      Parameters:
      type -
      bindingResult -
      model -
      typeId -
      Returns:
      redirect to the admin panel page
    • choiceBase

      @GetMapping("base/edit") public String choiceBase(@ModelAttribute("base") Base base, org.springframework.ui.Model model)
      generating a page for selecting the base to be edited
      Parameters:
      base -
      model -
      Returns:
      generates a page for the route /admin/base/edit
    • editBase

      @PostMapping("base/edit") public String editBase(@ModelAttribute("base") Base base, org.springframework.ui.Model model)
      Page with base edit form
      Parameters:
      base -
      model -
      Returns:
      sends a request to change the data
    • updateBase

      @PatchMapping("base/edit/{id}") public String updateBase(@ModelAttribute("base") @Valid @Valid Base base, org.springframework.validation.BindingResult bindingResult, @PathVariable("id") int baseId, org.springframework.ui.Model model)
      Validating and writing to the database of the updated base
      Parameters:
      base -
      bindingResult -
      baseId -
      model -
      Returns:
      redirect to the admin panel page
    • addPizza

      @GetMapping("/add/pizza") public String addPizza(@ModelAttribute("pizza") Pizza pizza, @ModelAttribute("base") Base base, @ModelAttribute("ingredient") Ingredient ingredient, org.springframework.ui.Model model)
      Creating a new pizza

      admin panel

      Parameters:
      pizza -
      base -
      ingredient -
      model -
      Returns:
      generates a page for the route /admin/add/pizza
    • creatPizza

      @PostMapping("/add/pizza") public String creatPizza(@ModelAttribute("pizza") @Valid @Valid Pizza pizza, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
      Validating and writing to the database of the created pizza
      Parameters:
      pizza -
      bindingResult -
      model -
      Returns:
      If successful redirect to admin panel page
    • selectPizzaForEdit

      @GetMapping("edit/pizza") public String selectPizzaForEdit(org.springframework.ui.Model model)
      Generating a page for selecting the pizza to be edited

      admin panel

      Parameters:
      model -
      Returns:
      Generates a page for the route /admin/edit/pizza
    • editPizza

      @GetMapping("/edit/pizza/{id}") public String editPizza(@PathVariable("id") int pizzaId, org.springframework.ui.Model model)
      Page with pizza edit form
      Parameters:
      pizzaId -
      model -
      Returns:
      sends a request to change the data
    • updatePizza

      @PatchMapping("/edit/pizza/{id}") public String updatePizza(@ModelAttribute("pizza") @Valid @Valid Pizza pizza, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, @PathVariable("id") int pizzaId)
      Validating and writing to the database of the updated pizza
      Parameters:
      pizza -
      bindingResult -
      model -
      pizzaId -
      Returns:
      If successful redirect to admin panel page
    • choiceIngredient

      @GetMapping("edit/ingredient") public String choiceIngredient(org.springframework.ui.Model model)
      Generating a page for selecting the ingredient to be edited
      Parameters:
      model -
      Returns:
      Generates a page for the route /admin/edit/ingredient
    • editIngredient

      @GetMapping("edit/ingredient/{id}") public String editIngredient(@PathVariable("id") int ingrId, org.springframework.ui.Model model)
      Page with pizza edit form
      Parameters:
      ingrId -
      model -
      Returns:
      sends a request to change the data
    • updateIngredient

      @PatchMapping("edit/ingredient/{id}") public String updateIngredient(@ModelAttribute("ingredient") @Valid @Valid Ingredient ingredient, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, @PathVariable("id") int ingrId)
      Validating and writing to the database of the updated ingredient
      Parameters:
      ingredient -
      bindingResult -
      model -
      ingrId -
      Returns:
      If successful redirect to admin panel page
    • addCafe

      @GetMapping("/add/cafe") public String addCafe(@ModelAttribute("cafe") Cafe cafe, org.springframework.ui.Model model)
      Creating a new cafe

      admin panel

      Parameters:
      cafe -
      model -
      Returns:
      generates a page for the route /admin/add/cafe
    • createCafe

      @PostMapping("/add/cafe") public String createCafe(@ModelAttribute("cafe") @Valid @Valid Cafe cafe, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model)
      Validating and writing to the database of the created cafe
      Parameters:
      cafe -
      bindingResult -
      model -
      Returns:
      If successful redirect to admin panel page
    • selectCafeForEdit

      @GetMapping("/edit/cafe") public String selectCafeForEdit(org.springframework.ui.Model model)
      Generating a page for selecting the cafe to be edited

      admin panel

      Parameters:
      model -
      Returns:
      Generates a page for the route /admin/edit/ingredient
    • editCafePage

      @GetMapping("/edit/cafe/{id}") public String editCafePage(@PathVariable("id") int cafeId, org.springframework.ui.Model model, @ModelAttribute("cafe") Cafe cafe)
      Page with cafe edit form
      Parameters:
      cafeId -
      model -
      cafe -
      Returns:
      sends a request to change the data
    • updateCafe

      @PatchMapping("/edit/cafe/{id}") public String updateCafe(@ModelAttribute("cafe") @Valid @Valid Cafe cafe, org.springframework.validation.BindingResult bindingResult, org.springframework.ui.Model model, @PathVariable("id") int cafeId)
      Validating and writing to the database of the updated cafe
      Parameters:
      cafe -
      bindingResult -
      model -
      cafeId -
      Returns:
      If successful redirect to admin panel page