| 1 | package edu.ucsb.cs156.example.controllers; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.example.entities.UCSBDate; | |
| 4 | import edu.ucsb.cs156.example.entities.UCSBDiningCommonMenuItem; | |
| 5 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
| 6 | import edu.ucsb.cs156.example.repositories.UCSBDateRepository; | |
| 7 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsMenuItemRepository; | |
| 8 | import io.swagger.v3.oas.annotations.Operation; | |
| 9 | import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | |
| 11 | import lombok.extern.slf4j.Slf4j; | |
| 12 | ||
| 13 | import com.fasterxml.jackson.core.JsonProcessingException; | |
| 14 | ||
| 15 | import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | import org.springframework.format.annotation.DateTimeFormat; | |
| 17 | import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | import org.springframework.web.bind.annotation.DeleteMapping; | |
| 19 | import org.springframework.web.bind.annotation.GetMapping; | |
| 20 | import org.springframework.web.bind.annotation.PostMapping; | |
| 21 | import org.springframework.web.bind.annotation.PutMapping; | |
| 22 | import org.springframework.web.bind.annotation.RequestBody; | |
| 23 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 24 | import org.springframework.web.bind.annotation.RequestParam; | |
| 25 | import org.springframework.web.bind.annotation.RestController; | |
| 26 | ||
| 27 | import jakarta.validation.Valid; | |
| 28 | ||
| 29 | import java.time.LocalDateTime; | |
| 30 | ||
| 31 | @Tag(name = "UCSBDiningCommonsMenuItem") | |
| 32 | @RequestMapping("/api/ucsbdiningcommonsmenuitem") | |
| 33 | @RestController | |
| 34 | @Slf4j | |
| 35 | ||
| 36 | public class UCSBDiningCommonsMenuItemController extends ApiController { | |
| 37 |     @Autowired | |
| 38 |     UCSBDiningCommonsMenuItemRepository ucsbDiningCommonsMenuItemRepository; | |
| 39 | ||
| 40 |     @Operation(summary= "List all menu items") | |
| 41 |     @PreAuthorize("hasRole('ROLE_USER')") | |
| 42 |     @GetMapping("/all") | |
| 43 |     public Iterable<UCSBDiningCommonMenuItem> allUCSBDiningCommonsMenuItems() { | |
| 44 |         Iterable<UCSBDiningCommonMenuItem> menuItem = ucsbDiningCommonsMenuItemRepository.findAll(); | |
| 45 | 
1
1. allUCSBDiningCommonsMenuItems : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::allUCSBDiningCommonsMenuItems → KILLED | 
        return menuItem; | 
| 46 |     } | |
| 47 | ||
| 48 |     @Operation(summary= "Get a single menu item") | |
| 49 |     @PreAuthorize("hasRole('ROLE_USER')") | |
| 50 |     @GetMapping("") | |
| 51 |     public UCSBDiningCommonMenuItem getById( | |
| 52 |             @Parameter(name="id") @RequestParam Long id) { | |
| 53 |         UCSBDiningCommonMenuItem ucsbDiningCommonMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 54 | 
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$getById$0 → KILLED | 
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonMenuItem.class, id)); | 
| 55 | ||
| 56 | 
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::getById → KILLED | 
        return ucsbDiningCommonMenuItem; | 
| 57 |     } | |
| 58 | ||
| 59 |     @Operation(summary= "Create a new menu item") | |
| 60 |     @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 61 |     @PostMapping("/post") | |
| 62 |     public UCSBDiningCommonMenuItem postUCSBDiningCommonsMenuItem( | |
| 63 |         @Parameter(name="diningCommonsCode") @RequestParam String diningCommonsCode, | |
| 64 |         @Parameter(name="name") @RequestParam String name, | |
| 65 |         @Parameter(name="station") @RequestParam String station) | |
| 66 |         throws JsonProcessingException { | |
| 67 | ||
| 68 |     // For an explanation of @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | |
| 69 |     // See: https://www.baeldung.com/spring-date-parameters | |
| 70 | ||
| 71 |     //log.info("localDateTime={}", localDateTime); | |
| 72 | ||
| 73 |     UCSBDiningCommonMenuItem ucsbDiningCommonMenuItem = new UCSBDiningCommonMenuItem(); | |
| 74 | 
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setDiningCommonsCode → KILLED | 
    ucsbDiningCommonMenuItem.setDiningCommonsCode(diningCommonsCode); | 
| 75 | 
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setName → KILLED | 
    ucsbDiningCommonMenuItem.setName(name); | 
| 76 | 
1
1. postUCSBDiningCommonsMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setStation → KILLED | 
    ucsbDiningCommonMenuItem.setStation(station); | 
| 77 | ||
| 78 |     UCSBDiningCommonMenuItem savedUcsbDiningCommonMenuItem = ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonMenuItem); | |
| 79 | ||
| 80 | 
1
1. postUCSBDiningCommonsMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::postUCSBDiningCommonsMenuItem → KILLED | 
    return savedUcsbDiningCommonMenuItem; | 
