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