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