Example #1
0
 @RequestMapping(value = "/{id}" + Urls.DELETE, method = RequestMethod.GET)
 public String delete(@PathVariable long id, Model model) {
   if (brickFacade.getBrick(id) == null) {
     throw new ResourceNotFoundException();
   }
   brickFacade.removeBrick(id);
   return "redirect:/brick";
 }
Example #2
0
  @RequestMapping(value = "/{id}" + Urls.EDIT, method = RequestMethod.GET)
  public String edit(@PathVariable long id, Model model) {
    BrickDto brickDto = brickFacade.getBrick(id);
    if (brickDto == null) {
      throw new ResourceNotFoundException();
    }

    model.addAttribute("brick", brickDto);

    return "bricks/form";
  }
Example #3
0
 @RequestMapping(value = Urls.CREATE, method = RequestMethod.POST)
 public String createProcess(
     @Valid @ModelAttribute("brick") BrickDto brickDto, BindingResult bindingResult) {
   brickValidator.validate(brickDto, bindingResult);
   if (!bindingResult.hasErrors()) {
     brickFacade.createBrick(brickDto);
     return "redirect:";
   } else {
     return "bricks/form";
   }
 }
Example #4
0
 @RequestMapping(value = "/{id}" + Urls.EDIT, method = RequestMethod.POST)
 public String editProcess(
     @PathVariable long id,
     @Valid @ModelAttribute("brick") BrickDto brickDto,
     BindingResult bindingResult) {
   brickDto.setId(id);
   brickValidator.validate(brickDto, bindingResult);
   if (!bindingResult.hasErrors()) {
     brickFacade.editBrick(brickDto);
     return "redirect:";
   } else {
     return "bricks/form";
   }
 }
Example #5
0
 @RequestMapping(value = Urls.MOST_USED + "/{amount}", method = RequestMethod.GET)
 public String getMostUsed(@PathVariable int amount, Model model) {
   model.addAttribute("bricks", brickFacade.getMostUsedBricks(amount));
   return "bricks/list";
 }
Example #6
0
 @RequestMapping(value = Urls.UNUSED, method = RequestMethod.GET)
 public String getUnused(Model model) {
   model.addAttribute("bricks", brickFacade.getUnusedBricks());
   return "bricks/list";
 }
Example #7
0
 @RequestMapping(method = RequestMethod.GET)
 public String getAll(Model model) {
   model.addAttribute("bricks", brickFacade.getAllBricks());
   return "bricks/list";
 }