1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBDiningCommons; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.UCSBDiningCommonsRepository; | |
6 | import io.swagger.annotations.Api; | |
7 | import io.swagger.annotations.ApiOperation; | |
8 | import io.swagger.annotations.ApiParam; | |
9 | import lombok.extern.slf4j.Slf4j; | |
10 | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | |
12 | import org.springframework.security.access.prepost.PreAuthorize; | |
13 | import org.springframework.web.bind.annotation.DeleteMapping; | |
14 | import org.springframework.web.bind.annotation.GetMapping; | |
15 | import org.springframework.web.bind.annotation.PostMapping; | |
16 | import org.springframework.web.bind.annotation.PutMapping; | |
17 | import org.springframework.web.bind.annotation.RequestBody; | |
18 | import org.springframework.web.bind.annotation.RequestMapping; | |
19 | import org.springframework.web.bind.annotation.RequestParam; | |
20 | import org.springframework.web.bind.annotation.RestController; | |
21 | ||
22 | import javax.validation.Valid; | |
23 | ||
24 | ||
25 | @Api(description = "UCSBDiningCommons") | |
26 | @RequestMapping("/api/ucsbdiningcommons") | |
27 | @RestController | |
28 | @Slf4j | |
29 | public class UCSBDiningCommonsController extends ApiController { | |
30 | ||
31 | @Autowired | |
32 | UCSBDiningCommonsRepository ucsbDiningCommonsRepository; | |
33 | ||
34 | @ApiOperation(value = "List all ucsb dining commons") | |
35 | @PreAuthorize("hasRole('ROLE_USER')") | |
36 | @GetMapping("/all") | |
37 | public Iterable<UCSBDiningCommons> allCommonss() { | |
38 | Iterable<UCSBDiningCommons> commons = ucsbDiningCommonsRepository.findAll(); | |
39 |
1
1. allCommonss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::allCommonss → KILLED |
return commons; |
40 | } | |
41 | ||
42 | @ApiOperation(value = "Get a single commons") | |
43 | @PreAuthorize("hasRole('ROLE_USER')") | |
44 | @GetMapping("") | |
45 | public UCSBDiningCommons getById( | |
46 | @ApiParam("code") @RequestParam String code) { | |
47 | UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code) | |
48 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code)); |
49 | ||
50 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::getById → KILLED |
return commons; |
51 | } | |
52 | ||
53 | @ApiOperation(value = "Create a new commons") | |
54 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
55 | @PostMapping("/post") | |
56 | public UCSBDiningCommons postCommons( | |
57 | @ApiParam("code") @RequestParam String code, | |
58 | @ApiParam("name") @RequestParam String name, | |
59 | @ApiParam("hasSackMeal") @RequestParam boolean hasSackMeal, | |
60 | @ApiParam("hasTakeOutMeal") @RequestParam boolean hasTakeOutMeal, | |
61 | @ApiParam("hasDiningCam") @RequestParam boolean hasDiningCam, | |
62 | @ApiParam("latitude") @RequestParam double latitude, | |
63 | @ApiParam("longitude") @RequestParam double longitude | |
64 | ) | |
65 | { | |
66 | ||
67 | UCSBDiningCommons commons = new UCSBDiningCommons(); | |
68 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setCode → KILLED |
commons.setCode(code); |
69 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED |
commons.setName(name); |
70 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED |
commons.setHasSackMeal(hasSackMeal); |
71 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED |
commons.setHasTakeOutMeal(hasTakeOutMeal); |
72 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED |
commons.setHasDiningCam(hasDiningCam); |
73 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED |
commons.setLatitude(latitude); |
74 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED |
commons.setLongitude(longitude); |
75 | ||
76 | UCSBDiningCommons savedCommons = ucsbDiningCommonsRepository.save(commons); | |
77 | ||
78 |
1
1. postCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::postCommons → KILLED |
return savedCommons; |
79 | } | |
80 | ||
81 | @ApiOperation(value = "Delete a UCSBDiningCommons") | |
82 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
83 | @DeleteMapping("") | |
84 | public Object deleteCommons( | |
85 | @ApiParam("code") @RequestParam String code) { | |
86 | UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code) | |
87 |
1
1. lambda$deleteCommons$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$deleteCommons$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code)); |
88 | ||
89 |
1
1. deleteCommons : removed call to edu/ucsb/cs156/example/repositories/UCSBDiningCommonsRepository::delete → KILLED |
ucsbDiningCommonsRepository.delete(commons); |
90 |
1
1. deleteCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::deleteCommons → KILLED |
return genericMessage("UCSBDiningCommons with id %s deleted".formatted(code)); |
91 | } | |
92 | ||
93 | @ApiOperation(value = "Update a single commons") | |
94 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
95 | @PutMapping("") | |
96 | public UCSBDiningCommons updateCommons( | |
97 | @ApiParam("code") @RequestParam String code, | |
98 | @RequestBody @Valid UCSBDiningCommons incoming) { | |
99 | ||
100 | UCSBDiningCommons commons = ucsbDiningCommonsRepository.findById(code) | |
101 |
1
1. lambda$updateCommons$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::lambda$updateCommons$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBDiningCommons.class, code)); |
102 | ||
103 | ||
104 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setName → KILLED |
commons.setName(incoming.getName()); |
105 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasSackMeal → KILLED |
commons.setHasSackMeal(incoming.getHasSackMeal()); |
106 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasTakeOutMeal → KILLED |
commons.setHasTakeOutMeal(incoming.getHasTakeOutMeal()); |
107 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setHasDiningCam → KILLED |
commons.setHasDiningCam(incoming.getHasDiningCam()); |
108 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLatitude → KILLED |
commons.setLatitude(incoming.getLatitude()); |
109 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBDiningCommons::setLongitude → KILLED |
commons.setLongitude(incoming.getLongitude()); |
110 | ||
111 | ucsbDiningCommonsRepository.save(commons); | |
112 | ||
113 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBDiningCommonsController::updateCommons → KILLED |
return commons; |
114 | } | |
115 | } | |
Mutations | ||
39 |
1.1 |
|
48 |
1.1 |
|
50 |
1.1 |
|
68 |
1.1 |
|
69 |
1.1 |
|
70 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
78 |
1.1 |
|
87 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
101 |
1.1 |
|
104 |
1.1 |
|
105 |
1.1 |
|
106 |
1.1 |
|
107 |
1.1 |
|
108 |
1.1 |
|
109 |
1.1 |
|
113 |
1.1 |