diff --git a/api/pom.xml b/api/pom.xml index 8b94c011..10d577d7 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -7,7 +7,7 @@ ca.bc.gov.educ educ-grad-report-api educ-grad-report-api - 1.8.51 + 1.8.53 Ministry of Education and Child Care REPORT API diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/CertificateTypeCodeRepository.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/CertificateTypeCodeRepository.java index 5ba22208..11b70717 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/CertificateTypeCodeRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/CertificateTypeCodeRepository.java @@ -14,4 +14,7 @@ public interface CertificateTypeCodeRepository extends JpaRepository getStudentCertificateTypes(UUID graduationStudentRecordId); + + @Query("select t from CertificateTypeCodeEntity t join StudentCertificateEntity c on t.certificateTypeCode = c.certificateTypeCode where c.documentStatusCode='COMPL' and c.graduationStudentRecordId=:graduationStudentRecordId and c.certificateTypeCode in (:certificateTypeCode)") + List getStudentCertificateTypes(UUID graduationStudentRecordId, List certificateTypeCode); } \ No newline at end of file diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java index b2f0353e..a2a9bc9c 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java @@ -488,7 +488,19 @@ public Pair, TotalCounts> getStudents(ReportData reportData) { Optional distributionDate = studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(pen.getEntityId())); distributionDate.ifPresent(student::setCertificateDistributionDate); - List certificateTypes = certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(pen.getEntityId())); + List studentCertificateTypeCodes = new ArrayList<>(); + if(st.getGraduationStatus() != null && StringUtils.isNotBlank(st.getGraduationStatus().getCertificates())) { + String studentCertificateTypeCodesString = st.getGraduationStatus().getCertificates(); + log.debug("Process student {} certificate credentials {}", student.getPen(), studentCertificateTypeCodesString); + studentCertificateTypeCodes = Arrays.asList(StringUtils.split(studentCertificateTypeCodesString, ",")); + } + + List certificateTypes; + if(!studentCertificateTypeCodes.isEmpty()) { + certificateTypes = certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(pen.getEntityId()), studentCertificateTypeCodes); + } else { + certificateTypes = certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(pen.getEntityId())); + } student.setCertificateTypes(certificateTypes.stream().map(CertificateTypeCodeEntity::getLabel).collect(Collectors.toList())); totals.countCertificate(certificateTypes.size()); diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/TranscriptCourseImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/TranscriptCourseImpl.java index befef943..91d111f6 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/TranscriptCourseImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/TranscriptCourseImpl.java @@ -18,6 +18,7 @@ package ca.bc.gov.educ.grad.report.dto.impl; import ca.bc.gov.educ.grad.report.model.transcript.TranscriptCourse; +import org.apache.commons.lang3.StringUtils; import java.util.Objects; import java.util.logging.Logger; @@ -240,20 +241,17 @@ public boolean courseEquals(final TranscriptCourse compareCourse) { @Override public boolean compareCourse(final TranscriptCourse compareCourse) { - final int interimPercentage = getInt(this.getInterimMark()); - final int finalPercentage = getInt(this.getFinalPercent()); - final int compareFinalPercentage = getInt(compareCourse.getFinalPercent()); - final int compareInterimPercentage = getInt(compareCourse.getInterimMark()); + // Interim % should only be looked at if the courses do not have a final LG + final int percentage = StringUtils.isBlank(this.getFinalLetterGrade())? getInt(this.getInterimMark()) : getInt(this.getFinalPercent()); + final int comparePercentage = StringUtils.isBlank(compareCourse.getFinalLetterGrade())? getInt(compareCourse.getInterimMark()) : getInt(compareCourse.getFinalPercent()); // Removes duplication of courses by comparing and finding course with - //highest percentage. - boolean replaceCourse = ((interimPercentage < compareFinalPercentage - && finalPercentage < compareFinalPercentage - && compareFinalPercentage != 0) - || (finalPercentage < compareInterimPercentage - && finalPercentage != 0 - && compareInterimPercentage != 0)); - return replaceCourse; + // highest percentage. + return percentage <= comparePercentage && comparePercentage != 0; + } + + public boolean isCompletedCourseUsedForGrad() { + return StringUtils.isNotBlank(this.finalLetterGrade) && StringUtils.isNotBlank(this.requirement); } /** diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/model/transcript/TranscriptCourse.java b/api/src/main/java/ca/bc/gov/educ/grad/report/model/transcript/TranscriptCourse.java index bcf73bc5..c413a742 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/model/transcript/TranscriptCourse.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/model/transcript/TranscriptCourse.java @@ -178,4 +178,10 @@ public interface TranscriptCourse { * @return true when compareCourse has highest marks. */ boolean compareCourse(final TranscriptCourse compareCourse); + + /** + * Check this course is completed and used for graduation + * @return + */ + boolean isCompletedCourseUsedForGrad(); } diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentTranscriptServiceImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentTranscriptServiceImpl.java index 5f8b6b22..1787947a 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentTranscriptServiceImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentTranscriptServiceImpl.java @@ -48,6 +48,7 @@ import java.time.LocalDate; import java.util.*; import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; @@ -710,12 +711,13 @@ private List filterCourses(final List result private TranscriptCourse getInterimCourse( TranscriptCourse course, final List results) { - //Check for dulicate courses + //Check for duplicate courses for (final TranscriptCourse compareCourse : results) { //Check and compare two courses for duplication and if required //replace course based on requirement. if (course.courseEquals(compareCourse) - && course.compareCourse(compareCourse)) { + && !course.isCompletedCourseUsedForGrad() + && course.compareCourse(compareCourse) ) { course = compareCourse; } }