Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grad release 1.11.0 #503

Merged
merged 24 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.50</version>
<version>1.8.51</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 @@ -90,7 +90,7 @@ public ResponseEntity<byte[]> reportTranscriptByPen(@PathVariable @NotNull Strin
@RequestHeader(name="Authorization") String accessToken) {
LOGGER.debug("Report Data By Student Pen: {}", pen);
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview, accessToken.replace(BEARER, ""));
if(resultBinary == null) {
if(resultBinary == null || resultBinary.length == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
byte[] encoded = Base64.encodeBase64(resultBinary);
Expand Down Expand Up @@ -372,7 +372,7 @@ public ResponseEntity<byte[]> getSchoolDistrictSuppReports(
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<byte[]> getSchoolReports(@RequestBody List<String> uniqueSchools, @RequestHeader(name="Authorization") String accessToken,@RequestParam(required = true) String type ) {
byte[] resultBinary = gradService.getSchoolReports(uniqueSchools,type,accessToken.replace(BEARER, ""));
if(resultBinary == null) {
if(resultBinary == null || resultBinary.length == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return handleBinaryResponse(resultBinary, String.format("%sSchoolReport.pdf", type), MediaType.APPLICATION_PDF);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.graduation.service;

import ca.bc.gov.educ.api.graduation.exception.ServiceException;
import ca.bc.gov.educ.api.graduation.model.dto.GradRequirement;
import ca.bc.gov.educ.api.graduation.model.dto.GraduationData;
import ca.bc.gov.educ.api.graduation.model.dto.*;
Expand All @@ -18,6 +19,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
Expand Down Expand Up @@ -138,10 +140,25 @@ public byte[] prepareTranscriptReport(String pen, String interim, String preview
reportParams.setOptions(options);
reportParams.setData(reportData);

return webClient.post().uri(educGraduationApiConstants.getTranscriptReport())
.headers(h -> { h.setBearerAuth(accessToken); h.set(EducGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); }
).body(BodyInserters.fromValue(reportParams)).retrieve().bodyToMono(byte[].class).block();

try {
return webClient.post().uri(educGraduationApiConstants.getTranscriptReport())
.headers(h -> {
h.setBearerAuth(accessToken);
h.set(EducGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
}
).body(BodyInserters.fromValue(reportParams)).retrieve()
.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;
}
}
}

/**
Expand All @@ -165,9 +182,10 @@ public Integer createAndStoreStudentCertificates(String pen, boolean isOverwrite
for (GradAlgorithmOptionalStudentProgram optionalPrograms : graduationData.getOptionalGradStatus()) {
if (optionalPrograms.getOptionalProgramCode().equals("FI") || optionalPrograms.getOptionalProgramCode().equals("DD") || optionalPrograms.getOptionalProgramCode().equals("FR")) {
StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram();
studentOptionalProgram.setGraduated(true);
studentOptionalProgram.setGraduated(optionalPrograms.getOptionalProgramCompletionDate() != null);
studentOptionalProgram.setOptionalProgramCode(optionalPrograms.getOptionalProgramCode());
studentOptionalProgram.setProgramCode(graduationStudentRecord.getProgram());
studentOptionalProgram.setStudentOptionalProgramData(optionalPrograms.getStudentOptionalProgramData());
projectedOptionalPrograms.add(studentOptionalProgram);
}
}
Expand Down
Loading
Loading