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