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