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