| 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 | ||
| 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 com.fasterxml.jackson.core.JsonProcessingException; | |
| 13 | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | import org.springframework.format.annotation.DateTimeFormat; | |
| 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 jakarta.validation.Valid; | |
| 27 | ||
| 28 | import java.time.LocalDateTime; | |
| 29 | ||
| 30 | /** | |
| 31 | * This is a REST controller for UCSBOrganization | |
| 32 | */ | |
| 33 | ||
| 34 | @Tag(name = "UCSBOrganization") | |
| 35 | @RequestMapping("/api/ucsborganization") | |
| 36 | @RestController | |
| 37 | @Slf4j | |
| 38 | public class UCSBOrganizationController extends ApiController{ | |
| 39 | ||
| 40 | @Autowired | |
| 41 | UCSBOrganizationRepository ucsbOrganizationRepository; | |
| 42 | ||
| 43 | /** | |
| 44 | * List all UCSB Organizations | |
| 45 | * | |
| 46 | * @return an iterable of UCSBOrganization | |
| 47 | */ | |
| 48 | @Operation(summary= "List all ucsb organizations") | |
| 49 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 50 | @GetMapping("/all") | |
| 51 | public Iterable<UCSBOrganization> allUCSBOrganization() { | |
| 52 | Iterable<UCSBOrganization> organizations = ucsbOrganizationRepository.findAll(); | |
| 53 |
1
1. allUCSBOrganization : replaced return value with Collections.emptyList for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::allUCSBOrganization → KILLED |
return organizations; |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Create a new organization | |
| 58 | * | |
| 59 | * @param orgCode the organization code | |
| 60 | * @param orgTranslationShort the short translation of the organization | |
| 61 | * @param orgTranslation the translation of the organization | |
| 62 | * @param inactive activity level of the organization | |
| 63 | * @return the saved ucsborganization | |
| 64 | */ | |
| 65 | @Operation(summary= "Create a new organization") | |
| 66 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 67 | @PostMapping("/post") | |
| 68 | public UCSBOrganization postUCSBOrganization( | |
| 69 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
| 70 | @Parameter(name="orgTranslationShort") @RequestParam String orgTranslationShort, | |
| 71 | @Parameter(name="orgTranslation") @RequestParam String orgTranslation, | |
| 72 | @Parameter(name="inactive") @RequestParam Boolean inactive | |
| 73 | ) | |
| 74 | { | |
| 75 | ||
| 76 | UCSBOrganization ucsbOrganization = new UCSBOrganization(); | |
| 77 |
1
1. postUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgCode → KILLED |
ucsbOrganization.setOrgCode(orgCode); |
| 78 |
1
1. postUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
ucsbOrganization.setOrgTranslationShort(orgTranslationShort); |
| 79 |
1
1. postUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
ucsbOrganization.setOrgTranslation(orgTranslation); |
| 80 |
1
1. postUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
ucsbOrganization.setInactive(inactive); |
| 81 | ||
| 82 | UCSBOrganization savedUcsbOrganization = ucsbOrganizationRepository.save(ucsbOrganization); | |
| 83 | ||
| 84 |
1
1. postUCSBOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::postUCSBOrganization → KILLED |
return savedUcsbOrganization; |
| 85 | | |
| 86 | } | |
| 87 | ||
| 88 | ||
| 89 | /** | |
| 90 | * Get a single UCSB organization by id | |
| 91 | * | |
| 92 | * @param orgCode the id of the UCSB organization | |
| 93 | * @return a UCSBDOrganization | |
| 94 | */ | |
| 95 | @Operation(summary= "Get a single organization") | |
| 96 | @PreAuthorize("hasRole('ROLE_USER')") | |
| 97 | @GetMapping("") | |
| 98 | public UCSBOrganization getById( | |
| 99 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
| 100 | UCSBOrganization ucsbOrganization = ucsbOrganizationRepository.findById(orgCode) | |
| 101 |
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)); |
| 102 | ||
| 103 |
1
1. getById : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::getById → KILLED |
return ucsbOrganization; |
| 104 | } | |
| 105 | ||
| 106 | ||
| 107 | /** | |
| 108 | * Update a single organization | |
| 109 | * | |
| 110 | * @param orgCode id of the organization to update | |
| 111 | * @param incoming the new organization | |
| 112 | * @return the updated organization object | |
| 113 | */ | |
| 114 | @Operation(summary= "Update a single organization") | |
| 115 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 116 | @PutMapping("") | |
| 117 | public UCSBOrganization updateUCSBOrganization( | |
| 118 | @Parameter(name="orgCode") @RequestParam String orgCode, | |
| 119 | @RequestBody @Valid UCSBOrganization incoming) { | |
| 120 | ||
| 121 | UCSBOrganization ucsbOrganization = ucsbOrganizationRepository.findById(orgCode) | |
| 122 |
1
1. lambda$updateUCSBOrganization$1 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$updateUCSBOrganization$1 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
| 123 | ||
| 124 |
1
1. updateUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslationShort → KILLED |
ucsbOrganization.setOrgTranslationShort(incoming.getOrgTranslationShort()); |
| 125 |
1
1. updateUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setOrgTranslation → KILLED |
ucsbOrganization.setOrgTranslation(incoming.getOrgTranslation()); |
| 126 |
1
1. updateUCSBOrganization : removed call to edu/ucsb/cs156/example/entities/UCSBOrganization::setInactive → KILLED |
ucsbOrganization.setInactive(incoming.getInactive()); |
| 127 | ||
| 128 | ucsbOrganizationRepository.save(ucsbOrganization); | |
| 129 | ||
| 130 |
1
1. updateUCSBOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::updateUCSBOrganization → KILLED |
return ucsbOrganization; |
| 131 | } | |
| 132 | ||
| 133 | ||
| 134 | /** | |
| 135 | * Delete a UCSBOrganization | |
| 136 | * | |
| 137 | * @param orgCode the id of the organization to delete | |
| 138 | * @return a message indicating the organization was deleted | |
| 139 | */ | |
| 140 | @Operation(summary= "Delete a UCSBOrganization") | |
| 141 | @PreAuthorize("hasRole('ROLE_ADMIN')") | |
| 142 | @DeleteMapping("") | |
| 143 | public Object deleteUCSBOrganization( | |
| 144 | @Parameter(name="orgCode") @RequestParam String orgCode) { | |
| 145 | UCSBOrganization ucsbOrganization = ucsbOrganizationRepository.findById(orgCode) | |
| 146 |
1
1. lambda$deleteUCSBOrganization$2 : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::lambda$deleteUCSBOrganization$2 → KILLED |
.orElseThrow(() -> new EntityNotFoundException(UCSBOrganization.class, orgCode)); |
| 147 | ||
| 148 |
1
1. deleteUCSBOrganization : removed call to edu/ucsb/cs156/example/repositories/UCSBOrganizationRepository::delete → KILLED |
ucsbOrganizationRepository.delete(ucsbOrganization); |
| 149 |
1
1. deleteUCSBOrganization : replaced return value with null for edu/ucsb/cs156/example/controllers/UCSBOrganizationController::deleteUCSBOrganization → KILLED |
return genericMessage("UCSBOrganization with id %s deleted".formatted(orgCode)); |
| 150 | } | |
| 151 | ||
| 152 | ||
| 153 | } | |
Mutations | ||
| 53 |
1.1 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 79 |
1.1 |
|
| 80 |
1.1 |
|
| 84 |
1.1 |
|
| 101 |
1.1 |
|
| 103 |
1.1 |
|
| 122 |
1.1 |
|
| 124 |
1.1 |
|
| 125 |
1.1 |
|
| 126 |
1.1 |
|
| 130 |
1.1 |
|
| 146 |
1.1 |
|
| 148 |
1.1 |
|
| 149 |
1.1 |