diff --git a/services/course-information/src/main/java/edu/uga/devdogs/course_information/controller/CourseInfoController.java b/services/course-information/src/main/java/edu/uga/devdogs/course_information/controller/CourseInfoController.java index 3ec4965e..b1e06239 100644 --- a/services/course-information/src/main/java/edu/uga/devdogs/course_information/controller/CourseInfoController.java +++ b/services/course-information/src/main/java/edu/uga/devdogs/course_information/controller/CourseInfoController.java @@ -359,7 +359,7 @@ public ResponseEntity getNumProfessorRatings(String lname, String fname /** * Returns a list of recommended CRNS given paramters. * - * @param inputCourseCrns Potentials CRNs for a schedule + * @param inputCourseNumbers Potential course numbers for a schedule * @param gapDay Day of the week to leave open * @param prefStartTime Preferred start time for the schedule * @param prefEndTime Preferred end time for the schedule @@ -379,11 +379,11 @@ public ResponseEntity getNumProfessorRatings(String lname, String fname }) @GetMapping("/get-recommended-schedules") @Tag(name="course-information") - public ResponseEntity>> getRecommendedSchedules(List inputCourseCrns, String gapDay, int prefStartTime, int prefEndTime, boolean showFilledClasses, + public ResponseEntity>> getRecommendedSchedules(List inputCourseNumbers, String gapDay, int prefStartTime, int prefEndTime, boolean showFilledClasses, List excludedCourseCrns, List excludedSectionCrns, String inputCampus, int minCreditHours, int maxCreditHours, boolean walking) { try { // Returns a list of recommended schedules based on input parameters - List> recommendedSchedules = courseInformationService.getRecommendedSchedules(inputCourseCrns, gapDay, prefStartTime, prefEndTime, showFilledClasses, + List> recommendedSchedules = courseInformationService.getRecommendedSchedules(inputCourseNumbers, gapDay, prefStartTime, prefEndTime, showFilledClasses, excludedCourseCrns, excludedSectionCrns, inputCampus, minCreditHours, maxCreditHours, walking); // Return the section if found diff --git a/services/course-information/src/main/java/edu/uga/devdogs/course_information/service/CourseInformationService.java b/services/course-information/src/main/java/edu/uga/devdogs/course_information/service/CourseInformationService.java index 95261515..28e1dd36 100644 --- a/services/course-information/src/main/java/edu/uga/devdogs/course_information/service/CourseInformationService.java +++ b/services/course-information/src/main/java/edu/uga/devdogs/course_information/service/CourseInformationService.java @@ -318,7 +318,7 @@ public double getLongitude(String buildingCode) { throw new BuildingNotFoundException(); } - public List> getRecommendedSchedules(List inputCourseCrns, String gapDay, int prefStartTime, int prefEndTime, boolean showFilledClasses, + public List> getRecommendedSchedules(List inputCourseNumbers, String gapDay, int prefStartTime, int prefEndTime, boolean showFilledClasses, List excludedCourseCrns, List excludedSectionCrns, String inputCampus, int minCreditHours, int maxCreditHours, boolean walking) { Set inputCourses = new HashSet<>(); @@ -332,6 +332,41 @@ public List> getRecommendedSchedules(List inputCourseCrns List excludedCourses = new ArrayList<>(); + // Building input courses list from given course numbers + + for (String fullCourseNumber : inputCourseNumbers) { + String subject = fullCourseNumber.substring(0, 4); + String courseNumber = fullCourseNumber.substring(4); + Course course = courseRepository.findBySubjectAndCourseNumber(subject, courseNumber); + + List
sections = new ArrayList<>(); + + for (CourseSection courseSection : course.getCourseSections()) { + int crn = courseSection.getCrn(); + String profLastName = courseSection.getInstructor(); + float rating = professorRepository.findByLastName(profLastName).getAverageRating(); + edu.uga.devdogs.course_information.Algorithm.records.Professor professor = new edu.uga.devdogs.course_information.Algorithm.records.Professor(profLastName, rating); + + List classes = new ArrayList<>(); + + for (ClassEntity classEntity : courseSection.getClasses()) { + String daysString = classEntity.getDays(); + List daysList = new ArrayList<>(); + for (int i = 0; i < daysString.length(); i++) { + daysList.add(BruteForceUtil.daySwitch(daysString.substring(i, i + 1))); + } + LocalTime startTime = classEntity.getStartTime(); + LocalTime endTime = classEntity.getEndTime(); + String buildingName = classEntity.getBuilding().getName(); + String campus = classEntity.getCampus(); + String buildingNumber = String.valueOf(classEntity.getBuilding().getBuildingCode()); + classes.add(new Class(crn, daysList, startTime, endTime, buildingName, campus, buildingNumber)); + } + sections.add(new Section(courseNumber, crn, professor, classes)); + } + inputCourses.add(new edu.uga.devdogs.course_information.Algorithm.records.Course(courseNumber, sections)); + } + //building excluded courses list from given crns for (Integer crn : excludedCourseCrns) {