1 | package edu.ucsb.cs156.courses.controllers; | |
2 | ||
3 | import com.fasterxml.jackson.core.JsonProcessingException; | |
4 | import com.fasterxml.jackson.databind.JsonNode; | |
5 | import com.fasterxml.jackson.databind.ObjectMapper; | |
6 | import edu.ucsb.cs156.courses.entities.PSCourse; | |
7 | import edu.ucsb.cs156.courses.entities.PersonalSchedule; | |
8 | import edu.ucsb.cs156.courses.entities.User; | |
9 | import edu.ucsb.cs156.courses.errors.BadEnrollCdException; | |
10 | import edu.ucsb.cs156.courses.errors.EntityNotFoundException; | |
11 | import edu.ucsb.cs156.courses.models.CurrentUser; | |
12 | import edu.ucsb.cs156.courses.repositories.PSCourseRepository; | |
13 | import edu.ucsb.cs156.courses.repositories.PersonalScheduleRepository; | |
14 | import edu.ucsb.cs156.courses.services.UCSBCurriculumService; | |
15 | import io.swagger.v3.oas.annotations.Operation; | |
16 | import io.swagger.v3.oas.annotations.Parameter; | |
17 | import io.swagger.v3.oas.annotations.tags.Tag; | |
18 | import java.util.ArrayList; | |
19 | import java.util.Iterator; | |
20 | import java.util.Optional; | |
21 | import javax.validation.Valid; | |
22 | import lombok.extern.slf4j.Slf4j; | |
23 | import org.springframework.beans.factory.annotation.Autowired; | |
24 | import org.springframework.security.access.prepost.PreAuthorize; | |
25 | import org.springframework.web.bind.annotation.DeleteMapping; | |
26 | import org.springframework.web.bind.annotation.GetMapping; | |
27 | import org.springframework.web.bind.annotation.PostMapping; | |
28 | import org.springframework.web.bind.annotation.PutMapping; | |
29 | import org.springframework.web.bind.annotation.RequestBody; | |
30 | import org.springframework.web.bind.annotation.RequestMapping; | |
31 | import org.springframework.web.bind.annotation.RequestParam; | |
32 | import org.springframework.web.bind.annotation.RestController; | |
33 | ||
34 | @Tag(name = "PSCourse") | |
35 | @RequestMapping("/api/courses") | |
36 | @RestController | |
37 | @Slf4j | |
38 | public class PSCourseController extends ApiController { | |
39 | ||
40 | @Autowired PSCourseRepository coursesRepository; | |
41 | @Autowired PersonalScheduleRepository personalScheduleRepository; | |
42 | @Autowired UCSBCurriculumService ucsbCurriculumService; | |
43 | @Autowired ObjectMapper mapper; | |
44 | ||
45 | @Operation(summary = "List all courses (admin)") | |
46 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
47 | @GetMapping("/admin/all") | |
48 | public Iterable<PSCourse> allUsersCourses() { | |
49 | Iterable<PSCourse> courses = coursesRepository.findAll(); | |
50 |
1
1. allUsersCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::allUsersCourses → KILLED |
return courses; |
51 | } | |
52 | ||
53 | @Operation(summary = "List all courses (user)") | |
54 | @PreAuthorize("hasRole('ROLE_USER')") | |
55 | @GetMapping("/user/all") | |
56 | public Iterable<PSCourse> thisUsersCourses() { | |
57 | CurrentUser currentUser = getCurrentUser(); | |
58 | Iterable<PSCourse> courses = coursesRepository.findAllByUserId(currentUser.getUser().getId()); | |
59 |
1
1. thisUsersCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::thisUsersCourses → KILLED |
return courses; |
60 | } | |
61 | ||
62 | @Operation(summary = "List all courses for a specified psId (admin)") | |
63 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
64 | @GetMapping("/admin/psid/all") | |
65 | public Iterable<PSCourse> allCoursesForPsId(@Parameter(name = "psId") @RequestParam Long psId) { | |
66 | Iterable<PSCourse> courses = coursesRepository.findAllByPsId(psId); | |
67 |
1
1. allCoursesForPsId : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::allCoursesForPsId → KILLED |
return courses; |
68 | } | |
69 | ||
70 | @Operation(summary = "List all courses for a specified psId (user)") | |
71 | @PreAuthorize("hasRole('ROLE_USER')") | |
72 | @GetMapping("/user/psid/all") | |
73 | public Iterable<PSCourse> thisUsersCoursesForPsId( | |
74 | @Parameter(name = "psId") @RequestParam Long psId) { | |
75 | User currentUser = getCurrentUser().getUser(); | |
76 | Iterable<PSCourse> courses = coursesRepository.findAllByPsIdAndUser(psId, currentUser); | |
77 |
1
1. thisUsersCoursesForPsId : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::thisUsersCoursesForPsId → KILLED |
return courses; |
78 | } | |
79 | ||
80 | @Operation(summary = "Get a single course (admin)") | |
81 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
82 | @GetMapping("/admin") | |
83 | public PSCourse getCourseById_admin(@Parameter(name = "id") @RequestParam Long id) { | |
84 | PSCourse courses = | |
85 | coursesRepository | |
86 | .findById(id) | |
87 |
1
1. lambda$getCourseById_admin$0 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$getCourseById_admin$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
88 | ||
89 |
1
1. getCourseById_admin : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::getCourseById_admin → KILLED |
return courses; |
90 | } | |
91 | ||
92 | @Operation(summary = "Get a single course (user)") | |
93 | @PreAuthorize("hasRole('ROLE_USER')") | |
94 | @GetMapping("/user") | |
95 | public PSCourse getCourseById(@Parameter(name = "id") @RequestParam Long id) { | |
96 | User currentUser = getCurrentUser().getUser(); | |
97 | PSCourse courses = | |
98 | coursesRepository | |
99 | .findByIdAndUser(id, currentUser) | |
100 |
1
1. lambda$getCourseById$1 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$getCourseById$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
101 | ||
102 |
1
1. getCourseById : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::getCourseById → KILLED |
return courses; |
103 | } | |
104 | ||
105 | @Operation(summary = "Create a new course") | |
106 | @PreAuthorize("hasRole('ROLE_USER')") | |
107 | @PostMapping("/post") | |
108 | public ArrayList<PSCourse> postCourses( | |
109 | @Parameter(name = "enrollCd") @RequestParam String enrollCd, | |
110 | @Parameter(name = "psId") @RequestParam Long psId) | |
111 | throws JsonProcessingException { | |
112 | CurrentUser currentUser = getCurrentUser(); | |
113 | log.info("currentUser={}", currentUser); | |
114 | ||
115 | PersonalSchedule checkPsId = | |
116 | personalScheduleRepository | |
117 | .findByIdAndUser(psId, currentUser.getUser()) | |
118 |
1
1. lambda$postCourses$2 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$postCourses$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PersonalSchedule.class, psId)); |
119 | ||
120 | String body = ucsbCurriculumService.getAllSections(enrollCd, checkPsId.getQuarter()); | |
121 |
1
1. postCourses : negated conditional → KILLED |
if (body.equals("{\"error\": \"401: Unauthorized\"}") |
122 |
1
1. postCourses : negated conditional → KILLED |
|| body.equals("{\"error\": \"Enroll code doesn't exist in that quarter.\"}")) { |
123 | throw new BadEnrollCdException(enrollCd); | |
124 | } | |
125 | ||
126 | String enrollCdPrimary = null; | |
127 | boolean hasSecondary = false; | |
128 | JsonNode courseInfo = mapper.readTree(body); | |
129 | Iterator<JsonNode> it = mapper.readTree(body).path("classSections").elements(); | |
130 |
1
1. postCourses : negated conditional → KILLED |
while (it.hasNext()) { |
131 | JsonNode classSection = it.next(); | |
132 | String section = classSection.path("section").asText(); | |
133 |
1
1. postCourses : negated conditional → KILLED |
if (section.endsWith("00")) { |
134 | String currentEnrollCd = classSection.path("enrollCode").asText(); | |
135 | enrollCdPrimary = currentEnrollCd; | |
136 |
1
1. postCourses : negated conditional → KILLED |
if (hasSecondary) break; |
137 | } else { | |
138 | hasSecondary = true; | |
139 | } | |
140 | } | |
141 | ||
142 |
1
1. postCourses : negated conditional → KILLED |
if (enrollCdPrimary == null) { |
143 | enrollCdPrimary = enrollCd; | |
144 | hasSecondary = false; | |
145 | } | |
146 | ||
147 |
1
1. postCourses : negated conditional → KILLED |
if (coursesRepository.findByPsIdAndEnrollCd(psId, enrollCdPrimary).isPresent()) { |
148 | throw new IllegalArgumentException("class exists in schedule"); | |
149 | } | |
150 | ||
151 | String quarter_YYYYQ = checkPsId.getQuarter(); | |
152 | String psName = checkPsId.getName(); | |
153 | String courseName = courseInfo.get("courseId").toString(); | |
154 | ||
155 |
1
1. postCourses : Replaced integer subtraction with addition → KILLED |
courseName = courseName.substring(1, courseName.length() - 1); |
156 | ||
157 | ArrayList<PSCourse> savedCourses = new ArrayList<>(); | |
158 | ||
159 |
1
1. postCourses : negated conditional → KILLED |
if (!enrollCdPrimary.equals(enrollCd)) { |
160 | String enrollCdSecondary = enrollCd; | |
161 | PSCourse secondary = new PSCourse(); | |
162 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setUser → KILLED |
secondary.setUser(currentUser.getUser()); |
163 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setEnrollCd → KILLED |
secondary.setEnrollCd(enrollCdSecondary); |
164 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsId → KILLED |
secondary.setPsId(psId); |
165 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsName → KILLED |
secondary.setPsName(psName); |
166 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setCourseName → KILLED |
secondary.setCourseName(courseName); |
167 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setQuarter → KILLED |
secondary.setQuarter(quarter_YYYYQ); |
168 | PSCourse savedSecondary = coursesRepository.save(secondary); | |
169 | savedCourses.add(savedSecondary); | |
170 |
1
1. postCourses : negated conditional → KILLED |
} else if (hasSecondary) { |
171 | throw new IllegalArgumentException( | |
172 | enrollCd | |
173 | + " is for a course with sections; please add a specific section and the lecture will be automatically added"); | |
174 | } | |
175 | ||
176 | PSCourse primary = new PSCourse(); | |
177 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setUser → KILLED |
primary.setUser(currentUser.getUser()); |
178 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setEnrollCd → KILLED |
primary.setEnrollCd(enrollCdPrimary); |
179 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsId → KILLED |
primary.setPsId(psId); |
180 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsName → KILLED |
primary.setPsName(psName); |
181 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setCourseName → KILLED |
primary.setCourseName(courseName); |
182 |
1
1. postCourses : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setQuarter → KILLED |
primary.setQuarter(quarter_YYYYQ); |
183 | PSCourse savedPrimary = coursesRepository.save(primary); | |
184 | savedCourses.add(savedPrimary); | |
185 |
1
1. postCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::postCourses → KILLED |
return savedCourses; |
186 | } | |
187 | ||
188 | @Operation(summary = "Delete a course (admin)") | |
189 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
190 | @DeleteMapping("/admin") | |
191 | public Object deleteCourses_Admin(@Parameter(name = "id") @RequestParam Long id) { | |
192 | PSCourse courses = | |
193 | coursesRepository | |
194 | .findById(id) | |
195 |
1
1. lambda$deleteCourses_Admin$3 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$deleteCourses_Admin$3 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
196 | ||
197 |
1
1. deleteCourses_Admin : removed call to edu/ucsb/cs156/courses/repositories/PSCourseRepository::delete → KILLED |
coursesRepository.delete(courses); |
198 | ||
199 |
1
1. deleteCourses_Admin : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourses_Admin → KILLED |
return genericMessage("PSCourse with id %s deleted".formatted(id)); |
200 | } | |
201 | ||
202 | @Operation(summary = "Delete a course (user)") | |
203 | @PreAuthorize("hasRole('ROLE_USER')") | |
204 | @DeleteMapping("/user") | |
205 | public Object deleteCourses(@Parameter(name = "id") @RequestParam Long id) | |
206 | throws JsonProcessingException { | |
207 | User currentUser = getCurrentUser().getUser(); | |
208 | PSCourse psCourse = | |
209 | coursesRepository | |
210 | .findByIdAndUser(id, currentUser) | |
211 |
1
1. lambda$deleteCourses$4 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$deleteCourses$4 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
212 | long psId = psCourse.getPsId(); | |
213 | PersonalSchedule checkPsId = | |
214 | personalScheduleRepository | |
215 | .findByIdAndUser(psId, currentUser) | |
216 |
1
1. lambda$deleteCourses$5 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$deleteCourses$5 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PersonalSchedule.class, psId)); |
217 | ||
218 | String body = | |
219 | ucsbCurriculumService.getAllSections(psCourse.getEnrollCd(), checkPsId.getQuarter()); | |
220 |
1
1. deleteCourses : negated conditional → KILLED |
if (body.equals("{\"error\": \"401: Unauthorized\"}") |
221 |
1
1. deleteCourses : negated conditional → KILLED |
|| body.equals("{\"error\": \"Enroll code doesn't exist in that quarter.\"}")) { |
222 |
1
1. deleteCourses : removed call to edu/ucsb/cs156/courses/repositories/PSCourseRepository::delete → KILLED |
coursesRepository.delete(psCourse); |
223 |
1
1. deleteCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourses → KILLED |
return genericMessage("PSCourse with id %s deleted".formatted(id)); |
224 | } | |
225 | ||
226 | Iterator<JsonNode> it = mapper.readTree(body).path("classSections").elements(); | |
227 | Optional<Long> primaryId = Optional.empty(); | |
228 | Optional<Long> secondaryId = Optional.empty(); | |
229 |
1
1. deleteCourses : negated conditional → KILLED |
while (it.hasNext()) { |
230 | JsonNode classSection = it.next(); | |
231 | String section = classSection.path("section").asText(); | |
232 | String currentEnrollCd = classSection.path("enrollCode").asText(); | |
233 | Optional<PSCourse> currentPsCourse = | |
234 | coursesRepository.findByPsIdAndEnrollCd(psId, currentEnrollCd); | |
235 |
1
1. deleteCourses : negated conditional → KILLED |
if (!currentPsCourse.isPresent()) continue; |
236 | Optional<Long> idOpt = Optional.of(currentPsCourse.get().getId()); | |
237 |
1
1. deleteCourses : negated conditional → KILLED |
if (section.endsWith("00")) primaryId = idOpt; |
238 | else secondaryId = idOpt; | |
239 |
1
1. deleteCourses : removed call to edu/ucsb/cs156/courses/repositories/PSCourseRepository::delete → KILLED |
coursesRepository.delete(currentPsCourse.get()); |
240 | } | |
241 | ||
242 |
2
1. deleteCourses : negated conditional → KILLED 2. deleteCourses : negated conditional → KILLED |
if (primaryId.isPresent() && secondaryId.isPresent()) { |
243 |
1
1. deleteCourses : negated conditional → KILLED |
if (primaryId.get() == id) |
244 |
1
1. deleteCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourses → KILLED |
return genericMessage( |
245 | "PSCourse with id %s and matching secondary with id %s deleted" | |
246 | .formatted(id, secondaryId.get())); | |
247 | else | |
248 |
1
1. deleteCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourses → KILLED |
return genericMessage( |
249 | "PSCourse with id %s and matching primary with id %s deleted" | |
250 | .formatted(id, primaryId.get())); | |
251 | } | |
252 | ||
253 |
1
1. deleteCourses : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourses → KILLED |
return genericMessage("PSCourse with id %s deleted".formatted(id)); |
254 | } | |
255 | ||
256 | @Operation(summary = "Delete a course by psId and enrollCd (user)") | |
257 | @PreAuthorize("hasRole('ROLE_USER')") | |
258 | @DeleteMapping("/user/deleteByPsIdAndEnrollCd") | |
259 | public Object deleteCourseByPsIdAndEnrollCd( | |
260 | @Parameter(name = "psId") @RequestParam Long psId, | |
261 | @Parameter(name = "enrollCd") @RequestParam String enrollCd) | |
262 | throws JsonProcessingException { | |
263 | User currentUser = getCurrentUser().getUser(); | |
264 | PSCourse psCourse = | |
265 | coursesRepository | |
266 | .findByPsIdAndEnrollCd(psId, enrollCd) | |
267 |
1
1. lambda$deleteCourseByPsIdAndEnrollCd$6 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$deleteCourseByPsIdAndEnrollCd$6 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, psId)); |
268 | long id = psCourse.getId(); | |
269 | ||
270 | // do i really need this?????? | |
271 | PersonalSchedule checkId = | |
272 | personalScheduleRepository | |
273 | .findByIdAndUser(psId, currentUser) | |
274 |
1
1. lambda$deleteCourseByPsIdAndEnrollCd$7 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$deleteCourseByPsIdAndEnrollCd$7 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PersonalSchedule.class, psId)); |
275 | ||
276 | String body = | |
277 | ucsbCurriculumService.getAllSections(psCourse.getEnrollCd(), checkId.getQuarter()); | |
278 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
if (body.equals("{\"error\": \"401: Unauthorized\"}") |
279 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
|| body.equals("{\"error\": \"Enroll code doesn't exist in that quarter.\"}")) { |
280 |
1
1. deleteCourseByPsIdAndEnrollCd : removed call to edu/ucsb/cs156/courses/repositories/PSCourseRepository::delete → KILLED |
coursesRepository.delete(psCourse); |
281 |
1
1. deleteCourseByPsIdAndEnrollCd : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourseByPsIdAndEnrollCd → KILLED |
return genericMessage("PSCourse with id %s deleted".formatted(id)); |
282 | } | |
283 | ||
284 | Iterator<JsonNode> it = mapper.readTree(body).path("classSections").elements(); | |
285 | Optional<Long> primaryId = Optional.empty(); | |
286 | Optional<Long> secondaryId = Optional.empty(); | |
287 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
while (it.hasNext()) { |
288 | JsonNode classSection = it.next(); | |
289 | String section = classSection.path("section").asText(); | |
290 | String currentEnrollCd = classSection.path("enrollCode").asText(); | |
291 | Optional<PSCourse> currentPsCourse = | |
292 | coursesRepository.findByPsIdAndEnrollCd(psId, currentEnrollCd); | |
293 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
if (!currentPsCourse.isPresent()) continue; |
294 | Optional<Long> idOpt = Optional.of(currentPsCourse.get().getId()); | |
295 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
if (section.endsWith("00")) primaryId = idOpt; |
296 | else secondaryId = idOpt; | |
297 |
1
1. deleteCourseByPsIdAndEnrollCd : removed call to edu/ucsb/cs156/courses/repositories/PSCourseRepository::delete → KILLED |
coursesRepository.delete(currentPsCourse.get()); |
298 | } | |
299 | ||
300 |
2
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED 2. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
if (primaryId.isPresent() && secondaryId.isPresent()) { |
301 |
1
1. deleteCourseByPsIdAndEnrollCd : negated conditional → KILLED |
if (primaryId.get() == id) |
302 |
1
1. deleteCourseByPsIdAndEnrollCd : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourseByPsIdAndEnrollCd → KILLED |
return genericMessage( |
303 | "PSCourse with id %s and matching secondary with id %s deleted" | |
304 | .formatted(id, secondaryId.get())); | |
305 | else | |
306 |
1
1. deleteCourseByPsIdAndEnrollCd : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourseByPsIdAndEnrollCd → KILLED |
return genericMessage( |
307 | "PSCourse with id %s and matching primary with id %s deleted" | |
308 | .formatted(id, primaryId.get())); | |
309 | } | |
310 | ||
311 |
1
1. deleteCourseByPsIdAndEnrollCd : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::deleteCourseByPsIdAndEnrollCd → KILLED |
return genericMessage("PSCourse with id %s deleted".formatted(id)); |
312 | } | |
313 | ||
314 | @Operation(summary = "Update a single Course (admin)") | |
315 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
316 | @PutMapping("/admin") | |
317 | public PSCourse putCourseById_admin( | |
318 | @Parameter(name = "id") @RequestParam Long id, @RequestBody @Valid PSCourse incomingCourses) { | |
319 | PSCourse courses = | |
320 | coursesRepository | |
321 | .findById(id) | |
322 |
1
1. lambda$putCourseById_admin$8 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$putCourseById_admin$8 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
323 | ||
324 |
1
1. putCourseById_admin : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setEnrollCd → KILLED |
courses.setEnrollCd(incomingCourses.getEnrollCd()); |
325 |
1
1. putCourseById_admin : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsId → KILLED |
courses.setPsId(incomingCourses.getPsId()); |
326 |
1
1. putCourseById_admin : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsName → KILLED |
courses.setPsName(incomingCourses.getPsName()); |
327 |
1
1. putCourseById_admin : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setCourseName → KILLED |
courses.setCourseName(incomingCourses.getCourseName()); |
328 |
1
1. putCourseById_admin : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setQuarter → KILLED |
courses.setQuarter(incomingCourses.getQuarter()); |
329 | ||
330 | coursesRepository.save(courses); | |
331 | ||
332 |
1
1. putCourseById_admin : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::putCourseById_admin → KILLED |
return courses; |
333 | } | |
334 | ||
335 | @Operation(summary = "Update a single course (user)") | |
336 | @PreAuthorize("hasRole('ROLE_USER')") | |
337 | @PutMapping("/user") | |
338 | public PSCourse putCoursesById( | |
339 | @Parameter(name = "id") @RequestParam Long id, @RequestBody @Valid PSCourse incomingCourses) { | |
340 | User currentUser = getCurrentUser().getUser(); | |
341 | PSCourse courses = | |
342 | coursesRepository | |
343 | .findByIdAndUser(id, currentUser) | |
344 |
1
1. lambda$putCoursesById$9 : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::lambda$putCoursesById$9 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(PSCourse.class, id)); |
345 | ||
346 |
1
1. putCoursesById : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setEnrollCd → KILLED |
courses.setEnrollCd(incomingCourses.getEnrollCd()); |
347 |
1
1. putCoursesById : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsId → KILLED |
courses.setPsId(incomingCourses.getPsId()); |
348 |
1
1. putCoursesById : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setPsName → KILLED |
courses.setPsName(incomingCourses.getPsName()); |
349 |
1
1. putCoursesById : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setCourseName → KILLED |
courses.setCourseName(incomingCourses.getCourseName()); |
350 |
1
1. putCoursesById : removed call to edu/ucsb/cs156/courses/entities/PSCourse::setQuarter → KILLED |
courses.setQuarter(incomingCourses.getQuarter()); |
351 | ||
352 | coursesRepository.save(courses); | |
353 | ||
354 |
1
1. putCoursesById : replaced return value with null for edu/ucsb/cs156/courses/controllers/PSCourseController::putCoursesById → KILLED |
return courses; |
355 | } | |
356 | } | |
Mutations | ||
50 |
1.1 |
|
59 |
1.1 |
|
67 |
1.1 |
|
77 |
1.1 |
|
87 |
1.1 |
|
89 |
1.1 |
|
100 |
1.1 |
|
102 |
1.1 |
|
118 |
1.1 |
|
121 |
1.1 |
|
122 |
1.1 |
|
130 |
1.1 |
|
133 |
1.1 |
|
136 |
1.1 |
|
142 |
1.1 |
|
147 |
1.1 |
|
155 |
1.1 |
|
159 |
1.1 |
|
162 |
1.1 |
|
163 |
1.1 |
|
164 |
1.1 |
|
165 |
1.1 |
|
166 |
1.1 |
|
167 |
1.1 |
|
170 |
1.1 |
|
177 |
1.1 |
|
178 |
1.1 |
|
179 |
1.1 |
|
180 |
1.1 |
|
181 |
1.1 |
|
182 |
1.1 |
|
185 |
1.1 |
|
195 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
211 |
1.1 |
|
216 |
1.1 |
|
220 |
1.1 |
|
221 |
1.1 |
|
222 |
1.1 |
|
223 |
1.1 |
|
229 |
1.1 |
|
235 |
1.1 |
|
237 |
1.1 |
|
239 |
1.1 |
|
242 |
1.1 2.2 |
|
243 |
1.1 |
|
244 |
1.1 |
|
248 |
1.1 |
|
253 |
1.1 |
|
267 |
1.1 |
|
274 |
1.1 |
|
278 |
1.1 |
|
279 |
1.1 |
|
280 |
1.1 |
|
281 |
1.1 |
|
287 |
1.1 |
|
293 |
1.1 |
|
295 |
1.1 |
|
297 |
1.1 |
|
300 |
1.1 2.2 |
|
301 |
1.1 |
|
302 |
1.1 |
|
306 |
1.1 |
|
311 |
1.1 |
|
322 |
1.1 |
|
324 |
1.1 |
|
325 |
1.1 |
|
326 |
1.1 |
|
327 |
1.1 |
|
328 |
1.1 |
|
332 |
1.1 |
|
344 |
1.1 |
|
346 |
1.1 |
|
347 |
1.1 |
|
348 |
1.1 |
|
349 |
1.1 |
|
350 |
1.1 |
|
354 |
1.1 |