From 992bc60fcd69f33ee64400ea95dd475690fb4b7a Mon Sep 17 00:00:00 2001 From: "chris.ditcher" Date: Tue, 1 Aug 2023 14:18:08 -0700 Subject: [PATCH 1/5] v1.8.45 --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 22666510..47f84b33 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-graduation-api - 1.8.44 + 1.8.45 educ-grad-graduation-api Ministry of Education GRAD GRADUATION API From e79c841e28e5ad260c83107357a0c3720a7b60cf Mon Sep 17 00:00:00 2001 From: "chris.ditcher" Date: Wed, 16 Aug 2023 07:31:06 -0700 Subject: [PATCH 2/5] Updated memory for webclient to 100MB --- .../ca/bc/gov/educ/api/graduation/config/RestWebClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java index 52423065..8532ccc6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java @@ -37,7 +37,7 @@ public WebClient webClient() { return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder() .codecs(configurer -> configurer .defaultCodecs() - .maxInMemorySize(40 * 1024 * 1024)) // 40MB + .maxInMemorySize(100 * 1024 * 1024)) // 100MB .build()) .filter(this.log()) .build(); From 96ddea64bd2b3f77a1458779283b61a7af0f12b0 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 2 Nov 2023 11:45:43 -0700 Subject: [PATCH 3/5] GRAD2-2393 & GRAD2-2252: task is complete. GRAD2-2393 & GRAD2-2252: task is complete. --- .../api/graduation/service/ReportService.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index aad18d48..420be35a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -308,12 +308,16 @@ private Transcript getTranscriptData(ca.bc.gov.educ.api.graduation.model.dto.Gra private void createCourseListForTranscript(List studentCourseList, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, List tList, String provincially, boolean xml) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA); String today = EducGraduationApiUtils.formatDate(cal.getTime(), EducGraduationApiConstants.DEFAULT_DATE_FORMAT); + for (StudentCourse sc : studentCourseList) { Date sessionDate = EducGraduationApiUtils.parseDate(sc.getSessionDate() + "/01", EducGraduationApiConstants.SECONDARY_DATE_FORMAT); String sDate = EducGraduationApiUtils.formatDate(sessionDate, EducGraduationApiConstants.DEFAULT_DATE_FORMAT); int diff = EducGraduationApiUtils.getDifferenceInMonths(sDate, today); boolean notCompletedCourse = xml && diff <= 0; - if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && !sc.isCutOffCourse() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) { + if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) { + if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc, xml)) { + continue; + } TranscriptResult result = new TranscriptResult(); String equivOrChallenge = ""; if (sc.getEquivOrChallenge() != null) { @@ -335,6 +339,27 @@ private void createCourseListForTranscript(List studentCourseList } } + /** + * check if the given cutoff course is the highest mark among the same courses, then it should be in transcript even though it is duplicate + * @param studentCourseList + * @param cutOffCourse + * @return + */ + private boolean isValidCutOffCourse(List studentCourseList, StudentCourse cutOffCourse, boolean xml) { + xml = false; + if (!xml) { + List dups = studentCourseList.stream().filter(sc -> + StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel()) + ).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).collect(Collectors.toList()); + + if (!dups.isEmpty()) { + StudentCourse topMarkCourse = dups.get(0); + return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate()); + } + } + return false; + } + private TranscriptCourse setCourseObjForTranscript(StudentCourse sc, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus) { TranscriptCourse crse = new TranscriptCourse(); crse.setCode(sc.getCourseCode()); From b41f860c7743935aa4caf5f0b97dee14f301b2e9 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 2 Nov 2023 12:15:17 -0700 Subject: [PATCH 4/5] GRAD2-2393: removed the code smells complained by sonar code quality. GRAD2-2393: removed the code smells complained by sonar code quality. --- .../api/graduation/service/ReportService.java | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index 420be35a..b27a2b4e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -315,7 +315,7 @@ private void createCourseListForTranscript(List studentCourseList int diff = EducGraduationApiUtils.getDifferenceInMonths(sDate, today); boolean notCompletedCourse = xml && diff <= 0; if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) { - if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc, xml)) { + if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc)) { continue; } TranscriptResult result = new TranscriptResult(); @@ -345,17 +345,14 @@ private void createCourseListForTranscript(List studentCourseList * @param cutOffCourse * @return */ - private boolean isValidCutOffCourse(List studentCourseList, StudentCourse cutOffCourse, boolean xml) { - xml = false; - if (!xml) { - List dups = studentCourseList.stream().filter(sc -> - StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel()) - ).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).collect(Collectors.toList()); - - if (!dups.isEmpty()) { - StudentCourse topMarkCourse = dups.get(0); - return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate()); - } + private boolean isValidCutOffCourse(List studentCourseList, StudentCourse cutOffCourse) { + List dups = studentCourseList.stream().filter(sc -> + StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel()) + ).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).toList(); + + if (!dups.isEmpty()) { + StudentCourse topMarkCourse = dups.get(0); + return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate()); } return false; } @@ -514,7 +511,7 @@ public List removeDuplicatedAssessmentsForTranscript(List new StudentAssessmentDuplicatesWrapper(studentAssessment, xml)) .distinct() .map(StudentAssessmentDuplicatesWrapper::getStudentAssessment) - .collect(Collectors.toList()); + .toList(); } private List getTranscriptResults(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, boolean xml, String accessToken) { @@ -523,13 +520,13 @@ private List getTranscriptResults(ca.bc.gov.educ.api.graduatio List studentCourseList = graduationDataStatus.getStudentCourses().getStudentCourseList(); if (!studentCourseList.isEmpty()) { if (program.contains("1950") || program.contains("1986")) { - List provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).collect(Collectors.toList()); + List provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).toList(); if (!provinciallyExaminable.isEmpty()) { sortOnCourseCode(provinciallyExaminable); createCourseListForTranscript(provinciallyExaminable, graduationDataStatus, tList, "provincially", xml); } - List nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).collect(Collectors.toList()); + List nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).toList(); if (!nonExaminable.isEmpty()) { sortOnCourseCode(nonExaminable); createCourseListForTranscript(nonExaminable, graduationDataStatus, tList, "non-examinable", xml); @@ -830,11 +827,11 @@ private void getStudentCoursesAssessmentsNExams(ReportData data, ca.bc.gov.educ. List studentExamList = sCList .stream() .filter(sc -> "Y".compareTo(sc.getProvExamCourse()) == 0) - .collect(Collectors.toList()); + .toList(); List studentCourseList = sCList .stream() .filter(sc -> "N".compareTo(sc.getProvExamCourse()) == 0) - .collect(Collectors.toList()); + .toList(); List studentAssessmentList = graduationDataStatus.getStudentAssessments().getStudentAssessmentList(); List sCourseList = new ArrayList<>(); List sExamList = new ArrayList<>(); @@ -1050,12 +1047,10 @@ public ReportData prepareCertificateData(GraduationStudentRecord gradResponse, data.setUpdateDate(EducGraduationApiUtils.formatDateForReportJasper(gradResponse.getUpdateDate().toString())); data.setCertificate(getCertificateData(gradResponse, certType)); data.getStudent().setGraduationData(graduationData); - switch (certType.getCertificateTypeCode()) { - case "F", "SCF", "S": - data.getStudent().setFrenchCert(certType.getCertificateTypeCode()); - break; - default: - data.getStudent().setEnglishCert(certType.getCertificateTypeCode()); + if (certType.getCertificateTypeCode().equals("F") || certType.getCertificateTypeCode().equals("SCF") || certType.getCertificateTypeCode().equals("S")) { + data.getStudent().setFrenchCert(certType.getCertificateTypeCode()); + } else { + data.getStudent().setEnglishCert(certType.getCertificateTypeCode()); } return data; } @@ -1207,7 +1202,7 @@ private List getRequirementsMetAchvReport(List scList = optionalStudentCourses.getStudentCourseList() .stream() .filter(sc -> gr.getTranscriptRule() != null && sc.getGradReqMet().contains(gr.getTranscriptRule())) - .collect(Collectors.toList()); + .toList(); List cdList = new ArrayList<>(); scList.forEach(sc -> { AchievementCourse cD = new AchievementCourse(); From 9e9003267bfd88633d250fd4ff647588dd8d7f5b Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 2 Nov 2023 13:32:37 -0700 Subject: [PATCH 5/5] GRAD2-2393: broken unit test is fixed and cutoff course is added for a new test case. GRAD2-2393: broken unit test is fixed and cutoff course is added for a new test case. --- .../api/graduation/service/ReportService.java | 4 +- api/src/test/resources/json/gradstatus.json | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index b27a2b4e..e86b2f3d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -520,13 +520,13 @@ private List getTranscriptResults(ca.bc.gov.educ.api.graduatio List studentCourseList = graduationDataStatus.getStudentCourses().getStudentCourseList(); if (!studentCourseList.isEmpty()) { if (program.contains("1950") || program.contains("1986")) { - List provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).toList(); + List provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).collect(Collectors.toList()); if (!provinciallyExaminable.isEmpty()) { sortOnCourseCode(provinciallyExaminable); createCourseListForTranscript(provinciallyExaminable, graduationDataStatus, tList, "provincially", xml); } - List nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).toList(); + List nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).collect(Collectors.toList()); if (!nonExaminable.isEmpty()) { sortOnCourseCode(nonExaminable); createCourseListForTranscript(nonExaminable, graduationDataStatus, tList, "non-examinable", xml); diff --git a/api/src/test/resources/json/gradstatus.json b/api/src/test/resources/json/gradstatus.json index 445d6d85..973ccc5c 100644 --- a/api/src/test/resources/json/gradstatus.json +++ b/api/src/test/resources/json/gradstatus.json @@ -1370,6 +1370,47 @@ "used": false, "careerPrep": false, "restricted": false + }, + { + "pen": "111111111", + "courseCode": "PH", + "courseName": "PHYSICS 12", + "courseLevel": "11", + "sessionDate": "2023/06", + "customizedCourseName": "", + "gradReqMet": "", + "gradReqMetDetail": "", + "completedCoursePercentage": 67.0, + "completedCourseLetterGrade": "C+", + "interimPercent": 67.0, + "interimLetterGrade": "C+", + "bestSchoolPercent": null, + "bestExamPercent": null, + "equivOrChallenge": "", + "fineArtsAppliedSkills": "", + "metLitNumRequirement": null, + "credits": 4, + "creditsUsedForGrad": 0, + "relatedCourse": "", + "relatedCourseName": null, + "relatedLevel": "", + "hasRelatedCourse": "N", + "genericCourseType": "", + "language": "", + "workExpFlag": null, + "provExamCourse": "N", + "notEligibleForElective": false, + "locallyDeveloped": false, + "independentDirectedStudies": false, + "boardAuthorityAuthorized": false, + "failed": false, + "duplicate": false, + "projected": false, + "notCompleted": false, + "used": false, + "careerPrep": false, + "restricted": false, + "cutOffCourse": true } ] },