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.Set; | |
11 | import java.util.stream.Collectors; | |
12 | import org.springframework.beans.factory.annotation.Autowired; | |
13 | import org.springframework.http.ResponseEntity; | |
14 | import org.springframework.web.bind.annotation.GetMapping; | |
15 | import org.springframework.web.bind.annotation.RequestMapping; | |
16 | import org.springframework.web.bind.annotation.RequestParam; | |
17 | import org.springframework.web.bind.annotation.RestController; | |
18 | ||
19 | @RestController | |
20 | @RequestMapping("/api/public/classrooms") | |
21 | public class NumbersForBuildingController { | |
22 | ||
23 | private ObjectMapper mapper = new ObjectMapper(); | |
24 | ||
25 | @Autowired private ConvertedSectionCollection convertedSectionCollection; | |
26 | ||
27 | @Operation(summary = "Get a list of room numbers for a specific building and quarter") | |
28 | @GetMapping(value = "/roomnumbers", produces = "application/json") | |
29 | public ResponseEntity<String> getRoomNumbers( | |
30 | @Parameter( | |
31 | name = "quarter", | |
32 | description = | |
33 | "Quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)", | |
34 | example = "20231", | |
35 | required = true) | |
36 | @RequestParam | |
37 | String quarter, | |
38 | @Parameter( | |
39 | name = "buildingCode", | |
40 | description = "Building code such as PHELP for Phelps, GIRV for Girvetz", | |
41 | example = "GIRV", | |
42 | required = true) | |
43 | @RequestParam | |
44 | String buildingCode) | |
45 | throws JsonProcessingException { | |
46 | List<ConvertedSection> sections = | |
47 | convertedSectionCollection.findByQuarterRangeAndBuildingCode( | |
48 | quarter, quarter, buildingCode); | |
49 | ||
50 | Set<String> roomNumbers = | |
51 | sections.stream() | |
52 |
1
1. lambda$getRoomNumbers$0 : replaced return value with Stream.empty for edu/ucsb/cs156/courses/controllers/NumbersForBuildingController::lambda$getRoomNumbers$0 → KILLED |
.flatMap(section -> section.getSection().getTimeLocations().stream()) |
53 |
2
1. lambda$getRoomNumbers$1 : replaced boolean return with true for edu/ucsb/cs156/courses/controllers/NumbersForBuildingController::lambda$getRoomNumbers$1 → KILLED 2. lambda$getRoomNumbers$1 : replaced boolean return with false for edu/ucsb/cs156/courses/controllers/NumbersForBuildingController::lambda$getRoomNumbers$1 → KILLED |
.filter(timeLocation -> buildingCode.equalsIgnoreCase(timeLocation.getBuilding())) |
54 |
1
1. lambda$getRoomNumbers$2 : replaced return value with "" for edu/ucsb/cs156/courses/controllers/NumbersForBuildingController::lambda$getRoomNumbers$2 → KILLED |
.map(timeLocation -> timeLocation.getRoom()) |
55 | .collect(Collectors.toSet()); | |
56 | ||
57 | String body = mapper.writeValueAsString(roomNumbers); | |
58 |
1
1. getRoomNumbers : replaced return value with null for edu/ucsb/cs156/courses/controllers/NumbersForBuildingController::getRoomNumbers → KILLED |
return ResponseEntity.ok().body(body); |
59 | } | |
60 | } | |
Mutations | ||
52 |
1.1 |
|
53 |
1.1 2.2 |
|
54 |
1.1 |
|
58 |
1.1 |