| 1 | package edu.ucsb.cs156.courses.controllers; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 4 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 5 | import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection; | |
| 6 | import edu.ucsb.cs156.courses.documents.ConvertedSection; | |
| 7 | import io.swagger.v3.oas.annotations.Operation; | |
| 8 | import io.swagger.v3.oas.annotations.Parameter; | |
| 9 | import java.util.List; | |
| 10 | import java.util.stream.Collectors; | |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | import org.springframework.http.ResponseEntity; | |
| 13 | import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | import org.springframework.web.bind.annotation.RestController; | |
| 17 | ||
| 18 | @RestController | |
| 19 | @RequestMapping("/api/public/courseovertime") | |
| 20 | public class CourseOverTimeBuildingController { | |
| 21 | ||
| 22 | private ObjectMapper mapper = new ObjectMapper(); | |
| 23 | ||
| 24 | @Autowired ConvertedSectionCollection convertedSectionCollection; | |
| 25 | ||
| 26 | @Operation(summary = "Get a list of courses over time, filtered by (abbreviated) building code") | |
| 27 | @GetMapping(value = "/buildingsearch", produces = "application/json") | |
| 28 | public ResponseEntity<String> search( | |
| 29 | @Parameter( | |
| 30 | name = "startQtr", | |
| 31 | description = | |
| 32 | "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 33 | example = "20231", | |
| 34 | required = true) | |
| 35 | @RequestParam | |
| 36 | String startQtr, | |
| 37 | @Parameter( | |
| 38 | name = "endQtr", | |
| 39 | description = | |
| 40 | "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 41 | example = "20231", | |
| 42 | required = true) | |
| 43 | @RequestParam | |
| 44 | String endQtr, | |
| 45 | @Parameter( | |
| 46 | name = "buildingCode", | |
| 47 | description = "Building code such as PHELP for Phelps, GIRV for Girvetz", | |
| 48 | example = "GIRV", | |
| 49 | required = true) | |
| 50 | @RequestParam | |
| 51 | String buildingCode) | |
| 52 | throws JsonProcessingException { | |
| 53 | List<ConvertedSection> courseResults = | |
| 54 | convertedSectionCollection.findByQuarterRangeAndBuildingCode( | |
| 55 | startQtr, endQtr, buildingCode); | |
| 56 | String body = mapper.writeValueAsString(courseResults); | |
| 57 |
1
1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::search → KILLED |
return ResponseEntity.ok().body(body); |
| 58 | } | |
| 59 | ||
| 60 | @Operation(summary = "Get a list of classroom numbers for a building within a quarter range") | |
| 61 | @GetMapping(value = "/classrooms", produces = "application/json") | |
| 62 | public ResponseEntity<String> getClassrooms( | |
| 63 | @Parameter( | |
| 64 | name = "startQtr", | |
| 65 | description = | |
| 66 | "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 67 | example = "20231", | |
| 68 | required = true) | |
| 69 | @RequestParam | |
| 70 | String startQtr, | |
| 71 | @Parameter( | |
| 72 | name = "endQtr", | |
| 73 | description = | |
| 74 | "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
| 75 | example = "20231", | |
| 76 | required = true) | |
| 77 | @RequestParam | |
| 78 | String endQtr, | |
| 79 | @Parameter( | |
| 80 | name = "buildingCode", | |
| 81 | description = "Building code such as PHELP for Phelps, GIRV for Girvetz", | |
| 82 | example = "GIRV", | |
| 83 | required = true) | |
| 84 | @RequestParam | |
| 85 | String buildingCode) | |
| 86 | throws JsonProcessingException { | |
| 87 | ||
| 88 | List<ConvertedSection> sections = | |
| 89 | convertedSectionCollection.findByQuarterRangeAndBuildingCode( | |
| 90 | startQtr, endQtr, buildingCode); | |
| 91 | ||
| 92 | List<String> rooms = | |
| 93 | sections.stream() | |
| 94 |
1
1. lambda$getClassrooms$0 : replaced return value with Stream.empty for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::lambda$getClassrooms$0 → KILLED |
.flatMap(cs -> cs.getSection().getTimeLocations().stream()) |
| 95 |
2
1. lambda$getClassrooms$1 : replaced boolean return with false for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::lambda$getClassrooms$1 → KILLED 2. lambda$getClassrooms$1 : replaced boolean return with true for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::lambda$getClassrooms$1 → KILLED |
.filter(tl -> buildingCode.equals(tl.getBuilding())) |
| 96 |
1
1. lambda$getClassrooms$2 : replaced return value with "" for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::lambda$getClassrooms$2 → KILLED |
.map(tl -> tl.getRoom()) |
| 97 | .distinct() | |
| 98 | .sorted() | |
| 99 | .collect(Collectors.toList()); | |
| 100 | ||
| 101 | String body = mapper.writeValueAsString(rooms); | |
| 102 |
1
1. getClassrooms : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::getClassrooms → KILLED |
return ResponseEntity.ok().body(body); |
| 103 | } | |
| 104 | } | |
Mutations | ||
| 57 |
1.1 |
|
| 94 |
1.1 |
|
| 95 |
1.1 2.2 |
|
| 96 |
1.1 |
|
| 102 |
1.1 |