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