Skip to content

Commit

Permalink
Merge pull request #542 from bcgov/feature/GRAD2-2929
Browse files Browse the repository at this point in the history
GRAD2-2929: task is completed.
  • Loading branch information
infstar authored Sep 18, 2024
2 parents 91d1e29 + 3c3bc81 commit e6f0ea7
Show file tree
Hide file tree
Showing 29 changed files with 1,654 additions and 1,737 deletions.
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,20 +64,18 @@ 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) {
public ResponseEntity<ReportData> reportDataByPen(@PathVariable @NotNull String pen, @RequestParam(required = false) String type) {
LOGGER.debug("Report Data By Student Pen: {}", pen);
return response.GET(gradService.prepareReportData(pen, type, accessToken.replace(BEARER, "")));
return response.GET(gradService.prepareReportData(pen, type));
}

@GetMapping(EducGraduationApiConstants.GRADUATE_TRANSCRIPT_REPORT)
Expand All @@ -86,10 +84,9 @@ public ResponseEntity<ReportData> reportDataByPen(@PathVariable @NotNull String
@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) {
@RequestParam(required = false) String preview) {
LOGGER.debug("Report Data By Student Pen: {}", pen);
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview, accessToken.replace(BEARER, ""));
byte[] resultBinary = gradService.prepareTranscriptReport(pen, interim, preview);
if(resultBinary == null || resultBinary.length == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Expand All @@ -102,18 +99,17 @@ public ResponseEntity<byte[]> reportTranscriptByPen(@PathVariable @NotNull Strin
@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 +270,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 +284,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 +300,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 +315,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 +364,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 +377,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
Expand Up @@ -46,8 +46,7 @@ public ExceptionMessage createStudentCertificateTranscriptReports(GraduationData
if(graduationDataStatus != null) {
try {
if (graduationDataStatus.isGraduated() && graduationStatusResponse.getProgramCompletionDate() != null && graduationDataStatus.getSchool() != null && graduationDataStatus.getSchool().getCertificateEligibility().equalsIgnoreCase("Y")) {
List<ProgramCertificateTranscript> certificateList = reportService.getCertificateList(gradResponse, graduationDataStatus, projectedOptionalGradResponse, processorData.getAccessToken(), exception);
tokenUtils.checkAndSetAccessToken(processorData);
List<ProgramCertificateTranscript> certificateList = reportService.getCertificateList(gradResponse, graduationDataStatus, projectedOptionalGradResponse, exception);
for (ProgramCertificateTranscript certType : certificateList) {
if("FMR".equalsIgnoreCase(processName)) {
boolean createCertificate = false;
Expand All @@ -61,15 +60,15 @@ public ExceptionMessage createStudentCertificateTranscriptReports(GraduationData
}
}
if(createCertificate) {
reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, processorData.getAccessToken(), certType, false);
reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, certType, false);
graduationDataStatus.getSchool().setSchoolCategoryCode(certType.getSchoolCategoryCode());
graduationDataStatus.getStudentCertificatesTranscript().addCertificateType(GradCertificateType.builder()
.code(certType.getCertificateTypeCode())
.description(certType.getCertificateTypeLabel())
.build());
}
} else {
reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, processorData.getAccessToken(), certType, false);
reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, certType, false);
graduationDataStatus.getSchool().setSchoolCategoryCode(certType.getSchoolCategoryCode());
graduationDataStatus.getStudentCertificatesTranscript().addCertificateType(GradCertificateType.builder()
.code(certType.getCertificateTypeCode())
Expand All @@ -83,8 +82,7 @@ public ExceptionMessage createStudentCertificateTranscriptReports(GraduationData
if ((graduationDataStatus.getStudentCourses().getStudentCourseList() == null || graduationDataStatus.getStudentCourses().getStudentCourseList().isEmpty()) && (graduationDataStatus.getStudentAssessments().getStudentAssessmentList() == null || graduationDataStatus.getStudentAssessments().getStudentAssessmentList().isEmpty())) {
logger.debug("**** No Transcript Generated: ****");
} else if (graduationDataStatus.getSchool() != null && graduationDataStatus.getSchool().getTranscriptEligibility().equalsIgnoreCase("Y")) {
tokenUtils.checkAndSetAccessToken(processorData);
reportService.saveStudentTranscriptReportJasper(data, processorData.getAccessToken(), graduationStatusResponse.getStudentID(), exception, graduationDataStatus.isGraduated(), "FMR".equalsIgnoreCase(processName));
reportService.saveStudentTranscriptReportJasper(data, graduationStatusResponse.getStudentID(), exception, graduationDataStatus.isGraduated(), "FMR".equalsIgnoreCase(processName));
if(data.getTranscript() != null && data.getTranscript().getTranscriptTypeCode() != null) {
String transcriptTypeCode = ObjectUtils.defaultIfNull(data.getTranscript().getTranscriptTypeCode().getCode(), "");
graduationDataStatus.getStudentCertificatesTranscript().setTranscriptTypeCode(transcriptTypeCode);
Expand Down
Loading

0 comments on commit e6f0ea7

Please sign in to comment.