@RequestMapping(
     value = {"/addmechanic"},
     method = {RequestMethod.POST})
 public ModelAndView addmechanic(
     @ModelAttribute("mechanic") Mechanic mechanic,
     BindingResult bindingResult,
     Model model,
     HttpSession session,
     Authentication auth) {
   ModelAndView mav = new ModelAndView();
   mechanicValidator.validate(mechanic, bindingResult);
   if (bindingResult.hasErrors()) {
     UserPrincipal user = userService.getUserByName(auth.getName());
     mav.addObject("user", user);
     mav.addObject("stos", directorService.getSto());
     mav.setViewName("director.addmechanic");
     return mav;
   }
   mechanic.setLogin(mechanic.getName());
   mechanic.setRating((float) 0);
   mechanic.setRole(UserRole.MECHANIC);
   directorService.saveOrUpdateMechanic(mechanic);
   mav.setViewName("redirect:/home");
   return mav;
 }
 @PreAuthorize("isFullyAuthenticated()")
 @RequestMapping(value = "/addmechanic", method = RequestMethod.GET)
 public ModelAndView addmechanic(HttpSession session, Authentication auth) {
   ModelAndView mav = new ModelAndView();
   UserPrincipal user = userService.getUserByName(auth.getName());
   mav.addObject("user", user);
   mav.addObject("mechanic", new Mechanic());
   mav.addObject("stos", directorService.getSto());
   mav.setViewName("director.addmechanic");
   return mav;
 };
 @PreAuthorize("isFullyAuthenticated()")
 @RequestMapping(value = "/updatemechanic/{id}", method = RequestMethod.GET)
 public ModelAndView updatemechanic(
     @PathVariable Long id, HttpSession session, Authentication auth) {
   ModelAndView mav = new ModelAndView();
   UserPrincipal user = userService.getUserByName(auth.getName());
   mav.addObject("user", user);
   mav.addObject("mechanic", directorService.getMechanicById(id));
   mav.addObject("stos", directorService.getSto());
   mav.setViewName("director.updatemechanic");
   return mav;
 };
  @RequestMapping(
      value = {"/getreport"},
      method = {RequestMethod.POST})
  public ModelAndView getreport(
      @ModelAttribute("reportinfo") ReportInfo reportinfo,
      BindingResult bindingResult,
      Model model,
      HttpSession session,
      Authentication auth) {
    ModelAndView mav = new ModelAndView();
    reportValidator.validate(reportinfo, bindingResult);
    if (bindingResult.hasErrors()) {
      logger.info("Returning getreport.jsp page");
      UserPrincipal user = userService.getUserByName(auth.getName());
      mav.addObject("user", user);

      mav.addObject("stos", directorService.getSto());
      mav.setViewName("director.getreport");
      return mav;
    } else {

      ModelAndView mave = new ModelAndView();
      UserPrincipal user = userService.getUserByName(auth.getName());
      mave.addObject("user", user);
      if (reportinfo.getWhom().equals("sto")) {
        mave.addObject(
            "report",
            directorService.getreportSto(
                reportinfo.getSto(), reportinfo.getDateStart(), reportinfo.getDateFinish()));
        mave.addObject("reportinfo", reportinfo);
        mave.setViewName("director.reportsto");
      } else {
        mave.addObject(
            "report",
            directorService.getreportAll(reportinfo.getDateStart(), reportinfo.getDateFinish()));
        mave.addObject("reportinfo", reportinfo);
        mave.setViewName("director.reportall");
      }

      return mave;
    }
  }