1 | package edu.ucsb.cs156.example.controllers; | |
2 | ||
3 | import edu.ucsb.cs156.example.entities.RecommendationRequest; | |
4 | import edu.ucsb.cs156.example.errors.EntityNotFoundException; | |
5 | import edu.ucsb.cs156.example.repositories.RecommendationRequestRepository; | |
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 | import org.springframework.format.annotation.DateTimeFormat; | |
12 | ||
13 | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | |
15 | import org.springframework.security.access.prepost.PreAuthorize; | |
16 | import org.springframework.web.bind.annotation.DeleteMapping; | |
17 | import org.springframework.web.bind.annotation.GetMapping; | |
18 | import org.springframework.web.bind.annotation.PostMapping; | |
19 | import org.springframework.web.bind.annotation.PutMapping; | |
20 | import org.springframework.web.bind.annotation.RequestBody; | |
21 | import org.springframework.web.bind.annotation.RequestMapping; | |
22 | import org.springframework.web.bind.annotation.RequestParam; | |
23 | import org.springframework.web.bind.annotation.RestController; | |
24 | ||
25 | import javax.validation.Valid; | |
26 | import java.time.LocalDateTime; | |
27 | ||
28 | @Tag(name = "RecommendationRequest") | |
29 | @RequestMapping("/api/RecommendationRequest") | |
30 | @RestController | |
31 | @Slf4j | |
32 | public class RecommendationRequestController extends ApiController { | |
33 | ||
34 | @Autowired | |
35 | RecommendationRequestRepository recommendationRequestRepository; | |
36 | ||
37 | @Operation(summary= "get all recommendation") | |
38 | @PreAuthorize("hasRole('ROLE_USER')") | |
39 | @GetMapping("/all") | |
40 | public Iterable<RecommendationRequest> allRequests() { | |
41 | Iterable<RecommendationRequest> recommendationRequest = recommendationRequestRepository.findAll(); | |
42 |
1
1. allRequests : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::allRequests → KILLED |
return recommendationRequest; |
43 | } | |
44 | ||
45 | @Operation(summary= "Create a new recommendation requests") | |
46 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
47 | @PostMapping("/post") | |
48 | public RecommendationRequest postRecommendationRequest( | |
49 | @Parameter(name="requesterEmail") @RequestParam String requesterEmail, | |
50 | @Parameter(name="professorEmail") @RequestParam String professorEmail, | |
51 | @Parameter(name="explanation") @RequestParam String explanation, | |
52 | @Parameter(name="dateRequested") @RequestParam("dateRequested") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime dateRequested, | |
53 | @Parameter(name="dateNeeded") @RequestParam("dateNeeded") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime dateNeeded, | |
54 | @Parameter(name="done") @RequestParam boolean done | |
55 | ) | |
56 | { | |
57 | ||
58 | RecommendationRequest recommendationRequest = new RecommendationRequest(); | |
59 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setRequesterEmail → KILLED |
recommendationRequest.setRequesterEmail(requesterEmail); |
60 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setProfessorEmail → KILLED |
recommendationRequest.setProfessorEmail(professorEmail); |
61 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setExplanation → KILLED |
recommendationRequest.setExplanation(explanation); |
62 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDateRequested → KILLED |
recommendationRequest.setDateRequested(dateRequested); |
63 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDateNeeded → KILLED |
recommendationRequest.setDateNeeded(dateNeeded); |
64 |
1
1. postRecommendationRequest : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDone → KILLED |
recommendationRequest.setDone(done); |
65 | ||
66 | RecommendationRequest savedRecommendationRequest = recommendationRequestRepository.save(recommendationRequest); | |
67 | ||
68 |
1
1. postRecommendationRequest : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::postRecommendationRequest → KILLED |
return savedRecommendationRequest; |
69 | } | |
70 | ||
71 | @Operation(summary= "Get a single recommendation request") | |
72 | @PreAuthorize("hasRole('ROLE_USER')") | |
73 | @GetMapping("") | |
74 | public RecommendationRequest getById( | |
75 | @Parameter(name="id") @RequestParam Long id) { | |
76 | RecommendationRequest rec = recommendationRequestRepository.findById(id) | |
77 |
1
1. lambda$getById$0 : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::lambda$getById$0 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(RecommendationRequest.class, id)); |
78 | ||
79 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::getById → KILLED |
return rec; |
80 | } | |
81 | ||
82 | @Operation(summary= "Delete a Rec") | |
83 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
84 | @DeleteMapping("") | |
85 | public Object deleteRec( | |
86 | @Parameter(name="id") @RequestParam Long id) { | |
87 | RecommendationRequest ucsbDate = recommendationRequestRepository.findById(id) | |
88 |
1
1. lambda$deleteRec$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::lambda$deleteRec$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(RecommendationRequest.class, id)); |
89 | ||
90 |
1
1. deleteRec : removed call to edu/ucsb/cs156/example/repositories/RecommendationRequestRepository::delete → KILLED |
recommendationRequestRepository.delete(ucsbDate); |
91 |
1
1. deleteRec : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::deleteRec → KILLED |
return genericMessage("RecommendationRequest with id %s deleted".formatted(id)); |
92 | } | |
93 | ||
94 | @Operation(summary= "Update a single rec") | |
95 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
96 | @PutMapping("") | |
97 | public RecommendationRequest updateRec( | |
98 | @Parameter(name="id") @RequestParam Long id, | |
99 | @RequestBody @Valid RecommendationRequest incoming) { | |
100 | ||
101 | RecommendationRequest rec = recommendationRequestRepository.findById(id) | |
102 |
1
1. lambda$updateRec$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::lambda$updateRec$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(RecommendationRequest.class, id)); |
103 | ||
104 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setRequesterEmail → KILLED |
rec.setRequesterEmail(incoming.getRequesterEmail()); |
105 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setProfessorEmail → KILLED |
rec.setProfessorEmail(incoming.getProfessorEmail()); |
106 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setExplanation → KILLED |
rec.setExplanation(incoming.getExplanation()); |
107 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDateRequested → KILLED |
rec.setDateRequested(incoming.getDateRequested()); |
108 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDateNeeded → KILLED |
rec.setDateNeeded(incoming.getDateNeeded()); |
109 |
1
1. updateRec : removed call to edu/ucsb/cs156/example/entities/RecommendationRequest::setDone → KILLED |
rec.setDone(incoming.getDone()); |
110 | ||
111 | recommendationRequestRepository.save(rec); | |
112 | ||
113 |
1
1. updateRec : replaced return value with null for edu/ucsb/cs156/example/controllers/RecommendationRequestController::updateRec → KILLED |
return rec; |
114 | } | |
115 | } | |
Mutations | ||
42 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
68 |
1.1 |
|
77 |
1.1 |
|
79 |
1.1 |
|
88 |
1.1 |
|
90 |
1.1 |
|
91 |
1.1 |
|
102 |
1.1 |
|
104 |
1.1 |
|
105 |
1.1 |
|
106 |
1.1 |
|
107 |
1.1 |
|
108 |
1.1 |
|
109 |
1.1 |
|
113 |
1.1 |