Skip to content

Commit

Permalink
Merge pull request #530 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.20.0
  • Loading branch information
githubmamatha authored Jun 4, 2024
2 parents d2c3962 + 65d86df commit dec7835
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-graduation-api</artifactId>
<version>1.8.56</version>
<version>1.8.57</version>
<name>educ-grad-graduation-api</name>
<description>Ministry of Education GRAD GRADUATION API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,35 @@ public Integer createAndStoreStudentCertificates(String pen, boolean isOverwrite
GraduationStudentRecord graduationStudentRecord = pair.getLeft();
GraduationData graduationData = pair.getRight();

List<StudentOptionalProgram> projectedOptionalPrograms = new ArrayList<>();
for (GradAlgorithmOptionalStudentProgram optionalPrograms : graduationData.getOptionalGradStatus()) {
if (optionalPrograms.getOptionalProgramCode().equals("FI") || optionalPrograms.getOptionalProgramCode().equals("DD") || optionalPrograms.getOptionalProgramCode().equals("FR")) {
StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram();
studentOptionalProgram.setGraduated(optionalPrograms.getOptionalProgramCompletionDate() != null);
studentOptionalProgram.setOptionalProgramCode(optionalPrograms.getOptionalProgramCode());
studentOptionalProgram.setProgramCode(graduationStudentRecord.getProgram());
studentOptionalProgram.setStudentOptionalProgramData(optionalPrograms.getStudentOptionalProgramData());
projectedOptionalPrograms.add(studentOptionalProgram);
if (isGraduated(graduationStudentRecord, graduationData)) {
List<StudentOptionalProgram> projectedOptionalPrograms = new ArrayList<>();
for (GradAlgorithmOptionalStudentProgram optionalPrograms : graduationData.getOptionalGradStatus()) {
if (optionalPrograms.getOptionalProgramCode().equals("FI") || optionalPrograms.getOptionalProgramCode().equals("DD") || optionalPrograms.getOptionalProgramCode().equals("FR")) {
StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram();
studentOptionalProgram.setGraduated(optionalPrograms.getOptionalProgramCompletionDate() != null);
studentOptionalProgram.setOptionalProgramCode(optionalPrograms.getOptionalProgramCode());
studentOptionalProgram.setProgramCode(graduationStudentRecord.getProgram());
studentOptionalProgram.setStudentOptionalProgramData(optionalPrograms.getStudentOptionalProgramData());
projectedOptionalPrograms.add(studentOptionalProgram);
}
}
ExceptionMessage exception = new ExceptionMessage();
List<ProgramCertificateTranscript> certificateList = reportService.getCertificateList(graduationStudentRecord, graduationData, projectedOptionalPrograms, accessToken, exception);
token = checkAndGetAccessToken(token);
for (ProgramCertificateTranscript certType : certificateList) {
reportService.saveStudentCertificateReportJasper(graduationStudentRecord, graduationData, token.getLeft(), certType, i == 0 && isOverwrite);
i++;
logger.debug("**** Saved Certificates: {} ****", certType.getCertificateTypeCode());
}
}
ExceptionMessage exception = new ExceptionMessage();
List<ProgramCertificateTranscript> certificateList = reportService.getCertificateList(graduationStudentRecord, graduationData, projectedOptionalPrograms, accessToken, exception);
token = checkAndGetAccessToken(token);
for (ProgramCertificateTranscript certType : certificateList) {
reportService.saveStudentCertificateReportJasper(graduationStudentRecord, graduationData, token.getLeft(), certType, i == 0 && isOverwrite);
i++;
logger.debug("**** Saved Certificates: {} ****", certType.getCertificateTypeCode());
}
}
return i;
}

private boolean isGraduated(GraduationStudentRecord graduationStudentRecord, GraduationData graduationData) {
return graduationData.isGraduated() && graduationStudentRecord.getProgramCompletionDate() != null;
}

public byte[] getSchoolReports(List<String> uniqueSchoolList, String type, String accessToken) {
byte[] result = new byte[0];
Pair<String, Long> res = Pair.of(accessToken, System.currentTimeMillis());
Expand Down Expand Up @@ -229,7 +235,7 @@ public byte[] getSchoolReports(List<String> uniqueSchoolList, String type, Strin
case NONGRADREG:
List<Student> nonGradRegStudents = processStudentList(filterStudentList(stdList, NONGRADREG), REGALG);
gradReport = getReportDataObj(schoolObj, nonGradRegStudents);
return getSchoolReportNonGradRegReport(gradReport, schoolObj.getMincode(), accessToken);
return getSchoolReportNonGradRegReport(gradReport, schoolObj.getMincode());
case NONGRADPRJ:
List<Student> nonGradPrjStudents = processStudentList(filterStudentList(stdList, NONGRADPRJ), TVRRUN);
gradReport = getReportDataObj(schoolObj, nonGradPrjStudents);
Expand Down Expand Up @@ -274,7 +280,7 @@ public Integer createAndStoreSchoolReports(List<String> uniqueSchoolList, String
numberOfReports = processGradRegReport(schoolObj, gradRegStudents, usl, accessToken, numberOfReports);
List<Student> nonGradRegStudents = processStudentList(filterStudentList(stdList, NONGRADREG), type);
logger.debug("*** Process processNonGradRegReport {} for {} students", schoolObj.getMincode(), nonGradRegStudents.size());
numberOfReports = processNonGradRegReport(schoolObj, nonGradRegStudents, usl, accessToken, numberOfReports);
numberOfReports = processNonGradRegReport(schoolObj, nonGradRegStudents, usl, numberOfReports);
}
}
}
Expand Down Expand Up @@ -307,9 +313,9 @@ private int processGradRegReport(School schoolObj, List<Student> stdList, String
return numberOfReports;
}

private int processNonGradRegReport(School schoolObj, List<Student> stdList, String mincode, String accessToken, int numberOfReports) {
private int processNonGradRegReport(School schoolObj, List<Student> stdList, String mincode, int numberOfReports) {
ReportData gradReport = getReportDataObj(schoolObj, stdList);
createAndSaveSchoolReportNonGradRegReport(gradReport, mincode, accessToken);
createAndSaveSchoolReportNonGradRegReport(gradReport, mincode);
numberOfReports++;
return numberOfReports;
}
Expand Down Expand Up @@ -440,7 +446,7 @@ private String getEncodedPdfFromBytes(byte[] bytesSAR) {
return new String(encoded, StandardCharsets.US_ASCII);
}

private byte[] getSchoolReportNonGradRegReport(ReportData data, String mincode, String accessToken) {
private byte[] getSchoolReportNonGradRegReport(ReportData data, String mincode) {
ReportOptions options = new ReportOptions();
options.setReportFile(String.format("%s_%s00_NONGRADREG", mincode, LocalDate.now().getYear()));
options.setReportName(String.format("%s_%s00_NONGRADREG.pdf", mincode, LocalDate.now().getYear()));
Expand All @@ -450,14 +456,13 @@ private byte[] getSchoolReportNonGradRegReport(ReportData data, String mincode,

return this.restService.post(educGraduationApiConstants.getSchoolNonGraduation(),
reportParams,
byte[].class,
accessToken);
byte[].class);

}

@Generated
private void createAndSaveSchoolReportNonGradRegReport(ReportData data, String mincode, String accessToken) {
byte[] bytesSAR = getSchoolReportNonGradRegReport(data, mincode, accessToken);
private void createAndSaveSchoolReportNonGradRegReport(ReportData data, String mincode) {
byte[] bytesSAR = getSchoolReportNonGradRegReport(data, mincode);
String encodedPdf = getEncodedPdfFromBytes(bytesSAR);
SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, NONGRADREG);
updateSchoolReport(requestObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,7 @@ public void testCreateAndStoreStudentCertificates() {

ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationData = new ca.bc.gov.educ.api.graduation.model.dto.GraduationData();
graduationData.setOptionalGradStatus(Arrays.asList(optionalStudentProgram1, optionalStudentProgram2));
graduationData.setGraduated(true);

try {
gsr.setStudentGradData(new ObjectMapper().writeValueAsString(graduationData));
Expand Down

0 comments on commit dec7835

Please sign in to comment.