1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.courses.repositories.UserRepository; | |
4 | import edu.ucsb.cs156.courses.services.UCSBCurriculumService; | |
5 | import io.swagger.v3.oas.annotations.Operation; | |
6 | import io.swagger.v3.oas.annotations.Parameter; | |
7 | import io.swagger.v3.oas.annotations.tags.Tag; | |
8 | import java.util.List; | |
9 | import lombok.extern.slf4j.Slf4j; | |
10 | import org.springframework.beans.factory.annotation.Autowired; | |
11 | import org.springframework.http.ResponseEntity; | |
12 | import org.springframework.web.bind.annotation.GetMapping; | |
13 | import org.springframework.web.bind.annotation.RequestMapping; | |
14 | import org.springframework.web.bind.annotation.RequestParam; | |
15 | import org.springframework.web.bind.annotation.RestController; | |
16 | ||
17 | @Tag(name = "UCSBCurriculumController") | |
18 | @RestController | |
19 | @RequestMapping("/api/public") | |
20 | @Slf4j | |
21 | public class UCSBCurriculumController extends ApiController { | |
22 | ||
23 | @Autowired UserRepository userRepository; | |
24 | @Autowired UCSBCurriculumService ucsbCurriculumService; | |
25 | ||
26 | @Operation(summary = "Get course data for a given quarter, department, and level") | |
27 | @GetMapping(value = "/basicsearch", produces = "application/json") | |
28 | public ResponseEntity<String> basicsearch( | |
29 | @RequestParam String qtr, @RequestParam String dept, @RequestParam String level) | |
30 | throws Exception { | |
31 | ||
32 | String body = ucsbCurriculumService.getJSON(dept, qtr, level); | |
33 | ||
34 |
1
1. basicsearch : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::basicsearch → KILLED |
return ResponseEntity.ok().body(body); |
35 | } | |
36 | ||
37 | // Backend for final exam info, similar to the above operation: | |
38 | @Operation(summary = "Get final exam information for a given quarter and course enrollment code") | |
39 | @GetMapping(value = "/finalsInfo", produces = "application/json") | |
40 | public ResponseEntity<String> finalsInfo( | |
41 | @RequestParam String quarterYYYYQ, @RequestParam String enrollCd) | |
42 | throws Exception { // Looks for quarter and code | |
43 | ||
44 | String body = ucsbCurriculumService.getFinalsInfo(quarterYYYYQ, enrollCd); | |
45 | ||
46 |
1
1. finalsInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::finalsInfo → KILLED |
return ResponseEntity.ok().body(body); |
47 | } | |
48 | ||
49 | @Operation(summary = "Get General Education areas, optionally filtered by collegeCode") | |
50 | @GetMapping(value = "/generalEducationInfo", produces = "application/json") | |
51 | public ResponseEntity<?> generalEducationInfo( | |
52 | @Parameter(description = "Enter either L&S, ENGR, or CRST") | |
53 | @RequestParam(value = "collegeCode", required = false) | |
54 | String collegeCode) | |
55 | throws Exception { | |
56 | ||
57 |
1
1. generalEducationInfo : negated conditional → KILLED |
if (collegeCode != null) { |
58 | // returns List<String> of requirementCode | |
59 | List<String> codes = ucsbCurriculumService.getRequirementCodesByCollege(collegeCode); | |
60 |
1
1. generalEducationInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::generalEducationInfo → KILLED |
return ResponseEntity.ok().body(codes); |
61 | } else { | |
62 | // returns the full raw JSON array | |
63 | String body = ucsbCurriculumService.getGeneralEducationInfo(); | |
64 |
1
1. generalEducationInfo : replaced return value with null for edu/ucsb/cs156/courses/controllers/UCSBCurriculumController::generalEducationInfo → KILLED |
return ResponseEntity.ok().body(body); |
65 | } | |
66 | } | |
67 | } | |
Mutations | ||
34 |
1.1 |
|
46 |
1.1 |
|
57 |
1.1 |
|
60 |
1.1 |
|
64 |
1.1 |