Skip to content

Commit

Permalink
Merge pull request #546 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.24 TEST
  • Loading branch information
githubmamatha authored Oct 3, 2024
2 parents cd11464 + 9e72716 commit f49926b
Show file tree
Hide file tree
Showing 36 changed files with 1,724 additions and 1,804 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ target/
build/

### VS Code ###
.vscode/
.vscode/

### Local dev ###
**/application-local.yaml
55 changes: 0 additions & 55 deletions api/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-graduation-api</artifactId>
<version>1.8.62</version>

<version>1.8.63</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 @@ -72,7 +72,7 @@ public WebClient webClient() {
return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
.codecs(configurer -> configurer
.defaultCodecs()
.maxInMemorySize(300 * 1024 * 1024)) // 100MB
.maxInMemorySize(300 * 1024 * 1024)) // 300MB
.build())
.filter(this.log())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public class EdwSnapshotController {

private static final Logger LOGGER = LoggerFactory.getLogger(EdwSnapshotController.class);
private static final String BEARER = "Bearer ";

@Autowired
EdwSnapshotService edwSnapshotService;
Expand All @@ -41,9 +40,9 @@ public class EdwSnapshotController {
@PreAuthorize(PermissionsContants.GRADUATE_STUDENT)
@Operation(summary = "Run a Graduation snapshot for EDW", description = "Run a Graduation snapshot for EDW", tags = { "EDW Snapshot" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<EdwGraduationSnapshot> snapshotGraduationStatus(@RequestBody EdwGraduationSnapshot snapshotRequest, @RequestHeader(name="Authorization") String accessToken) {
public ResponseEntity<EdwGraduationSnapshot> snapshotGraduationStatus(@RequestBody EdwGraduationSnapshot snapshotRequest) {
LOGGER.debug("Snapshot Graduation Status for Student - pen# {}", snapshotRequest.getPen());
return response.GET(edwSnapshotService.processSnapshot(snapshotRequest, accessToken.replace(BEARER, "")));
return response.GET(edwSnapshotService.processSnapshot(snapshotRequest));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,56 +64,61 @@ public class GraduationController {
@Operation(summary = "Run different Grad Runs and Graduate Student by Student ID and projected type", description = "Run different Grad Runs and Graduate Student by Student ID and projected type", tags = { "Graduation" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<AlgorithmResponse> graduateStudentNew(@PathVariable String studentID, @PathVariable String projectedType,
@RequestParam(required = false) Long batchId,
@RequestHeader(name="Authorization") String accessToken) {
@RequestParam(required = false) Long batchId) {
LOGGER.debug("Graduate Student for Student ID: {}", studentID);
return response.GET(gradService.graduateStudent(studentID,batchId,accessToken.replace(BEARER, ""),projectedType));
return response.GET(gradService.graduateStudent(studentID,batchId,projectedType));
}

@GetMapping(EducGraduationApiConstants.GRADUATE_REPORT_DATA_BY_PEN)
@PreAuthorize(PermissionsContants.GRADUATE_DATA)
@Operation(summary = "Get Report data from graduation by student pen", description = "Get Report data from graduation by student pen", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<ReportData> reportDataByPen(@PathVariable @NotNull String pen, @RequestParam(required = false) String type,
@RequestHeader(name="Authorization") String accessToken) {
LOGGER.debug("Report Data By Student Pen: {}", pen);
return response.GET(gradService.prepareReportData(pen, type, accessToken.replace(BEARER, "")));
public ResponseEntity<ReportData> reportDataByPen(@PathVariable @NotNull String pen, @RequestParam(required = false) String type) {
return response.GET(gradService.prepareReportData(pen, type));
}

@GetMapping(EducGraduationApiConstants.GRADUATE_TRANSCRIPT_REPORT)
@PreAuthorize(PermissionsContants.GRADUATE_TRANSCRIPT)
@Operation(summary = "Get Transcript binary from graduation by student pen", description = "Get Transcript binary from graduation by student pen", tags = { "Graduation Data" })
@Operation(summary = "Get Transcript encoded binary from graduation by student pen", description = "Get Transcript encoded binary from graduation by student pen", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<byte[]> reportTranscriptByPen(@PathVariable @NotNull String pen,
@RequestParam(required = false) String interim,
@RequestParam(required = false) String preview,
@RequestHeader(name="Authorization") String accessToken) {
LOGGER.debug("Report Data By Student Pen: {}", pen);
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview, accessToken.replace(BEARER, ""));
@RequestParam(required = false) String preview) {
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview);
if(resultBinary == null || resultBinary.length == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
byte[] encoded = Base64.encodeBase64(resultBinary);
return handleBinaryResponse(encoded, String.format("%sTranscript%sReport.pdfencoded", pen, interim), MediaType.TEXT_PLAIN);
}

@GetMapping(EducGraduationApiConstants.GRADUATE_TRANSCRIPT_PDF_REPORT)
@PreAuthorize(PermissionsContants.GRADUATE_TRANSCRIPT)
@Operation(summary = "Get Transcript binary from graduation by student pen", description = "Get Transcript binary from graduation by student pen", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<byte[]> reportTranscriptPdfByPen(@PathVariable @NotNull String pen,
@RequestParam(required = false) String interim,
@RequestParam(required = false) String preview) {
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview);
return handleBinaryResponse(resultBinary, String.format("%sTranscript%sReport.pdf", pen, interim), MediaType.APPLICATION_PDF);
}

@PostMapping(EducGraduationApiConstants.GRADUATE_REPORT_DATA)
@PreAuthorize(PermissionsContants.GRADUATE_DATA)
@Operation(summary = "Adapt graduation data for reporting", description = "Adapt graduation data for reporting", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<ReportData> reportDataFromGraduation(@RequestBody @NotNull GraduationData graduationData,
@RequestParam(required = false) String type,
@RequestHeader(name="Authorization") String accessToken) {
@RequestParam(required = false) String type) {
LOGGER.debug("Report Data from graduation for student: {}", graduationData.getGradStudent().getStudentID());
return response.GET(gradService.prepareReportData(graduationData, type, accessToken.replace(BEARER, "")));
return response.GET(gradService.prepareReportData(graduationData, type));
}

@PostMapping(EducGraduationApiConstants.SCHOOL_REPORTS)
@PreAuthorize(PermissionsContants.GRADUATE_STUDENT)
@Operation(summary = "School Report Creation", description = "When triggered, School Reports are created", tags = { "Reports" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> createAndStoreSchoolReports(@RequestBody List<String> uniqueSchools, @RequestHeader(name="Authorization") String accessToken,@RequestParam(required = false) String type ) {
return response.GET(gradService.createAndStoreSchoolReports(uniqueSchools,type,accessToken.replace(BEARER, "")));
return response.GET(gradService.createAndStoreSchoolReports(uniqueSchools,type));
}

@PostMapping(EducGraduationApiConstants.SCHOOL_REPORTS_LABELS)
Expand Down Expand Up @@ -274,9 +279,7 @@ public ResponseEntity<Integer> createAndStoreSchoolDistrictSuppReports(
@PreAuthorize(PermissionsContants.GRADUATE_STUDENT)
@Operation(summary = "Students for year end reports", description = "When triggered, list of students, eligible for the year end reports returns", tags = { "Reports" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<ReportGradStudentData>> getStudentsForYearEndReports(
@RequestHeader(name="Authorization") String accessToken
) {
public ResponseEntity<List<ReportGradStudentData>> getStudentsForYearEndReports(@RequestHeader(name="Authorization") String accessToken) {
return response.GET(reportService.getStudentsForSchoolYearEndReport(accessToken.replace(BEARER, "")));
}

Expand All @@ -290,7 +293,7 @@ public ResponseEntity<Integer> createAndStoreSchoolDistrictYearEndNonGradReports
@RequestParam(required = false) String drt,
@RequestParam(required = false) String srt
) {
List<ReportGradStudentData> reportGradStudentDataList = reportService.getStudentsForSchoolNonGradYearEndReport(accessToken.replace(BEARER, ""));
List<ReportGradStudentData> reportGradStudentDataList = reportService.getStudentsForSchoolNonGradYearEndReport();
return response.GET(schoolReportsService.createAndStoreSchoolDistrictReports(accessToken.replace(BEARER, ""), reportGradStudentDataList, slrt, drt, srt));
}

Expand All @@ -306,7 +309,7 @@ public ResponseEntity<Integer> createAndStoreSchoolDistrictYearEndNonGradReports
@RequestBody List<String> schools) {
List<ReportGradStudentData> reportGradStudentDataTotalList = new ArrayList<>();
for(String mincode: schools) {
List<ReportGradStudentData> sd = reportService.getStudentsForSchoolNonGradYearEndReport(mincode, accessToken.replace(BEARER, ""));
List<ReportGradStudentData> sd = reportService.getStudentsForSchoolNonGradYearEndReport(mincode);
reportGradStudentDataTotalList.addAll(sd);
}
return response.GET(schoolReportsService.createAndStoreSchoolDistrictReports(accessToken.replace(BEARER, ""), reportGradStudentDataTotalList, slrt, drt, srt));
Expand All @@ -321,7 +324,7 @@ public ResponseEntity<byte[]> getSchoolDistrictYearEndNonGradReports(
@RequestParam(required = false) String slrt,
@RequestParam(required = false) String drt,
@RequestParam(required = false) String srt) {
List<ReportGradStudentData> reportGradStudentDataList = reportService.getStudentsForSchoolNonGradYearEndReport(accessToken.replace(BEARER, ""));
List<ReportGradStudentData> reportGradStudentDataList = reportService.getStudentsForSchoolNonGradYearEndReport();
byte[] resultBinary = schoolReportsService.getSchoolDistrictReports(accessToken.replace(BEARER, ""), reportGradStudentDataList, slrt, drt, srt);
return handleBinaryResponse(resultBinary, "DistrictSchoolYearEndNonGradReports.pdf", MediaType.APPLICATION_PDF);
}
Expand Down Expand Up @@ -370,8 +373,8 @@ public ResponseEntity<byte[]> getSchoolDistrictSuppReports(
@PreAuthorize(PermissionsContants.GRADUATE_STUDENT)
@Operation(summary = "School Report Generation", description = "When triggered, School Report is generated", tags = { "Reports", "type=GRADREG", "type=NONGRADREG", "type=NONGRADPRJ" })
@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, ""));
public ResponseEntity<byte[]> getSchoolReports(@RequestBody List<String> uniqueSchools, @RequestParam(required = true) String type ) {
byte[] resultBinary = gradService.getSchoolReports(uniqueSchools,type);
if(resultBinary == null || resultBinary.length == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Expand All @@ -383,9 +386,8 @@ public ResponseEntity<byte[]> getSchoolReports(@RequestBody List<String> uniqueS
@Operation(summary = "Student Certificate Creation", description = "When triggered, Student Certificates are created for a given student", tags = { "Reports" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> createAndStoreStudentCertificate(@PathVariable @NotNull String pen,
@RequestParam(name="isOverwrite", required=false, defaultValue="N") String isOverwrite,
@RequestHeader(name="Authorization") String accessToken) {
return response.GET(gradService.createAndStoreStudentCertificates(pen, "Y".equalsIgnoreCase(isOverwrite), accessToken.replace(BEARER, "")));
@RequestParam(name="isOverwrite", required=false, defaultValue="N") String isOverwrite) {
return response.GET(gradService.createAndStoreStudentCertificates(pen, "Y".equalsIgnoreCase(isOverwrite)));
}

private ResponseEntity<byte[]> handleBinaryResponse(byte[] resultBinary, String reportFile, MediaType contentType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ public class ProcessorData {

private GraduationStudentRecord gradResponse;
private AlgorithmResponse algorithmResponse;
private String accessToken;
private String studentID;
private Long batchId;
private ExceptionMessage exception;

private long startTime;

public ProcessorData(GraduationStudentRecord gradResponse, AlgorithmResponse algorithmResponse, String accessToken, String studentID, Long batchId, ExceptionMessage exception) {
public ProcessorData(GraduationStudentRecord gradResponse, AlgorithmResponse algorithmResponse, String studentID, Long batchId, ExceptionMessage exception) {
this.gradResponse = gradResponse;
this.algorithmResponse = algorithmResponse;
this.accessToken = accessToken;
this.studentID = studentID;
this.batchId = batchId;
this.exception = exception;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package ca.bc.gov.educ.api.graduation.model.report;

import ca.bc.gov.educ.api.graduation.util.EducGraduationApiUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.util.Date;
import java.util.Objects;

public class TranscriptResult {
Expand Down Expand Up @@ -62,8 +67,19 @@ public void setUsedForGrad(String value) {
this.usedForGrad = value;
}

@JsonIgnore
public Double getCompletedPercentage() {
return this.mark != null? this.mark.getCompletedCoursePercentage() : null;
return this.mark != null ? this.mark.getCompletedCoursePercentage() : null;
}

@JsonIgnore
public Double getInterimPercentage() {
return this.mark != null && NumberUtils.isDigits(this.mark.getInterimPercent()) ? NumberUtils.createDouble(this.mark.getInterimPercent()) : 0d;
}

@JsonIgnore
public Date getSessionDate() {
return this.course != null && StringUtils.isNotBlank(this.course.getSessionDate()) ? EducGraduationApiUtils.parsingCourseTraxDate(this.course.getSessionDate()) : null;
}

@Override
Expand Down
Loading

0 comments on commit f49926b

Please sign in to comment.