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 jakarta.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 Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allOrganizations → KILLED |
return organizations; |
40 | } | |
41 | ||
42 | @Operation(summary= "Create a new ucsb 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 | UCSBOrganization org = new UCSBOrganization(); | |
53 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
org.setOrgCode(orgCode); |
54 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
org.setOrgTranslationShort(orgTranslationShort); |
55 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
org.setOrgTranslation(orgTranslation); |
56 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
org.setInactive(inactive); |
57 | UCSBOrganization savedOrg = ucsbOrganizationRepository.save(org); | |
58 |
1
1. postOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postOrganization → KILLED |
return savedOrg; |
59 | } | |
60 | ||
61 | @Operation(summary= "Get a single organization") | |
62 | @PreAuthorize("hasRole('ROLE_USER')") | |
63 | @GetMapping("") | |
64 | public UCSBOrganization getById( | |
65 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
66 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
67 |
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)); |
68 | | |
69 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return organization; |
70 | } | |
71 | ||
72 | @Operation(summary= "Update a single organization") | |
73 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
74 | @PutMapping("") | |
75 | public UCSBOrganization updateOrganization( | |
76 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
77 | @RequestBody @Valid UCSBOrganization newOrg) { | |
78 | ||
79 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
80 |
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)); |
81 | ||
82 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(newOrg.getOrgCode()); |
83 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(newOrg.getOrgTranslationShort()); |
84 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(newOrg.getOrgTranslation()); |
85 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(newOrg.getInactive()); |
86 | ||
87 | ucsbOrganizationRepository.save(organization); | |
88 | ||
89 |
1
1. updateOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateOrganization → KILLED |
return organization; |
90 | } | |
91 | ||
92 | @Operation(summary= "Delete a UCSBOrganization") | |
93 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
94 | @DeleteMapping("") | |
95 | public Object deleteOrganization( | |
96 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
97 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
98 |
1
1. lambda$deleteOrganization$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteOrganization$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
99 | ||
100 |
1
1. deleteOrganization : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(organization); |
101 |
1
1. deleteOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteOrganization → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(orgCode)); |
102 | } | |
103 | } | |
Mutations | ||
39 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
58 |
1.1 |
|
67 |
1.1 |
|
69 |
1.1 |
|
80 |
1.1 |
|
82 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
85 |
1.1 |
|
89 |
1.1 |
|
98 |
1.1 |
|
100 |
1.1 |
|
101 |
1.1 |