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