// Sending request------------------------------------------------------------------ @RequestMapping(value = "/sendRequest", method = RequestMethod.GET) public ModelAndView sendRequest(@RequestParam int teamId) { ModelAndView result; Collection<Team> teams; Collection<Team> teamsRequested = new ArrayList<Team>(); Team team; Boolean showSend = true; Collection<RequestTeam> requestTeam; User principal; principal = userService.findByPrincipal(); team = teamService.findOne(teamId); requestTeamService.sendRequest(teamId); teams = teamService.findAllOtherUser(principal.getId()); requestTeam = requestTeamService.findAllRequestSendFromUser(principal.getId()); for (RequestTeam r : requestTeam) { teamsRequested.add(r.getTeam()); } result = new ModelAndView("team/list"); result.addObject("teams", teams); result.addObject("teamsRequested", teamsRequested); result.addObject("showSend", showSend); result.addObject("requestURI", "team/user/listAllTeams.do"); return result; }
// Accepting request------------------------------------------------------------------ @RequestMapping(value = "/acceptRequest", method = RequestMethod.GET) public ModelAndView acceptRequest(@RequestParam int requestTeamId) { ModelAndView result; RequestTeam requestTeam; requestTeam = requestTeamService.findOne(requestTeamId); teamService.joinTeam(requestTeam.getTeam(), requestTeam); result = new ModelAndView("team/list"); result.addObject("requestURI", "team/user/list.do"); return result; }