1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBOrganization; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.UCSBOrganizationRepository; | |
6 | ||
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 org.springframework.beans.factory.annotation.Autowired; | |
13 | import org.springframework.security.access.prepost.PreAuthorize; | |
14 | import org.springframework.web.bind.annotation.DeleteMapping; | |
15 | import org.springframework.web.bind.annotation.GetMapping; | |
16 | import org.springframework.web.bind.annotation.PostMapping; | |
17 | import org.springframework.web.bind.annotation.PutMapping; | |
18 | import org.springframework.web.bind.annotation.RequestBody; | |
19 | import org.springframework.web.bind.annotation.RequestMapping; | |
20 | import org.springframework.web.bind.annotation.RequestParam; | |
21 | import org.springframework.web.bind.annotation.RestController; | |
22 | ||
23 | import javax.validation.Valid; | |
24 | ||
25 | @Tag(name = "UCSBOrganization") | |
26 | @RequestMapping("/api/ucsborganization") | |
27 | @RestController | |
28 | @Slf4j | |
29 | public class UCSBOrganizationController extends ApiController { | |
30 | ||
31 | @Autowired | |
32 | UCSBOrganizationRepository ucsbOrganizationRepository; | |
33 | ||
34 | @Operation(summary= "List all ucsb organizations") | |
35 | @PreAuthorize("hasRole('ROLE_USER')") | |
36 | @GetMapping("/all") | |
37 | public Iterable<UCSBOrganization> allOrganizations() { | |
38 | Iterable<UCSBOrganization> organizations = ucsbOrganizationRepository.findAll(); | |
39 |
1
1. allOrganizations : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allOrganizations → KILLED |
return organizations; |
40 | } | |
41 | ||
42 | @Operation(summary= "Create a new organization") | |
43 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
44 | @PostMapping("/post") | |
45 | public UCSBOrganization postOrganization( | |
46 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
47 | @Parameter(name="orgTranslationShort") @RequestParam String orgTranslationShort, | |
48 | @Parameter(name="orgTranslation") @RequestParam String orgTranslation, | |
49 | @Parameter(name="inactive") @RequestParam boolean inactive | |
50 | ) | |
51 | { | |
52 | ||
53 | UCSBOrganization organization = new UCSBOrganization(); | |
54 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(orgCode); |
55 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(orgTranslationShort); |
56 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(orgTranslation); |
57 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(inactive); |
58 | ||
59 | UCSBOrganization savedOrganization = ucsbOrganizationRepository.save(organization); | |
60 | ||
61 |
1
1. postOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postOrganization → KILLED |
return savedOrganization; |
62 | } | |
63 | ||
64 | @Operation(summary= "Get a single organization") | |
65 | @PreAuthorize("hasRole('ROLE_USER')") | |
66 | @GetMapping("") | |
67 | public UCSBOrganization getById( | |
68 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
69 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
70 |
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)); |
71 | ||
72 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return organization; |
73 | } | |
74 | ||
75 | @Operation(summary= "Update a single organization") | |
76 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
77 | @PutMapping("") | |
78 | public UCSBOrganization updateOrganization( | |
79 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
80 | @RequestBody @Valid UCSBOrganization incoming) { | |
81 | ||
82 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
83 |
1
1. lambda$updateOrganization$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$updateOrganization$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
84 | ||
85 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(incoming.getOrgCode()); |
86 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
87 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(incoming.getOrgTranslation()); |
88 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(incoming.getInactive()); |
89 | ||
90 | ucsbOrganizationRepository.save(organization); | |
91 | ||
92 |
1
1. updateOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateOrganization → KILLED |
return organization; |
93 | } | |
94 | ||
95 | @Operation(summary= "Delete a UCSBOrganization") | |
96 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
97 | @DeleteMapping("") | |
98 | public Object deleteCommons( | |
99 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
100 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
101 |
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)); |
102 | ||
103 |
1
1. deleteCommons : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(organization); |
104 |
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)); |
105 | } | |
106 | ||
107 | } | |
Mutations | ||
39 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
57 |
1.1 |
|
61 |
1.1 |
|
70 |
1.1 |
|
72 |
1.1 |
|
83 |
1.1 |
|
85 |
1.1 |
|
86 |
1.1 |
|
87 |
1.1 |
|
88 |
1.1 |
|
92 |
1.1 |
|
101 |
1.1 |
|
103 |
1.1 |
|
104 |
1.1 |