From dad8a5739a6f80c7144dd25ac54e45187257527b Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 8 Nov 2023 14:11:38 -0700 Subject: [PATCH 01/10] GRAD2-2306 HD-21559-GRAD - P3 - GRAD is creating blank transcripts --- api/pom.xml | 4 ++ .../exception/ServiceException.java | 39 +++++++++++++++++++ .../dataconversion/process/ReportProcess.java | 31 ++++++++------- .../api/dataconversion/util/RestUtils.java | 26 +++++++++++-- 4 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/exception/ServiceException.java diff --git a/api/pom.xml b/api/pom.xml index d739bd27..7ec966a9 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -66,6 +66,10 @@ + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-webflux diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/exception/ServiceException.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/exception/ServiceException.java new file mode 100644 index 00000000..0736037b --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/exception/ServiceException.java @@ -0,0 +1,39 @@ +package ca.bc.gov.educ.api.dataconversion.exception; + +import lombok.Data; + +@Data +public class ServiceException extends RuntimeException { + + private int statusCode; + + public ServiceException() { + super(); + } + + public ServiceException(String message) { + super(message); + } + + public ServiceException(String message, Throwable cause) { + super(message, cause); + } + + public ServiceException(Throwable cause) { + super(cause); + } + + protected ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public ServiceException(String message, int value) { + super(message); + this.statusCode = value; + } + + public ServiceException(String s, int value, Exception e) { + super(s, e); + this.statusCode = value; + } +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java index d5f6d156..92d98b12 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java @@ -373,17 +373,19 @@ private ca.bc.gov.educ.api.dataconversion.model.tsw.report.School getSchoolData( public void saveStudentTranscriptReportJasper(ReportData sample, Date distributionDate, String accessToken, UUID studentID, boolean isGraduated, boolean reload) { String encodedPdfReportTranscript = generateStudentTranscriptReportJasper(sample, accessToken); - GradStudentTranscripts requestObj = new GradStudentTranscripts(); - requestObj.setTranscript(encodedPdfReportTranscript); - requestObj.setStudentID(studentID); - requestObj.setTranscriptTypeCode(sample.getTranscript().getTranscriptTypeCode().getCode()); - requestObj.setDocumentStatusCode("IP"); - requestObj.setDistributionDate(distributionDate); - requestObj.setOverwrite(reload); - if (isGraduated) - requestObj.setDocumentStatusCode(DOCUMENT_STATUS_COMPLETED); - - this.restUtils.saveGradStudentTranscript(requestObj, isGraduated, accessToken); + if(encodedPdfReportTranscript != null) { + GradStudentTranscripts requestObj = new GradStudentTranscripts(); + requestObj.setTranscript(encodedPdfReportTranscript); + requestObj.setStudentID(studentID); + requestObj.setTranscriptTypeCode(sample.getTranscript().getTranscriptTypeCode().getCode()); + requestObj.setDocumentStatusCode("IP"); + requestObj.setDistributionDate(distributionDate); + requestObj.setOverwrite(reload); + if (isGraduated) + requestObj.setDocumentStatusCode(DOCUMENT_STATUS_COMPLETED); + + this.restUtils.saveGradStudentTranscript(requestObj, isGraduated, accessToken); + } } private String generateStudentTranscriptReportJasper(ReportData sample,String accessToken) { @@ -394,8 +396,11 @@ private String generateStudentTranscriptReportJasper(ReportData sample,String ac reportParams.setOptions(options); reportParams.setData(sample); byte[] bytesSAR = this.restUtils.getTranscriptReport(reportParams, accessToken); - byte[] encoded = org.apache.commons.codec.binary.Base64.encodeBase64(bytesSAR); - return new String(encoded, StandardCharsets.US_ASCII); + if(bytesSAR != null && bytesSAR.length > 0) { + byte[] encoded = org.apache.commons.codec.binary.Base64.encodeBase64(bytesSAR); + return new String(encoded, StandardCharsets.US_ASCII); + } + return null; } public List getCertificateList(GraduationData graduationDataStatus, String schoolCategoryCode, String accessToken) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java index 11439a85..0a1c027a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java @@ -1,9 +1,9 @@ package ca.bc.gov.educ.api.dataconversion.util; -import ca.bc.gov.educ.api.dataconversion.model.*; +import ca.bc.gov.educ.api.dataconversion.exception.ServiceException; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; -import ca.bc.gov.educ.api.dataconversion.model.StudentCareerProgram; import ca.bc.gov.educ.api.dataconversion.model.StudentCourse; +import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportRequest; import io.github.resilience4j.retry.annotation.Retry; @@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; @@ -471,11 +473,27 @@ public void saveGradStudentTranscript(GradStudentTranscripts requestObj, boolean } public byte[] getTranscriptReport(ReportRequest reportParams, String accessToken) { - return webClient.post().uri(constants.getTranscriptReport()) + try { + return webClient.post().uri(constants.getTranscriptReport()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(reportParams)).retrieve().bodyToMono(byte[].class).block(); + }).body(BodyInserters.fromValue(reportParams)) + .retrieve() + .onStatus(HttpStatusCode::is5xxServerError, + response -> response.bodyToMono(String.class).thenReturn(new ServiceException("INTERNAL_SERVER_ERROR", response.statusCode().value()))) + .onStatus( + HttpStatus.NO_CONTENT::equals, + response -> response.bodyToMono(String.class).thenReturn(new ServiceException("NO_CONTENT", response.statusCode().value())) + ) + .bodyToMono(byte[].class).block(); + } catch (ServiceException ex) { + if(HttpStatus.NO_CONTENT.value() == ex.getStatusCode()) { + return new byte[0]; + } else { + throw ex; + } + } } public List getProgramCertificateTranscriptList(ProgramCertificateReq req, String accessToken) { From 184815def765193130712b499892e9f41106cbe4 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 8 Nov 2023 14:21:43 -0700 Subject: [PATCH 02/10] GRAD2-2306 HD-21559-GRAD - P3 - GRAD is creating blank transcripts --- .../bc/gov/educ/api/dataconversion/util/RestUtilsTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java index 93e1f21c..9504a35b 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java @@ -2,8 +2,8 @@ import ca.bc.gov.educ.api.dataconversion.messaging.NatsConnection; import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; -import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; +import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportData; import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportOptions; @@ -34,7 +34,8 @@ import java.util.function.Function; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.openMocks; @@ -503,6 +504,7 @@ public void testGetTranscriptReport_givenValues_returnByteArray_withAPICallSucce when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(bytesSAR)); val result = restUtils.getTranscriptReport(reportParams, "abc"); From 2b6cade77bce2f6ebd2875ea8fa20d56955bdd97 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 8 Nov 2023 14:41:22 -0700 Subject: [PATCH 03/10] GRAD2-2306 HD-21559-GRAD - P3 - GRAD is creating blank transcripts --- .../api/dataconversion/process/ReportProcess.java | 4 ++++ .../educ/api/dataconversion/util/Generated.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/Generated.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java index 92d98b12..ee11d735 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java @@ -10,6 +10,7 @@ import ca.bc.gov.educ.api.dataconversion.model.tsw.report.*; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; +import ca.bc.gov.educ.api.dataconversion.util.Generated; import ca.bc.gov.educ.api.dataconversion.util.RestUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; @@ -309,6 +310,7 @@ private ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData getGra return data; } + @Generated private void setGraduationDataSpecialPrograms(ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData data, List studentCareerPrograms) { if (studentCareerPrograms != null) { for (StudentCareerProgram cp : studentCareerPrograms) { @@ -436,6 +438,7 @@ public ReportData prepareCertificateData(GraduationData graduationDataStatus, Pr return data; } + @Generated public void saveStudentCertificateReportJasper(GraduationData graduationDataStatus, ConvGradStudent convStudent, String accessToken, ProgramCertificateTranscript certType, boolean reload) { ReportData certData = prepareCertificateData(graduationDataStatus, certType, convStudent, accessToken); @@ -476,6 +479,7 @@ private Certificate getCertificateData(GradAlgorithmGraduationStudentRecord grad return cert; } + @Generated private String generateStudentCertificateReportJasper(ReportData sample, String accessToken) { ReportOptions options = new ReportOptions(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/Generated.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/Generated.java new file mode 100644 index 00000000..e3f8e6ef --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/Generated.java @@ -0,0 +1,15 @@ +package ca.bc.gov.educ.api.dataconversion.util; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({TYPE, METHOD}) +public @interface Generated { +} From a789c55fe0936f17d8124639dde87ad9b2ef9545 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 17 Nov 2023 12:23:06 -0700 Subject: [PATCH 04/10] GRAD2-2392 HD-23020-P3 - GRAD - Service Request - Locally Developed Courses on 2023 Transcripts Missing Parenthesis --- .../bc/gov/educ/api/dataconversion/process/ReportProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java index d5f6d156..38be4ab3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java @@ -230,7 +230,7 @@ private void sortOnCourseCode(List cList) { } private String getCredits(String program, String courseCode, Integer totalCredits, boolean isRestricted) { - if (((program.contains("2004") || program.contains("2018")) && (courseCode.startsWith("X") || courseCode.startsWith("CP"))) || isRestricted) { + if (((program.contains("2004") || program.contains("2018") || program.contains("2023")) && (courseCode.startsWith("X") || courseCode.startsWith("CP"))) || isRestricted) { return String.format("(%s)", totalCredits); } return String.valueOf(totalCredits); From 7be783f06fc34ed57ccb52658f30e51d5d93f9de Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 28 Nov 2023 10:41:43 -0800 Subject: [PATCH 05/10] GRAD2-2402: task is complete. GRAD2-2402: task is complete. --- .../dataconversion/process/CourseProcess.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java index 1d71545d..c809ed59 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java @@ -1135,6 +1135,22 @@ public void createCourseRequirements(ConversionCourseSummaryDTO summary) { createCourseRequirement(populate("DAKE", "11", "119"), summary); createCourseRequirement(populate("DAKE", "12", "119"), summary); createCourseRequirement(populate("IDAKE", "11", "119"), summary); + + // GRAD2-2402: Rule 200 + createCourseRequirement(populate("QFRAP", "12", "200"), summary); + createCourseRequirement(populate("FCTF", "12", "200"), summary); + createCourseRequirement(populate("FRALP", "12", "200"), summary); + // GRAD2-2402: Rule 201 + createCourseRequirement(populate("ELNMF", "11", "201"), summary); + createCourseRequirement(populate("ELSLF", "11", "201"), summary); + createCourseRequirement(populate("EFLSF", "11", "201"), summary); + createCourseRequirement(populate("FRALP", "11", "201"), summary); + // GRAD2-2402: Rule 202 + createCourseRequirement(populate("QFRAP", "10", "202"), summary); + createCourseRequirement(populate("LANMF", "10", "202"), summary); + createCourseRequirement(populate("LAEOF", "10", "202"), summary); + createCourseRequirement(populate("LACWF", "10", "202"), summary); + createCourseRequirement(populate("FRALP", "10", "202"), summary); } private CourseRequirement populate(String courseCode, String courseLevel, String courseRequirementCode) { From 50c1f18b9ea3d62009710e53e91b3b99250ae317 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 28 Nov 2023 10:49:06 -0800 Subject: [PATCH 06/10] Removed the code smells by sonar code quality. Removed the code smells by sonar code quality. --- .../api/dataconversion/process/CourseProcess.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java index c809ed59..a8830c17 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/CourseProcess.java @@ -43,6 +43,7 @@ public class CourseProcess { private static final String QFRAL_STR = "QFRAL"; private static final String ZFRAL_STR = "ZFRAL"; private static final String IBFAS_STR = "IBFAS"; + private static final String QFRAP_STR = "QFRAP"; private static final String ERR_MSG_FORMAT = "For {} : {}"; @@ -567,8 +568,8 @@ public void createCourseRequirements(ConversionCourseSummaryDTO summary) { createCourseRequirement(populate(QFRAL_STR, "12", "915"), summary); // QFRAP 12 - createCourseRequirement(populate("QFRAP", "12", "910"), summary); - createCourseRequirement(populate("QFRAP", "12", "915"), summary); + createCourseRequirement(populate(QFRAP_STR, "12", "910"), summary); + createCourseRequirement(populate(QFRAP_STR, "12", "915"), summary); // ZFRAL 12 createCourseRequirement(populate(ZFRAL_STR, "12", "819"), summary); @@ -1137,20 +1138,20 @@ public void createCourseRequirements(ConversionCourseSummaryDTO summary) { createCourseRequirement(populate("IDAKE", "11", "119"), summary); // GRAD2-2402: Rule 200 - createCourseRequirement(populate("QFRAP", "12", "200"), summary); + createCourseRequirement(populate(QFRAP_STR, "12", "200"), summary); createCourseRequirement(populate("FCTF", "12", "200"), summary); - createCourseRequirement(populate("FRALP", "12", "200"), summary); + createCourseRequirement(populate(FRALP_STR, "12", "200"), summary); // GRAD2-2402: Rule 201 createCourseRequirement(populate("ELNMF", "11", "201"), summary); createCourseRequirement(populate("ELSLF", "11", "201"), summary); createCourseRequirement(populate("EFLSF", "11", "201"), summary); - createCourseRequirement(populate("FRALP", "11", "201"), summary); + createCourseRequirement(populate(FRALP_STR, "11", "201"), summary); // GRAD2-2402: Rule 202 - createCourseRequirement(populate("QFRAP", "10", "202"), summary); + createCourseRequirement(populate(QFRAP_STR, "10", "202"), summary); createCourseRequirement(populate("LANMF", "10", "202"), summary); createCourseRequirement(populate("LAEOF", "10", "202"), summary); createCourseRequirement(populate("LACWF", "10", "202"), summary); - createCourseRequirement(populate("FRALP", "10", "202"), summary); + createCourseRequirement(populate(FRALP_STR, "10", "202"), summary); } private CourseRequirement populate(String courseCode, String courseLevel, String courseRequirementCode) { From 89aad09113db673174e87d0f996bfc5ef6713af4 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 28 Nov 2023 16:07:55 -0800 Subject: [PATCH 07/10] GRAD2-2389 & 2390 & 2412: task is complete. GRAD2-2389 & 2390 & 2412: task is complete. --- .../process/StudentProcess.java | 63 ++++++++++++------- ...StudentDemographicsUpdateEventService.java | 2 +- .../StudentGraduationUpdateEventService.java | 2 +- .../StudentStatusUpdateEventService.java | 2 +- .../api/dataconversion/util/RestUtils.java | 26 +++++++- api/src/main/resources/application.yaml | 7 +++ .../process/StudentProcessTest.java | 59 ++++++++--------- 7 files changed, 102 insertions(+), 59 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index d9c38560..30d21701 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.api.dataconversion.process; import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; +import ca.bc.gov.educ.api.dataconversion.constant.EventType; import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; @@ -226,7 +227,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, gradStudent.setUpdateDate(null); gradStudent.setUpdateUser(null); try { - gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, false, summary.getAccessToken()); + gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); } catch (Exception e) { log.error(EXCEPTION_MSG, e); handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "saving a GraduationStudentRecord : " + e.getLocalizedMessage()); @@ -245,7 +246,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, } if (ConversionResultType.FAILURE != convGradStudent.getResult()) { try { - gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, false, summary.getAccessToken()); + gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); } catch (Exception e) { log.error(EXCEPTION_MSG, e); handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "saving a GraduationStudentRecord : " + e.getLocalizedMessage()); @@ -292,7 +293,7 @@ private void processDependencies(ConvGradStudent convGradStudent, log.error("Json Parsing Error for StudentGradData: " + jpe.getLocalizedMessage()); } try { - restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, false, summary.getAccessToken()); + restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); } catch (Exception e) { handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "updating a GraduationStudentRecord with clob data : " + e.getLocalizedMessage()); } @@ -1094,30 +1095,44 @@ private List getCareerProgramCodes(List studentCar * @param gradStudent * @param accessToken */ - public void saveGraduationStudent(StudentGradDTO gradStudent, String accessToken) { + public void saveGraduationStudent(StudentGradDTO gradStudent, EventType eventType, String accessToken) { GraduationStudentRecord object = restUtils.getStudentGradStatus(gradStudent.getStudentID().toString(), accessToken); if (object != null) { - if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { - object.setProgram(gradStudent.getNewProgram()); - } - if (StringUtils.isNotBlank(gradStudent.getNewGradDate())) { - object.setProgramCompletionDate(gradStudent.getNewGradDate()); - } - if (StringUtils.isNotBlank(gradStudent.getNewStudentGrade())) { - object.setStudentGrade(gradStudent.getNewStudentGrade()); + // UPD_GRAD ==================================================== + if (eventType == EventType.UPD_GRAD) { + // School of Record + if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) { + object.setSchoolOfRecord(gradStudent.getNewSchoolOfRecord()); + } + // GRAD Program + if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { + object.setProgram(gradStudent.getNewProgram()); + } + // Adult Start Date when GRAD program is changed + if (StringUtils.isNotBlank(gradStudent.getNewAdultStartDate())) { + object.setAdultStartDate(gradStudent.getNewAdultStartDate()); + } + // SLP Date + if (StringUtils.isNotBlank(gradStudent.getNewGradDate())) { + object.setProgramCompletionDate(gradStudent.getNewGradDate()); + } + // Student Grade + if (StringUtils.isNotBlank(gradStudent.getNewStudentGrade())) { + object.setStudentGrade(gradStudent.getNewStudentGrade()); + } + // Citizenship + if (StringUtils.isNotBlank(gradStudent.getNewCitizenship())) { + object.setStudentCitizenship(gradStudent.getNewCitizenship()); + } } - if (StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { + // UPD_GRAD ==================================================== + // Student Status + if (eventType == EventType.UPD_STD_STATUS && StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { object.setStudentStatus(gradStudent.getNewStudentStatus()); } - if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) { - object.setSchoolOfRecord(gradStudent.getNewSchoolOfRecord()); - } - if (StringUtils.isNotBlank(gradStudent.getNewCitizenship())) { - object.setStudentCitizenship(gradStudent.getNewCitizenship()); - } - if (StringUtils.isNotBlank(gradStudent.getNewAdultStartDate())) { - object.setAdultStartDate(gradStudent.getNewAdultStartDate()); - } + + // Others ====================================================== + // Batch Flags if (StringUtils.isNotBlank(gradStudent.getNewRecalculateGradStatus())) { object.setRecalculateGradStatus(gradStudent.getNewRecalculateGradStatus()); } @@ -1125,7 +1140,7 @@ public void saveGraduationStudent(StudentGradDTO gradStudent, String accessToken object.setRecalculateProjectedGrad(gradStudent.getNewRecalculateProjectedGrad()); } - restUtils.saveStudentGradStatus(gradStudent.getStudentID().toString(), object, true, accessToken); + restUtils.updateStudentGradStatus(gradStudent.getStudentID().toString(), object, eventType, accessToken); } if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { @@ -1214,7 +1229,7 @@ public void triggerGraduationBatchRun(UUID studentID, String recalculateGradStat object.setRecalculateGradStatus(recalculateGradStatus == null? "Y" : recalculateGradStatus); object.setRecalculateProjectedGrad(recalculateProjectedGrad == null? "Y" : recalculateProjectedGrad); } - restUtils.saveStudentGradStatus(studentID.toString(), object, false, accessToken); + restUtils.saveStudentGradStatus(studentID.toString(), object, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java index 2a3dbd39..ec817f02 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java @@ -109,7 +109,7 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateDemog.getPen()); - studentProcess.saveGraduationStudent(currentStudent, accessToken); + studentProcess.saveGraduationStudent(currentStudent, UPD_DEMOG, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 9095d9ce..24eb8356 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -139,7 +139,7 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); - studentProcess.saveGraduationStudent(currentStudent, accessToken); + studentProcess.saveGraduationStudent(currentStudent, UPD_GRAD, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java index 5b0b0468..f185f701 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java @@ -88,7 +88,7 @@ public void processStudent(TraxStudentStatusUpdateDTO studentStatusUpdate, Stude if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), studentStatusUpdate.getPen()); - studentProcess.saveGraduationStudent(currentStudent, accessToken); + studentProcess.saveGraduationStudent(currentStudent, UPD_STD_STATUS, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java index 0a1c027a..1cb2ea6b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java @@ -1,9 +1,10 @@ package ca.bc.gov.educ.api.dataconversion.util; +import ca.bc.gov.educ.api.dataconversion.constant.EventType; import ca.bc.gov.educ.api.dataconversion.exception.ServiceException; +import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; import ca.bc.gov.educ.api.dataconversion.model.StudentCourse; -import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportRequest; import io.github.resilience4j.retry.annotation.Retry; @@ -534,10 +535,24 @@ public GraduationStudentRecord getStudentGradStatus(String studentID, String acc // Save GraduationStudentRecord - POST /student/conv/studentid/{id} @Retry(name = "rt-saveStudentGradStatus", fallbackMethod = "rtSaveStudentGradStatusFallback") - public GraduationStudentRecord saveStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, boolean ongoingUpdate, String accessToken) { + public GraduationStudentRecord saveStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, String accessToken) { + return webClient.post() + .uri(String.format(constants.getSaveGraduationStudentRecord(),studentID), + uri -> uri.queryParam("ongoingUpdate", false) + .build()) + .headers(h -> { + h.setBearerAuth(accessToken); + h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); + }).body(BodyInserters.fromValue(toBeSaved)).retrieve().bodyToMono(GraduationStudentRecord.class).block(); + } + + // Update GraduationStudentRecord - POST /student/conv/studentid/{id}?ongoingUpdate=true&eventType=UPD_GRAD + @Retry(name = "rt-updateStudentGradStatus", fallbackMethod = "rtUpdateStudentGradStatusFallback") + public GraduationStudentRecord updateStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, EventType eventType, String accessToken) { return webClient.post() .uri(String.format(constants.getSaveGraduationStudentRecord(),studentID), - uri -> uri.queryParam("ongoingUpdate", ongoingUpdate) + uri -> uri.queryParam("ongoingUpdate", true) + .queryParam("eventType", eventType.name()) .build()) .headers(h -> { h.setBearerAuth(accessToken); @@ -621,4 +636,9 @@ public ConvGradStudent rtSaveStudentGradStatusFallback(HttpServerErrorException log.error("STUDENT GRAD STATUS NOT Saved after many attempts: {}", exception); return null; } + + public ConvGradStudent rtUpdateStudentGradStatusFallback(HttpServerErrorException exception){ + log.error("STUDENT GRAD STATUS NOT Updated after many attempts: {}", exception); + return null; + } } diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index a7179628..276d2f1c 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -142,6 +142,13 @@ resilience4j.retry: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException + rt-updateStudentGradStatus: + maxAttempts: ${MAX_RETRY_ATTEMPTS} + waitDuration: 5s + retryExceptions: + - org.springframework.web.client.HttpServerErrorException + ignoreExceptions: + - java.lang.NullPointerException rt-conversionStatus: maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 5s diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java index 9e17af71..4c330c2e 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.api.dataconversion.process; import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; +import ca.bc.gov.educ.api.dataconversion.constant.EventType; import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.messaging.NatsConnection; import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; @@ -194,7 +195,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ gradStudent.setStudentStatus("CUR"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -237,7 +238,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram gradStudent.setStudentStatus("CUR"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -304,7 +305,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -381,7 +382,7 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -458,7 +459,7 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -534,7 +535,7 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -610,7 +611,7 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -687,7 +688,7 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -740,7 +741,7 @@ public void convertGraduatedStudent_whenGiven1950Data_withoutProgramCompletionDa school.setCertificateEligibility("Y"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -803,7 +804,7 @@ public void convertGraduatedStudent_whenGiven1950DataFor2Programs_withoutSccDate school.setCertificateEligibility("Y"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -873,7 +874,7 @@ public void convertGraduatedStudent_whenGivenSCCPData_withoutSlpDate_thenReturnF when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -942,7 +943,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsRetrievedAndGra when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenThrow(new RuntimeException("GRAD Student API is down!")); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -1018,7 +1019,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsCreatedAndGradS when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -1095,7 +1096,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsUpdatedAndGradS when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -1332,7 +1333,7 @@ public void convertGraduatedStudent_whenGiven1986Data_withFrenchImmersionSpecial when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -1588,7 +1589,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -1844,7 +1845,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -2086,7 +2087,7 @@ public void convertGraduatedStudent_whenGiven2018Data_withFrenchImmersionSpecial when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -2327,7 +2328,7 @@ public void convertGraduatedStudent_whenGiven1996Data_withAdvancedPlacementProgr when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); @@ -2568,7 +2569,7 @@ public void convertGraduatedStudent_whenGiven2018PFData_witDualDogwoodProgram_th when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); @@ -2759,7 +2760,7 @@ public void convertGraduatedStudent_forAdult1950_thenReturnSuccess() throws Exce when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -2958,7 +2959,7 @@ public void convertGraduatedStudent_forAdult1950_whenAssessmentIsLTE10AndProfici when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -3140,7 +3141,7 @@ public void convertGraduatedStudent_for1950NotInAD_thenReturnSuccess() throws Ex when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -3320,7 +3321,7 @@ public void convertGraduatedStudent_forSCCP_whenSlpDate_isWrongFormat_thenReturn when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); @@ -3503,7 +3504,7 @@ public void convertGraduatedStudent_forSCCP_thenReturnSuccess() throws Exception when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); @@ -3686,7 +3687,7 @@ public void convertStudentFor2Programs_withAdult1950AndSCCP_thenReturnSuccess() when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -3876,7 +3877,7 @@ public void testSaveGraduationStudent_whenENisChangedToPF_then_returnAPICallSucc boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, "123"); + studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } @@ -3924,7 +3925,7 @@ public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSucc boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, "123"); + studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } @@ -3961,7 +3962,7 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, "123"); + studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } From a7b48aababb738f83ecea27c83fe6e0f98f8eb33 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Wed, 29 Nov 2023 09:32:14 -0800 Subject: [PATCH 08/10] GRAD2-2389: Ongoing updates at field level is supported. GRAD2-2389: Ongoing updates at field level is supported. --- .../ChoreographEventHandler.java | 2 +- .../dataconversion/constant/FieldName.java | 15 ++ .../dataconversion/constant/FieldType.java | 6 + .../model/OngoingUpdateFieldDTO.java | 39 +++++ .../model/OngoingUpdateRequestDTO.java | 18 +++ .../process/StudentProcess.java | 146 +++++++++++------- .../StudentAssessmentUpdateEventService.java | 2 +- .../StudentCourseUpdateEventService.java | 2 +- ...StudentDemographicsUpdateEventService.java | 2 +- .../StudentFrenchImmersionEventService.java | 2 +- .../StudentGraduationUpdateEventService.java | 2 +- .../StudentStatusUpdateEventService.java | 2 +- .../student/StudentXProgramEventService.java | 3 +- .../EducGradDataConversionApiConstants.java | 3 + .../api/dataconversion/util/RestUtils.java | 10 +- api/src/main/resources/application.yaml | 1 + .../process/StudentProcessTest.java | 16 +- api/src/test/resources/application.yaml | 1 + 18 files changed, 194 insertions(+), 78 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateFieldDTO.java create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateRequestDTO.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java index 1fa6243f..75a740a0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java @@ -84,7 +84,7 @@ public void handleEvent(@NonNull final Event event) { break; } } catch (final Exception exception) { - log.error("Exception while processing event :: {}", event, exception); + log.error("Exception while processing event :: {} - {}", event, exception.getMessage()); } }); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java new file mode 100644 index 00000000..1d8cec7c --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java @@ -0,0 +1,15 @@ +package ca.bc.gov.educ.api.dataconversion.constant; + +public enum FieldName { + SCHOOL_OF_RECORD, + GRAD_PROGRAM, + ADULT_START_DATE, + SLP_DATE, + STUDENT_GRADE, + CITIZENSHIP, + STUDENT_STATUS, + + RECALC_GRAD_ALG, + RECALC_TVR + +} \ No newline at end of file diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java new file mode 100644 index 00000000..394bc82c --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java @@ -0,0 +1,6 @@ +package ca.bc.gov.educ.api.dataconversion.constant; + +public enum FieldType { + STRING, + DATE +} \ No newline at end of file diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateFieldDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateFieldDTO.java new file mode 100644 index 00000000..c6c4c7d4 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateFieldDTO.java @@ -0,0 +1,39 @@ +package ca.bc.gov.educ.api.dataconversion.model; + +import ca.bc.gov.educ.api.dataconversion.constant.FieldName; +import ca.bc.gov.educ.api.dataconversion.constant.FieldType; +import lombok.Builder; +import lombok.Data; + +import java.util.Objects; + +@Builder +@Data +public class OngoingUpdateFieldDTO { + private FieldType type; + private FieldName name; + private Object value; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + OngoingUpdateFieldDTO that = (OngoingUpdateFieldDTO) o; + return getName() == that.getName(); + } + + @Override + public int hashCode() { + return Objects.hash(getName()); + } + + @Override + public String toString() { + return "OngoingUpdateField{" + + "type=" + type + + ", name=" + name + + ", value=" + value + + '}'; + } + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateRequestDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateRequestDTO.java new file mode 100644 index 00000000..3bffe417 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/OngoingUpdateRequestDTO.java @@ -0,0 +1,18 @@ +package ca.bc.gov.educ.api.dataconversion.model; + +import ca.bc.gov.educ.api.dataconversion.constant.EventType; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@NoArgsConstructor +@Data +public class OngoingUpdateRequestDTO { + private String studentID; + private String pen; + private EventType eventType; + private List updateFields = new ArrayList<>(); +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index 30d21701..53a355bc 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -1,8 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.process; -import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; -import ca.bc.gov.educ.api.dataconversion.constant.EventType; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; +import ca.bc.gov.educ.api.dataconversion.constant.*; import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; import ca.bc.gov.educ.api.dataconversion.model.StudentCourse; @@ -1091,58 +1089,83 @@ private List getCareerProgramCodes(List studentCar /** * Save Graduation Student Record * for Ongoing Updates from TRAX to GRAD - * - * @param gradStudent - * @param accessToken */ - public void saveGraduationStudent(StudentGradDTO gradStudent, EventType eventType, String accessToken) { - GraduationStudentRecord object = restUtils.getStudentGradStatus(gradStudent.getStudentID().toString(), accessToken); - if (object != null) { - // UPD_GRAD ==================================================== - if (eventType == EventType.UPD_GRAD) { - // School of Record - if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) { - object.setSchoolOfRecord(gradStudent.getNewSchoolOfRecord()); - } - // GRAD Program - if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { - object.setProgram(gradStudent.getNewProgram()); - } - // Adult Start Date when GRAD program is changed - if (StringUtils.isNotBlank(gradStudent.getNewAdultStartDate())) { - object.setAdultStartDate(gradStudent.getNewAdultStartDate()); - } - // SLP Date - if (StringUtils.isNotBlank(gradStudent.getNewGradDate())) { - object.setProgramCompletionDate(gradStudent.getNewGradDate()); - } - // Student Grade - if (StringUtils.isNotBlank(gradStudent.getNewStudentGrade())) { - object.setStudentGrade(gradStudent.getNewStudentGrade()); - } - // Citizenship - if (StringUtils.isNotBlank(gradStudent.getNewCitizenship())) { - object.setStudentCitizenship(gradStudent.getNewCitizenship()); - } + public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventType eventType, String accessToken) { + OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO(); + requestDTO.setStudentID(gradStudent.getStudentID().toString()); + requestDTO.setPen(pen); + requestDTO.setEventType(eventType); + // UPD_GRAD ==================================================== + if (eventType == EventType.UPD_GRAD) { + // School of Record + if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.SCHOOL_OF_RECORD).value(gradStudent.getNewSchoolOfRecord()) + .build(); + requestDTO.getUpdateFields().add(field); } - // UPD_GRAD ==================================================== - // Student Status - if (eventType == EventType.UPD_STD_STATUS && StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { - object.setStudentStatus(gradStudent.getNewStudentStatus()); + // GRAD Program + if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.GRAD_PROGRAM).value(gradStudent.getNewProgram()) + .build(); + requestDTO.getUpdateFields().add(field); } - - // Others ====================================================== - // Batch Flags - if (StringUtils.isNotBlank(gradStudent.getNewRecalculateGradStatus())) { - object.setRecalculateGradStatus(gradStudent.getNewRecalculateGradStatus()); + // Adult Start Date when GRAD program is changed + if (StringUtils.isNotBlank(gradStudent.getNewAdultStartDate())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.DATE).name(FieldName.ADULT_START_DATE).value(gradStudent.getNewAdultStartDate()) + .build(); + requestDTO.getUpdateFields().add(field); } - if (StringUtils.isNotBlank(gradStudent.getNewRecalculateProjectedGrad())) { - object.setRecalculateProjectedGrad(gradStudent.getNewRecalculateProjectedGrad()); + // SLP Date + if (StringUtils.isNotBlank(gradStudent.getNewGradDate())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.DATE).name(FieldName.SLP_DATE).value(gradStudent.getNewGradDate()) + .build(); + requestDTO.getUpdateFields().add(field); } + // Student Grade + if (StringUtils.isNotBlank(gradStudent.getNewStudentGrade())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.STUDENT_GRADE).value(gradStudent.getNewStudentGrade()) + .build(); + requestDTO.getUpdateFields().add(field); + } + // Citizenship + if (StringUtils.isNotBlank(gradStudent.getNewCitizenship())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.CITIZENSHIP).value(gradStudent.getNewCitizenship()) + .build(); + requestDTO.getUpdateFields().add(field); + } + } + // UPD_GRAD ==================================================== + // Student Status + if (eventType == EventType.UPD_STD_STATUS && StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(gradStudent.getNewStudentStatus()) + .build(); + requestDTO.getUpdateFields().add(field); + } - restUtils.updateStudentGradStatus(gradStudent.getStudentID().toString(), object, eventType, accessToken); + // Others ====================================================== + // Batch Flags + if (StringUtils.isNotBlank(gradStudent.getNewRecalculateGradStatus())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.RECALC_GRAD_ALG).value(gradStudent.getNewRecalculateGradStatus()) + .build(); + requestDTO.getUpdateFields().add(field); + } + if (StringUtils.isNotBlank(gradStudent.getNewRecalculateProjectedGrad())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.RECALC_TVR).value(gradStudent.getNewRecalculateProjectedGrad()) + .build(); + requestDTO.getUpdateFields().add(field); } + restUtils.updateStudentGradStatusByFields(requestDTO, accessToken); + if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { removeAndReCreateOptionalPrograms(gradStudent, accessToken); handleFIorDDOptionalProgram(gradStudent, accessToken); @@ -1219,17 +1242,30 @@ public boolean existsCareerProgram(UUID studentID, String accessToken) { return list != null && !list.isEmpty(); } - public void triggerGraduationBatchRun(UUID studentID, String recalculateGradStatus, String recalculateProjectedGrad, String accessToken) { + public void triggerGraduationBatchRun(EventType eventType, UUID studentID, String pen, String recalculateGradStatus, String recalculateProjectedGrad, String accessToken) { GraduationStudentRecord object = restUtils.getStudentGradStatus(studentID.toString(), accessToken); if (object != null) { - if (StringUtils.equals(object.getStudentStatus(), STUDENT_STATUS_MERGED)) { - object.setRecalculateGradStatus(null); - object.setRecalculateProjectedGrad(null); - } else { - object.setRecalculateGradStatus(recalculateGradStatus == null? "Y" : recalculateGradStatus); - object.setRecalculateProjectedGrad(recalculateProjectedGrad == null? "Y" : recalculateProjectedGrad); + OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO(); + requestDTO.setStudentID(studentID.toString()); + requestDTO.setPen(pen); + requestDTO.setEventType(eventType); + + boolean isMerged = StringUtils.equals(object.getStudentStatus(), STUDENT_STATUS_MERGED); + // Batch Flags + if (StringUtils.isNotBlank(recalculateGradStatus)) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.RECALC_GRAD_ALG).value(isMerged ? null : recalculateGradStatus) + .build(); + requestDTO.getUpdateFields().add(field); } - restUtils.saveStudentGradStatus(studentID.toString(), object, accessToken); + if (StringUtils.isNotBlank(recalculateProjectedGrad)) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.RECALC_TVR).value(isMerged ? null : recalculateProjectedGrad) + .build(); + requestDTO.getUpdateFields().add(field); + } + + restUtils.updateStudentGradStatusByFields(requestDTO, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java index b20ea131..cf4782d8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java @@ -68,7 +68,7 @@ public void processEvent(T request, Event event) { public void processAssessment(TraxStudentUpdateDTO studentAssessmentUpdate, StudentGradDTO currentStudent, String accessToken) { log.info(" Process Assessment : studentID = {}, pen = {} ", currentStudent.getStudentID(),studentAssessmentUpdate.getPen()); - studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken); + studentProcess.triggerGraduationBatchRun(ASSESSMENT, currentStudent.getStudentID(), studentAssessmentUpdate.getPen(), "Y", "Y", accessToken); } @Override diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java index d10d4982..cc00a685 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java @@ -67,7 +67,7 @@ public void processEvent(T request, Event event) { public void processCourse(TraxStudentUpdateDTO studentCourseUpdate, StudentGradDTO currentStudent, String accessToken) { log.info(" Process Course : studentID = {}, pen = {} ", currentStudent.getStudentID(), studentCourseUpdate.getPen()); - studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken); + studentProcess.triggerGraduationBatchRun(COURSE, currentStudent.getStudentID(), studentCourseUpdate.getPen(), "Y", "Y", accessToken); } @Override diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java index ec817f02..5367ab9e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java @@ -109,7 +109,7 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateDemog.getPen()); - studentProcess.saveGraduationStudent(currentStudent, UPD_DEMOG, accessToken); + studentProcess.saveGraduationStudent(updateDemog.getPen(), currentStudent, UPD_DEMOG, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java index 268fee62..3b72f224 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java @@ -68,7 +68,7 @@ public void processFrenchImmersion(TraxFrenchImmersionUpdateDTO frenchImmersionU if (studentProcess.hasAnyFrenchImmersionCourse(currentStudent.getProgram(), frenchImmersionUpdate.getPen(), accessToken)) { log.info(" => create FI optional program"); studentProcess.addStudentOptionalProgram("FI", currentStudent, false, accessToken); - studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken); + studentProcess.triggerGraduationBatchRun(FI10ADD, currentStudent.getStudentID(), frenchImmersionUpdate.getPen(), "Y", "Y", accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 24eb8356..f7855103 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -139,7 +139,7 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); - studentProcess.saveGraduationStudent(currentStudent, UPD_GRAD, accessToken); + studentProcess.saveGraduationStudent(updateGrad.getPen(), currentStudent, UPD_GRAD, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java index f185f701..90b6b09d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java @@ -88,7 +88,7 @@ public void processStudent(TraxStudentStatusUpdateDTO studentStatusUpdate, Stude if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), studentStatusUpdate.getPen()); - studentProcess.saveGraduationStudent(currentStudent, UPD_STD_STATUS, accessToken); + studentProcess.saveGraduationStudent(studentStatusUpdate.getPen(), currentStudent, UPD_STD_STATUS, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java index d1037bcb..d96443cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java @@ -107,7 +107,8 @@ public void processOptionalAndCareerPrograms(TraxXProgramDTO xprogram, StudentGr currentStudent.setNewRecalculateGradStatus("Y"); // TVR currentStudent.setNewRecalculateProjectedGrad("Y"); - studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), currentStudent.getNewRecalculateGradStatus(), currentStudent.getNewRecalculateProjectedGrad(), accessToken); + + studentProcess.triggerGraduationBatchRun(XPROGRAM, currentStudent.getStudentID(), xprogram.getPen(), currentStudent.getNewRecalculateGradStatus(), currentStudent.getNewRecalculateProjectedGrad(), accessToken); } private void handleOptionalAndCareerProgramChange(List reqProgramCodes, List curProgramCodes, StudentGradDTO currentStudent) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java index b2f9274a..4bf19040 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java @@ -92,6 +92,9 @@ public class EducGradDataConversionApiConstants { @Value("${endpoint.grad-student-api.save-grad-student-record}") private String saveGraduationStudentRecord; + @Value("${endpoint.grad-student-api.save-grad-student-record-for-ongoing-updates}") + private String saveGraduationStudentRecordForOngoingUpdates; + @Value("${endpoint.grad-student-api.read-student-optional-programs}") private String readStudentOptionalPrograms; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java index 1cb2ea6b..a0e3c7be 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.dataconversion.util; -import ca.bc.gov.educ.api.dataconversion.constant.EventType; import ca.bc.gov.educ.api.dataconversion.exception.ServiceException; import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; @@ -548,16 +547,13 @@ public GraduationStudentRecord saveStudentGradStatus(String studentID, Graduatio // Update GraduationStudentRecord - POST /student/conv/studentid/{id}?ongoingUpdate=true&eventType=UPD_GRAD @Retry(name = "rt-updateStudentGradStatus", fallbackMethod = "rtUpdateStudentGradStatusFallback") - public GraduationStudentRecord updateStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, EventType eventType, String accessToken) { + public GraduationStudentRecord updateStudentGradStatusByFields(OngoingUpdateRequestDTO requestDTO, String accessToken) { return webClient.post() - .uri(String.format(constants.getSaveGraduationStudentRecord(),studentID), - uri -> uri.queryParam("ongoingUpdate", true) - .queryParam("eventType", eventType.name()) - .build()) + .uri(constants.getSaveGraduationStudentRecordForOngoingUpdates()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(toBeSaved)).retrieve().bodyToMono(GraduationStudentRecord.class).block(); + }).body(BodyInserters.fromValue(requestDTO)).retrieve().bodyToMono(GraduationStudentRecord.class).block(); } // Remove All Student Related Data - DELETE /student/conv/studentid/{id} diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 276d2f1c..7eb3f960 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -230,6 +230,7 @@ endpoint: save-student-career-program: ${GRAD_STUDENT_API}api/v1/student/conv/studentcareerprogram remove-student-career-program: ${GRAD_STUDENT_API}api/v1/student/conv/studentcareerprogram/%s/%s read-student-career-programs: ${GRAD_STUDENT_API}api/v1/student/studentcareerprogram/studentid/%s + save-grad-student-record-for-ongoing-updates: ${GRAD_STUDENT_API}api/v1/student/conv/ongoingupdate/gradstatus grad-assessment-api: assessment-requirement: url: ${GRAD_ASSESSMENT_API}api/v1/assessment/requirement diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java index 4c330c2e..9c991535 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java @@ -3839,7 +3839,7 @@ public void testRemoveStudentOptionalProgram() { @Test public void testSaveGraduationStudent_whenENisChangedToPF_then_returnAPICallSuccess() { String program = "2018-EN"; - + String pen = "111222333"; UUID studentID = UUID.randomUUID(); GraduationStudentRecord graduationStudentRecord = new GraduationStudentRecord(); @@ -3877,7 +3877,7 @@ public void testSaveGraduationStudent_whenENisChangedToPF_then_returnAPICallSucc boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); + studentProcess.saveGraduationStudent(pen, requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } @@ -3887,7 +3887,7 @@ public void testSaveGraduationStudent_whenENisChangedToPF_then_returnAPICallSucc @Test public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSuccess() { String program = "2018-PF"; - + String pen = "111222333"; UUID studentID = UUID.randomUUID(); GraduationStudentRecord graduationStudentRecord = new GraduationStudentRecord(); @@ -3925,7 +3925,7 @@ public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSucc boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); + studentProcess.saveGraduationStudent(pen, requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } @@ -3935,7 +3935,7 @@ public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSucc @Test public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPICallSuccess() { String program = "2018-EN"; - + String pen = "111222333"; UUID studentID = UUID.randomUUID(); GraduationStudentRecord graduationStudentRecord = new GraduationStudentRecord(); @@ -3962,7 +3962,7 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC boolean exceptionIsThrown = false; try { - studentProcess.saveGraduationStudent(requestStudent, EventType.UPD_GRAD, "123"); + studentProcess.saveGraduationStudent(pen, requestStudent, EventType.UPD_GRAD, "123"); } catch (Exception e) { exceptionIsThrown = true; } @@ -4242,7 +4242,7 @@ public void testTriggerGraduationBatchRun_withMergedStatus_returnsNoBatchRun() { when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); boolean isExceptionThrown = false; try { - studentProcess.triggerGraduationBatchRun(studentID, "Y", "Y", "123"); + studentProcess.triggerGraduationBatchRun(EventType.XPROGRAM, studentID, pen, "Y", "Y", "123"); } catch (Exception e) { isExceptionThrown = true; } @@ -4275,7 +4275,7 @@ public void testTriggerGraduationBatchRun_withCurrentStatus_returnsNoBatchRun() boolean isExceptionThrown = false; try { - studentProcess.triggerGraduationBatchRun(studentID, "Y", "Y", "123"); + studentProcess.triggerGraduationBatchRun(EventType.XPROGRAM, studentID, pen, "Y", "Y", "123"); } catch (Exception e) { isExceptionThrown = true; } diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 95a6fffe..6f7080aa 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -143,6 +143,7 @@ endpoint: save-student-career-program: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/conv/studentcareerprogram remove-student-career-program: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/conv/studentcareerprogram/%s/%s read-student-career-programs: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentcareerprogram/studentid/%s + save-grad-student-record-for-ongoing-updates: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/conv/ongoingupdate/gradstatus grad-assessment-api: assessment-requirement: url: https://educ-grad-assessment-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/assessment/requirement From fd06516ea8b7f32eef154b4569768b5cad64cb98 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Wed, 29 Nov 2023 15:03:09 -0800 Subject: [PATCH 09/10] GRAD2-2389: NewStudent event is enhanced to use the right history activity code. GRAD2-2389: NewStudent event is enhanced to use the right history activity code. --- .../process/StudentProcess.java | 41 ++++--- .../processor/StudentPartitionProcessor.java | 2 +- .../student/NewStudentEventService.java | 2 +- .../service/student/StudentBaseService.java | 5 +- .../StudentFrenchImmersionEventService.java | 2 +- .../student/StudentXProgramEventService.java | 12 +- .../api/dataconversion/util/RestUtils.java | 4 +- .../process/StudentProcessTest.java | 112 +++++++++--------- .../service/NewStudentEventServiceTest.java | 2 +- ...udentAssessmentUpdateEventServiceTest.java | 2 +- .../StudentCourseUpdateEventServiceTest.java | 2 +- ...entDemographicsUpdateEventServiceTest.java | 2 +- ...tudentFrenchImmersionEventServiceTest.java | 2 +- ...udentGraduationUpdateEventServiceTest.java | 2 +- .../StudentStatusUpdateEventServiceTest.java | 2 +- .../StudentXProgramEventServiceTest.java | 2 +- 16 files changed, 98 insertions(+), 98 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index 53a355bc..c22d53fa 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -66,7 +66,7 @@ public void clearMaps() { specialCaseMap.clear(); } - public ConvGradStudent convertStudent(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, boolean reload) throws Exception { + public ConvGradStudent convertStudent(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) throws Exception { long startTime = System.currentTimeMillis(); summary.setProcessedCount(summary.getProcessedCount() + 1L); @@ -91,7 +91,7 @@ public ConvGradStudent convertStudent(ConvGradStudent convGradStudent, Conversio } // Student conversion process - process(convGradStudent, students, summary, reload); + process(convGradStudent, students, summary, reload, ongoingUpdate); long diff = (System.currentTimeMillis() - startTime) / 1000L; log.info("** PEN: {} - {} secs", convGradStudent.getPen(), diff); @@ -155,16 +155,16 @@ private boolean validateProgramCompletionDate(ConvGradStudent convGradStudent, C return true; } - private void process(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload) { + private void process(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) { convGradStudent.setOriginalStudentLoadType(convGradStudent.getStudentLoadType()); switch (convGradStudent.getStudentLoadType()) { case UNGRAD -> { log.debug("Process Non-Graduated Student for pen# : " + convGradStudent.getPen()); - processConversion(convGradStudent, students, summary, reload); + processConversion(convGradStudent, students, summary, reload, ongoingUpdate); } case GRAD_ONE -> { log.debug("Process Graduated Student - 1 Program for pen# : " + convGradStudent.getPen()); - processConversion(convGradStudent, students, summary, reload); + processConversion(convGradStudent, students, summary, reload, ongoingUpdate); } case GRAD_TWO -> { log.debug("Process Graduated Student - 2 Programs for pen# : " + convGradStudent.getPen()); @@ -172,7 +172,7 @@ private void process(ConvGradStudent convGradStudent, List students, Co String graduationRequirementYear = convGradStudent.getGraduationRequirementYear(); convGradStudent.setGraduationRequirementYear("SCCP"); convGradStudent.setStudentLoadType(StudentLoadType.GRAD_ONE); - processConversion(convGradStudent, students, summary, reload); + processConversion(convGradStudent, students, summary, reload, ongoingUpdate); // phase 2 convGradStudent.setGraduationRequirementYear(graduationRequirementYear); convGradStudent.setSccDate(null); @@ -182,20 +182,20 @@ private void process(ConvGradStudent convGradStudent, List students, Co } else { convGradStudent.setStudentLoadType(StudentLoadType.UNGRAD); } - processConversion(convGradStudent, students, summary, false); + processConversion(convGradStudent, students, summary, false, ongoingUpdate); } default -> log.debug("skip process"); } } - private void processConversion(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload) { + private void processConversion(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) { students.forEach(st -> { if (reload) { restUtils.removeAllStudentRelatedData(UUID.fromString(st.getStudentID()), summary.getAccessToken()); } - GraduationStudentRecord gradStudent = processStudent(convGradStudent, st, summary); + GraduationStudentRecord gradStudent = processStudent(convGradStudent, st, ongoingUpdate, summary); if (gradStudent != null) { - processDependencies(convGradStudent, gradStudent, st, summary, reload); + processDependencies(convGradStudent, gradStudent, st, summary, reload, ongoingUpdate); } if (convGradStudent.getResult() == null) { @@ -204,7 +204,7 @@ private void processConversion(ConvGradStudent convGradStudent, List st }); } - private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, Student penStudent, ConversionStudentSummaryDTO summary) { + private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, Student penStudent, boolean ongoingUpdate, ConversionStudentSummaryDTO summary) { UUID studentID = UUID.fromString(penStudent.getStudentID()); GraduationStudentRecord gradStudent = null; try { @@ -225,7 +225,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, gradStudent.setUpdateDate(null); gradStudent.setUpdateUser(null); try { - gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); + gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, ongoingUpdate, summary.getAccessToken()); } catch (Exception e) { log.error(EXCEPTION_MSG, e); handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "saving a GraduationStudentRecord : " + e.getLocalizedMessage()); @@ -244,7 +244,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, } if (ConversionResultType.FAILURE != convGradStudent.getResult()) { try { - gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); + gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, ongoingUpdate, summary.getAccessToken()); } catch (Exception e) { log.error(EXCEPTION_MSG, e); handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "saving a GraduationStudentRecord : " + e.getLocalizedMessage()); @@ -264,7 +264,7 @@ private void processDependencies(ConvGradStudent convGradStudent, GraduationStudentRecord gradStudent, Student penStudent, ConversionStudentSummaryDTO summary, - boolean reload) { + boolean reload, boolean ongoingUpdate) { ConversionResultType result; // process dependencies @@ -291,7 +291,7 @@ private void processDependencies(ConvGradStudent convGradStudent, log.error("Json Parsing Error for StudentGradData: " + jpe.getLocalizedMessage()); } try { - restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, summary.getAccessToken()); + restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, ongoingUpdate, summary.getAccessToken()); } catch (Exception e) { handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "updating a GraduationStudentRecord with clob data : " + e.getLocalizedMessage()); } @@ -1179,16 +1179,16 @@ private void removeAndReCreateOptionalPrograms(StudentGradDTO gradStudent, Strin List optionalProgramCodes = new ArrayList<>(); studentOptionalPrograms.forEach(op -> { - log.info(" => [{}] optional program will be removed if exist.", op.getOptionalProgramCode()); + log.info(" => [{}] optional program will be removed if exist for {}.", op.getOptionalProgramCode(), gradStudent.getProgram()); removeStudentOptionalProgram(op.getOptionalProgramID(), gradStudent, accessToken); - if (isOptionalProgramRecreationRequired(op.getOptionalProgramCode())) { + if (isOptionalProgramRecreationRequired(op.getOptionalProgramCode(), gradStudent.getNewProgram())) { optionalProgramCodes.add(op.getOptionalProgramCode()); } }); // Recreate nonFI & nonDD optional programs optionalProgramCodes.forEach(opc -> { - log.info(" => [{}] optional program will be re-created.", opc); + log.info(" => [{}] optional program will be re-created for {}.", opc, gradStudent.getNewProgram()); addStudentOptionalProgram(opc, gradStudent, true, accessToken); }); } @@ -1196,11 +1196,11 @@ private void removeAndReCreateOptionalPrograms(StudentGradDTO gradStudent, Strin private void handleFIorDDOptionalProgram(StudentGradDTO gradStudent, String accessToken) { if (gradStudent.isAddDualDogwood()) { - log.info(" => [DD] optional program will be added if not exist."); + log.info(" => [DD] optional program will be added if not exist for {}.", gradStudent.getNewProgram()); // new grad program has to be used addStudentOptionalProgram("DD", gradStudent, true, accessToken); } else if (gradStudent.isAddFrenchImmersion()) { - log.info(" => [FI] optional program will be added if not exist."); + log.info(" => [FI] optional program will be added if not exist for {}.", gradStudent.getNewProgram()); // new grad program has to be used addStudentOptionalProgram("FI", gradStudent, true, accessToken); } @@ -1209,7 +1209,6 @@ private void handleFIorDDOptionalProgram(StudentGradDTO gradStudent, String acce public void removeStudentOptionalProgram(String optionalProgramCode, StudentGradDTO gradStudent, String accessToken) { OptionalProgram optionalProgram = restUtils.getOptionalProgram(gradStudent.getProgram(), optionalProgramCode, accessToken); if (optionalProgram != null) { - log.info(" => removed optional program code : {}", optionalProgramCode); removeStudentOptionalProgram(optionalProgram.getOptionalProgramID(), gradStudent, accessToken); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java index f18b538f..7b04d1f1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java @@ -55,7 +55,7 @@ public ConvGradStudent process(String pen) throws Exception { return null; } // convert - responseStudent = studentProcess.convertStudent(students.get(0), summaryDTO, StringUtils.equalsIgnoreCase(reload, "Y")); + responseStudent = studentProcess.convertStudent(students.get(0), summaryDTO, StringUtils.equalsIgnoreCase(reload, "Y"), false); } } catch (Exception e) { e.printStackTrace(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java index 60ec79fc..dc1a108c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java @@ -51,7 +51,7 @@ public void processEvent(T request, Event event) { ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken(accessToken); try { - studentProcess.convertStudent(convStudent, summary, false); + studentProcess.convertStudent(convStudent, summary, false, true); } catch (Exception e) { ConversionAlert error = new ConversionAlert(); error.setItem(convStudent.getPen()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java index 84f17d53..97e1ef37 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java @@ -26,6 +26,7 @@ public class StudentBaseService { // Optional Program Codes private static final List OPTIONAL_PROGRAM_CODES = Arrays.asList("AD", "BC", "BD"); private static final List OPTIONAL_PROGRAM_CODES_FOR_RECREATION = Arrays.asList("AD", "BC", "BD", "CP"); + private static final List OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION = Arrays.asList("FR", "CP"); protected void handleException(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, String pen, ConversionResultType type, String reason) { ConversionAlert error = new ConversionAlert(); @@ -144,8 +145,8 @@ public boolean isOptionalProgramCode(String code) { return OPTIONAL_PROGRAM_CODES.contains(code); } - public boolean isOptionalProgramRecreationRequired(String code) { - return OPTIONAL_PROGRAM_CODES_FOR_RECREATION.contains(code); + public boolean isOptionalProgramRecreationRequired(String code, String program) { + return "SCCP".equalsIgnoreCase(program)? OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION.contains(code) : OPTIONAL_PROGRAM_CODES_FOR_RECREATION.contains(code); } // GRAD2-2103: applied to 2023 & 2018 programs. diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java index 3b72f224..902c74a5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java @@ -66,7 +66,7 @@ public void processEvent(T request, Event event) { public void processFrenchImmersion(TraxFrenchImmersionUpdateDTO frenchImmersionUpdate, StudentGradDTO currentStudent, String accessToken) { log.info(" Process French Immersion : studentID = {}", currentStudent.getStudentID()); if (studentProcess.hasAnyFrenchImmersionCourse(currentStudent.getProgram(), frenchImmersionUpdate.getPen(), accessToken)) { - log.info(" => create FI optional program"); + log.info(" => [FI] optional program will be added if not exist for {}.", currentStudent.getProgram()); studentProcess.addStudentOptionalProgram("FI", currentStudent, false, accessToken); studentProcess.triggerGraduationBatchRun(FI10ADD, currentStudent.getStudentID(), frenchImmersionUpdate.getPen(), "Y", "Y", accessToken); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java index d96443cb..a3a99ebd 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java @@ -76,30 +76,30 @@ public void processOptionalAndCareerPrograms(TraxXProgramDTO xprogram, StudentGr currentStudent.getRemovedProgramCodes().forEach(p -> { if (isOptionalProgramCode(p)) { - log.info(" => removed optional program code : {}", p); + log.info(" => [{}] optional program will be removed if exist for {}.", p, currentStudent.getProgram()); studentProcess.removeStudentOptionalProgram(p, currentStudent, accessToken); } else { - log.info(" => removed career program code : {}", p); + log.info(" => [{}] career program will be removed if exist for {}.", p, currentStudent.getProgram()); studentProcess.removeStudentCareerProgram(p, currentStudent, accessToken); } }); currentStudent.getAddedProgramCodes().forEach(p -> { if (isOptionalProgramCode(p)) { - log.info(" => new optional program code : {}", p); + log.info(" => [{}] optional program will be added if not exist for {}.", p, currentStudent.getProgram()); studentProcess.addStudentOptionalProgram(p, currentStudent, false, accessToken); } else { - log.info(" => new career program code : {}", p); + log.info(" => [{}] career program will be added if not exist for {}.", p, currentStudent.getProgram()); studentProcess.addStudentCareerProgram(p, currentStudent.getStudentID(), accessToken); } }); // No Career Program? then remove CP optional program if (studentProcess.existsCareerProgram(currentStudent.getStudentID(), accessToken)) { - log.info(" => [CP] optional program will be added if not exist."); + log.info(" => [CP] optional program will be added if not exist for {}.", currentStudent.getProgram()); studentProcess.addStudentOptionalProgram("CP", currentStudent, false, accessToken); } else { - log.info(" => [CP] optional program will be removed if exist."); + log.info(" => [CP] optional program will be removed if exist for {}.", currentStudent.getProgram()); studentProcess.removeStudentOptionalProgram("CP", currentStudent, accessToken); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java index a0e3c7be..dd5fb3c5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java @@ -534,10 +534,10 @@ public GraduationStudentRecord getStudentGradStatus(String studentID, String acc // Save GraduationStudentRecord - POST /student/conv/studentid/{id} @Retry(name = "rt-saveStudentGradStatus", fallbackMethod = "rtSaveStudentGradStatusFallback") - public GraduationStudentRecord saveStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, String accessToken) { + public GraduationStudentRecord saveStudentGradStatus(String studentID, GraduationStudentRecord toBeSaved, boolean ongoingUpdate, String accessToken) { return webClient.post() .uri(String.format(constants.getSaveGraduationStudentRecord(),studentID), - uri -> uri.queryParam("ongoingUpdate", false) + uri -> uri.queryParam("ongoingUpdate", ongoingUpdate) .build()) .headers(h -> { h.setBearerAuth(accessToken); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java index 9c991535..35352859 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java @@ -89,7 +89,7 @@ public void convertStudent_forSchoolValidation_whenGivenSchool_doesNotExist_then .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -109,7 +109,7 @@ public void convertGraduatedStudent_forSchoolValidation_whenGivenSPMSchool_doesN .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -136,7 +136,7 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -163,7 +163,7 @@ public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnF .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -195,7 +195,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ gradStudent.setStudentStatus("CUR"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -207,7 +207,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -238,7 +238,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram gradStudent.setStudentStatus("CUR"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -250,7 +250,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -305,7 +305,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -319,7 +319,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -382,7 +382,7 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -396,7 +396,7 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -459,7 +459,7 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -472,7 +472,7 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -535,7 +535,7 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -548,7 +548,7 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -611,7 +611,7 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -625,7 +625,7 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -688,7 +688,7 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP studentCareerProgram.setCareerProgramCode("XC"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); @@ -702,7 +702,7 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -741,7 +741,7 @@ public void convertGraduatedStudent_whenGiven1950Data_withoutProgramCompletionDa school.setCertificateEligibility("Y"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -766,7 +766,7 @@ public void convertGraduatedStudent_whenGiven1950Data_withoutProgramCompletionDa ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -804,7 +804,7 @@ public void convertGraduatedStudent_whenGiven1950DataFor2Programs_withoutSccDate school.setCertificateEligibility("Y"); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -830,7 +830,7 @@ public void convertGraduatedStudent_whenGiven1950DataFor2Programs_withoutSccDate ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -874,7 +874,7 @@ public void convertGraduatedStudent_whenGivenSCCPData_withoutSlpDate_thenReturnF when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -900,7 +900,7 @@ public void convertGraduatedStudent_whenGivenSCCPData_withoutSlpDate_thenReturnF ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -943,7 +943,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsRetrievedAndGra when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenThrow(new RuntimeException("GRAD Student API is down!")); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -968,7 +968,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsRetrievedAndGra ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -1019,7 +1019,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsCreatedAndGradS when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -1045,7 +1045,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsCreatedAndGradS ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -1096,7 +1096,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsUpdatedAndGradS when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); @@ -1122,7 +1122,7 @@ public void convertGraduatedStudent_whenGraduationStudentRecordIsUpdatedAndGradS ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); @@ -1333,7 +1333,7 @@ public void convertGraduatedStudent_whenGiven1986Data_withFrenchImmersionSpecial when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -1375,7 +1375,7 @@ public void convertGraduatedStudent_whenGiven1986Data_withFrenchImmersionSpecial when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -1589,7 +1589,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -1631,7 +1631,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -1845,7 +1845,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -1887,7 +1887,7 @@ public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaur when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -2087,7 +2087,7 @@ public void convertGraduatedStudent_whenGiven2018Data_withFrenchImmersionSpecial when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); @@ -2129,7 +2129,7 @@ public void convertGraduatedStudent_whenGiven2018Data_withFrenchImmersionSpecial when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -2328,7 +2328,7 @@ public void convertGraduatedStudent_whenGiven1996Data_withAdvancedPlacementProgr when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); @@ -2369,7 +2369,7 @@ public void convertGraduatedStudent_whenGiven1996Data_withAdvancedPlacementProgr when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -2569,7 +2569,7 @@ public void convertGraduatedStudent_whenGiven2018PFData_witDualDogwoodProgram_th when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); @@ -2610,7 +2610,7 @@ public void convertGraduatedStudent_whenGiven2018PFData_witDualDogwoodProgram_th when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -2760,7 +2760,7 @@ public void convertGraduatedStudent_forAdult1950_thenReturnSuccess() throws Exce when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -2792,7 +2792,7 @@ public void convertGraduatedStudent_forAdult1950_thenReturnSuccess() throws Exce ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -2959,7 +2959,7 @@ public void convertGraduatedStudent_forAdult1950_whenAssessmentIsLTE10AndProfici when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -2992,7 +2992,7 @@ public void convertGraduatedStudent_forAdult1950_whenAssessmentIsLTE10AndProfici ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -3141,7 +3141,7 @@ public void convertGraduatedStudent_for1950NotInAD_thenReturnSuccess() throws Ex when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -3173,7 +3173,7 @@ public void convertGraduatedStudent_for1950NotInAD_thenReturnSuccess() throws Ex ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -3321,7 +3321,7 @@ public void convertGraduatedStudent_forSCCP_whenSlpDate_isWrongFormat_thenReturn when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); @@ -3355,7 +3355,7 @@ public void convertGraduatedStudent_forSCCP_whenSlpDate_isWrongFormat_thenReturn ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -3504,7 +3504,7 @@ public void convertGraduatedStudent_forSCCP_thenReturnSuccess() throws Exception when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); @@ -3538,7 +3538,7 @@ public void convertGraduatedStudent_forSCCP_thenReturnSuccess() throws Exception ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); @@ -3687,7 +3687,7 @@ public void convertStudentFor2Programs_withAdult1950AndSCCP_thenReturnSuccess() when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq("123"))).thenReturn(gradStudent); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); @@ -3720,7 +3720,7 @@ public void convertStudentFor2Programs_withAdult1950AndSCCP_thenReturnSuccess() ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false); + var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/NewStudentEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/NewStudentEventServiceTest.java index 289440db..55d0e4a5 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/NewStudentEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/NewStudentEventServiceTest.java @@ -124,7 +124,7 @@ public void testProcessStudent_whenException_isThrown_returnsAPICallError() thro event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); newStudentEventService.processEvent(traxNewStudent, event); assertThat(event).isNotNull(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java index 6f534e9b..3f2cfd41 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentAssessmentUpdateEventServiceTest.java @@ -136,7 +136,7 @@ public void testProcessStudentAssessment_whenException_isThrown_returnsAPICallEr event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentAssessmentUpdateEventService.processEvent(traxStudentUpdate, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java index 01d5907b..be9e01c9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentCourseUpdateEventServiceTest.java @@ -135,7 +135,7 @@ public void testProcessStudentCourse_whenException_isThrown_returnsAPICallError( event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentCourseUpdateEventService.processEvent(traxStudentUpdate, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java index 9a6c3f4f..25151460 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentDemographicsUpdateEventServiceTest.java @@ -119,7 +119,7 @@ public void testProcessStudentDemographics_whenException_isThrown_returnsAPICall event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentDemographicsUpdateEventService.processEvent(traxDemog, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java index a0c5b3aa..a54f0510 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentFrenchImmersionEventServiceTest.java @@ -190,7 +190,7 @@ public void testProcessStudentForFrenchImmersion_whenException_isThrown_returnsA event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentFrenchImmersionEventService.processEvent(traxFrenchImmersion, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index f0f00627..b5db7315 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -697,7 +697,7 @@ public void testProcessStudentForGrad2018ENProgram_whenException_isThrown_return event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentGraduationUpdateEventService.processEvent(traxStudentUpdate, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentStatusUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentStatusUpdateEventServiceTest.java index 7e3a8b19..cedaeaef 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentStatusUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentStatusUpdateEventServiceTest.java @@ -136,7 +136,7 @@ public void testProcessStudentStatus_whenException_isThrown_returnsAPICallError( event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentStatusUpdateEventService.processEvent(traxStudentUpdate, event); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java index 1701de82..fd530be8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentXProgramEventServiceTest.java @@ -462,7 +462,7 @@ public void testProcessStudentForXPrograms_whenException_isThrown_returnsAPICall event.setEventId(UUID.randomUUID()); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); - when(this.studentProcess.convertStudent(any(), any(), eq(false))).thenThrow(new RuntimeException("Test Exception is thrown!")); + when(this.studentProcess.convertStudent(any(), any(), eq(false), eq(true))).thenThrow(new RuntimeException("Test Exception is thrown!")); studentXProgramEventService.processEvent(traxXProgram, event); From e93da0f367704b41846e28e5c71e6eb01c21cdd7 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Thu, 7 Dec 2023 11:12:08 -0700 Subject: [PATCH 10/10] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 7ec966a9..3aa6cc17 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-data-conversion-api - 1.8.48 + 1.8.50 educ-grad-data-conversion-api Ministry of Education GRAD DATA CONVERSION API