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 | import io.swagger.v3.oas.annotations.Operation; | |
7 | import io.swagger.v3.oas.annotations.tags.Tag; | |
8 | import io.swagger.v3.oas.annotations.Parameter; | |
9 | import lombok.extern.slf4j.Slf4j; | |
10 | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | |
12 | import org.springframework.security.access.prepost.PreAuthorize; | |
13 | import org.springframework.web.bind.annotation.GetMapping; | |
14 | import org.springframework.web.bind.annotation.PostMapping; | |
15 | import org.springframework.web.bind.annotation.RequestBody; | |
16 | import org.springframework.web.bind.annotation.RequestMapping; | |
17 | import org.springframework.web.bind.annotation.PutMapping; | |
18 | import org.springframework.web.bind.annotation.DeleteMapping; | |
19 | import org.springframework.web.bind.annotation.RequestParam; | |
20 | import org.springframework.web.bind.annotation.RestController; | |
21 | import org.springframework.data.repository.query.Param; | |
22 | import javax.validation.Valid; | |
23 | @Tag(name = "UCSBOrganization") | |
24 | @RequestMapping("/api/ucsborganizations") | |
25 | @RestController | |
26 | @Slf4j | |
27 | public class UCSBOrganizationController extends ApiController { | |
28 | ||
29 | @Autowired | |
30 | UCSBOrganizationRepository ucsbOrganizationRepository; | |
31 | ||
32 | @PreAuthorize("hasRole('ROLE_USER')") | |
33 | @GetMapping("/all") | |
34 | public Iterable<UCSBOrganization> allOrganizations() { | |
35 | Iterable<UCSBOrganization> organizations = ucsbOrganizationRepository.findAll(); | |
36 |
1
1. allOrganizations : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allOrganizations → KILLED |
return organizations; |
37 | } | |
38 | @Operation(summary= "Create a new organization") | |
39 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
40 | @PostMapping("/post") | |
41 | public UCSBOrganization postOrganization( | |
42 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
43 | @Parameter(name="orgTranslationShort") @RequestParam String orgTranslationShort, | |
44 | @Parameter(name="orgTranslation") @RequestParam String orgTranslation, | |
45 | @Parameter(name="inactive") @RequestParam boolean inactive) { | |
46 | UCSBOrganization organization = new UCSBOrganization(); | |
47 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
organization.setOrgCode(orgCode); |
48 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(orgTranslationShort); |
49 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(orgTranslation); |
50 |
1
1. postOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(inactive); |
51 | ||
52 | UCSBOrganization savedOrganization = ucsbOrganizationRepository.save(organization); | |
53 | ||
54 |
1
1. postOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postOrganization → KILLED |
return savedOrganization; |
55 | } | |
56 | @Operation(summary= "Get an organization by id") | |
57 | @PreAuthorize("hasRole('ROLE_USER')") | |
58 | @GetMapping("") | |
59 | public UCSBOrganization getById(@Parameter(name="orgCode") @RequestParam String orgCode) { | |
60 | UCSBOrganization org = ucsbOrganizationRepository.findById(orgCode) | |
61 |
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)); |
62 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return org; |
63 | } | |
64 | ||
65 | @Operation(summary= "Update an organization") | |
66 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
67 | @PutMapping("") | |
68 | public UCSBOrganization updateOrganization( | |
69 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
70 | @RequestBody @Valid UCSBOrganization incoming) { | |
71 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
72 |
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)); |
73 | ||
74 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
organization.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
75 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
organization.setOrgTranslation(incoming.getOrgTranslation()); |
76 |
1
1. updateOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
organization.setInactive(incoming.getInactive()); |
77 | ||
78 | ucsbOrganizationRepository.save(organization); | |
79 | ||
80 |
1
1. updateOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateOrganization → KILLED |
return organization; |
81 | } | |
82 | ||
83 | @Operation(summary= "Delete an organization") | |
84 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
85 | @DeleteMapping("") | |
86 | public Object deleteOrganization( | |
87 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
88 | UCSBOrganization organization = ucsbOrganizationRepository.findById(orgCode) | |
89 |
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)); |
90 | ||
91 |
1
1. deleteOrganization : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(organization); |
92 |
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)); |
93 | } | |
94 | } | |
Mutations | ||
36 |
1.1 |
|
47 |
1.1 |
|
48 |
1.1 |
|
49 |
1.1 |
|
50 |
1.1 |
|
54 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
72 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
76 |
1.1 |
|
80 |
1.1 |
|
89 |
1.1 |
|
91 |
1.1 |
|
92 |
1.1 |