1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.courses.documents.Primary; | |
4 | import edu.ucsb.cs156.courses.repositories.UserRepository; | |
5 | import edu.ucsb.cs156.courses.services.UCSBCurriculumService; | |
6 | import io.swagger.v3.oas.annotations.Operation; | |
7 | import io.swagger.v3.oas.annotations.Parameter; | |
8 | import io.swagger.v3.oas.annotations.tags.Tag; | |
9 | import java.util.List; | |
10 | import lombok.extern.slf4j.Slf4j; | |
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 | @Tag(name = "UCSBCurriculumController") | |
19 | @RestController | |
20 | @RequestMapping("/api/public") | |
21 | @Slf4j | |
22 | public class UCSBCurriculumController extends ApiController { | |
23 | ||
24 | @Autowired UserRepository userRepository; | |
25 | @Autowired UCSBCurriculumService ucsbCurriculumService; | |
26 | ||
27 | @Operation( | |
28 | summary = | |
29 | "Get course data (in original UCSB API format) for a given quarter, department, and level") | |
30 | @GetMapping(value = "/basicsearch", produces = "application/json") | |
31 | public ResponseEntity<String> basicsearch( | |
32 | @RequestParam String qtr, @RequestParam String dept, @RequestParam String level) | |
33 | throws Exception { | |
34 | ||
35 | String body = ucsbCurriculumService.getJSON(dept, qtr, level); | |
36 | ||
37 |
1
1. basicsearch : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::basicsearch → KILLED |
return ResponseEntity.ok().body(body); |
38 | } | |
39 | ||
40 | /** | |
41 | * Get primaries for a given quarter, department, and level. This endpoint returns a list of | |
42 | * Primary objects. | |
43 | * | |
44 | * @param qtr the quarter in YYYYQ format | |
45 | * @param dept the department code (e.g., "CS") | |
46 | * @param level the course level (e.g., "UG" for undergraduate) | |
47 | * @return a list of Primary objects | |
48 | */ | |
49 | @Operation(summary = "Get primaries for a given quarter, department, and level") | |
50 | @GetMapping(value = "/primaries", produces = "application/json") | |
51 | public List<Primary> primaries( | |
52 | @RequestParam String qtr, @RequestParam String dept, @RequestParam String level) | |
53 | throws Exception { | |
54 | ||
55 | List<Primary> primaries = ucsbCurriculumService.getPrimaries(dept, qtr, level); | |
56 | ||
57 |
1
1. primaries : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::primaries → KILLED |
return primaries; |
58 | } | |
59 | ||
60 | // Backend for final exam info, similar to the above operation: | |
61 | @Operation(summary = "Get final exam information for a given quarter and course enrollment code") | |
62 | @GetMapping(value = "/finalsInfo", produces = "application/json") | |
63 | public ResponseEntity<String> finalsInfo( | |
64 | @RequestParam String quarterYYYYQ, @RequestParam String enrollCd) | |
65 | throws Exception { // Looks for quarter and code | |
66 | ||
67 | String body = ucsbCurriculumService.getFinalsInfo(quarterYYYYQ, enrollCd); | |
68 | ||
69 |
1
1. finalsInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::finalsInfo → KILLED |
return ResponseEntity.ok().body(body); |
70 | } | |
71 | ||
72 | @Operation(summary = "Get General Education areas, optionally filtered by collegeCode") | |
73 | @GetMapping(value = "/generalEducationInfo", produces = "application/json") | |
74 | public ResponseEntity<?> generalEducationInfo( | |
75 | @Parameter(description = "Enter either L&S, ENGR, or CRST") | |
76 | @RequestParam(value = "collegeCode", required = false) | |
77 | String collegeCode) | |
78 | throws Exception { | |
79 | ||
80 |
1
1. generalEducationInfo : negated conditional → KILLED |
if (collegeCode != null) { |
81 | // returns List<String> of requirementCode | |
82 | List<String> codes = ucsbCurriculumService.getRequirementCodesByCollege(collegeCode); | |
83 |
1
1. generalEducationInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::generalEducationInfo → KILLED |
return ResponseEntity.ok().body(codes); |
84 | } else { | |
85 | // returns the full raw JSON array | |
86 | String body = ucsbCurriculumService.getGeneralEducationInfo(); | |
87 |
1
1. generalEducationInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::generalEducationInfo → KILLED |
return ResponseEntity.ok().body(body); |
88 | } | |
89 | } | |
90 | } | |
Mutations | ||
37 |
1.1 |
|
57 |
1.1 |
|
69 |
1.1 |
|
80 |
1.1 |
|
83 |
1.1 |
|
87 |
1.1 |