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