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 com.fasterxml.jackson.core.JsonProcessingException; | |
13 | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | |
15 | import org.springframework.security.access.prepost.PreAuthorize; | |
16 | import org.springframework.web.bind.annotation.DeleteMapping; | |
17 | import org.springframework.web.bind.annotation.GetMapping; | |
18 | import org.springframework.web.bind.annotation.PostMapping; | |
19 | import org.springframework.web.bind.annotation.PutMapping; | |
20 | import org.springframework.web.bind.annotation.RequestBody; | |
21 | import org.springframework.web.bind.annotation.RequestMapping; | |
22 | import org.springframework.web.bind.annotation.RequestParam; | |
23 | import org.springframework.web.bind.annotation.RestController; | |
24 | ||
25 | import javax.validation.Valid; | |
26 | ||
27 | import java.time.LocalDateTime; | |
28 | ||
29 | @Tag(name = "UCSBOrganization") | |
30 | @RequestMapping("/api/UCSBOrganization") | |
31 | @RestController | |
32 | @Slf4j | |
33 | public class UCSBOrganizationController extends ApiController { | |
34 | ||
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> allUCSBOrgs() { | |
42 | Iterable<UCSBOrganization> orgs = ucsbOrganizationRepository.findAll(); | |
43 |
1
1. allUCSBOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allUCSBOrgs → KILLED |
return orgs; |
44 | } | |
45 | ||
46 | @Operation(summary= "Create a new UCSB Organization") | |
47 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
48 | @PostMapping("/post") | |
49 | public UCSBOrganization postUCSBOrgs( | |
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 | // String orgCode | |
57 | // String orgTranslationShort | |
58 | // String orgTranslation | |
59 | // boolean inactive | |
60 | UCSBOrganization org = new UCSBOrganization(); | |
61 |
1
1. postUCSBOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
org.setOrgCode(orgCode); |
62 |
1
1. postUCSBOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
org.setOrgTranslationShort(orgTranslationShort); |
63 |
1
1. postUCSBOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
org.setOrgTranslation(orgTranslation); |
64 |
1
1. postUCSBOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
org.setInactive(inactive); |
65 | | |
66 | UCSBOrganization savedOrg = ucsbOrganizationRepository.save(org); | |
67 |
1
1. postUCSBOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postUCSBOrgs → KILLED |
return savedOrg; |
68 | } | |
69 | ||
70 | @Operation(summary= "Get a single UCSB Organization") | |
71 | @PreAuthorize("hasRole('ROLE_USER')") | |
72 | @GetMapping("") | |
73 | public UCSBOrganization getById( | |
74 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
75 | UCSBOrganization org = ucsbOrganizationRepository.findById(orgCode) | |
76 |
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)); |
77 | ||
78 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return org; |
79 | } | |
80 | ||
81 | @Operation(summary= "Delete a UCSBOrganization") | |
82 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
83 | @DeleteMapping("") | |
84 | public Object deleteUCSBOrg( | |
85 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
86 | UCSBOrganization org = ucsbOrganizationRepository.findById(orgCode) | |
87 |
1
1. lambda$deleteUCSBOrg$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteUCSBOrg$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
88 | ||
89 |
1
1. deleteUCSBOrg : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(org); |
90 |
1
1. deleteUCSBOrg : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteUCSBOrg → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(orgCode)); |
91 | } | |
92 | ||
93 | @Operation(summary= "Update a single UCSB Organization") | |
94 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
95 | @PutMapping("") | |
96 | public UCSBOrganization updateCommons( | |
97 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
98 | @RequestBody @Valid UCSBOrganization incoming) { | |
99 | ||
100 | UCSBOrganization org = ucsbOrganizationRepository.findById(orgCode) | |
101 |
1
1. lambda$updateCommons$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$updateCommons$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
102 | ||
103 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
org.setOrgCode(incoming.getOrgCode()); |
104 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
org.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
105 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
org.setOrgTranslation(incoming.getOrgTranslation()); |
106 |
1
1. updateCommons : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
org.setInactive(incoming.getInactive()); |
107 | ||
108 | ucsbOrganizationRepository.save(org); | |
109 | ||
110 |
1
1. updateCommons : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateCommons → KILLED |
return org; |
111 | } | |
112 | } | |
Mutations | ||
43 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
67 |
1.1 |
|
76 |
1.1 |
|
78 |
1.1 |
|
87 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
101 |
1.1 |
|
103 |
1.1 |
|
104 |
1.1 |
|
105 |
1.1 |
|
106 |
1.1 |
|
110 |
1.1 |