Skip to content

Commit

Permalink
Merge pull request #619 from bcgov/develop/alex-GRAD2-2339
Browse files Browse the repository at this point in the history
GRAD2-2339
  • Loading branch information
arybakov-cgi authored Nov 1, 2023
2 parents ff9d399 + e03f46c commit 3e7257f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public interface CertificateTypeCodeRepository extends JpaRepository<Certificate

@Query("select t from CertificateTypeCodeEntity t join StudentCertificateEntity c on t.certificateTypeCode = c.certificateTypeCode where c.documentStatusCode='COMPL' and c.graduationStudentRecordId=:graduationStudentRecordId")
List<CertificateTypeCodeEntity> 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<CertificateTypeCodeEntity> getStudentCertificateTypes(UUID graduationStudentRecordId, List<String> certificateTypeCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,19 @@ public Pair<List<Student>, TotalCounts> getStudents(ReportData reportData) {
Optional<Date> distributionDate = studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(pen.getEntityId()));
distributionDate.ifPresent(student::setCertificateDistributionDate);

List<CertificateTypeCodeEntity> certificateTypes = certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(pen.getEntityId()));
List<String> 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<CertificateTypeCodeEntity> 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());

Expand Down

0 comments on commit 3e7257f

Please sign in to comment.