Пример #1
0
 private List<UserDto> allUsers(boolean flag, Long accountId) {
   List<UserDto> users = new ArrayList<>();
   if (flag) {
     users = userBusinessLogic.findAll();
   } else {
     users = userBusinessLogic.findAllByAccountId(accountId);
   }
   return users;
 }
Пример #2
0
 private List<UserDto> inactiveUsers(boolean flag, Long accountId) {
   List<UserDto> inActive = new ArrayList<>();
   if (flag) {
     inActive = userBusinessLogic.findAllInActive();
   } else {
     inActive = userBusinessLogic.findAllInActiveByAccountId(accountId);
   }
   return inActive;
 }
Пример #3
0
 private String update(UserDto user, RedirectAttributes redir, Model model) {
   try {
     userBusinessLogic.update(user);
     redir.addFlashAttribute(
         "message", String.format("Successfully updated user \"%s\". ", user.getFullName()));
     updateParkingUser(user);
   } catch (Exception e) {
     model.addAttribute("message", e.getMessage());
     model.addAttribute("user", userBusinessLogic.findOneById(user.getId()));
     model.addAttribute("action", "UPDATE");
     return EDIT_PAGE;
   }
   return REDIRECT_MAIN_PAGE;
 }
Пример #4
0
 @RequestMapping(value = "/changepassword", method = RequestMethod.POST)
 public String changePassword(
     @ModelAttribute UserDto user, RedirectAttributes redir, Model model) {
   model.addAttribute("authority", loggedinUserRole());
   try {
     userBusinessLogic.updatePassword(user);
     redir.addFlashAttribute(
         "message",
         String.format("Successfully updated password of user \"%s\". ", user.getFullName()));
   } catch (Exception e) {
     model.addAttribute("message", e.getMessage());
     model.addAttribute("user", userBusinessLogic.findOneById(user.getId()));
     return USER_CHANGE_PASS_PAGE;
   }
   return REDIRECT_MAIN_PAGE;
 }
Пример #5
0
  @RequestMapping("/edit")
  public String editPage(
      @RequestParam String action, @RequestParam(required = false) Long id, Model model) {
    model.addAttribute("authority", loggedinUserRole());
    model.addAttribute("action", action);
    // ParkingJ user related.
    // Set allowed parking
    if (id == null) {
      model.addAttribute("allowedParkingArea", allowedParkingArea(id));
      model.addAttribute("user", new UserDto());
      model.addAttribute("updateMode", false);
    } else {
      UserDto dbUser = userBusinessLogic.findOneById(id);
      // ParkingJ user related.
      // Set allowed parking
      model.addAttribute("allowedParkingArea", allowedParkingArea(dbUser.getAccountId()));
      // Set first allowed parking before setting to model
      List<Long> selectedParkingArea =
          parkingUserBusinessLogic.findByUserId(dbUser.getId()).getAllowedParkingArea();
      dbUser.setSelectedParkingArea(selectedParkingArea);
      ;
      // End.
      model.addAttribute("user", dbUser);

      model.addAttribute("updateMode", true);
    }
    return EDIT_PAGE;
  }
Пример #6
0
 @RequestMapping("/changepassword")
 public String changePasswordPage(@RequestParam Long id, Model model) {
   model.addAttribute("authority", loggedinUserRole());
   UserDto user = userBusinessLogic.findOneById(id);
   user.setConfirmPassword("");
   user.setPassword("");
   model.addAttribute("user", user);
   return USER_CHANGE_PASS_PAGE;
 }
Пример #7
0
 private String create(UserDto user, RedirectAttributes redir, Model model) {
   try {
     UserDto dbUser = userBusinessLogic.create(user);
     redir.addFlashAttribute(
         "message", String.format("Successfully created user \"%s\". ", user.getFullName()));
     createParkingUser(dbUser, user);
   } catch (Exception e) {
     model.addAttribute("message", e.getMessage());
     model.addAttribute("user", new UserDto());
     model.addAttribute("action", "CREATE");
     return EDIT_PAGE;
   }
   return REDIRECT_MAIN_PAGE;
 }