1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonsMenuItem; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
6 | ||
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 lombok.extern.slf4j.Slf4j; | |
11 | ||
12 | import com.fasterxml.jackson.core.JsonProcessingException; | |
13 | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | |
15 | import org.springframework.format.annotation.DateTimeFormat; | |
16 | import org.springframework.security.access.prepost.PreAuthorize; | |
17 | import org.springframework.web.bind.annotation.DeleteMapping; | |
18 | import org.springframework.web.bind.annotation.GetMapping; | |
19 | import org.springframework.web.bind.annotation.PostMapping; | |
20 | import org.springframework.web.bind.annotation.PutMapping; | |
21 | import org.springframework.web.bind.annotation.RequestBody; | |
22 | import org.springframework.web.bind.annotation.RequestMapping; | |
23 | import org.springframework.web.bind.annotation.RequestParam; | |
24 | import org.springframework.web.bind.annotation.RestController; | |
25 | ||
26 | import jakarta.validation.Valid; | |
27 | ||
28 | /** | |
29 | * This is a REST controller for UCSBDiningCommonsMenuItem | |
30 | */ | |
31 | ||
32 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
33 | @RequestMapping("/api/ucsbdiningcommonsmenuitems") | |
34 | @RestController | |
35 | @Slf4j | |
36 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
37 | ||
38 | @Autowired | |
39 | UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
40 | ||
41 | /** | |
42 | * List all UCSB dining commons menu items | |
43 | * | |
44 | * @return an iterable of UCSBDiningCommonsMenuItem | |
45 | */ | |
46 | @Operation(summary= "List all ucsb dining commons menu items") | |
47 | @PreAuthorize("hasRole('ROLE_USER')") | |
48 | @GetMapping("/all") | |
49 | public Iterable<UCSBDiningCommonsMenuItem> allUCSBDiningCommonsMenuItems() { | |
50 | Iterable<UCSBDiningCommonsMenuItem> diningCommonsMenuItems = ucsbDiningCommonsMenuItemRepository.findAll(); | |
51 |
1
1. allUCSBDiningCommonsMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItems → KILLED |
return diningCommonsMenuItems; |
52 | } | |
53 | ||
54 | /** | |
55 | * Create a new dining commons menu item | |
56 | * | |
57 | * @param diningCommonsCode the dining commons code | |
58 | * @param name the name of the dining commons menu item | |
59 | * @param station the station | |
60 | * @return the saved ucsbDiningCommonsMenuItem | |
61 | */ | |
62 | @Operation(summary= "Create a new dining commons menu item") | |
63 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
64 | @PostMapping("/post") | |
65 | public UCSBDiningCommonsMenuItem postUCSBDiningCommonsMenuItem( | |
66 | @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
67 | @Parameter(name="name") @RequestParam String name, | |
68 | @Parameter(name="station") @RequestParam String station) | |
69 | throws JsonProcessingException { | |
70 | ||
71 | UCSBDiningCommonsMenuItem ucsbDinUCSBDiningCommonsMenuItem = new UCSBDiningCommonsMenuItem(); | |
72 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDinUCSBDiningCommonsMenuItem.setDiningCommonsCode(diningCommonsCode); |
73 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDinUCSBDiningCommonsMenuItem.setName(name); |
74 |
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDinUCSBDiningCommonsMenuItem.setStation(station); |
75 | ||
76 | UCSBDiningCommonsMenuItem savedUcsbDinUCSBDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.save(ucsbDinUCSBDiningCommonsMenuItem); | |
77 | ||
78 |
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED |
return savedUcsbDinUCSBDiningCommonsMenuItem; |
79 | } | |
80 | ||
81 | ||
82 | /** | |
83 | * Get a single dining commons menu item by id | |
84 | * | |
85 | * @param id the id of the dining commons menu item | |
86 | * @return a UCSBDiningCommonsMenuItem | |
87 | */ | |
88 | @Operation(summary= "Get a single dining commons menu item") | |
89 | @PreAuthorize("hasRole('ROLE_USER')") | |
90 | @GetMapping("") | |
91 | public UCSBDiningCommonsMenuItem getById( | |
92 | @Parameter(name="id") @RequestParam Long id) { | |
93 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
94 |
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)); |
95 | ||
96 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED |
return ucsbDiningCommonsMenuItem; |
97 | } | |
98 | ||
99 | /** | |
100 | * Update a single dining commons menu item | |
101 | * | |
102 | * @param id id of the dining commons menu item to update | |
103 | * @param incoming the new dining commons menu item | |
104 | * @return the updated diningcommonsmenuitem object | |
105 | */ | |
106 | @Operation(summary= "Update a single dining commons menu item") | |
107 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
108 | @PutMapping("") | |
109 | public UCSBDiningCommonsMenuItem updateUCSBDiningCommonsMenuItem( | |
110 | @Parameter(name="id") @RequestParam Long id, | |
111 | @RequestBody @Valid UCSBDiningCommonsMenuItem incoming) { | |
112 | ||
113 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
114 |
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)); |
115 | ||
116 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setDiningCommonsCode → KILLED |
ucsbDiningCommonsMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); |
117 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setName → KILLED |
ucsbDiningCommonsMenuItem.setName(incoming.getName()); |
118 |
1
1. updateUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonsMenuItem::setStation → KILLED |
ucsbDiningCommonsMenuItem.setStation(incoming.getStation()); |
119 | ||
120 | ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonsMenuItem); | |
121 | ||
122 |
1
1. updateUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonsMenuItem → KILLED |
return ucsbDiningCommonsMenuItem; |
123 | } | |
124 | ||
125 | /** | |
126 | * Delete a UCSBDiningCommonsMenuItem | |
127 | * | |
128 | * @param id the id of the dining commons menu item to delete | |
129 | * @return a message indicating the dining commons menu item was deleted | |
130 | */ | |
131 | @Operation(summary= "Delete a UCSBDiningCommonsMenuItem") | |
132 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
133 | @DeleteMapping("") | |
134 | public Object deleteUCSBDiningCommonsMenuItem( | |
135 | @Parameter(name="id") @RequestParam Long id) { | |
136 | UCSBDiningCommonsMenuItem ucsbDiningCommonsMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
137 |
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)); |
138 | ||
139 |
1
1. deleteUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED |
ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonsMenuItem); |
140 |
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)); |
141 | } | |
142 | } | |
143 | ||
Mutations | ||
51 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
78 |
1.1 |
|
94 |
1.1 |
|
96 |
1.1 |
|
114 |
1.1 |
|
116 |
1.1 |
|
117 |
1.1 |
|
118 |
1.1 |
|
122 |
1.1 |
|
137 |
1.1 |
|
139 |
1.1 |
|
140 |
1.1 |