| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBOrganization; | |
| 4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 5 | import edu.ucsb.cs156.example.repositories.UCSBOrganizationRepository; | |
| 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 jakarta.validation.Valid; | |
| 10 | import lombok.extern.slf4j.Slf4j; | |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 14 | import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | import org.springframework.web.bind.annotation.PutMapping; | |
| 17 | import org.springframework.web.bind.annotation.RequestBody; | |
| 18 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 19 | import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | import org.springframework.web.bind.annotation.RestController; | |
| 21 | ||
| 22 | @Tag(name = "UCSBOrganization") | |
| 23 | @RequestMapping("/api/ucsborganization") | |
| 24 | @RestController | |
| 25 | @Slf4j | |
| 26 | public class UCSBOrganizationController extends ApiController { | |
| 27 | ||
| 28 | @Autowired UCSBOrganizationRepository ucsbOrganizationRepository; | |
| 29 | ||
| 30 | @Operation(summary = "List all UCSB organizations") | |
| 31 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 32 | @GetMapping("/all") | |
| 33 | public Iterable<UCSBOrganization> allOrganizations() { | |
| 34 |
1
1. allOrganizations : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allOrganizations → KILLED |
return ucsbOrganizationRepository.findAll(); |
| 35 | } | |
| 36 | ||
| 37 | @Operation(summary = "Get a single UCSB organization") | |
| 38 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 39 | @GetMapping("") | |
| 40 | public UCSBOrganization getById(@Parameter(name = "orgCode") @RequestParam String orgCode) { | |
| 41 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return ucsbOrganizationRepository |
| 42 | .findById(orgCode) | |
| 43 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
| 44 | } | |
| 45 | ||
| 46 | @Operation(summary = "Create a new UCSB organization") | |
| 47 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 48 | @PostMapping("/post") | |
| 49 | public UCSBOrganization postOrganization( | |
| 50 | @Parameter(name = "orgCode") @RequestParam String orgCode, | |
| 51 | @Parameter(name = "orgTranslationShort") @RequestParam String orgTranslationShort, | |
| 52 | @Parameter(name = "orgTranslation") @RequestParam String orgTranslation, | |
| 53 | @Parameter(name = "inactive") @RequestParam boolean inactive) { | |
| 54 | ||
| 55 | UCSBOrganization organization = new UCSBOrganization(); | |
| 56 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(orgCode); |
| 57 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(orgTranslationShort); |
| 58 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(orgTranslation); |
| 59 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(inactive); |
| 60 | ||
| 61 |
1
1. postOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postOrganization → KILLED |
return ucsbOrganizationRepository.save(organization); |
| 62 | } | |
| 63 | ||
| 64 | @Operation(summary = "Delete a UCSB organization") | |
| 65 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 66 | @DeleteMapping("") | |
| 67 | public Object deleteOrganization(@Parameter(name = "orgCode") @RequestParam String orgCode) { | |
| 68 | ||
| 69 | UCSBOrganization organization = | |
| 70 | ucsbOrganizationRepository | |
| 71 | .findById(orgCode) | |
| 72 |
1
1. lambda$deleteOrganization$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteOrganization$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
| 73 | ||
| 74 |
1
1. deleteOrganization : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(organization); |
| 75 |
1
1. deleteOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteOrganization → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(orgCode)); |
| 76 | } | |
| 77 | ||
| 78 | @Operation(summary = "Update a UCSB organization") | |
| 79 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 80 | @PutMapping("") | |
| 81 | public UCSBOrganization updateOrganization( | |
| 82 | @Parameter(name = "orgCode") @RequestParam String orgCode, | |
| 83 | @RequestBody @Valid UCSBOrganization incoming) { | |
| 84 | ||
| 85 | UCSBOrganization organization = | |
| 86 | ucsbOrganizationRepository | |
| 87 | .findById(orgCode) | |
| 88 |
1
1. lambda$updateOrganization$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$updateOrganization$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
| 89 | ||
| 90 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
| 91 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(incoming.getOrgTranslation()); |
| 92 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(incoming.getInactive()); |
| 93 | ||
| 94 | ucsbOrganizationRepository.save(organization); | |
| 95 |
1
1. updateOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateOrganization → KILLED |
return organization; |
| 96 | } | |
| 97 | } | |
Mutations | ||
| 34 |
1.1 |
|
| 41 |
1.1 |
|
| 43 |
1.1 |
|
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 58 |
1.1 |
|
| 59 |
1.1 |
|
| 61 |
1.1 |
|
| 72 |
1.1 |
|
| 74 |
1.1 |
|
| 75 |
1.1 |
|
| 88 |
1.1 |
|
| 90 |
1.1 |
|
| 91 |
1.1 |
|
| 92 |
1.1 |
|
| 95 |
1.1 |