| 81 | } | |
| 82 | ||
| 83 |     @Operation(summary= "Delete a menu item") | |
| 84 |     @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 85 |     @DeleteMapping("") | |
| 86 |     public Object deleteUCSBDiningCommonMenuItem( | |
| 87 |             @Parameter(name="id") @RequestParam Long id) { | |
| 88 |         UCSBDiningCommonMenuItem ucsbDiningCommonMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 89 | 
1
1. lambda$deleteUCSBDiningCommonMenuItem$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$deleteUCSBDiningCommonMenuItem$1 → KILLED | 
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonMenuItem.class, id)); | 
| 90 | ||
| 91 | 
1
1. deleteUCSBDiningCommonMenuItem : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsMenuItemRepository::delete → KILLED | 
        ucsbDiningCommonsMenuItemRepository.delete(ucsbDiningCommonMenuItem); | 
| 92 | 
1
1. deleteUCSBDiningCommonMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::deleteUCSBDiningCommonMenuItem → KILLED | 
        return genericMessage("UCSBDiningCommonMenuItem with id %s deleted".formatted(id)); | 
| 93 |     } | |
| 94 | ||
| 95 |     @Operation(summary= "Update a single menu item") | |
| 96 |     @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 97 |     @PutMapping("") | |
| 98 |     public UCSBDiningCommonMenuItem updateUCSBDiningCommonMenuItem( | |
| 99 |             @Parameter(name="id") @RequestParam Long id, | |
| 100 |             @RequestBody @Valid UCSBDiningCommonMenuItem incoming) { | |
| 101 | ||
| 102 |         UCSBDiningCommonMenuItem ucsbDiningCommonMenuItem = ucsbDiningCommonsMenuItemRepository.findById(id) | |
| 103 | 
1
1. lambda$updateUCSBDiningCommonMenuItem$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::lambda$updateUCSBDiningCommonMenuItem$2 → KILLED | 
                .orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommonMenuItem.class, id)); | 
| 104 | ||
| 105 | 
1
1. updateUCSBDiningCommonMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setDiningCommonsCode → KILLED | 
        ucsbDiningCommonMenuItem.setDiningCommonsCode(incoming.getDiningCommonsCode()); | 
| 106 | 
1
1. updateUCSBDiningCommonMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setName → KILLED | 
        ucsbDiningCommonMenuItem.setName(incoming.getName()); | 
| 107 | 
1
1. updateUCSBDiningCommonMenuItem : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommonMenuItem::setStation → KILLED | 
        ucsbDiningCommonMenuItem.setStation(incoming.getStation()); | 
| 108 | ||
| 109 |         ucsbDiningCommonsMenuItemRepository.save(ucsbDiningCommonMenuItem); | |
| 110 | ||
| 111 | 
1
1. updateUCSBDiningCommonMenuItem : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsMenuItemController::updateUCSBDiningCommonMenuItem → KILLED | 
        return ucsbDiningCommonMenuItem; | 
| 112 |     } | |
| 113 | ||
| 114 | } | |
Mutations | ||
| 45 | 
 
 1.1  | 
|
| 54 | 
 
 1.1  | 
|
| 56 | 
 
 1.1  | 
|
| 74 | 
 
 1.1  | 
|
| 75 | 
 
 1.1  | 
|
| 76 | 
 
 1.1  | 
|
| 80 | 
 
 1.1  | 
|
| 89 | 
 
 1.1  | 
|
| 91 | 
 
 1.1  | 
|
| 92 | 
 
 1.1  | 
|
| 103 | 
 
 1.1  | 
|
| 105 | 
 
 1.1  | 
|
| 106 | 
 
 1.1  | 
|
| 107 | 
 
 1.1  | 
|
| 111 | 
 
 1.1  |