1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.UCSBOrganizations; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.UCSBOrganizationsRepository; | |
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 = "UCSBOrganizations") | |
26 | @RequestMapping("/api/UCSBOrganization") | |
27 | @RestController | |
28 | @Slf4j | |
29 | public class UCSBOrganizationsController extends ApiController { | |
30 | ||
31 | @Autowired | |
32 | UCSBOrganizationsRepository ucsbOrganizationsRepository; | |
33 | ||
34 | @Operation(summary = "List all UCSBOrganizations") | |
35 | @PreAuthorize("hasRole('ROLE_USER')") | |
36 | @GetMapping("/all") | |
37 | public Iterable<UCSBOrganizations> allOrgss() { | |
38 | Iterable<UCSBOrganizations> orgs = ucsbOrganizationsRepository.findAll(); | |
39 |
1
1. allOrgss : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::allOrgss → KILLED |
return orgs; |
40 | } | |
41 | ||
42 | @Operation(summary = "Create a new UCSBOrganizations") | |
43 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
44 | @PostMapping("/post") | |
45 | public UCSBOrganizations postOrgs( | |
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 | UCSBOrganizations org = new UCSBOrganizations(); | |
52 |
1
1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgCode → KILLED |
org.setOrgCode(orgCode); |
53 |
1
1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED |
org.setOrgTranslationShort(orgTranslationShort); |
54 |
1
1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED |
org.setOrgTranslation(orgTranslation); |
55 |
1
1. postOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED |
org.setInactive(inactive); |
56 | ||
57 | UCSBOrganizations savedOrgs = ucsbOrganizationsRepository.save(org); | |
58 | ||
59 |
1
1. postOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::postOrgs → KILLED |
return savedOrgs; |
60 | } | |
61 | ||
62 | @Operation(summary = "Get a single UCSBOrganizations") | |
63 | @PreAuthorize("hasRole('ROLE_USER')") | |
64 | @GetMapping("") | |
65 | public UCSBOrganizations getById( | |
66 | @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id) { | |
67 | UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id) | |
68 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id)); |
69 | ||
70 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::getById → KILLED |
return orgs; |
71 | } | |
72 | ||
73 | @Operation(summary = "Delete a UCSBOrganizations") | |
74 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
75 | @DeleteMapping("") | |
76 | public Object deleteOrgs( | |
77 | @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id) { | |
78 | UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id) | |
79 |
1
1. lambda$deleteOrgs$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$deleteOrgs$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id)); |
80 | ||
81 |
1
1. deleteOrgs : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationsRepository::delete → KILLED |
ucsbOrganizationsRepository.delete(orgs); |
82 |
1
1. deleteOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::deleteOrgs → KILLED |
return genericMessage("UCSBOrganizations with id %s deleted".formatted(id)); |
83 | } | |
84 | ||
85 | @Operation(summary = "Update a single UCSBOrganizations") | |
86 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
87 | @PutMapping("") | |
88 | public UCSBOrganizations updateOrgs( | |
89 | @Parameter(name = "orgCode") @RequestParam(name = "orgCode") String id, | |
90 | @RequestBody @Valid UCSBOrganizations incoming) { | |
91 | ||
92 | UCSBOrganizations orgs = ucsbOrganizationsRepository.findById(id) | |
93 |
1
1. lambda$updateOrgs$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::lambda$updateOrgs$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganizations.class, id)); |
94 | ||
95 | // orgs.setOrgCode(incoming.getOrgCode()); | |
96 |
1
1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslationShort → KILLED |
orgs.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
97 |
1
1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setOrgTranslation → KILLED |
orgs.setOrgTranslation(incoming.getOrgTranslation()); |
98 |
1
1. updateOrgs : removed call to edu/ucsb/cs156/example/entities/UCSBOrganizations::setInactive → KILLED |
orgs.setInactive(incoming.getInactive()); |
99 | ||
100 | ucsbOrganizationsRepository.save(orgs); | |
101 | ||
102 |
1
1. updateOrgs : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationsController::updateOrgs → KILLED |
return orgs; |
103 | } | |
104 | } | |
Mutations | ||
39 |
1.1 |
|
52 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
59 |
1.1 |
|
68 |
1.1 |
|
70 |
1.1 |
|
79 |
1.1 |
|
81 |
1.1 |
|
82 |
1.1 |
|
93 |
1.1 |
|
96 |
1.1 |
|
97 |
1.1 |
|
98 |
1.1 |
|
102 |
1.1 |