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