| 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> allCommonss() { | |
| 38 | Iterable<UCSBOrganization> commons = ucsbOrganizationRepository.findAll(); | |
| 39 |
1
1. allCommonss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allCommonss → KILLED |
return commons; |
| 40 | } | |
| 41 | ||
| 42 | @Operation(summary= "Create a new organization") | |
| 43 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 44 | @PostMapping("/post") | |
| 45 | public UCSBOrganization postCommons( | |
| 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 | ||
| 53 | UCSBOrganization commons = new UCSBOrganization(); | |
| 54 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
commons.setOrgCode(orgCode); |
| 55 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
commons.setOrgTranslationShort(orgTranslationShort); |
| 56 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
commons.setOrgTranslation(orgTranslation); |
| 57 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
commons.setInactive(inactive); |
| 58 | ||
| 59 | UCSBOrganization savedCommons = ucsbOrganizationRepository.save(commons); | |
| 60 | ||
| 61 |
1
1. postCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postCommons → KILLED |
return savedCommons; |
| 62 | } | |
| 63 | ||
| 64 | @Operation(summary= "Get a single organization") | |
| 65 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 66 | @GetMapping("") | |
| 67 | public UCSBOrganization getById( | |
| 68 | @Parameter(name="code") @RequestParam String code) { | |
| 69 | UCSBOrganization commons = ucsbOrganizationRepository.findById(code) | |
| 70 |
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, code)); |
| 71 | ||
| 72 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return commons; |
| 73 | } | |
| 74 | ||
| 75 | @Operation(summary= "Delete a UCSBOrganization") | |
| 76 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 77 | @DeleteMapping("") | |
| 78 | public Object deleteCommons( | |
| 79 | @Parameter(name="code") @RequestParam String code) { | |
| 80 | UCSBOrganization commons = ucsbOrganizationRepository.findById(code) | |
| 81 |
1
1. lambda$deleteCommons$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteCommons$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, code)); |
| 82 | ||
| 83 |
1
1. deleteCommons : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(commons); |
| 84 |
1
1. deleteCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteCommons → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(code)); |
| 85 | } | |
| 86 | ||
| 87 | @Operation(summary= "Update a single organization") | |
| 88 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 89 | @PutMapping("") | |
| 90 | public UCSBOrganization updateCommons( | |
| 91 | @Parameter(name="code") @RequestParam String code, | |
| 92 | @RequestBody @Valid UCSBOrganization incoming) { | |
| 93 | ||
| 94 | UCSBOrganization commons = ucsbOrganizationRepository.findById(code) | |
| 95 |
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, code)); |
| 96 | ||
| 97 | ||
| 98 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
commons.setOrgCode(incoming.getOrgCode()); |
| 99 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
commons.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
| 100 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
commons.setOrgTranslation(incoming.getOrgTranslation()); |
| 101 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
commons.setInactive(incoming.getInactive()); |
| 102 | ||
| 103 | ucsbOrganizationRepository.save(commons); | |
| 104 | ||
| 105 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateCommons → KILLED |
return commons; |
| 106 | } | |
| 107 | } | |
| 108 | ||
Mutations | ||
| 39 |
1.1 |
|
| 54 |
1.1 |
|
| 55 |
1.1 |
|
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 61 |
1.1 |
|
| 70 |
1.1 |
|
| 72 |
1.1 |
|
| 81 |
1.1 |
|
| 83 |
1.1 |
|
| 84 |
1.1 |
|
| 95 |
1.1 |
|
| 98 |
1.1 |
|
| 99 |
1.1 |
|
| 100 |
1.1 |
|
| 101 |
1.1 |
|
| 105 |
1.1 |