| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 4 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItem; | |
| 5 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 6 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
| 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 jakarta.validation.Valid; | |
| 11 | import lombok.extern.slf4j.Slf4j; | |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 14 | import org.springframework.web.bind.annotation.*; | |
| 15 | ||
| 16 | @Tag(name = "UCSBDiningCommonsMenuItems") | |
| 17 | @RequestMapping("/api/UCSBDiningCommonsMenuItem") | |
| 18 | @RestController | |
| 19 | @Slf4j | |
| 20 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 21 | ||
| 22 | @Autowired UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 23 | ||
| 24 | @Operation(summary = "List all UCSB Dining Commons menu items") | |
| 25 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 26 | @GetMapping("/all") | |
| 27 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItems() { | |
| 28 |
1
1. allUCSBDiningCommonsMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItems → KILLED |
return ucsbDiningCommonsMenuItemRepository.findAll(); |
| 29 | } | |
| 30 | ||
| 31 | @Operation(summary = "Get a single UCSB Dining Commons menu item") | |
| 32 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 33 | @GetMapping("") | |
| 34 | public UCSBDiningCommonsMenuItem getById(@Parameter(name = "id") @RequestParam Long id) { | |
| 35 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItemRepository |
| 36 | .findById(id) | |
| 37 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 38 | } | |
| 39 | ||
| 40 | @Operation(summary = "Create a new UCSB Dining Commons menu item") | |
| 41 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 42 | @PostMapping("/post") | |
| 43 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 44 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 45 | @Parameter(name = "name") @RequestParam String name, | |
| 46 | @Parameter(name = "station") @RequestParam String station) | |
| 47 | throws JsonProcessingException { | |
| 48 | ||
| 49 | UCSBDiningCommonsMenuItem menuItem = new UCSBDiningCommonsMenuItem(); | |
| 50 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(diningCommonsCode); |
| 51 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
menuItem.setName(name); |
| 52 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
menuItem.setStation(station); |
| 53 | ||
| 54 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItemRepository.save(menuItem); |
| 55 | } | |
| 56 | ||
| 57 | @Operation(summary = "Update a single UCSB Dining Commons menu item") | |
| 58 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 59 | @PutMapping("") | |
| 60 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 61 | @Parameter(name = "id") @RequestParam Long id, | |
| 62 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 63 | ||
| 64 | UCSBDiningCommonsMenuItem menuItem = | |
| 65 | ucsbDiningCommonsMenuItemRepository | |
| 66 | .findById(id) | |
| 67 |
1
1. lambda$updateUCSBDiningCommonsMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonsMenuItem$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 68 | ||
| 69 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
menuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 70 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
menuItem.setName(incoming.getName()); |
| 71 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
menuItem.setStation(incoming.getStation()); |
| 72 | ||
| 73 | ucsbDiningCommonsMenuItemRepository.save(menuItem); | |
| 74 | ||
| 75 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return menuItem; |
| 76 | } | |
| 77 | ||
| 78 | @Operation(summary = "Delete a UCSB Dining Commons menu item") | |
| 79 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 80 | @DeleteMapping("") | |
| 81 | public Object deleteUCSBDiningCommonsMenuItem(@Parameter(name = "id") @RequestParam Long id) { | |
| 82 | ||
| 83 | UCSBDiningCommonsMenuItem menuItem = | |
| 84 | ucsbDiningCommonsMenuItemRepository | |
| 85 | .findById(id) | |
| 86 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 87 | ||
| 88 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(menuItem); |
| 89 | ||
| 90 |
1
1. deleteUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteUCSBDiningCommonsMenuItem → KILLED |
return genericMessage("UCSBDiningCommonsMenuItem with id %s deleted".formatted(id)); |
| 91 | } | |
| 92 | } | |
Mutations | ||
| 28 |
1.1 |
|
| 35 |
1.1 |
|
| 37 |
1.1 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |
|
| 52 |
1.1 |
|
| 54 |
1.1 |
|
| 67 |
1.1 |
|
| 69 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 75 |
1.1 |
|
| 86 |
1.1 |
|
| 88 |
1.1 |
|
| 90 |
1.1 |