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