/** * Loads the editProfile.jsp page * * @param principal the logged in principal. * @return the editProfile page. */ @RequestMapping(value = "/editProfile", method = RequestMethod.GET) public ModelAndView editProfile(Principal principal) { ModelAndView model = new ModelAndView("editProfile"); User user = userService.getPrincipalUser(); model.addObject(user); ArrayList<Course> courses = searchService.getCourses(); ArrayList<Course> nonUserCourses = new ArrayList<Course>(); for (Course course : courses) { if (userCourseDao.findByUserAndCourse(user, course) == null) { nonUserCourses.add(course); } } model.addObject("courses", nonUserCourses); return model; }
/** * Serve model with subjects. * * @return the subjects from the database. */ @ModelAttribute("subjects") public ArrayList<Subject> getSubjects() { ArrayList<Subject> subjects = new ArrayList<Subject>(); subjects = searchService.getSubjects(); return subjects; }
/** * Serve model with universities. * * @return universities from the database. */ @ModelAttribute("universities") public ArrayList<University> getUniversities() { ArrayList<University> universities = new ArrayList<University>(); universities = searchService.getUniversities(); return universities; }