Skip to content

Commit

Permalink
Merge pull request #628 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.15.0
  • Loading branch information
githubmamatha authored Mar 4, 2024
2 parents 1eb227a + 33a5582 commit dc8d61a
Show file tree
Hide file tree
Showing 21 changed files with 902 additions and 424 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -277,36 +278,66 @@ public ResponseEntity<List<UUID>> getDeceasedStudentIDs(@RequestBody List<UUID>
return response.GET(commonService.getDeceasedStudentIDs(studentIds));
}

@PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAMS)
@PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_BY_ID)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Create Student Optional Grad Program by Student ID", description = "Create Student Optional Grad Program by Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> createStudentGradOptionalProgram(@PathVariable UUID studentID, @RequestBody StudentOptionalProgram gradStudentOptionalProgram, @RequestParam (value = "careerProgramCode", required = false) String careerProgramCode,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create student Optional Grad Program for Student ID: {}", studentID);
graduationStatusService.createStudentGradOptionalProgram(studentID, gradStudentOptionalProgram, careerProgramCode);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
@Operation(summary = "Create a Student Optional Program by Student ID and Optional Program ID", description = "Create a Student Optional Program by Student ID and Optional Program ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "BAD REQUEST"),
@ApiResponse(responseCode = "404", description = "NOT FOUND"),
@ApiResponse(responseCode = "422", description = "VALIDATION ERROR")
})
public ResponseEntity<ApiResponseModel<GraduationStudentRecord>> saveStudentOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create a Student Optional Program for Student ID: {}, OptionalProgram ID: {}", studentID, optionalProgramID);
graduationStatusService.createStudentOptionalProgram(studentID, optionalProgramID, accessToken.replace(BEARER, ""));
return response.UPDATED(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}

@PutMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_UPDATE)
@PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_CAREER_PROGRAMS)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Update Student Optional Grad Program for Student ID", description = "Update Student Optional Grad Program for Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> updateStudentGradOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestBody StudentOptionalProgram gradStudentOptionalProgram,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create student Optional Grad Program for Student ID: {}", studentID);
graduationStatusService.updateStudentGradOptionalProgram(studentID, optionalProgramID, gradStudentOptionalProgram);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
@Operation(summary = "Create Student Career Programs by Student ID with Career Program Codes", description = "Create Student Career Programs by Student ID with Career Program Codes", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "BAD REQUEST"),
@ApiResponse(responseCode = "404", description = "NOT FOUND"),
@ApiResponse(responseCode = "422", description = "VALIDATION ERROR")
})
public ResponseEntity<ApiResponseModel<GraduationStudentRecord>> saveStudentCareerPrograms(@PathVariable UUID studentID, @NotNull @Valid @RequestBody StudentCareerProgramRequestDTO studentCareerProgramReq,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create Student Career Programs for Student ID: {}", studentID);
validation.requiredField(studentCareerProgramReq.getCareerProgramCodes(), "Career Program Codes");
if (validation.hasErrors()) {
validation.stopOnErrors();
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}

graduationStatusService.createStudentCareerPrograms(studentID, studentCareerProgramReq, accessToken.replace(BEARER, ""));
return response.UPDATED(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}

@DeleteMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_DELETE)
@DeleteMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_BY_ID)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Delete Student Optional Grad Program by Student ID", description = "Delete Student Optional Grad Program by Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> deleteStudentGradOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestParam (value = "careerProgramCode", required = false) String careerProgramCode,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Delete student Optional Program for Student ID: {}", studentID);
graduationStatusService.deleteStudentGradOptionalProgram(studentID, optionalProgramID, careerProgramCode);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
@Operation(summary = "Delete a Student Optional Program by Student ID and Optional Program ID", description = "Delete a Student Optional Program by Student ID and Optional Program ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "BAD REQUEST"),
@ApiResponse(responseCode = "404", description = "NOT FOUND"),
@ApiResponse(responseCode = "422", description = "VALIDATION ERROR")
})
public ResponseEntity<ApiResponseModel<GraduationStudentRecord>> deleteStudentOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestHeader(name="Authorization") String accessToken) {
logger.debug("Delete a Student Optional Program for Student ID: {}, OptionalProgram ID: {}", studentID, optionalProgramID);
graduationStatusService.deleteStudentOptionalProgram(studentID, optionalProgramID, accessToken.replace(BEARER, ""));
return response.UPDATED(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}

@DeleteMapping (EducGradStudentApiConstants.GRAD_STUDENT_CAREER_PROGRAMS_BY_CODE)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Delete a Student Career Program by Student ID and Career Program Code", description = "Delete a Student Career Program by Student ID and Career Program Code", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "BAD REQUEST"),
@ApiResponse(responseCode = "404", description = "NOT FOUND"),
@ApiResponse(responseCode = "422", description = "VALIDATION ERROR")
})
public ResponseEntity<ApiResponseModel<GraduationStudentRecord>> deleteStudentCareerProgram(@PathVariable UUID studentID, @PathVariable String careerProgramCode, @RequestHeader(name="Authorization") String accessToken) {
logger.debug("Delete a Student Career Program for Student ID: {}, Career Program: {}", studentID, careerProgramCode);
graduationStatusService.deleteStudentCareerProgram(studentID, careerProgramCode, accessToken.replace(BEARER, ""));
return response.UPDATED(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ca.bc.gov.educ.api.gradstudent.model.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@Component
public class StudentCareerProgramRequestDTO extends BaseModel {

private List<String> careerProgramCodes = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,9 @@ void updateStudentGuidPenXrefRecord(

@Modifying
@Query("update GraduationStudentRecordEntity e set e.recalculateGradStatus = :recalculateGradStatus, e.recalculateProjectedGrad = :recalculateProjectedGrad where e.studentID = :studentGuid")
void updateGradStudentRecalculationFlags(@Param(value = "studentGuid") UUID studentGuid, @Param(value = "recalculateGradStatus") String recalculateGradStatus, @Param(value = "recalculateProjectedGrad") String recalculateProjectedGrad);
void updateGradStudentRecalculationAllFlags(@Param(value = "studentGuid") UUID studentGuid, @Param(value = "recalculateGradStatus") String recalculateGradStatus, @Param(value = "recalculateProjectedGrad") String recalculateProjectedGrad);

@Modifying
@Query("update GraduationStudentRecordEntity e set e.recalculateGradStatus = :recalculateGradStatus where e.studentID = :studentGuid")
void updateGradStudentRecalculationRecalculateGradStatusFlag(@Param(value = "studentGuid") UUID studentGuid, @Param(value = "recalculateGradStatus") String recalculateGradStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ public interface StudentCareerProgramRepository extends JpaRepository<StudentCar

void deleteByStudentID(UUID studentID);

void deleteStudentCareerProgramEntityByStudentIDAndCareerProgramCode(UUID studentGuid, String careerProgramCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ public GradStudentAlgorithmData getGradStudentAlgorithmData(String studentID,Str
GradSearchStudent gradStudent = gradStudentService.getStudentByStudentIDFromStudentAPI(studentID, accessToken);
GraduationStudentRecord gradStudentRecord = graduationStatusService.getGraduationStatusForAlgorithm(UUID.fromString(studentID));
List<StudentCareerProgram> cpList = getAllGradStudentCareerProgramList(studentID, accessToken);
GradTraxStudent gradTraxStudent = gradStudentService.getTraxStudentMasterDataByPen(gradStudent.getPen(), accessToken);
if(gradTraxStudent != null) {
gradStudent.setStudentCitizenship(gradTraxStudent.getStudentCitizenship());
gradStudentRecord.setStudentCitizenship(gradTraxStudent.getStudentCitizenship());
if(gradStudentRecord != null && StringUtils.isNotBlank(gradStudentRecord.getStudentCitizenship())) {
gradStudent.setStudentCitizenship(gradStudentRecord.getStudentCitizenship());
}
data.setGradStudent(gradStudent);
data.setGraduationStudentRecord(gradStudentRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public StudentOptionalProgram saveStudentOptionalProgram(StudentOptionalProgramR
studentOptionalProgramReq.setMainProgramCode(currentGradProgramCode);
}
}
OptionalProgram gradOptionalProgram = getOptionalProgram(studentOptionalProgramReq.getMainProgramCode(), studentOptionalProgramReq.getOptionalProgramCode(), accessToken);
OptionalProgram gradOptionalProgram = graduationStatusService.getOptionalProgram(studentOptionalProgramReq.getMainProgramCode(), studentOptionalProgramReq.getOptionalProgramCode(), accessToken);
if (gradOptionalProgram == null) {
return null;
}
Expand All @@ -156,24 +156,6 @@ public StudentOptionalProgram saveStudentOptionalProgram(StudentOptionalProgramR
}
}

private OptionalProgram getOptionalProgram(String mainProgramCode, String optionalProgramCode, String accessToken) {
OptionalProgram optionalProgram = null;
try {
optionalProgram = webClient.get()
.uri(String.format(constants.getGradOptionalProgramDetailsUrl(), mainProgramCode, optionalProgramCode))
.headers(h -> {
h.setBearerAuth(accessToken);
h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
})
.retrieve()
.bodyToMono(OptionalProgram.class)
.block();
} catch (Exception e) {
log.error("Program API is failed to find an optional program: [{}] / [{}]", mainProgramCode, optionalProgramCode);
}
return optionalProgram;
}

@Transactional
public StudentCareerProgram saveStudentCareerProgram(StudentCareerProgram studentCareerProgram) {
Optional<StudentCareerProgramEntity> studentCareerOptional = gradStudentCareerProgramRepository.findByStudentIDAndCareerProgramCode(studentCareerProgram.getStudentID(), studentCareerProgram.getCareerProgramCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,31 +356,12 @@ public GradSearchStudent getStudentByStudentIDFromStudentAPI(String studentID, S
return gradStu;
}

@Transactional
@Retry(name = "rt-getTraxStudent")
public GradTraxStudent getTraxStudentMasterDataByPen(String pen, String accessToken) {
final ParameterizedTypeReference<List<GradTraxStudent>> responseType = new ParameterizedTypeReference<>() {
};
List<GradTraxStudent> result = this.webClient.get()
.uri(String.format(constants.getTraxStudentMasterDataByPenUrl(), pen))
.headers(h -> {
h.setBearerAuth(accessToken);
h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
})
.retrieve().bodyToMono(responseType).block();
if(result != null && !result.isEmpty()) {
return result.get(0);
}
return null;
}

@Transactional
@Retry(name = "searchbyid")
public GraduationStudentRecordDistribution getStudentByStudentIDFromGrad(String studentID) {
return graduationStatusTransformer.tToDForDistribution(graduationStatusRepository.findByStudentID(UUID.fromString(studentID)));
}


@Transactional
public Student addNewPenFromStudentAPI(StudentCreate student, String accessToken) {
return webClient.post()
Expand Down
Loading

0 comments on commit dc8d61a

Please sign in to comment.