1 | ||
2 | package edu.ucsb.cs156.example.controllers; | |
3 | ||
4 | ||
5 | import edu.ucsb.cs156.example.entities.UCSBDiningCommons; | |
6 | import edu.ucsb.cs156.example.entities.UCSBOrganization; | |
7 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
8 | ||
9 | import edu.ucsb.cs156.example.repositories.UCSBOrganizationRepository; | |
10 | ||
11 | import io.swagger.v3.oas.annotations.Operation; | |
12 | import io.swagger.v3.oas.annotations.Parameter; | |
13 | import io.swagger.v3.oas.annotations.tags.Tag; | |
14 | import lombok.extern.slf4j.Slf4j; | |
15 | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | |
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 javax.validation.Valid; | |
28 | ||
29 | @Tag(name = "UCSBOrganization") | |
30 | @RequestMapping("/api/UCSBOrganization") | |
31 | @RestController | |
32 | @Slf4j | |
33 | ||
34 | public class UCSBOrganizationController extends ApiController{ | |
35 | @Autowired | |
36 | UCSBOrganizationRepository ucsbOrganizationRepository ; | |
37 | ||
38 | @Operation(summary= "List all UCSB Organizations") | |
39 | @PreAuthorize("hasRole('ROLE_USER')") | |
40 | @GetMapping("/all") | |
41 | public Iterable<UCSBOrganization> allCommonss() { | |
42 | Iterable<UCSBOrganization> organizations = ucsbOrganizationRepository.findAll(); | |
43 |
1
1. allCommonss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allCommonss → KILLED |
return organizations; |
44 | } | |
45 | ||
46 | @Operation(summary= "Create a new Organization") | |
47 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
48 | @PostMapping("/post") | |
49 | public UCSBOrganization postCommons( | |
50 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
51 | @Parameter(name="orgTranslationShort") @RequestParam String orgTranslationShort, | |
52 | @Parameter(name="orgTranslation") @RequestParam String orgTranslation, | |
53 | @Parameter(name="inactive") @RequestParam boolean inactive | |
54 | ) | |
55 | { | |
56 | ||
57 | UCSBOrganization organizations = new UCSBOrganization(); | |
58 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organizations.setOrgCode(orgCode); |
59 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organizations.setOrgTranslationShort(orgTranslationShort); |
60 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organizations.setOrgTranslation(orgTranslation); |
61 |
1
1. postCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organizations.setInactive(inactive); |
62 | UCSBOrganization savedOrganizations = ucsbOrganizationRepository.save(organizations); | |
63 |
1
1. postCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postCommons → KILLED |
return savedOrganizations; |
64 | | |
65 | } | |
66 | @Operation(summary= "Get a single organization") | |
67 | @PreAuthorize("hasRole('ROLE_USER')") | |
68 | @GetMapping("") | |
69 | public UCSBOrganization getById( | |
70 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
71 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
72 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
73 | ||
74 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return organization; |
75 | ||
76 | } | |
77 | ||
78 | @Operation(summary= "Update a single organization") | |
79 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
80 | @PutMapping("") | |
81 | public UCSBOrganization updateCommons( | |
82 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
83 | @RequestBody @Valid UCSBOrganization incoming) { | |
84 | ||
85 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
86 |
1
1. lambda$updateCommons$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$updateCommons$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
87 | ||
88 | ||
89 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(incoming.getOrgCode()); |
90 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
91 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(incoming.getOrgTranslation()); |
92 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(incoming.getInactive()); |
93 | ||
94 | ucsbOrganizationRepository.save(organization); | |
95 | ||
96 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateCommons → KILLED |
return organization; |
97 | } | |
98 | ||
99 | @Operation(summary= "Delete a UCSBOrganization") | |
100 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
101 | @DeleteMapping("") | |
102 | public Object deleteCommons( | |
103 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
104 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
105 |
1
1. lambda$deleteCommons$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteCommons$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
106 | ||
107 |
1
1. deleteCommons : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(organization); |
108 |
1
1. deleteCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteCommons → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(orgCode)); |
109 | } | |
110 | } | |
Mutations | ||
43 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
63 |
1.1 |
|
72 |
1.1 |
|
74 |
1.1 |
|
86 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
91 |
1.1 |
|
92 |
1.1 |
|
96 |
1.1 |
|
105 |
1.1 |
|
107 |
1.1 |
|
108 |
1.1 |