| 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.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 | /** This is a REST controller for UCSBDiningCommonsMenuItem */ | |
| 24 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 25 | @RequestMapping("/api/UCSBDiningCommonsMenuItem") | |
| 26 | @RestController | |
| 27 | @Slf4j | |
| 28 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 29 | ||
| 30 | @Autowired UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 31 | ||
| 32 | /** | |
| 33 | * List all UCSBDiningCommonsMenuItem | |
| 34 | * | |
| 35 | * @return an iterable of UCSBDiningCommonsMenuItem | |
| 36 | */ | |
| 37 | @Operation(summary = "List all UCSBDiningCommonsMenuItem") | |
| 38 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 39 | @GetMapping("/all") | |
| 40 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItem() { | |
| 41 | Iterable<UCSBDiningCommonsMenuItem> items = ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 42 | ||
| 43 |
1
1. allUCSBDiningCommonsMenuItem : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItem → KILLED |
return items; |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Get a single MenuItem by id | |
| 48 | * | |
| 49 | * @param id the id of the MenuItem | |
| 50 | * @return a UCSBDiningCommonsMenuItem | |
| 51 | */ | |
| 52 | @Operation(summary = "Get a single UCSBDiningCommonsMenuItem") | |
| 53 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 54 | @GetMapping("") | |
| 55 | public UCSBDiningCommonsMenuItem getById(@Parameter(name = "id") @RequestParam Long id) { | |
| 56 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 57 | ucsbDiningCommonsMenuItemRepository | |
| 58 | .findById(id) | |
| 59 |
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)); |
| 60 | ||
| 61 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItem; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Create a new UCSBDiningCommonsMenuItem | |
| 66 | * | |
| 67 | * @param diningCommonsCode the dining commons code | |
| 68 | * @param name the name of the menu item | |
| 69 | * @param station the station where the menu item is served | |
| 70 | * @return the saved UCSBDiningCommonsMenuItem | |
| 71 | */ | |
| 72 | @Operation(summary = "Create a new UCSBDiningCommonsMenuItem") | |
| 73 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 74 | @PostMapping("/post") | |
| 75 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
| 76 | @Parameter(name = "diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 77 | @Parameter(name = "name") @RequestParam String name, | |
| 78 | @Parameter(name = "station") @RequestParam String station) | |
| 79 | throws JsonProcessingException { | |
| 80 | ||
| 81 | UCSBDiningCommonsMenuItem item = new UCSBDiningCommonsMenuItem(); | |
| 82 | ||
| 83 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
item.setDiningCommonsCode(diningCommonsCode); |
| 84 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
item.setName(name); |
| 85 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
item.setStation(station); |
| 86 | ||
| 87 | UCSBDiningCommonsMenuItem savedItem = ucsbDiningCommonsMenuItemRepository.save(item); | |
| 88 | ||
| 89 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedItem; |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * Delete a UCSBDiningCommonsMenuItem | |
| 94 | * | |
| 95 | * @param id the id of the UCSBDiningCommonsMenuItem to delete | |
| 96 | * @return a message indicating the UCSBDiningCommonsMenuItem was deleted | |
| 97 | */ | |
| 98 | @Operation(summary = "Delete a UCSBDiningCommonsMenuItem") | |
| 99 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 100 | @DeleteMapping("") | |
| 101 | public Object deleteUCSBDiningCommonsMenuItem(@Parameter(name = "id") @RequestParam Long id) { | |
| 102 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 103 | ucsbDiningCommonsMenuItemRepository | |
| 104 | .findById(id) | |
| 105 |
1
1. lambda$deleteUCSBDiningCommonsMenuItem$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonsMenuItem$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 106 | ||
| 107 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
| 108 |
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)); |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Update a single UCSBDiningCommonsMenuItem | |
| 113 | * | |
| 114 | * @param id id of the UCSBDiningCommonsMenuItem to update | |
| 115 | * @param incoming the new UCSBDiningCommonsMenuItem | |
| 116 | * @return the updated UCSBDiningCommonsMenuItem object | |
| 117 | */ | |
| 118 | @Operation(summary = "Update a single UCSBDiningCommonsMenuItem") | |
| 119 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 120 | @PutMapping("") | |
| 121 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
| 122 | @Parameter(name = "id") @RequestParam Long id, | |
| 123 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
| 124 | ||
| 125 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = | |
| 126 | ucsbDiningCommonsMenuItemRepository | |
| 127 | .findById(id) | |
| 128 |
1
1. lambda$updateUCSBDiningCommonsMenuItem$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonsMenuItem$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonsMenuItem.class, id)); |
| 129 | ||
| 130 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
| 131 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(incoming.getName()); |
| 132 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(incoming.getStation()); |
| 133 | ||
| 134 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
| 135 | ||
| 136 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItem; |
| 137 | } | |
| 138 | } | |
Mutations | ||
| 43 |
1.1 |
|
| 59 |
1.1 |
|
| 61 |
1.1 |
|
| 83 |
1.1 |
|
| 84 |
1.1 |
|
| 85 |
1.1 |
|
| 89 |
1.1 |
|
| 105 |
1.1 |
|
| 107 |
1.1 |
|
| 108 |
1.1 |
|
| 128 |
1.1 |
|
| 130 |
1.1 |
|
| 131 |
1.1 |
|
| 132 |
1.1 |
|
| 136 |
1.1 |