package at.ac.tuwien.inso.controller.student;

import at.ac.tuwien.inso.controller.*;
import at.ac.tuwien.inso.entity.*;
import at.ac.tuwien.inso.service.*;
import at.ac.tuwien.inso.service.course_recommendation.*;
import org.slf4j.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.data.domain.*;
import org.springframework.data.web.*;
import org.springframework.stereotype.*;
import org.springframework.ui.*;
import org.springframework.web.bind.annotation.*;

import java.security.*;
import java.util.*;

@Controller
@RequestMapping("/student/courses")
public class StudentCoursesController {

    private static final Logger log = LoggerFactory.getLogger(StudentMyCoursesController.class);

    @Autowired
    private CourseService courseService;

    @Autowired
    private UserAccountService userAccountService;

    @Autowired
    private StudentService studentService;

    @Autowired
    private RecommendationService recommendationService;

    @ModelAttribute("allCourses")
    private Page<Course> getAllCourses(@RequestParam(value = "search", defaultValue = "") String search,
                                       @PageableDefault Pageable pageable) {
        if (pageable.getPageSize() > Constants.MAX_PAGE_SIZE) {
            pageable = new PageRequest(pageable.getPageNumber(), Constants.MAX_PAGE_SIZE);
        }

        return courseService.findCourseForCurrentSemesterWithName(search, pageable);
    }

    @ModelAttribute("recommendedCourses")
    private List<Course> getRecommendedCourses(Principal principal) {
        Student student = studentService.findByUsername(principal.getName());

        return recommendationService.recommendCourses(student);
    }

    @ModelAttribute("searchString")
    private String getSearchString(@RequestParam(value = "search", defaultValue = "") String search) {
        return search;
    }

    @GetMapping
    public String courses() {
        return "/student/courses";
    }

    @GetMapping("/{id}")
    public String course(@PathVariable Long id,
                         Model model,
                         Principal principal) {
        log.debug("Student " + principal.getName() + " requesting course " + id + " details");

        Student student = studentService.findByUsername(principal.getName());

        model.addAttribute("course", courseService.courseDetailsFor(student, id));

        return "/student/course-details";
    }

}

@@ -200,32 +200,33 @@
 commendation.*;%0A
+%0A
 import org.slf4j
@@ -810,170 +810,30 @@
 ate 
-UserAccountService userAccountService;%0A%0A    @Autowired%0A    private StudentService studentService;%0A%0A    @Autowired%0A    private RecommendationService recommendation
+StudentService student
 Serv
@@ -980,47 +980,8 @@
 rch,
-%0A                                      
  @Pa
@@ -1277,270 +1277,8 @@
  %7D%0A%0A
-    @ModelAttribute(%22recommendedCourses%22)%0A    private List%3CCourse%3E getRecommendedCourses(Principal principal) %7B%0A        Student student = studentService.findByUsername(principal.getName());%0A%0A        return recommendationService.recommendCourses(student);%0A    %7D%0A%0A
     
@@ -1606,71 +1606,21 @@
  id,
-%0A                         Model model,%0A                        
+ Model model,
  Pri

Refactor courses controller to only show all courses