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