From 0939ba7fe90fb92e7e664e5c0dbb59f86fa8811c Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 10 Jan 2024 14:14:37 -0700 Subject: [PATCH 01/20] GRAD2-2377 BATCH - HD-22859-GRAD - P3 Monthly, Supplemental and YE Distribution runs should direct Certificates to School at Graduation, not School of Record --- .../controller/JobLauncherController.java | 2 +- ...BaseRunCompletionNotificationListener.java | 2 +- ...tionRunCompletionNotificationListener.java | 4 +- ...tionRunCompletionNotificationListener.java | 2 +- .../GraduationStudentRecordDistribution.java | 1 + .../DistributionRunStatusUpdateProcessor.java | 2 +- .../processor/EDWSnapshotSchoolProcessor.java | 3 +- .../RunCertificateRegenerationProcessor.java | 6 +- .../reader/BasePartitioner.java | 2 +- .../reader/DistributionRunPartitioner.java | 5 +- .../DistributionRunPartitionerPsiUserReq.java | 2 +- .../DistributionRunPartitionerUserReq.java | 2 +- ...istributionRunSupplementalPartitioner.java | 10 +- ...stributionRunYearlyNonGradPartitioner.java | 10 +- .../DistributionRunYearlyPartitioner.java | 8 +- .../reader/EDWSnapshotSchoolPartitioner.java | 2 +- .../reader/RegGradAlgPartitioner.java | 2 +- .../RegenerateCertificatePartitioner.java | 6 +- .../reader/SpcRegGradAlgPartitioner.java | 2 +- .../reader/TvrRunPartitioner.java | 2 +- .../api/batchgraduation/rest/RestUtils.java | 145 +++++++++--------- .../service/DistributionService.java | 14 +- .../service/GradDashboardService.java | 2 +- .../service/GraduationReportService.java | 2 +- .../service/ParallelDataFetch.java | 14 +- ...RunCompletionNotificationListenerTest.java | 4 +- ...RunCompletionNotificationListenerTest.java | 6 +- .../service/GradDashboardServiceTest.java | 2 +- .../service/ParallelDataFetchTest.java | 4 +- .../batchgraduation/util/RestUtilsTest.java | 50 +++--- 30 files changed, 161 insertions(+), 157 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java index 1b72e427..d58b6ee0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java @@ -180,7 +180,7 @@ public ResponseEntity launchTvrRunJob() { public ResponseEntity loadStudentIDs(@RequestBody List loadStudentData, @RequestHeader(name="Authorization") String accessToken) { logger.debug("Inside loadStudentIDs"); - Integer recordsAdded = restUtils.getStudentByPenFromStudentAPI(loadStudentData, accessToken.replace(BEARER, "")); + Integer recordsAdded = restUtils.getStudentByPenFromStudentAPI(loadStudentData); if(recordsAdded != null) return ResponseEntity.ok("Record Added Successfully"); return ResponseEntity.status(500).body("Student Record Could not be added"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java index d8466496..3f7d93d2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java @@ -103,7 +103,7 @@ private void updateBackStudentFlagForErroredStudents(Map err List erroredStudentIDs = new ArrayList<>(errors.keySet()); if (!erroredStudentIDs.isEmpty()) { LOGGER.info(" Update Student Flags: [{}] for {} errored students ----------------------------", jobType, erroredStudentIDs.size()); - restUtils.updateStudentFlagReadyForBatch(erroredStudentIDs, jobType, accessToken); + restUtils.updateStudentFlagReadyForBatch(erroredStudentIDs, jobType); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java index 2a4397e7..8e09f0af 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java @@ -164,7 +164,7 @@ private void addTranscriptsToDistributionRequest(List transcriptDistributionList = restUtils.getStudentsForUserReqDisRun("OT",searchRequest,restUtils.getTokenResponseObject().getAccess_token()); + List transcriptDistributionList = restUtils.getStudentsForUserReqDisRun("OT",searchRequest); for(StudentCredentialDistribution certScd: uniqueCertificateList) { for(StudentCredentialDistribution trScd: transcriptDistributionList) { if(certScd.getStudentID().equals(trScd.getStudentID())) { @@ -197,7 +197,7 @@ private void updateBackStudentRecords(List cList, List studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().collect(Collectors.toList()); studentIDs.forEach(sid-> { String accessToken = restUtils.fetchAccessToken(); - restUtils.updateStudentGradRecord(sid,batchId,activityCode,accessToken); + restUtils.updateStudentGradRecord(sid,batchId,activityCode); }); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java index d453ca64..03f2b722 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java @@ -110,7 +110,7 @@ private void updateBackStudentRecords(List cList, Lon cList.forEach(scd-> { LOGGER.debug("Update back Student Record {}", scd.getStudentID()); String accessToken = restUtils.fetchAccessToken(); - restUtils.updateStudentGradRecord(scd.getStudentID(),batchId,activityCode,accessToken); + restUtils.updateStudentGradRecord(scd.getStudentID(),batchId,activityCode); }); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/GraduationStudentRecordDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/GraduationStudentRecordDistribution.java index 6b72d27a..c589545f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/GraduationStudentRecordDistribution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/GraduationStudentRecordDistribution.java @@ -18,6 +18,7 @@ public class GraduationStudentRecordDistribution extends BaseModel{ private String legalMiddleNames; private String legalLastName; private String schoolOfRecord; + private String schoolAtGrad; private String programCompletionDate; private String honoursStanding; private String program; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java index 3a406930..30ee2b48 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java @@ -76,7 +76,7 @@ private Map updateBackStudentRecords(List>>> { @@ -31,7 +30,7 @@ public class EDWSnapshotSchoolProcessor implements ItemProcessor>> process(String mincode) throws Exception { summaryDTO.setBatchId(batchId); LOGGER.debug("Processing partitionData for School: {} ", mincode); - List edwStudents = restUtils.getEDWSnapshotStudents(summaryDTO.getGradYear(), mincode, summaryDTO.getAccessToken()); + List edwStudents = restUtils.getEDWSnapshotStudents(summaryDTO.getGradYear(), mincode); if ("L".equals(summaryDTO.getOption())) { List list = edwStudents.stream().filter(s -> StringUtils.isNotBlank(s.getGraduatedDate()) || ("12".equals(s.getStudentGrade()) || "AD".equals(s.getStudentGrade()))).toList(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunCertificateRegenerationProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunCertificateRegenerationProcessor.java index 94cfaa9a..479cc100 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunCertificateRegenerationProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/RunCertificateRegenerationProcessor.java @@ -26,15 +26,15 @@ public class RunCertificateRegenerationProcessor implements ItemProcessor 0) { - restUtils.updateStudentGradRecord(key, batchId, "CERTREGEN", summaryDTO.getAccessToken()); + restUtils.updateStudentGradRecord(key, batchId, "CERTREGEN"); } return count; } catch(Exception e) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 8c8fd18b..4168ba2a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -244,7 +244,7 @@ void filterByStudentSearchRequest(List eligibleSt void filterOutDeceasedStudents(List credentialList) { LOGGER.debug("Total size of credential list: {}", credentialList.size()); - List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); + List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList()); if (!deceasedIDs.isEmpty()) { LOGGER.debug("Deceased students: {}", deceasedIDs.size()); credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java index 8580c37c..d5c17405 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java @@ -35,14 +35,14 @@ public Map partition(int gridSize) { // Clean up existing reports before running new one logger.debug("Delete School Reports for Monthly Distribution"); long startTime = System.currentTimeMillis(); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL"); long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; logger.debug("Old School Reports deleted in {} sec", diff); startTime = System.currentTimeMillis(); logger.debug("Retrieve students for Monthly Distribution"); - Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(restUtils.getAccessToken()); + Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); List credentialList = new ArrayList<>(); if(parallelDTO != null) { @@ -62,7 +62,6 @@ public Map partition(int gridSize) { return new HashMap<>(); } - @Override protected JobExecution getJobExecution() { return context; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerPsiUserReq.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerPsiUserReq.java index 7a79fd2a..750e900b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerPsiUserReq.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerPsiUserReq.java @@ -33,7 +33,7 @@ public Map partition(int gridSize) { String transmissionType = jobParameters.getString("transmissionType"); PsiCredentialRequest req = (PsiCredentialRequest)jsonTransformer.unmarshall(searchRequest, PsiCredentialRequest.class); String accessToken = restUtils.getAccessToken(); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_PSI", accessToken); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_PSI"); List credentialList = getRecordsForPSIUserReqDisRun(req,transmissionType,accessToken); if(!credentialList.isEmpty()) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java index d989d458..40bb4c40 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java @@ -31,7 +31,7 @@ public Map partition(int gridSize) { JobParameters jobParameters = context.getJobParameters(); String credentialType = jobParameters.getString("credentialType"); StudentSearchRequest req = getStudentSearchRequest(); - List credentialList = restUtils.getStudentsForUserReqDisRun(credentialType,req,accessToken); + List credentialList = restUtils.getStudentsForUserReqDisRun(credentialType,req); if(!credentialList.isEmpty()) { Map map = getStringExecutionContextMap(gridSize, credentialList, credentialType); LOGGER.info("Found {} in total running on {} partitions",credentialList.size(),map.size()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java index 7d500b41..f4fe9aca 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.batchgraduation.reader; -import ca.bc.gov.educ.api.batchgraduation.model.DistributionDataParallelDTO; import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; import org.slf4j.Logger; @@ -9,9 +8,10 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import reactor.core.publisher.Mono; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class DistributionRunSupplementalPartitioner extends BasePartitioner { @@ -29,8 +29,8 @@ public Map partition(int gridSize) { logger.debug("Delete School Reports for Supplemental Distribution"); long startTime = System.currentTimeMillis(); // Clean up existing reports before running new one - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "DISTREP_SC", restUtils.getAccessToken()); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL"); + restUtils.deleteSchoolReportRecord("", "DISTREP_SC"); long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; logger.debug("Old School Reports deleted in {} sec", diff); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java index b0afd1ec..be4e8f60 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java @@ -34,10 +34,10 @@ public Map partition(int gridSize) { // Clean up existing reports before running new one logger.debug("Delete School Reports for Yearly Distribution"); long startTime = System.currentTimeMillis(); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SC", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SD", restUtils.getAccessToken()); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL"); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE"); + restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SC"); + restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SD"); long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; logger.debug("Old School Reports deleted in {} sec", diff); @@ -52,7 +52,7 @@ public Map partition(int gridSize) { if(eligibleStudentSchoolDistricts.isEmpty() ) { logger.debug("No filter found, retrieve all districts"); startTime = System.currentTimeMillis(); - eligibleStudentSchoolDistricts = parallelDataFetch.fetchDistributionRequiredDataDistrictsNonGradYearly(restUtils.getAccessToken()); + eligibleStudentSchoolDistricts = parallelDataFetch.fetchDistributionRequiredDataDistrictsNonGradYearly(); endTime = System.currentTimeMillis(); diff = (endTime - startTime)/1000; logger.debug("All {} districts retrieved in {} sec", eligibleStudentSchoolDistricts.size(), diff); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java index 4acd136c..523537d6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java @@ -29,10 +29,10 @@ public Map partition(int gridSize) { // Clean up existing reports before running new one logger.debug("Delete School Reports for Yearly Distribution"); long startTime = System.currentTimeMillis(); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "DISTREP_YE_SC", restUtils.getAccessToken()); - restUtils.deleteSchoolReportRecord("", "DISTREP_YE_SD", restUtils.getAccessToken()); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL"); + restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE"); + restUtils.deleteSchoolReportRecord("", "DISTREP_YE_SC"); + restUtils.deleteSchoolReportRecord("", "DISTREP_YE_SD"); long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; logger.debug("Old School Reports deleted in {} sec", diff); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java index c47e37c0..ea9418d6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java @@ -40,7 +40,7 @@ public Map partition(int gridSize) { if (req.getSchoolOfRecords() != null && !req.getSchoolOfRecords().isEmpty()) { schools = req.getSchoolOfRecords(); } else { - schools = restUtils.getEDWSnapshotSchools(req.getGradYear(), accessToken); + schools = restUtils.getEDWSnapshotSchools(req.getGradYear()); } long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java index fcec33b2..b7340f3c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java @@ -39,7 +39,7 @@ public Map partition(int gridSize) { if (res != null) { accessToken = res.getAccess_token(); } - studentList = restUtils.getStudentsForAlgorithm(accessToken); + studentList = restUtils.getStudentsForAlgorithm(); } else { studentList = getInputDataFromPreviousJob(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java index 34bcf843..9564d9a2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java @@ -40,7 +40,7 @@ public Map partition(int gridSize) { JobParameters jobParameters = context.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST); if (StringUtils.isBlank(searchRequest)) { - Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); + Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); if(parallelDTO != null) { credentialList.addAll(parallelDTO.certificateList()); @@ -84,7 +84,7 @@ public Map partition(int gridSize) { private List getStudentsForDistRun(String accessToken) { List credentialList = new ArrayList<>(); - Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); + Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); if(parallelDTO != null) { credentialList.addAll(parallelDTO.certificateList()); @@ -103,7 +103,7 @@ private List getStudentsForUserReqRun(String sear if (certRegenReq != null && "Y".equalsIgnoreCase(certRegenReq.getRunMode())) { StudentSearchRequest req = new StudentSearchRequest(); req.setPens(certRegenReq.getPens()); - return restUtils.getStudentsForUserReqDisRun("OC", req, accessToken); + return restUtils.getStudentsForUserReqDisRun("OC", req); } else { return getStudentsForDistRun(accessToken); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java index 8adadbf4..49c58cb5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java @@ -46,7 +46,7 @@ public Map partition(int gridSize) { JobParameters jobParameters = jobExecution.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST, "{}"); StudentSearchRequest req = (StudentSearchRequest)jsonTransformer.unmarshall(searchRequest, StudentSearchRequest.class); - studentList = restUtils.getStudentsForSpecialGradRun(req, accessToken); + studentList = restUtils.getStudentsForSpecialGradRun(req); } else { studentList = getInputDataFromPreviousJob(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java index b76e6f62..6ea0e228 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java @@ -39,7 +39,7 @@ public Map partition(int gridSize) { if (res != null) { accessToken = res.getAccess_token(); } - studentList = restUtils.getStudentsForProjectedAlgorithm(accessToken); + studentList = restUtils.getStudentsForProjectedAlgorithm(); } else { studentList = getInputDataFromPreviousJob(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index ec00a08c..e661e270 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -7,6 +7,7 @@ import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiUtils; import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil; import io.github.resilience4j.retry.annotation.Retry; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -159,7 +160,8 @@ public ResponseObj rtGetTokenFallBack(HttpServerErrorException exception){ } @Retry(name = "rt-getStudent") - public List getStudentsByPen(String pen, String accessToken) { + public List getStudentsByPen(String pen) { + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; LOGGER.debug(URL_FORMAT_STR,constants.getPenStudentApiByPenUrl()); @@ -170,9 +172,10 @@ public List getStudentsByPen(String pen, String accessToken) { } @Retry(name = "reggradrun") - public AlgorithmResponse runGradAlgorithm(UUID studentID, String accessToken, String gradProgram, String programCompleteDate,Long batchId) { + public AlgorithmResponse runGradAlgorithm(UUID studentID, String gradProgram, String programCompleteDate, Long batchId) { UUID correlationID = UUID.randomUUID(); - if(isReportOnly(studentID, gradProgram, programCompleteDate, accessToken)) { + String accessToken = getAccessToken(); + if(isReportOnly(studentID, gradProgram, programCompleteDate)) { return this.webClient.get() .uri(String.format(constants.getGraduationApiReportOnlyUrl(), studentID,batchId)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -185,8 +188,9 @@ public AlgorithmResponse runGradAlgorithm(UUID studentID, String accessToken, St } @Retry(name = "tvrrun") - public AlgorithmResponse runProjectedGradAlgorithm(UUID studentID, String accessToken,Long batchId) { + public AlgorithmResponse runProjectedGradAlgorithm(UUID studentID, Long batchId) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); return this.webClient.get() .uri(String.format(constants.getGraduationApiProjectedGradUrl(), studentID,batchId)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -195,8 +199,9 @@ public AlgorithmResponse runProjectedGradAlgorithm(UUID studentID, String access } @Retry(name = "rt-getStudent") - public BatchGraduationStudentRecord runGetStudentForBatchInput(UUID studentID, String accessToken) { + public BatchGraduationStudentRecord runGetStudentForBatchInput(UUID studentID) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); return this.webClient.get() .uri(String.format(constants.getGradStudentApiGradStatusForBatchUrl(), studentID)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -207,7 +212,7 @@ public BatchGraduationStudentRecord runGetStudentForBatchInput(UUID studentID, S public BatchGraduationStudentRecord getStudentForBatchInput(UUID studentID, AlgorithmSummaryDTO summary) { LOGGER.debug(STUDENT_READ,studentID); try { - return this.runGetStudentForBatchInput(studentID, summary.getAccessToken()); + return this.runGetStudentForBatchInput(studentID); } catch(Exception e) { summary.updateError(studentID,"GRAD-STUDENT-API IS DOWN","GRAD Student API is unavailable at this moment"); LOGGER.info("GET Failed STU-ID:{} Errors:{}",studentID,summary.getErrors().size()); @@ -216,20 +221,21 @@ public BatchGraduationStudentRecord getStudentForBatchInput(UUID studentID, Algo } public List fetchDistributionRequiredDataStudentsNonGradYearly() { - return graduationReportService.getStudentsNonGradForYearlyDistribution(getTokenResponseObject().getAccess_token()); + return graduationReportService.getStudentsNonGradForYearlyDistribution(getAccessToken()); } public List fetchDistributionRequiredDataStudentsNonGradYearly(String mincode) { - return graduationReportService.getStudentsNonGradForYearlyDistribution(mincode, getTokenResponseObject().getAccess_token()); + return graduationReportService.getStudentsNonGradForYearlyDistribution(mincode, getAccessToken()); } public List fetchDistributionRequiredDataStudentsYearly() { - return graduationReportService.getStudentsForYearlyDistribution(getTokenResponseObject().getAccess_token()); + return graduationReportService.getStudentsForYearlyDistribution(getAccessToken()); } - public Integer runRegenerateStudentCertificate(String pen, String accessToken) { + public Integer runRegenerateStudentCertificate(String pen) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); return this.webClient.get() .uri(String.format(constants.getStudentCertificateRegeneration(), pen), uri -> uri.queryParam("isOverwrite", "Y").build()) @@ -237,8 +243,9 @@ public Integer runRegenerateStudentCertificate(String pen, String accessToken) { .retrieve().bodyToMono(Integer.class).block(); } - public List getStudentsForAlgorithm(String accessToken) { + public List getStudentsForAlgorithm() { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.get() @@ -247,8 +254,9 @@ public List getStudentsForAlgorithm(String accessToken) { .retrieve().bodyToMono(responseType).block(); } - public List getStudentsForProjectedAlgorithm(String accessToken) { + public List getStudentsForProjectedAlgorithm() { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.get() @@ -259,8 +267,9 @@ public List getStudentsForProjectedAlgorithm(String accessToken) { // EDUC-GRAD-STUDENT-API ======================================== - public GraduationStudentRecord saveGraduationStudentRecord(GraduationStudentRecord graduationStudentRecord, String accessToken) { + public GraduationStudentRecord saveGraduationStudentRecord(GraduationStudentRecord graduationStudentRecord) { // No need to add a correlationID here. + String accessToken = getAccessToken(); return this.webClient.post() .uri(String.format(constants.getGradStudentApiGradStatusUrl(),graduationStudentRecord.getStudentID())) .headers(h -> h.setBearerAuth(accessToken)) @@ -268,8 +277,9 @@ public GraduationStudentRecord saveGraduationStudentRecord(GraduationStudentReco .retrieve().bodyToMono(GraduationStudentRecord.class).block(); } - public List getStudentsForSpecialGradRun(StudentSearchRequest req,String accessToken) { + public List getStudentsForSpecialGradRun(StudentSearchRequest req) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GraduationStudentRecordSearchResult res = this.webClient.post() .uri(constants.getGradStudentApiStudentForSpcGradListUrl()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -285,7 +295,7 @@ public GraduationStudentRecord processStudent(GraduationStudentRecord item, Algo summary.setProcessedCount(summary.getProcessedCount() + 1L); try { String accessToken = summary.getAccessToken(); - AlgorithmResponse algorithmResponse = this.runGradAlgorithm(item.getStudentID(), accessToken, + AlgorithmResponse algorithmResponse = this.runGradAlgorithm(item.getStudentID(), item.getProgram(), item.getProgramCompletionDate(), summary.getBatchId()); return processGraduationStudentRecord(item, summary, algorithmResponse); }catch(Exception e) { @@ -306,14 +316,14 @@ private GraduationStudentRecord processGraduationStudentRecord(GraduationStudent return algorithmResponse.getGraduationStudentRecord(); } - public boolean isReportOnly(UUID studentID, String gradProgram, String programCompletionDate, String accessToken) { + public boolean isReportOnly(UUID studentID, String gradProgram, String programCompletionDate) { boolean isFMR = false; if ("SCCP".equalsIgnoreCase(gradProgram)) { if (programCompletionDate != null) { Date pCD = EducGradBatchGraduationApiUtils.parsingTraxDate(programCompletionDate); int diff = EducGradBatchGraduationApiUtils.getDifferenceInDays(EducGradBatchGraduationApiUtils.getProgramCompletionDate(pCD), EducGradBatchGraduationApiUtils.getCurrentDate()); if (diff >= 0) { - isFMR = checkSccpCertificateExists(studentID, accessToken); + isFMR = checkSccpCertificateExists(studentID); } else { isFMR = false; } @@ -329,7 +339,7 @@ public GraduationStudentRecord processProjectedGradStudent(GraduationStudentReco summary.setProcessedCount(summary.getProcessedCount() + 1L); try { String accessToken = summary.getAccessToken(); - AlgorithmResponse algorithmResponse = this.runProjectedGradAlgorithm(item.getStudentID(), accessToken,summary.getBatchId()); + AlgorithmResponse algorithmResponse = this.runProjectedGradAlgorithm(item.getStudentID(), summary.getBatchId()); return processGraduationStudentRecord(item, summary, algorithmResponse); } catch(Exception e) { summary.updateError(item.getStudentID(),GRADUATION_API_IS_DOWN,GRADUATION_API_DOWN_MSG); @@ -339,10 +349,10 @@ public GraduationStudentRecord processProjectedGradStudent(GraduationStudentReco } } - public Integer getStudentByPenFromStudentAPI(List loadStudentData, String accessToken) { + public Integer getStudentByPenFromStudentAPI(List loadStudentData) { AtomicReference recordsAdded = new AtomicReference<>(0); loadStudentData.forEach(student -> { - List stuDataList = this.getStudentsByPen(student.getPen(), accessToken); + List stuDataList = this.getStudentsByPen(student.getPen()); stuDataList.forEach(st-> { GraduationStudentRecord gradStu = new GraduationStudentRecord(); gradStu.setProgram(student.getProgramCode()); @@ -351,15 +361,16 @@ public Integer getStudentByPenFromStudentAPI(List loadStudentDa gradStu.setRecalculateGradStatus("Y"); gradStu.setStudentStatus(student.getStudentStatus()); gradStu.setStudentID(UUID.fromString(st.getStudentID())); - this.saveGraduationStudentRecord(gradStu, accessToken); + this.saveGraduationStudentRecord(gradStu); recordsAdded.getAndSet(recordsAdded.get() + 1); }); }); return recordsAdded.get(); } - public List getStudentData(List studentIds, String accessToken) { + public List getStudentData(List studentIds) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; StudentList stuList = new StudentList(); @@ -374,32 +385,19 @@ public List getStudentData(List studentIds, Strin public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary) { LOGGER.info(STUDENT_PROCESS,item.getStudentID()); summary.setProcessedCount(summary.getProcessedCount() + 1L); - String accessToken = summary.getAccessToken(); - - StudentCredentialDistribution scObj = summary.getGlobalList().stream().filter(pr -> pr.getStudentID().compareTo(item.getStudentID()) == 0) - .findAny() - .orElse(null); - if(scObj != null) { - item.setSchoolOfRecord(scObj.getSchoolOfRecord()); - item.setPen(scObj.getPen()); - item.setLegalLastName(scObj.getLegalLastName()); - item.setLegalFirstName(scObj.getLegalFirstName()); - item.setLegalMiddleNames(scObj.getLegalMiddleNames()); - } else { - GraduationStudentRecordDistribution stuRec =this.getStudentData(item.getStudentID().toString(),accessToken); - if (stuRec != null) { - item.setProgram(stuRec.getProgram()); - item.setHonoursStanding(stuRec.getHonoursStanding()); - item.setSchoolOfRecord(stuRec.getSchoolOfRecord()); - item.setProgramCompletionDate(stuRec.getProgramCompletionDate()); - item.setStudentID(stuRec.getStudentID()); - item.setPen(stuRec.getPen()); - item.setLegalFirstName(stuRec.getLegalFirstName()); - item.setLegalMiddleNames(stuRec.getLegalMiddleNames()); - item.setLegalLastName(stuRec.getLegalLastName()); - item.setNonGradReasons(stuRec.getNonGradReasons()); - item.setStudentGrade(stuRec.getStudentGrade()); - } + GraduationStudentRecordDistribution stuRec = getStudentData(item.getStudentID().toString()); + if (stuRec != null) { + item.setProgram(stuRec.getProgram()); + item.setHonoursStanding(stuRec.getHonoursStanding()); + item.setSchoolOfRecord(StringUtils.isBlank(stuRec.getSchoolAtGrad()) ? stuRec.getSchoolOfRecord() : stuRec.getSchoolAtGrad()); + item.setProgramCompletionDate(stuRec.getProgramCompletionDate()); + item.setStudentID(stuRec.getStudentID()); + item.setPen(stuRec.getPen()); + item.setLegalFirstName(stuRec.getLegalFirstName()); + item.setLegalMiddleNames(stuRec.getLegalMiddleNames()); + item.setLegalLastName(stuRec.getLegalLastName()); + item.setNonGradReasons(stuRec.getNonGradReasons()); + item.setStudentGrade(stuRec.getStudentGrade()); } summary.getGlobalList().add(item); LOGGER.info(STUDENT_PROCESSED, item.getStudentID(), summary.getProcessedCount(), summary.getReadCount(), summary.getBatchId()); @@ -410,7 +408,7 @@ public PsiCredentialDistribution processPsiDistribution(PsiCredentialDistributio summary.setProcessedCount(summary.getProcessedCount() + 1L); String accessToken = summary.getAccessToken(); try { - List stuDataList = this.getStudentsByPen(item.getPen(), accessToken); + List stuDataList = this.getStudentsByPen(item.getPen()); if(!stuDataList.isEmpty()) { item.setStudentID(UUID.fromString(stuDataList.get(0).getStudentID())); } @@ -429,7 +427,7 @@ public BlankCredentialDistribution processBlankDistribution(BlankCredentialDistr String accessToken = summary.getAccessToken(); String credentialType = summary.getCredentialType(); if (credentialType != null && credentialType.equalsIgnoreCase("OC")){ - GradCertificateTypes certType = this.getCertTypes(item.getCredentialTypeCode(), accessToken); + GradCertificateTypes certType = this.getCertTypes(item.getCredentialTypeCode()); if (certType != null) item.setPaperType(certType.getPaperType()); else @@ -441,8 +439,9 @@ public BlankCredentialDistribution processBlankDistribution(BlankCredentialDistr return item; } - public GradCertificateTypes getCertTypes(String certType,String accessToken) { + public GradCertificateTypes getCertTypes(String certType) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GradCertificateTypes result = webClient.get() .uri(String.format(constants.getCertificateTypes(),certType)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -455,8 +454,9 @@ public GradCertificateTypes getCertTypes(String certType,String accessToken) { return result; } - public GraduationStudentRecord getStudentDataForBatch(String studentID, String accessToken) { + public GraduationStudentRecord getStudentDataForBatch(String studentID) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GraduationStudentRecord result = webClient.get() .uri(String.format(constants.getStudentInfo(),studentID)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -470,8 +470,9 @@ public GraduationStudentRecord getStudentDataForBatch(String studentID, String a return result; } - public GraduationStudentRecordDistribution getStudentData(String studentID, String accessToken) { + public GraduationStudentRecordDistribution getStudentData(String studentID) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GraduationStudentRecordDistribution result = webClient.get() .uri(String.format(constants.getStudentInfo(),studentID)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -598,15 +599,17 @@ public void updateSchoolReportRecord(String schoolOfRecord, String reportTypeCod .retrieve().bodyToMono(boolean.class).block(); } - public void deleteSchoolReportRecord(String schoolOfRecord, String reportTypeCode, String accessToken) { + public void deleteSchoolReportRecord(String schoolOfRecord, String reportTypeCode) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); webClient.delete().uri(String.format(constants.getUpdateSchoolReport(),schoolOfRecord,reportTypeCode)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .retrieve().bodyToMono(boolean.class).block(); } - public List getStudentsForUserReqDisRun(String credentialType, StudentSearchRequest req, String accessToken) { + public List getStudentsForUserReqDisRun(String credentialType, StudentSearchRequest req) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.post() @@ -618,8 +621,9 @@ public List getStudentsForUserReqDisRun(String cr .block(); } - public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode, String accessToken) { + public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode) { //Grad2-1931 not updating the school record if student id does not exist. + String accessToken = getAccessToken(); try { if (studentID != null) { String url = String.format(constants.getUpdateStudentRecord(), studentID, batchId, activityCode); @@ -630,8 +634,9 @@ public void updateStudentGradRecord(UUID studentID, Long batchId,String activity } } - public List updateStudentFlagReadyForBatch(List studentIds, String batchJobType, String accessToken) { + public List updateStudentFlagReadyForBatch(List studentIds, String batchJobType) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; StudentList stuList = new StudentList(); @@ -643,7 +648,8 @@ public List updateStudentFlagReadyForBatch(List s .retrieve().bodyToMono(responseType).block(); } - public Boolean checkSccpCertificateExists (UUID studentID, String accessToken) { + public Boolean checkSccpCertificateExists (UUID studentID) { + String accessToken = getAccessToken(); return this.webClient.get() .uri(constants.getCheckSccpCertificateExists(), uri -> uri.queryParam("studentID", studentID).build()) @@ -651,7 +657,8 @@ public Boolean checkSccpCertificateExists (UUID studentID, String accessToken) { .retrieve().bodyToMono(Boolean.class).block(); } - public List getEDWSnapshotSchools(Integer gradYear, String accessToken) { + public List getEDWSnapshotSchools(Integer gradYear) { + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; String url = String.format(constants.getEdwSnapshotSchoolsUrl(), gradYear); @@ -662,7 +669,8 @@ public List getEDWSnapshotSchools(Integer gradYear, String accessToken) .retrieve().bodyToMono(responseType).block(); } - public List getEDWSnapshotStudents(Integer gradYear, String mincode, String accessToken) { + public List getEDWSnapshotStudents(Integer gradYear, String mincode) { + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; String url = String.format(constants.getEdwSnapshotStudentsByMincodeUrl(), gradYear, mincode); @@ -740,8 +748,9 @@ public TraxSchool getTraxSchool(String mincode) { return get(String.format(constants.getTraxSchoolByMincode(), mincode), TraxSchool.class, getAccessToken()); } - public List getDeceasedStudentIDs(List studentIDs, String accessToken) { + public List getDeceasedStudentIDs(List studentIDs) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.post() @@ -751,18 +760,6 @@ public List getDeceasedStudentIDs(List studentIDs, String accessToke .retrieve().bodyToMono(responseType).block(); } - public UUID getStudentIDByPen(String pen, String accessToken) { - try { - List stuDataList = this.getStudentsByPen(pen, accessToken); - if(!stuDataList.isEmpty()) { - return UUID.fromString(stuDataList.get(0).getStudentID()); - } - } catch (Exception e) { - LOGGER.error("Error processing student with pen# {} due to {}", pen, e.getLocalizedMessage()); - } - return null; - } - public EdwGraduationSnapshot processSnapshot(EdwGraduationSnapshot item, EdwSnapshotSummaryDTO summary) { UUID correlationID = UUID.randomUUID(); LOGGER.debug(STUDENT_PROCESS,item.getPen()); @@ -774,7 +771,7 @@ public EdwGraduationSnapshot processSnapshot(EdwGraduationSnapshot item, EdwSnap .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .body(BodyInserters.fromValue(item)) .retrieve().bodyToMono(EdwGraduationSnapshot.class).block(); - }catch(Exception e) { + } catch(Exception e) { summary.updateError(item.getPen(),item.getSchoolOfRecord(),GRADUATION_API_IS_DOWN,GRADUATION_API_DOWN_MSG); summary.setProcessedCount(summary.getProcessedCount() - 1L); LOGGER.info("Failed STU-PEN:{} Errors:{}",item.getPen(),summary.getErrors().size()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java index 16634af9..f5d8660e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java @@ -75,12 +75,14 @@ public void saveStudentCredentialDistribution(Long batchId, String jobType, Stud public void updateDistributionBatchJobStatus(Long batchId, int failedCount, String status) { log.debug("updateDistributionBatchJobStatus - retrieve the batch job history: batchId = {}", batchId); BatchGradAlgorithmJobHistoryEntity jobHistory = gradBatchHistoryService.getGradAlgorithmJobHistory(batchId); - jobHistory.setEndTime(LocalDateTime.now()); - jobHistory.setStatus(status); - jobHistory.setActualStudentsProcessed(jobHistory.getExpectedStudentsProcessed() - failedCount); - log.debug("updateDistributionBatchJobStatus - save the batch job history: batchId = {}, status = {}. actual processed count = {}", batchId, status, jobHistory.getActualStudentsProcessed()); - gradBatchHistoryService.saveGradAlgorithmJobHistory(jobHistory); - log.debug("updateDistributionBatchJobStatus - save the batch job history is completed!"); + if(jobHistory != null) { + jobHistory.setEndTime(LocalDateTime.now()); + jobHistory.setStatus(status); + jobHistory.setActualStudentsProcessed(jobHistory.getExpectedStudentsProcessed() - failedCount); + log.debug("updateDistributionBatchJobStatus - save the batch job history: batchId = {}, status = {}. actual processed count = {}", batchId, status, jobHistory.getActualStudentsProcessed()); + gradBatchHistoryService.saveGradAlgorithmJobHistory(jobHistory); + log.debug("updateDistributionBatchJobStatus - save the batch job history is completed!"); + } } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java index 3aaacb28..c3f8d195 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java @@ -89,7 +89,7 @@ public ErrorDashBoard getErrorInfo(Long batchId, Integer pageNumber, Integer pag List studentIds = list.stream().map(BatchGradAlgorithmStudentEntity::getStudentID).toList(); List eList = new ArrayList<>(); if(!studentIds.isEmpty()) { - List studentList = restUtils.getStudentData(studentIds, accessToken); + List studentList = restUtils.getStudentData(studentIds); for (GraduationStudentRecord gRec : studentList) { ErrorBoard eD = new ErrorBoard(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java index c1e80391..43cb0bc6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java @@ -98,7 +98,7 @@ private StudentCredentialDistribution populateStudentCredentialDistribution(Repo } dist.setStudentID(data.getGraduationStudentRecordId()); dist.setPaperType(paperType); - dist.setSchoolOfRecord(data.getMincode()); + dist.setSchoolOfRecord(StringUtils.isBlank(data.getMincodeAtGrad()) ? data.getMincode() : data.getMincodeAtGrad()); dist.setDocumentStatusCode("COMPL"); dist.setPen(data.getPen()); dist.setLegalFirstName(data.getFirstName()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetch.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetch.java index 7f067852..2fb93575 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetch.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetch.java @@ -19,15 +19,19 @@ public class ParallelDataFetch { RestUtils restUtils; // Monthly distribution - public Mono fetchDistributionRequiredData(String accessToken) { + public Mono fetchDistributionRequiredData() { + String accessToken = restUtils.getAccessToken(); Mono> transcriptList = graduationReportService.getTranscriptList(accessToken); + accessToken = restUtils.getAccessToken(); Mono> certificateList = graduationReportService.getCertificateList(accessToken); return Mono.zip(transcriptList,certificateList).map(tuple -> new DistributionDataParallelDTO(tuple.getT1(),tuple.getT2())); } // Supplemental distribution - public Mono fetchDistributionRequiredDataYearly(String accessToken) { + public Mono fetchDistributionRequiredDataYearly() { + String accessToken = restUtils.getAccessToken(); Mono> transcriptList = graduationReportService.getTranscriptListYearly(accessToken); + accessToken = restUtils.getAccessToken(); Mono> certificateList = graduationReportService.getCertificateList(accessToken); return Mono.zip(transcriptList,certificateList).map(tuple -> new DistributionDataParallelDTO(tuple.getT1(),tuple.getT2())); } @@ -41,11 +45,13 @@ public List fetchStudentCredentialsDistributionDa return restUtils.fetchDistributionRequiredDataStudentsNonGradYearly(); } - public List fetchDistributionRequiredDataSchoolsNonGradYearly(String accessToken) { + public List fetchDistributionRequiredDataSchoolsNonGradYearly() { + String accessToken = restUtils.getAccessToken(); return graduationReportService.getSchoolsNonGradYearly(accessToken); } - public List fetchDistributionRequiredDataDistrictsNonGradYearly(String accessToken) { + public List fetchDistributionRequiredDataDistrictsNonGradYearly() { + String accessToken = restUtils.getAccessToken(); return graduationReportService.getDistrictsNonGradYearly(accessToken); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java index debc564f..047462e4 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java @@ -208,8 +208,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); Mockito.when(graduationReportService.getTranscriptList(null)).thenReturn(Mono.just(tList)); Mockito.when(graduationReportService.getCertificateList(null)).thenReturn(Mono.just(cList)); - Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); - Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); + Mockito.when(parallelDataFetch.fetchDistributionRequiredData()).thenReturn(Mono.just(dp)); + Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly()).thenReturn(Mono.just(dp)); Mockito.when(restUtils.mergeAndUpload(121L, distributionRequest,"YEARENDDIST",null)).thenReturn(new DistributionResponse()); distributionRunCompletionNotificationListener.afterJob(jobExecution); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java index 22c88d1d..87a70033 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java @@ -194,7 +194,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); Mockito.when(graduationReportService.getTranscriptList(null)).thenReturn(Mono.just(tList)); Mockito.when(graduationReportService.getCertificateList(null)).thenReturn(Mono.just(cList)); - Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); + Mockito.when(parallelDataFetch.fetchDistributionRequiredData()).thenReturn(Mono.just(dp)); userReqDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); @@ -329,8 +329,8 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); Mockito.when(graduationReportService.getTranscriptList(null)).thenReturn(Mono.just(tList)); Mockito.when(graduationReportService.getCertificateList(null)).thenReturn(Mono.just(cList)); - Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); - Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); + Mockito.when(parallelDataFetch.fetchDistributionRequiredData()).thenReturn(Mono.just(dp)); + Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly()).thenReturn(Mono.just(dp)); userReqDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java index 00963e97..04375dc9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java @@ -201,7 +201,7 @@ public void testGetErrorInfo() { rec.setPen("673213121"); Mockito.when(batchGradAlgorithmStudentRepository.findByJobExecutionIdAndStatusIn(batchId,Arrays.asList("STARTED", "FAILED"), paging)).thenReturn(pagedData); - Mockito.when(restUtils.getStudentData(List.of(studentId), "accessToken")).thenReturn(List.of(rec)); + Mockito.when(restUtils.getStudentData(List.of(studentId))).thenReturn(List.of(rec)); Mockito.when(batchGradAlgorithmStudentRepository.findByStudentIDAndJobExecutionId(rec.getStudentID(),batchId)).thenReturn(Optional.of(ent)); ErrorDashBoard res = gradDashboardService.getErrorInfo(batchId,0,10,"accessToken"); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetchTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetchTest.java index 53c6d52a..d2d36b9a 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetchTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/ParallelDataFetchTest.java @@ -92,7 +92,7 @@ public void testFetchDistributionRequiredDataSchoolsNonGradYearly() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(List.of("1234567"))); - List result = parallelDataFetch.fetchDistributionRequiredDataSchoolsNonGradYearly("accessToken"); + List result = parallelDataFetch.fetchDistributionRequiredDataSchoolsNonGradYearly(); assertThat(result).isNotEmpty(); } @@ -108,7 +108,7 @@ public void testFetchDistributionRequiredDataDistrictsNonGradYearly() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(List.of("123"))); - List result = parallelDataFetch.fetchDistributionRequiredDataDistrictsNonGradYearly("accessToken"); + List result = parallelDataFetch.fetchDistributionRequiredDataDistrictsNonGradYearly(); assertThat(result).isNotEmpty(); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index 6e29a907..0f4d502c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -131,7 +131,7 @@ public void testGetStudentByPen_givenValues_returnsStudent_with_APICallSuccess() }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(student))); - val result = this.restUtils.getStudentsByPen(pen, "abc"); + val result = this.restUtils.getStudentsByPen(pen); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); assertThat(result.get(0).getPen()).isEqualTo(pen); @@ -154,7 +154,7 @@ public void testSaveGraduationStatus_givenValues_returnsGraduationStatus_with_AP when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStatus)); - var result = this.restUtils.saveGraduationStudentRecord(graduationStatus, "123"); + var result = this.restUtils.saveGraduationStudentRecord(graduationStatus); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); } @@ -184,7 +184,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess() { when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); - var result = this.restUtils.getStudentsForSpecialGradRun(req, "123"); + var result = this.restUtils.getStudentsForSpecialGradRun(req); assertThat(result).isNotNull(); assertThat(result.get(0)).isEqualTo(studentID); } @@ -214,7 +214,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess_null() { when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(inputResponseSR); when(this.inputResponseSR.block()).thenReturn(null); - var result = this.restUtils.getStudentsForSpecialGradRun(req, "123"); + var result = this.restUtils.getStudentsForSpecialGradRun(req); assertThat(result).isNotNull().isEmpty(); } @@ -409,7 +409,7 @@ public void testGetStudentData_withlist() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(graduationStatus))); - List resList = this.restUtils.getStudentData(studentList,"abc"); + List resList = this.restUtils.getStudentData(studentList); assertNotNull(resList); assertThat(resList).hasSize(1); } @@ -888,7 +888,7 @@ public void testRunGradAlgorithm() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(AlgorithmResponse.class)).thenReturn(Mono.just(res)); - val result = this.restUtils.runGradAlgorithm(UUID.fromString(studentID), grd.getProgram(), "123",programCompletionDate,null); + val result = this.restUtils.runGradAlgorithm(UUID.fromString(studentID), "123",programCompletionDate,null); assertThat(result).isNotNull(); } @@ -912,7 +912,7 @@ public void testRunGradAlgorithm_programCompletionDateNull() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(AlgorithmResponse.class)).thenReturn(Mono.just(res)); - val result = this.restUtils.runGradAlgorithm(UUID.fromString(studentID), grd.getProgram(), "123",null,null); + val result = this.restUtils.runGradAlgorithm(UUID.fromString(studentID), "123",null,null); assertThat(result).isNotNull(); } @@ -931,7 +931,7 @@ public void testRunProjectedGradAlgorithm() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(AlgorithmResponse.class)).thenReturn(Mono.just(res)); - val result = this.restUtils.runProjectedGradAlgorithm(UUID.fromString(studentID), "123",null); + val result = this.restUtils.runProjectedGradAlgorithm(UUID.fromString(studentID), null); assertThat(result).isNotNull(); } @@ -951,7 +951,7 @@ public void testGetStudentsForAlgorithm() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(grd.getStudentID()))); - val result = this.restUtils.getStudentsForAlgorithm("abc"); + val result = this.restUtils.getStudentsForAlgorithm(); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -972,7 +972,7 @@ public void testGetStudentsForProjectedAlgorithm() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(grd.getStudentID()))); - val result = this.restUtils.getStudentsForProjectedAlgorithm("abc"); + val result = this.restUtils.getStudentsForProjectedAlgorithm(); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -1012,7 +1012,7 @@ public void testGetStudentForBatchInput_When_APIisDown_returns_null() { AlgorithmSummaryDTO summary = new AlgorithmSummaryDTO(); summary.setAccessToken("123"); - when(this.restUtils.runGetStudentForBatchInput(studentID, summary.getAccessToken())).thenThrow(new RuntimeException("GRAD-STUDENT-API is down.")); + when(this.restUtils.runGetStudentForBatchInput(studentID)).thenThrow(new RuntimeException("GRAD-STUDENT-API is down.")); val result = this.restUtils.getStudentForBatchInput(studentID, summary); assertThat(result).isNull(); @@ -1031,7 +1031,7 @@ public void testGetStudentDataForBatch() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(grd)); - GraduationStudentRecord res = this.restUtils.getStudentDataForBatch(studentID.toString(),null); + GraduationStudentRecord res = this.restUtils.getStudentDataForBatch(studentID.toString()); assertThat(res).isNotNull(); assertThat(res.getStudentID()).isEqualTo(studentID); } @@ -1085,7 +1085,7 @@ public void testGetStudentsForUserReqDisRun() { when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(scdList)); - val result = this.restUtils.getStudentsForUserReqDisRun(credentialType,req,null); + val result = this.restUtils.getStudentsForUserReqDisRun(credentialType,req); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -1250,7 +1250,7 @@ public void testGetStudentData() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecordDistribution.class)).thenReturn(Mono.just(grd)); - GraduationStudentRecordDistribution res = this.restUtils.getStudentData(studentID.toString(),null); + GraduationStudentRecordDistribution res = this.restUtils.getStudentData(studentID.toString()); assertThat(res).isNotNull(); } @@ -1341,7 +1341,7 @@ public void testupdateStudentGradRecord() { when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(rec)); - this.restUtils.updateStudentGradRecord(studentID,batchId,activityCode,"acb"); + this.restUtils.updateStudentGradRecord(studentID,batchId,activityCode); assertNotNull(rec); } @@ -1366,7 +1366,7 @@ public void testUpdateSchoolReportRecord() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(boolean.class)).thenReturn(Mono.just(true)); - restUtils.deleteSchoolReportRecord(mincode,reportTypeCode,null); + restUtils.deleteSchoolReportRecord(mincode,reportTypeCode); assertThat(reportTypeCode).isEqualTo("E"); } @@ -1381,7 +1381,7 @@ public void testDeleteSchoolReportRecord() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(boolean.class)).thenReturn(Mono.just(true)); - this.restUtils.deleteSchoolReportRecord(mincode,reportTypeCode,null); + this.restUtils.deleteSchoolReportRecord(mincode,reportTypeCode); assertThat(reportTypeCode).isEqualTo("E"); } @@ -1426,7 +1426,7 @@ public void testGetStudentByPenFromStudentAPI() { when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStatus)); - Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData,"abc"); + Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData); assertThat(res).isEqualTo(1); } @@ -1456,7 +1456,7 @@ public void testUpdateStudentFlagReadyForBatch() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(graduationStatus))); - val result = this.restUtils.updateStudentFlagReadyForBatch(studentIDs, batchJobType, "abc"); + val result = this.restUtils.updateStudentFlagReadyForBatch(studentIDs, batchJobType); assertThat(result).hasSize(1); } @@ -1475,7 +1475,7 @@ public void testIsReportOnly_when_programCompletionDate_isInFuture_thenReturns_G when(this.responseMock.bodyToMono(Boolean.class)).thenReturn(Mono.just(true)); - val result = this.restUtils.isReportOnly(studentID, gradProgram, programCompletionDate, "abc"); + val result = this.restUtils.isReportOnly(studentID, gradProgram, programCompletionDate); assertThat(result).isFalse(); } @@ -1492,7 +1492,7 @@ public void testIsReportOnly_when_programCompletionDate_isNotInFuture_and_SCCPce when(this.responseMock.bodyToMono(Boolean.class)).thenReturn(Mono.just(true)); - val result = this.restUtils.isReportOnly(studentID, gradProgram, programCompletionDate, "abc"); + val result = this.restUtils.isReportOnly(studentID, gradProgram, programCompletionDate); assertThat(result).isTrue(); } @@ -1507,7 +1507,7 @@ public void testRunRegenerateStudentCertificates() { when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(Integer.valueOf(1))); - val result = this.restUtils.runRegenerateStudentCertificate(pen, "abc"); + val result = this.restUtils.runRegenerateStudentCertificate(pen); assertThat(result).isEqualTo(1); } @@ -1575,7 +1575,7 @@ public void testGetEDWSnapshotSchools() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(schools)); - val result = this.restUtils.getEDWSnapshotSchools(gradYear, "abc"); + val result = this.restUtils.getEDWSnapshotSchools(gradYear); assertThat(result).hasSize(2); } @@ -1600,7 +1600,7 @@ public void testGetEDWSnapshotStudents() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(snapshotResponse))); - val result = this.restUtils.getEDWSnapshotStudents(gradYear, mincode, "abc"); + val result = this.restUtils.getEDWSnapshotStudents(gradYear, mincode); assertThat(result).hasSize(1); } @@ -1647,7 +1647,7 @@ public void testGetDeceasedStudentIDs() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(studentIDs)); - val result = this.restUtils.getDeceasedStudentIDs(studentIDs, "abc"); + val result = this.restUtils.getDeceasedStudentIDs(studentIDs); assertThat(result).hasSize(2); } From c6799431aa57752611985e4a81c8018e5b72c869 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 10 Jan 2024 14:32:30 -0700 Subject: [PATCH 02/20] GRAD2-2377 BATCH - HD-22859-GRAD - P3 Monthly, Supplemental and YE Distribution runs should direct Certificates to School at Graduation, not School of Record --- .../batchgraduation/util/RestUtilsTest.java | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index 0f4d502c..d45b6f51 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -122,6 +122,8 @@ public void testGetStudentByPen_givenValues_returnsStudent_with_APICallSuccess() student.setStudentID(studentID); student.setPen(pen); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(), pen))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -146,6 +148,8 @@ public void testSaveGraduationStatus_givenValues_returnsGraduationStatus_with_AP graduationStatus.setStudentID(studentID); graduationStatus.setPen(pen); + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getGradStudentApiGradStatusUrl(), studentID))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -174,7 +178,6 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess() { GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); res.setStudentIDs(Arrays.asList(graduationStatus.getStudentID())); - when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getGradStudentApiStudentForSpcGradListUrl(), studentID))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -183,6 +186,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); + mockTokenResponseObject(); var result = this.restUtils.getStudentsForSpecialGradRun(req); assertThat(result).isNotNull(); @@ -204,6 +208,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess_null() { GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); res.setStudentIDs(Arrays.asList(graduationStatus.getStudentID())); + mockTokenResponseObject(); when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getGradStudentApiStudentForSpcGradListUrl(), studentID))).thenReturn(this.requestBodyUriMock); @@ -235,6 +240,8 @@ public void testProcessStudent() { AlgorithmSummaryDTO summary = new AlgorithmSummaryDTO(); summary.setBatchId(batchId); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiUrl(), studentID,batchId))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -319,6 +326,8 @@ public void testProcessProjectedStudent() { AlgorithmSummaryDTO summary = new AlgorithmSummaryDTO(); summary.setBatchId(batchId); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiProjectedGradUrl(), studentID,batchId))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -398,6 +407,8 @@ public void testGetStudentData_withlist() { graduationStatus.setStudentID(studentID); graduationStatus.setPen(pen); + mockTokenResponseObject(); + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -418,9 +429,21 @@ public void testGetStudentData_withlist() { public void testProcessDistribution() { final UUID studentID = UUID.randomUUID(); - final String pen = "123456789"; final Long batchId = 9879L; final String mincode = "123121111"; + + GraduationStudentRecordDistribution grd = new GraduationStudentRecordDistribution(); + grd.setStudentID(studentID); + grd.setProgram("2018-EN"); + + mockTokenResponseObject(); + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(GraduationStudentRecordDistribution.class)).thenReturn(Mono.just(grd)); + List globalList = new ArrayList<>(); StudentCredentialDistribution scd = new StudentCredentialDistribution(); @@ -431,9 +454,6 @@ public void testProcessDistribution() { scd.setStudentID(studentID); globalList.add(scd); - - - DistributionSummaryDTO summary = new DistributionSummaryDTO(); summary.setBatchId(batchId); summary.setGlobalList(globalList); @@ -479,6 +499,8 @@ public void testProcessDistribution_elsecase() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecordDistribution.class)).thenReturn(Mono.just(grd)); + mockTokenResponseObject(); + DistributionSummaryDTO summary = new DistributionSummaryDTO(); summary.setBatchId(batchId); summary.setGlobalList(globalList); @@ -518,6 +540,8 @@ public void testProcessDistribution_elsecase_null() { grd.setStudentGrade("12"); grd.setSchoolOfRecord("454445444"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID2))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -578,6 +602,8 @@ public void testProcessBlankDistribution_OC() { certificateTypes.setDescription("SDS"); certificateTypes.setLabel("fere"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getCertificateTypes(),"E"))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -606,6 +632,8 @@ public void testProcessBlankDistribution_OC_null() { certificateTypes.setDescription("SDS"); certificateTypes.setLabel("fere"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getCertificateTypes(),"E"))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -675,6 +703,8 @@ public void testProcessPsiDistribution_else() { student.setStudentID(studentID.toString()); student.setPen(pen2); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(), pen2))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -715,6 +745,8 @@ public void testProcessPsiDistribution_else_2() { student.setStudentID(studentID.toString()); student.setPen(pen2); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(), pen2))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -882,6 +914,8 @@ public void testRunGradAlgorithm() { res.setGraduationStudentRecord(grd); res.setStudentOptionalProgram(new ArrayList<>()); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiReportOnlyUrl(), studentID,null))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -906,6 +940,8 @@ public void testRunGradAlgorithm_programCompletionDateNull() { res.setGraduationStudentRecord(grd); res.setStudentOptionalProgram(new ArrayList<>()); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiUrl(), studentID,null))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -925,6 +961,9 @@ public void testRunProjectedGradAlgorithm() { AlgorithmResponse res = new AlgorithmResponse(); res.setGraduationStudentRecord(grd); res.setStudentOptionalProgram(new ArrayList<>()); + + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiProjectedGradUrl(), studentID,null))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -942,6 +981,8 @@ public void testGetStudentsForAlgorithm() { grd.setStudentID(new UUID(1,1)); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(constants.getGradStudentApiStudentForGradListUrl())).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -963,6 +1004,8 @@ public void testGetStudentsForProjectedAlgorithm() { grd.setStudentID(new UUID(1,1)); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(constants.getGradStudentApiStudentForProjectedGradListUrl())).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -983,6 +1026,8 @@ public void testGetStudentForBatchInput() { final UUID studentID = UUID.randomUUID(); BatchGraduationStudentRecord grd = new BatchGraduationStudentRecord(studentID, "2018-EN", null, "1234567"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGradStudentApiGradStatusForBatchUrl(), studentID))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1002,6 +1047,8 @@ public void testGetStudentForBatchInput_When_APIisDown_returns_null() { final UUID studentID = UUID.randomUUID(); BatchGraduationStudentRecord grd = new BatchGraduationStudentRecord(studentID, "2018-EN", null, "1234567"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGradStudentApiGradStatusForBatchUrl(), studentID))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1025,6 +1072,8 @@ public void testGetStudentDataForBatch() { grd.setStudentID(studentID); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1074,6 +1123,8 @@ public void testGetStudentsForUserReqDisRun() { scd.setId(new UUID(1,1)); scdList.add(scd); + mockTokenResponseObject(); + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -1224,6 +1275,8 @@ public void testMergePSIAndUpload_null() { Long batchId = 3344L; String transmissionType = "ftp"; + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getMergePsiAndUpload(),batchId,"Y"))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -1244,6 +1297,8 @@ public void testGetStudentData() { grd.setStudentID(studentID); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1312,6 +1367,8 @@ public void testGetSchoolByDistrictCode() { public void testExecutePostDistribution() { DistributionResponse distributionResponse = new DistributionResponse(); + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(constants.getPostingDistribution())).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -1332,6 +1389,9 @@ public void testupdateStudentGradRecord() { GraduationStudentRecord rec = new GraduationStudentRecord(); rec.setStudentID(studentID); + + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getUpdateStudentRecord(),studentID,batchId,activityCode))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -1351,6 +1411,8 @@ public void testUpdateSchoolReportRecord() { final String mincode = "123213123"; String reportTypeCode = "E"; + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1375,6 +1437,8 @@ public void testDeleteSchoolReportRecord() { final String mincode = "123213123"; String reportTypeCode = "E"; + mockTokenResponseObject(); + when(this.webClient.delete()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1412,6 +1476,7 @@ public void testGetStudentByPenFromStudentAPI() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(student))); + mockTokenResponseObject(); GraduationStudentRecord graduationStatus = new GraduationStudentRecord(); graduationStatus.setStudentID(studentID); @@ -1446,6 +1511,8 @@ public void testUpdateStudentFlagReadyForBatch() { StudentList stuList = new StudentList(); stuList.setStudentids(studentIDs); + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getUpdateStudentFlagReadyForBatchByStudentIDs(), batchJobType))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -1468,6 +1535,8 @@ public void testIsReportOnly_when_programCompletionDate_isInFuture_thenReturns_G Date futureDate = DateUtils.addMonths(new Date(), 1); final String programCompletionDate = EducGradBatchGraduationApiUtils.formatDate(futureDate, "yyyy/MM"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(eq(constants.getCheckSccpCertificateExists()), any(Function.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1485,6 +1554,8 @@ public void testIsReportOnly_when_programCompletionDate_isNotInFuture_and_SCCPce final String gradProgram = "SCCP"; final String programCompletionDate = "2023/01"; + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(eq(constants.getCheckSccpCertificateExists()), any(Function.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1500,6 +1571,8 @@ public void testIsReportOnly_when_programCompletionDate_isNotInFuture_and_SCCPce public void testRunRegenerateStudentCertificates() { final String pen = "123456789"; + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(eq(String.format(constants.getStudentCertificateRegeneration(), pen)), any(Function.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1566,6 +1639,8 @@ public void testGetEDWSnapshotSchools() { List schools = Arrays.asList("12345678","11223344"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getEdwSnapshotSchoolsUrl(), gradYear))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1591,6 +1666,8 @@ public void testGetEDWSnapshotStudents() { snapshotResponse.setGpa(BigDecimal.valueOf(3.75)); snapshotResponse.setHonourFlag("N"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getEdwSnapshotStudentsByMincodeUrl(), gradYear, mincode))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1637,6 +1714,8 @@ public void testGetDeceasedStudentIDs() { List studentIDs = Arrays.asList(studentID1, studentID2); + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(constants.getDeceasedStudentIDList())).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); From cbb34d2d8db82c870e2f405de30d8e1b9cd41f3e Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 3 Apr 2024 13:20:30 -0600 Subject: [PATCH 03/20] GRAD2-2570 Regenerate Certificate Process Modifications --- .../model/CertificateRegenerationRequest.java | 16 ++++---- .../model/StudentSearchRequest.java | 6 +-- .../RegenerateCertificatePartitioner.java | 38 ++++++------------- .../reader/RegenerateCertificateReader.java | 1 + 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/CertificateRegenerationRequest.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/CertificateRegenerationRequest.java index add4d234..1f8a3e88 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/CertificateRegenerationRequest.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/CertificateRegenerationRequest.java @@ -1,20 +1,22 @@ package ca.bc.gov.educ.api.batchgraduation.model; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; -import java.io.Serializable; -import java.util.List; - @Data @Component @NoArgsConstructor @AllArgsConstructor -@Builder -public class CertificateRegenerationRequest implements Serializable { - private List pens; +public class CertificateRegenerationRequest extends StudentSearchRequest { private String runMode; // "Y" or "N" + + public boolean runForAll () { + return (getPens() == null || getPens().isEmpty()) && + (getDistricts() == null || getDistricts().isEmpty()) && + (getSchoolOfRecords() == null || getSchoolOfRecords().isEmpty()) && + (getSchoolCategoryCodes() == null || getSchoolCategoryCodes().isEmpty()) && + (getStudentIDs() == null || getStudentIDs().isEmpty()); + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java index 8bff9ac9..ae37c4fb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Component; import java.io.Serializable; -import java.util.Date; +import java.time.LocalDate; import java.util.List; import java.util.UUID; @@ -29,9 +29,9 @@ public class StudentSearchRequest implements Serializable { private Address address; @JsonFormat(pattern = "yyyy-MM-dd") - Date gradDateFrom; + LocalDate gradDateFrom; @JsonFormat(pattern = "yyyy-MM-dd") - Date gradDateTo; + LocalDate gradDateTo; Boolean validateInput; String localDownload; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java index 34bcf843..22b31023 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java @@ -2,9 +2,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.*; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.StringUtils; +import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; @@ -29,6 +27,9 @@ public class RegenerateCertificatePartitioner extends BasePartitioner { @Autowired ParallelDataFetch parallelDataFetch; + @Autowired + JsonTransformer jsonTransformer; + @Override public Map partition(int gridSize) { ResponseObj res = restUtils.getTokenResponseObject(); @@ -39,14 +40,15 @@ public Map partition(int gridSize) { List credentialList = new ArrayList<>(); JobParameters jobParameters = context.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST); - if (StringUtils.isBlank(searchRequest)) { + CertificateRegenerationRequest certificateRegenerationRequest = (CertificateRegenerationRequest)jsonTransformer.unmarshall(searchRequest, CertificateRegenerationRequest.class); + if (certificateRegenerationRequest.runForAll()) { Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); if(parallelDTO != null) { credentialList.addAll(parallelDTO.certificateList()); } } else { - credentialList.addAll(getStudentsForUserReqRun(searchRequest, accessToken)); + credentialList.addAll(getStudentsForUserReqRun(certificateRegenerationRequest, accessToken)); } Set studentSet = new HashSet<>(); @@ -82,30 +84,12 @@ public Map partition(int gridSize) { return new HashMap<>(); } - private List getStudentsForDistRun(String accessToken) { - List credentialList = new ArrayList<>(); - Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); - DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); - if(parallelDTO != null) { - credentialList.addAll(parallelDTO.certificateList()); - } - return credentialList; - } - // retrieve students based on the search criteria requested by user - private List getStudentsForUserReqRun(String searchRequest, String accessToken) { - CertificateRegenerationRequest certRegenReq = null; - try { - certRegenReq = new ObjectMapper().readValue(searchRequest, CertificateRegenerationRequest.class); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - if (certRegenReq != null && "Y".equalsIgnoreCase(certRegenReq.getRunMode())) { - StudentSearchRequest req = new StudentSearchRequest(); - req.setPens(certRegenReq.getPens()); - return restUtils.getStudentsForUserReqDisRun("OC", req, accessToken); + private List getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest, String accessToken) { + if(certificateRegenerationRequest != null && "Y".equalsIgnoreCase(certificateRegenerationRequest.getRunMode())) { + return restUtils.getStudentsForUserReqDisRun("OC", certificateRegenerationRequest, accessToken); } else { - return getStudentsForDistRun(accessToken); + return new ArrayList<>(); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java index cd1ea8d5..2bd35a0c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java @@ -21,6 +21,7 @@ public UUID read() throws Exception { nextStudent = studentList.get(nxtStudentForProcessing); LOGGER.info("StudID:{} - {} of {}", nextStudent, nxtStudentForProcessing + 1, summaryDTO.getReadCount()); nxtStudentForProcessing++; + summaryDTO.setProcessedCount(nxtStudentForProcessing); } else { aggregate("regenCertSummaryDTO"); } From dc77727b9df63b61031498bf6c1885561fc2180b Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 11 Apr 2024 15:16:11 -0600 Subject: [PATCH 04/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- ...tionRunCompletionNotificationListener.java | 1 - .../DistributionRunPartitionerUserReq.java | 6 -- .../reader/EDWSnapshotSchoolPartitioner.java | 6 -- .../reader/RegGradAlgPartitioner.java | 6 -- .../api/batchgraduation/rest/RestUtils.java | 43 ++++++++----- .../batchgraduation/util/RestUtilsTest.java | 62 ++++++++++++++----- 6 files changed, 74 insertions(+), 50 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java index 7c4dfc31..4715f750 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java @@ -196,7 +196,6 @@ private void updateBackStudentRecords(List cList, }); List studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().collect(Collectors.toList()); studentIDs.forEach(sid-> { - String accessToken = restUtils.fetchAccessToken(); restUtils.updateStudentGradRecord(sid,batchId,activityCode); }); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java index 40bb4c40..3688fc77 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.batchgraduation.reader; -import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution; import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; import org.slf4j.Logger; @@ -23,11 +22,6 @@ public class DistributionRunPartitionerUserReq extends BasePartitioner { @Override public Map partition(int gridSize) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } JobParameters jobParameters = context.getJobParameters(); String credentialType = jobParameters.getString("credentialType"); StudentSearchRequest req = getStudentSearchRequest(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java index ea9418d6..a2eab877 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/EDWSnapshotSchoolPartitioner.java @@ -1,7 +1,6 @@ package ca.bc.gov.educ.api.batchgraduation.reader; import ca.bc.gov.educ.api.batchgraduation.model.EdwSnapshotSchoolSummaryDTO; -import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.model.SnapshotRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,11 +25,6 @@ public class EDWSnapshotSchoolPartitioner extends BasePartitioner { @Override public Map partition(int gridSize) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } long startTime = System.currentTimeMillis(); logger.debug("Retrieve schools for EDW Snapshot"); JobParameters jobParameters = context.getJobParameters(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java index b7340f3c..be76349c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegGradAlgPartitioner.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO; -import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.model.RunTypeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,11 +33,6 @@ public Map partition(int gridSize) { BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory(); List studentList; if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } studentList = restUtils.getStudentsForAlgorithm(); } else { studentList = getInputDataFromPreviousJob(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index ae480f35..75dc02aa 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -254,8 +254,9 @@ public List fetchDistributionRequiredDataStudents } - public Integer runRegenerateStudentCertificate(String pen, String accessToken) { + public Integer runRegenerateStudentCertificate(String pen) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); return this.webClient.get() .uri(String.format(constants.getStudentCertificateRegeneration(), pen), uri -> uri.queryParam("isOverwrite", "Y").build()) @@ -263,8 +264,9 @@ public Integer runRegenerateStudentCertificate(String pen, String accessToken) { .retrieve().bodyToMono(Integer.class).block(); } - public List getStudentsForAlgorithm(String accessToken) { + public List getStudentsForAlgorithm() { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.get() @@ -273,8 +275,9 @@ public List getStudentsForAlgorithm(String accessToken) { .retrieve().bodyToMono(responseType).block(); } - public List getStudentsForProjectedAlgorithm(String accessToken) { + public List getStudentsForProjectedAlgorithm() { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.get() @@ -294,8 +297,9 @@ public GraduationStudentRecord saveGraduationStudentRecord(GraduationStudentReco .retrieve().bodyToMono(GraduationStudentRecord.class).block(); } - public List getStudentsForSpecialGradRun(StudentSearchRequest req,String accessToken) { + public List getStudentsForSpecialGradRun(StudentSearchRequest req) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GraduationStudentRecordSearchResult res = this.webClient.post() .uri(constants.getGradStudentApiStudentForSpcGradListUrl()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -365,9 +369,10 @@ public GraduationStudentRecord processProjectedGradStudent(GraduationStudentReco } } - public Integer getStudentByPenFromStudentAPI(List loadStudentData, String accessToken) { + public Integer getStudentByPenFromStudentAPI(List loadStudentData) { AtomicReference recordsAdded = new AtomicReference<>(0); loadStudentData.forEach(student -> { + String accessToken = getAccessToken(); List stuDataList = this.getStudentsByPen(student.getPen(), accessToken); stuDataList.forEach(st-> { GraduationStudentRecord gradStu = new GraduationStudentRecord(); @@ -384,12 +389,13 @@ public Integer getStudentByPenFromStudentAPI(List loadStudentDa return recordsAdded.get(); } - public List getStudentData(List studentIds, String accessToken) { + public List getStudentData(List studentIds) { UUID correlationID = UUID.randomUUID(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; StudentList stuList = new StudentList(); stuList.setStudentids(studentIds); + String accessToken = getAccessToken(); return this.webClient.post() .uri(constants.getGradStudentApiStudentDataListUrl()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -400,8 +406,6 @@ public List getStudentData(List studentIds, Strin public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary) { LOGGER.info(STUDENT_PROCESS,item.getStudentID()); summary.setProcessedCount(summary.getProcessedCount() + 1L); - String accessToken = summary.getAccessToken(); - StudentCredentialDistribution scObj = summary.getGlobalList().stream().filter(pr -> pr.getStudentID().compareTo(item.getStudentID()) == 0) .findAny() .orElse(null); @@ -412,7 +416,7 @@ public StudentCredentialDistribution processDistribution(StudentCredentialDistri item.setLegalFirstName(scObj.getLegalFirstName()); item.setLegalMiddleNames(scObj.getLegalMiddleNames()); } else { - GraduationStudentRecordDistribution stuRec =this.getStudentData(item.getStudentID().toString(),accessToken); + GraduationStudentRecordDistribution stuRec =this.getStudentData(item.getStudentID().toString()); if (stuRec != null) { item.setProgram(stuRec.getProgram()); item.setHonoursStanding(stuRec.getHonoursStanding()); @@ -496,8 +500,9 @@ public GraduationStudentRecord getStudentDataForBatch(String studentID, String a return result; } - public GraduationStudentRecordDistribution getStudentData(String studentID, String accessToken) { + public GraduationStudentRecordDistribution getStudentData(String studentID) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); GraduationStudentRecordDistribution result = webClient.get() .uri(String.format(constants.getStudentInfo(),studentID)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) @@ -624,15 +629,17 @@ public void updateSchoolReportRecord(String schoolOfRecord, String reportTypeCod .retrieve().bodyToMono(boolean.class).block(); } - public void deleteSchoolReportRecord(String schoolOfRecord, String reportTypeCode, String accessToken) { + public void deleteSchoolReportRecord(String schoolOfRecord, String reportTypeCode) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); webClient.delete().uri(String.format(constants.getUpdateSchoolReport(),schoolOfRecord,reportTypeCode)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .retrieve().bodyToMono(boolean.class).block(); } - public List getStudentsForUserReqDisRun(String credentialType, StudentSearchRequest req, String accessToken) { + public List getStudentsForUserReqDisRun(String credentialType, StudentSearchRequest req) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.post() @@ -644,10 +651,11 @@ public List getStudentsForUserReqDisRun(String cr .block(); } - public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode, String accessToken) { + public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode) { //Grad2-1931 not updating the school record if student id does not exist. try { if (studentID != null) { + String accessToken = getAccessToken(); String url = String.format(constants.getUpdateStudentRecord(), studentID, batchId, activityCode); this.post(url, "{}", GraduationStudentRecord.class, accessToken); } @@ -688,7 +696,8 @@ public Boolean checkSccpCertificateExists (UUID studentID, String accessToken) { .retrieve().bodyToMono(Boolean.class).block(); } - public List getEDWSnapshotSchools(Integer gradYear, String accessToken) { + public List getEDWSnapshotSchools(Integer gradYear) { + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; String url = String.format(constants.getEdwSnapshotSchoolsUrl(), gradYear); @@ -699,7 +708,8 @@ public List getEDWSnapshotSchools(Integer gradYear, String accessToken) .retrieve().bodyToMono(responseType).block(); } - public List getEDWSnapshotStudents(Integer gradYear, String mincode, String accessToken) { + public List getEDWSnapshotStudents(Integer gradYear, String mincode) { + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; String url = String.format(constants.getEdwSnapshotStudentsByMincodeUrl(), gradYear, mincode); @@ -777,8 +787,9 @@ public TraxSchool getTraxSchool(String mincode) { return get(String.format(constants.getTraxSchoolByMincode(), mincode), TraxSchool.class, getAccessToken()); } - public List getDeceasedStudentIDs(List studentIDs, String accessToken) { + public List getDeceasedStudentIDs(List studentIDs) { UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; return this.webClient.post() diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index bfc8b39a..eb4017aa 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -174,6 +174,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess() { GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); res.setStudentIDs(Arrays.asList(graduationStatus.getStudentID())); + mockTokenResponseObject(); when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getGradStudentApiStudentForSpcGradListUrl(), studentID))).thenReturn(this.requestBodyUriMock); @@ -184,7 +185,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess() { when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); - var result = this.restUtils.getStudentsForSpecialGradRun(req, "123"); + var result = this.restUtils.getStudentsForSpecialGradRun(req); assertThat(result).isNotNull(); assertThat(result.get(0)).isEqualTo(studentID); } @@ -204,6 +205,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess_null() { GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); res.setStudentIDs(Arrays.asList(graduationStatus.getStudentID())); + mockTokenResponseObject(); when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(String.format(constants.getGradStudentApiStudentForSpcGradListUrl(), studentID))).thenReturn(this.requestBodyUriMock); @@ -214,7 +216,7 @@ public void testGetStudentsForSpecialGradRun_with_APICallSuccess_null() { when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(inputResponseSR); when(this.inputResponseSR.block()).thenReturn(null); - var result = this.restUtils.getStudentsForSpecialGradRun(req, "123"); + var result = this.restUtils.getStudentsForSpecialGradRun(req); assertThat(result).isNotNull().isEmpty(); } @@ -376,6 +378,8 @@ public void testProcessProjectedStudent_witherrors2() { AlgorithmSummaryDTO summary = new AlgorithmSummaryDTO(); summary.setBatchId(batchId); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getGraduationApiProjectedGradUrl(), studentID,batchId))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -398,6 +402,8 @@ public void testGetStudentData_withlist() { graduationStatus.setStudentID(studentID); graduationStatus.setPen(pen); + mockTokenResponseObject(); + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -409,7 +415,7 @@ public void testGetStudentData_withlist() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(graduationStatus))); - List resList = this.restUtils.getStudentData(studentList,"abc"); + List resList = this.restUtils.getStudentData(studentList); assertNotNull(resList); assertThat(resList).hasSize(1); } @@ -473,6 +479,8 @@ public void testProcessDistribution_elsecase() { grd.setStudentGrade("12"); grd.setSchoolOfRecord("454445444"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID2))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -511,6 +519,7 @@ public void testProcessDistribution_elsecase_null() { scd2.setSchoolOfRecord(mincode); scd2.setStudentID(studentID2); + mockTokenResponseObject(); GraduationStudentRecordDistribution grd = new GraduationStudentRecordDistribution(); grd.setStudentID(studentID2); @@ -942,6 +951,8 @@ public void testGetStudentsForAlgorithm() { grd.setStudentID(new UUID(1,1)); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(constants.getGradStudentApiStudentForGradListUrl())).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -951,7 +962,7 @@ public void testGetStudentsForAlgorithm() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(grd.getStudentID()))); - val result = this.restUtils.getStudentsForAlgorithm("abc"); + val result = this.restUtils.getStudentsForAlgorithm(); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -963,6 +974,8 @@ public void testGetStudentsForProjectedAlgorithm() { grd.setStudentID(new UUID(1,1)); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(constants.getGradStudentApiStudentForProjectedGradListUrl())).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -972,7 +985,7 @@ public void testGetStudentsForProjectedAlgorithm() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(grd.getStudentID()))); - val result = this.restUtils.getStudentsForProjectedAlgorithm("abc"); + val result = this.restUtils.getStudentsForProjectedAlgorithm(); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -1074,6 +1087,8 @@ public void testGetStudentsForUserReqDisRun() { scd.setId(new UUID(1,1)); scdList.add(scd); + mockTokenResponseObject(); + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -1085,7 +1100,7 @@ public void testGetStudentsForUserReqDisRun() { when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(scdList)); - val result = this.restUtils.getStudentsForUserReqDisRun(credentialType,req,null); + val result = this.restUtils.getStudentsForUserReqDisRun(credentialType,req); assertThat(result).isNotNull(); assertThat(result.size() > 0).isTrue(); } @@ -1244,13 +1259,15 @@ public void testGetStudentData() { grd.setStudentID(studentID); grd.setProgram("2018-EN"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getStudentInfo(),studentID))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecordDistribution.class)).thenReturn(Mono.just(grd)); - GraduationStudentRecordDistribution res = this.restUtils.getStudentData(studentID.toString(),null); + GraduationStudentRecordDistribution res = this.restUtils.getStudentData(studentID.toString()); assertThat(res).isNotNull(); } @@ -1330,6 +1347,8 @@ public void testupdateStudentGradRecord() { final String activityCode = "USERDISOC"; final Long batchId = 4567L; + mockTokenResponseObject(); + GraduationStudentRecord rec = new GraduationStudentRecord(); rec.setStudentID(studentID); when(this.webClient.post()).thenReturn(this.requestBodyUriMock); @@ -1341,7 +1360,7 @@ public void testupdateStudentGradRecord() { when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(rec)); - this.restUtils.updateStudentGradRecord(studentID,batchId,activityCode,"acb"); + this.restUtils.updateStudentGradRecord(studentID,batchId,activityCode); assertNotNull(rec); } @@ -1380,6 +1399,8 @@ public void testUpdateSchoolReportRecord() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(boolean.class)).thenReturn(Mono.just(true)); + mockTokenResponseObject(); + restUtils.updateSchoolReportRecord(mincode,reportTypeCode,null); assertThat(reportTypeCode).isEqualTo("E"); @@ -1389,7 +1410,7 @@ public void testUpdateSchoolReportRecord() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(boolean.class)).thenReturn(Mono.just(true)); - restUtils.deleteSchoolReportRecord(mincode,reportTypeCode,null); + restUtils.deleteSchoolReportRecord(mincode,reportTypeCode); assertThat(reportTypeCode).isEqualTo("E"); } @@ -1398,13 +1419,15 @@ public void testDeleteSchoolReportRecord() { final String mincode = "123213123"; String reportTypeCode = "E"; + mockTokenResponseObject(); + when(this.webClient.delete()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(boolean.class)).thenReturn(Mono.just(true)); - this.restUtils.deleteSchoolReportRecord(mincode,reportTypeCode,null); + this.restUtils.deleteSchoolReportRecord(mincode,reportTypeCode); assertThat(reportTypeCode).isEqualTo("E"); } @@ -1435,6 +1458,7 @@ public void testGetStudentByPenFromStudentAPI() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(student))); + mockTokenResponseObject(); GraduationStudentRecord graduationStatus = new GraduationStudentRecord(); graduationStatus.setStudentID(studentID); @@ -1449,7 +1473,7 @@ public void testGetStudentByPenFromStudentAPI() { when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStatus)); - Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData,"abc"); + Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData); assertThat(res).isEqualTo(1); } @@ -1524,6 +1548,8 @@ public void testIsReportOnly_when_programCompletionDate_isNotInFuture_and_SCCPce public void testRunRegenerateStudentCertificates() { final String pen = "123456789"; + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(eq(String.format(constants.getStudentCertificateRegeneration(), pen)), any(Function.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1531,7 +1557,7 @@ public void testRunRegenerateStudentCertificates() { when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(Integer.valueOf(1))); - val result = this.restUtils.runRegenerateStudentCertificate(pen, "abc"); + val result = this.restUtils.runRegenerateStudentCertificate(pen); assertThat(result).isEqualTo(1); } @@ -1590,6 +1616,8 @@ public void testGetEDWSnapshotSchools() { List schools = Arrays.asList("12345678","11223344"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getEdwSnapshotSchoolsUrl(), gradYear))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1599,7 +1627,7 @@ public void testGetEDWSnapshotSchools() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(schools)); - val result = this.restUtils.getEDWSnapshotSchools(gradYear, "abc"); + val result = this.restUtils.getEDWSnapshotSchools(gradYear); assertThat(result).hasSize(2); } @@ -1615,6 +1643,8 @@ public void testGetEDWSnapshotStudents() { snapshotResponse.setGpa(BigDecimal.valueOf(3.75)); snapshotResponse.setHonourFlag("N"); + mockTokenResponseObject(); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(constants.getEdwSnapshotStudentsByMincodeUrl(), gradYear, mincode))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); @@ -1624,7 +1654,7 @@ public void testGetEDWSnapshotStudents() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(snapshotResponse))); - val result = this.restUtils.getEDWSnapshotStudents(gradYear, mincode, "abc"); + val result = this.restUtils.getEDWSnapshotStudents(gradYear, mincode); assertThat(result).hasSize(1); } @@ -1661,6 +1691,8 @@ public void testGetDeceasedStudentIDs() { List studentIDs = Arrays.asList(studentID1, studentID2); + mockTokenResponseObject(); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.uri(constants.getDeceasedStudentIDList())).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); @@ -1671,7 +1703,7 @@ public void testGetDeceasedStudentIDs() { }; when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(studentIDs)); - val result = this.restUtils.getDeceasedStudentIDs(studentIDs, "abc"); + val result = this.restUtils.getDeceasedStudentIDs(studentIDs); assertThat(result).hasSize(2); } From eddf4d31e83982208e6cbf588b75f93b6d92a38d Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 11 Apr 2024 15:42:16 -0600 Subject: [PATCH 05/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../batchgraduation/controller/JobLauncherController.java | 2 +- .../ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java | 5 ++--- .../bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java index ce9539af..45464f60 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java @@ -182,7 +182,7 @@ public ResponseEntity launchTvrRunJob() { public ResponseEntity loadStudentIDs(@RequestBody List loadStudentData, @RequestHeader(name="Authorization") String accessToken) { logger.debug("Inside loadStudentIDs"); - Integer recordsAdded = restUtils.getStudentByPenFromStudentAPI(loadStudentData); + Integer recordsAdded = restUtils.getStudentByPenFromStudentAPI(loadStudentData, accessToken.replace(BEARER, "")); if(recordsAdded != null) return ResponseEntity.ok("Record Added Successfully"); return ResponseEntity.status(500).body("Student Record Could not be added"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 75dc02aa..17ec320f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -369,10 +369,9 @@ public GraduationStudentRecord processProjectedGradStudent(GraduationStudentReco } } - public Integer getStudentByPenFromStudentAPI(List loadStudentData) { + public Integer getStudentByPenFromStudentAPI(List loadStudentData, String accessToken) { AtomicReference recordsAdded = new AtomicReference<>(0); loadStudentData.forEach(student -> { - String accessToken = getAccessToken(); List stuDataList = this.getStudentsByPen(student.getPen(), accessToken); stuDataList.forEach(st-> { GraduationStudentRecord gradStu = new GraduationStudentRecord(); @@ -382,7 +381,7 @@ public Integer getStudentByPenFromStudentAPI(List loadStudentDa gradStu.setRecalculateGradStatus("Y"); gradStu.setStudentStatus(student.getStudentStatus()); gradStu.setStudentID(UUID.fromString(st.getStudentID())); - this.saveGraduationStudentRecord(gradStu, accessToken); + saveGraduationStudentRecord(gradStu, accessToken); recordsAdded.getAndSet(recordsAdded.get() + 1); }); }); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index eb4017aa..75e86cd2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -1473,7 +1473,7 @@ public void testGetStudentByPenFromStudentAPI() { when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStatus)); - Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData); + Integer res = this.restUtils.getStudentByPenFromStudentAPI(loadStudentData, "accessToken"); assertThat(res).isEqualTo(1); } From 24f09127b28015d979814858281cd12d0a9bfbb7 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 11 Apr 2024 16:38:12 -0600 Subject: [PATCH 06/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../batchgraduation/reader/SpcRegGradAlgPartitioner.java | 6 ------ .../educ/api/batchgraduation/reader/TvrRunPartitioner.java | 6 ------ 2 files changed, 12 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java index 49c58cb5..c3109cfb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/SpcRegGradAlgPartitioner.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO; -import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.model.RunTypeEnum; import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; import org.slf4j.Logger; @@ -38,11 +37,6 @@ public Map partition(int gridSize) { BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory(); List studentList; if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } JobParameters jobParameters = jobExecution.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST, "{}"); StudentSearchRequest req = (StudentSearchRequest)jsonTransformer.unmarshall(searchRequest, StudentSearchRequest.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java index 6ea0e228..5f9d2b5f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/TvrRunPartitioner.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO; -import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.model.RunTypeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,11 +33,6 @@ public Map partition(int gridSize) { BatchGradAlgorithmJobHistoryEntity jobHistory = createBatchJobHistory(); List studentList; if (runType == RunTypeEnum.NORMAL_JOB_PROCESS) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } studentList = restUtils.getStudentsForProjectedAlgorithm(); } else { studentList = getInputDataFromPreviousJob(); From d38ea0ab63518f245786306f0bea38920ba7b3f7 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 12 Apr 2024 11:20:36 -0600 Subject: [PATCH 07/20] GRAD2-2570 Regenerate Certificate Process Modifications --- .../reader/RegenerateCertificatePartitioner.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java index d90d246e..8674db96 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.batchgraduation.model.*; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; @@ -43,7 +42,7 @@ public Map partition(int gridSize) { String searchRequest = jobParameters.getString(SEARCH_REQUEST); CertificateRegenerationRequest certificateRegenerationRequest = (CertificateRegenerationRequest)jsonTransformer.unmarshall(searchRequest, CertificateRegenerationRequest.class); if (certificateRegenerationRequest.runForAll()) { - Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); + Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); if(parallelDTO != null) { credentialList.addAll(parallelDTO.certificateList()); @@ -88,7 +87,7 @@ public Map partition(int gridSize) { // retrieve students based on the search criteria requested by user private List getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest, String accessToken) { if(certificateRegenerationRequest != null && "Y".equalsIgnoreCase(certificateRegenerationRequest.getRunMode())) { - return restUtils.getStudentsForUserReqDisRun("OC", certificateRegenerationRequest, accessToken); + return restUtils.getStudentsForUserReqDisRun("OC", certificateRegenerationRequest); } else { return new ArrayList<>(); } From af3ece809ccba36aaa5b44c05ac65ab14a83c0db Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 15 Apr 2024 10:47:34 -0600 Subject: [PATCH 08/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../model/StudentCredentialDistribution.java | 6 ++++++ .../educ/api/batchgraduation/reader/BasePartitioner.java | 5 +++++ .../batchgraduation/service/GraduationReportService.java | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java index ffd4aaba..ee3cc93f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java @@ -1,5 +1,6 @@ package ca.bc.gov.educ.api.batchgraduation.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -27,4 +28,9 @@ public class StudentCredentialDistribution implements Serializable { private String studentGrade; private List nonGradReasons; + @JsonIgnore + private String schoolAtGrad; + @JsonIgnore + private String schoolOfRecordOrigin; + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 4168ba2a..13c98a3f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -227,18 +227,23 @@ void filterByStudentSearchRequest(List eligibleSt } } eligibleStudentSchoolDistricts.removeIf(scr->StringUtils.isNotBlank(scr.getSchoolOfRecord()) && !useFilterSchoolDistricts.contains(scr.getSchoolOfRecord())); + LOGGER.debug("Student Credential Distribution filtered by schoolCategory code {}: ", searchRequest.getSchoolCategoryCodes()); } if(searchRequest != null && searchRequest.getDistricts() != null && !searchRequest.getDistricts().isEmpty()) { eligibleStudentSchoolDistricts.removeIf(scr->StringUtils.isNotBlank(scr.getSchoolOfRecord()) && !searchRequest.getDistricts().contains(StringUtils.substring(scr.getSchoolOfRecord(), 0, 3))); + LOGGER.debug("Student Credential Distribution filtered by district code {}: ", searchRequest.getDistricts()); } if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) { eligibleStudentSchoolDistricts.removeIf(scr->StringUtils.isNotBlank(scr.getSchoolOfRecord()) && !searchRequest.getSchoolOfRecords().contains(scr.getSchoolOfRecord())); + LOGGER.debug("Student Credential Distribution filtered by schoolOfRecord code {}: ", searchRequest.getSchoolOfRecords()); } if(searchRequest != null && searchRequest.getStudentIDs() != null && !searchRequest.getStudentIDs().isEmpty()) { eligibleStudentSchoolDistricts.removeIf(scr->scr.getStudentID() != null && !searchRequest.getStudentIDs().contains(scr.getStudentID())); + LOGGER.debug("Student Credential Distribution filtered by student ID {}: ", searchRequest.getStudentIDs()); } if(searchRequest != null && searchRequest.getPens() != null && !searchRequest.getPens().isEmpty()) { eligibleStudentSchoolDistricts.removeIf(scr->StringUtils.isNotBlank(scr.getPen()) && !searchRequest.getPens().contains(scr.getPen())); + LOGGER.debug("Student Credential Distribution filtered by pen {}: ", searchRequest.getPens()); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java index 43cb0bc6..0c432552 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GraduationReportService.java @@ -5,6 +5,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.stereotype.Service; @@ -18,6 +20,8 @@ @Service public class GraduationReportService { + private static final Logger LOGGER = LoggerFactory.getLogger(GraduationReportService.class); + @Autowired WebClient webClient; @@ -99,6 +103,8 @@ private StudentCredentialDistribution populateStudentCredentialDistribution(Repo dist.setStudentID(data.getGraduationStudentRecordId()); dist.setPaperType(paperType); dist.setSchoolOfRecord(StringUtils.isBlank(data.getMincodeAtGrad()) ? data.getMincode() : data.getMincodeAtGrad()); + dist.setSchoolAtGrad(data.getMincodeAtGrad()); + dist.setSchoolOfRecordOrigin(data.getMincode()); dist.setDocumentStatusCode("COMPL"); dist.setPen(data.getPen()); dist.setLegalFirstName(data.getFirstName()); @@ -110,6 +116,7 @@ private StudentCredentialDistribution populateStudentCredentialDistribution(Repo dist.setStudentGrade(data.getStudentGrade()); dist.setNonGradReasons(data.getNonGradReasons()); dist.setLastUpdateDate(data.lastUpdateDateAsString()); + LOGGER.info("Populate Student Credential Distribution for pen {}: SchoolOfRecordOrigin->{}, SchoolAtGrad->{}, SchoolOfRecord->{}", dist.getPen(), dist.getSchoolOfRecordOrigin(), dist.getSchoolAtGrad(), dist.getSchoolOfRecord()); return dist; } } From c58a909ac3d13257064c0692bcff0d33516a88f1 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 15 Apr 2024 10:49:04 -0600 Subject: [PATCH 09/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../api/batchgraduation/model/StudentCredentialDistribution.java | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java index ee3cc93f..797ed7c9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java @@ -28,6 +28,7 @@ public class StudentCredentialDistribution implements Serializable { private String studentGrade; private List nonGradReasons; + //For debug purpose only @JsonIgnore private String schoolAtGrad; @JsonIgnore From aa525c6ecdd3d065a10fef9efcbb65c26d985236 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 17 Apr 2024 12:04:13 -0600 Subject: [PATCH 10/20] GRAD2-2570 Regenerate Certificate Process Modifications - added job names for regenerate certificates --- .../gov/educ/api/batchgraduation/model/JobProperName.java | 3 ++- .../bc/gov/educ/api/batchgraduation/model/JobSelection.java | 3 ++- .../model/StudentCredentialDistribution.java | 6 ++++++ .../gov/educ/api/batchgraduation/model/TaskSelection.java | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobProperName.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobProperName.java index ce8f8715..6eaf21af 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobProperName.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobProperName.java @@ -9,7 +9,8 @@ public enum JobProperName { NDBJ("Non-Grad Distribution Batch Job"), URDBJ ("User Req Distribution Batch Job"), URPDBJ("PSI Distribution Batch Job"), - BDBJ ("Blank Distribution Batch Job"); + BDBJ ("Blank Distribution Batch Job"), + RCBJ ("Regenerate Certificates Batch Job"); private final String value; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobSelection.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobSelection.java index 7849917f..88d6f439 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobSelection.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/JobSelection.java @@ -9,7 +9,8 @@ public enum JobSelection { NDBJ("NONGRADRUN"), URDBJ ("DISTRUNUSER"), URPDBJ ("PSIRUN"), - BDBJ ("DISTRUNUSER"); + BDBJ ("DISTRUNUSER"), + RCBJ ("CERT_REGEN"); private final String value; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java index ffd4aaba..ee3cc93f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java @@ -1,5 +1,6 @@ package ca.bc.gov.educ.api.batchgraduation.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -27,4 +28,9 @@ public class StudentCredentialDistribution implements Serializable { private String studentGrade; private List nonGradReasons; + @JsonIgnore + private String schoolAtGrad; + @JsonIgnore + private String schoolOfRecordOrigin; + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/TaskSelection.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/TaskSelection.java index 9309d64a..c2cc737d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/TaskSelection.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/TaskSelection.java @@ -9,7 +9,8 @@ public enum TaskSelection { NDBJ ("YearlyNonGradDistributionBatchJob"), URDBJ ("UserReqDistributionBatchJob"), URPDBJ("psiDistributionBatchJob"), - BDBJ ("blankDistributionBatchJob"); + BDBJ ("blankDistributionBatchJob"), + RCBJ ("certRegenBatchJob"); private final String value; From c317b0e66f7200e03a7a23ebcdcccbbe0fb93203 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 18 Apr 2024 15:22:12 -0700 Subject: [PATCH 11/20] GRAD2-2596: task is complete. GRAD2-2596: task is complete. --- .../1.0/V1.0.46__DDL-ALTER_TABLES-for-institution-api.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 api/src/main/resources/db/migration/1.0/V1.0.46__DDL-ALTER_TABLES-for-institution-api.sql diff --git a/api/src/main/resources/db/migration/1.0/V1.0.46__DDL-ALTER_TABLES-for-institution-api.sql b/api/src/main/resources/db/migration/1.0/V1.0.46__DDL-ALTER_TABLES-for-institution-api.sql new file mode 100644 index 00000000..fd10c9fa --- /dev/null +++ b/api/src/main/resources/db/migration/1.0/V1.0.46__DDL-ALTER_TABLES-for-institution-api.sql @@ -0,0 +1,6 @@ +ALTER TABLE BATCH_GRAD_ALG_STUDENT ADD SCHOOL_OF_RECORD_ID RAW(16); +ALTER TABLE STUDENT_CREDENTIAL_DISTRIBUTION ADD SCHOOL_OF_RECORD_ID RAW(16); + + + + From c55f687457ba0fbaf527a836e364208598349ef6 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 18 Apr 2024 19:24:09 -0600 Subject: [PATCH 12/20] GRAD2-2570 Regenerate Certificate Process Modifications - added job names for regenerate certificates --- .../api/batchgraduation/reader/RegenerateCertificateReader.java | 1 - .../java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java index 2bd35a0c..cd1ea8d5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificateReader.java @@ -21,7 +21,6 @@ public UUID read() throws Exception { nextStudent = studentList.get(nxtStudentForProcessing); LOGGER.info("StudID:{} - {} of {}", nextStudent, nxtStudentForProcessing + 1, summaryDTO.getReadCount()); nxtStudentForProcessing++; - summaryDTO.setProcessedCount(nxtStudentForProcessing); } else { aggregate("regenCertSummaryDTO"); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 17ec320f..e8b678d5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -259,7 +259,7 @@ public Integer runRegenerateStudentCertificate(String pen) { String accessToken = getAccessToken(); return this.webClient.get() .uri(String.format(constants.getStudentCertificateRegeneration(), pen), - uri -> uri.queryParam("isOverwrite", "Y").build()) + uri -> uri.queryParam("isOverwrite", "N").build()) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .retrieve().bodyToMono(Integer.class).block(); } From 773bc96d5c6c60ee8351d7f7b715e9bf1598f428 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 19 Apr 2024 17:22:43 -0600 Subject: [PATCH 13/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../batchgraduation/config/BatchJobConfig.java | 8 +++++++- .../processor/DistributionRunProcessor.java | 2 +- .../DistributionRunYearlyProcessor.java | 2 +- .../api/batchgraduation/rest/RestUtils.java | 17 +++++++++++++---- .../api/batchgraduation/util/RestUtilsTest.java | 6 +++--- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java index ac7ba394..ac0d0d78 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java @@ -519,6 +519,12 @@ public DistributionRunProcessor itemProcessorDisRun() { return new DistributionRunProcessor(); } + @Bean + @StepScope + public DistributionRunYearlyProcessor itemProcessorYearlyDisRun() { + return new DistributionRunYearlyProcessor(); + } + @Bean @StepScope public DistributionRunYearlyNonGradProcessor itemProcessorDisRunYearlyNonGradByMincode() { @@ -571,7 +577,7 @@ public Step slaveStepDisRunYearly(JobRepository jobRepository, PlatformTransacti return new StepBuilder("slaveStepDisRun", jobRepository) .chunk(1, transactionManager) .reader(itemReaderDisRun()) - .processor(itemProcessorDisRun()) + .processor(itemProcessorYearlyDisRun()) .writer(itemWriterDisRun()) .build(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java index e2efbc65..33b84cf1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java @@ -27,7 +27,7 @@ public class DistributionRunProcessor implements ItemProcessor getStudentData(List studentIds) { .retrieve().bodyToMono(responseType).block(); } - public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary) { + public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary, boolean useSchoolAtGrad) { LOGGER.info(STUDENT_PROCESS,item.getStudentID()); summary.setProcessedCount(summary.getProcessedCount() + 1L); StudentCredentialDistribution scObj = summary.getGlobalList().stream().filter(pr -> pr.getStudentID().compareTo(item.getStudentID()) == 0) .findAny() .orElse(null); if(scObj != null) { - item.setSchoolOfRecord(scObj.getSchoolOfRecord()); + if(useSchoolAtGrad) { + item.setSchoolOfRecord(StringUtils.isBlank(scObj.getSchoolAtGrad()) ? scObj.getSchoolOfRecord() : scObj.getSchoolAtGrad()); + } else { + item.setSchoolOfRecord(scObj.getSchoolOfRecord()); + } item.setPen(scObj.getPen()); item.setLegalLastName(scObj.getLegalLastName()); item.setLegalFirstName(scObj.getLegalFirstName()); item.setLegalMiddleNames(scObj.getLegalMiddleNames()); } else { - GraduationStudentRecordDistribution stuRec =this.getStudentData(item.getStudentID().toString()); + GraduationStudentRecordDistribution stuRec = getStudentData(item.getStudentID().toString()); if (stuRec != null) { item.setProgram(stuRec.getProgram()); item.setHonoursStanding(stuRec.getHonoursStanding()); - item.setSchoolOfRecord(stuRec.getSchoolOfRecord()); + if(useSchoolAtGrad) { + item.setSchoolOfRecord(StringUtils.isBlank(stuRec.getSchoolAtGrad()) ? stuRec.getSchoolOfRecord() : stuRec.getSchoolAtGrad()); + } else { + item.setSchoolOfRecord(stuRec.getSchoolOfRecord()); + } item.setProgramCompletionDate(stuRec.getProgramCompletionDate()); item.setStudentID(stuRec.getStudentID()); item.setPen(stuRec.getPen()); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index 75e86cd2..393aa392 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -444,7 +444,7 @@ public void testProcessDistribution() { summary.setBatchId(batchId); summary.setGlobalList(globalList); - StudentCredentialDistribution res = this.restUtils.processDistribution(scd,summary); + StudentCredentialDistribution res = this.restUtils.processDistribution(scd,summary, false); assertNotNull(res); } @@ -491,7 +491,7 @@ public void testProcessDistribution_elsecase() { summary.setBatchId(batchId); summary.setGlobalList(globalList); - StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary); + StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary, false); assertNotNull(res); } @@ -538,7 +538,7 @@ public void testProcessDistribution_elsecase_null() { summary.setBatchId(batchId); summary.setGlobalList(globalList); - StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary); + StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary, false); assertNotNull(res); } From 9a8cf43ce673e90efe1339ac189d215bce14a749 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 22 Apr 2024 11:28:27 -0700 Subject: [PATCH 14/20] GRAD2-2570: the issues have been resolved to support null distribution date for regen cert. GRAD2-2570: the issues have been resolved to support null distribution date for regen cert. --- .../api/batchgraduation/config/RestWebClient.java | 2 +- .../entity/BatchJobExecutionEntity.java | 1 - .../reader/RegenerateCertificatePartitioner.java | 13 ++++--------- .../educ/api/batchgraduation/rest/RestUtils.java | 14 ++++++++++++++ .../util/EducGradBatchGraduationApiConstants.java | 3 +++ api/src/main/resources/application.yaml | 2 ++ api/src/test/resources/application.yaml | 2 ++ 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RestWebClient.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RestWebClient.java index 2535789d..4d1cf748 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RestWebClient.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RestWebClient.java @@ -27,7 +27,7 @@ public WebClient webClient() { return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder() .codecs(configurer -> configurer .defaultCodecs() - .maxInMemorySize(300 * 1024 * 1024)) // 100 MB + .maxInMemorySize(300 * 1024 * 1024)) // 300 MB .build()).build(); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java index 094b9b9a..a46d5a74 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java @@ -4,7 +4,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; -import java.time.Instant; import java.time.LocalDateTime; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java index 8674db96..71e0707d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java @@ -32,23 +32,18 @@ public class RegenerateCertificatePartitioner extends BasePartitioner { @Override public Map partition(int gridSize) { - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } List credentialList = new ArrayList<>(); JobParameters jobParameters = context.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST); CertificateRegenerationRequest certificateRegenerationRequest = (CertificateRegenerationRequest)jsonTransformer.unmarshall(searchRequest, CertificateRegenerationRequest.class); - if (certificateRegenerationRequest.runForAll()) { + if (certificateRegenerationRequest == null || certificateRegenerationRequest.runForAll()) { Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); if(parallelDTO != null) { credentialList.addAll(parallelDTO.certificateList()); } } else { - credentialList.addAll(getStudentsForUserReqRun(certificateRegenerationRequest, accessToken)); + credentialList.addAll(getStudentsForUserReqRun(certificateRegenerationRequest)); } Set studentSet = new HashSet<>(); @@ -85,9 +80,9 @@ public Map partition(int gridSize) { } // retrieve students based on the search criteria requested by user - private List getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest, String accessToken) { + private List getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest) { if(certificateRegenerationRequest != null && "Y".equalsIgnoreCase(certificateRegenerationRequest.getRunMode())) { - return restUtils.getStudentsForUserReqDisRun("OC", certificateRegenerationRequest); + return restUtils.getStudentsForUserReqDisRunWithNullDistributionDate("OC", certificateRegenerationRequest); } else { return new ArrayList<>(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index c942ef11..605bffb1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -659,6 +659,20 @@ public List getStudentsForUserReqDisRun(String cr .block(); } + public List getStudentsForUserReqDisRunWithNullDistributionDate(String credentialType, StudentSearchRequest req) { + UUID correlationID = UUID.randomUUID(); + String accessToken = getAccessToken(); + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { + }; + return this.webClient.post() + .uri(String.format(constants.getStudentDataForUserReqDisRunWithNullDistributionDate(),credentialType)) + .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) + .body(BodyInserters.fromValue(req)) + .retrieve() + .bodyToMono(responseType) + .block(); + } + public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode) { //Grad2-1931 not updating the school record if student id does not exist. try { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java index cde6a5cb..152b6959 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java @@ -213,6 +213,9 @@ public class EducGradBatchGraduationApiConstants { @Value("${endpoint.grad-graduation-report-api.user-req-dis-run.url}") private String studentDataForUserReqDisRun; + @Value("${endpoint.grad-graduation-report-api.user-req-dis-run-for-not-yet-distributed.url}") + private String studentDataForUserReqDisRunWithNullDistributionDate; + @Value("${endpoint.grad-graduation-api.schoolreport.url}") private String createAndStoreSchoolReports; diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index f4a20368..4136a68f 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -224,6 +224,8 @@ endpoint: url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentcredential?studentID=%s&credentialTypeCode=%s&paperType=%s&documentStatusCode=%s&activityCode=%s user-req-dis-run: url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/userrequest/%s + user-req-dis-run-for-not-yet-distributed: + url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/userrequest/notyetdistributed/%s get-district-data-yearly: url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/districtdataearly get-certificate-types: diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index add51811..4dbad8a7 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -154,6 +154,8 @@ endpoint: url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentcredential?studentID=%s&credentialTypeCode=%s&paperType=%s&documentStatusCode=%s&activityCode=%s user-req-dis-run: url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/userrequest/%s + user-req-dis-run-for-not-yet-distributed: + url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/userrequest/notyetdistributed/%s get-district-data-yearly: url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/districtdataearly get-certificate-types: From b7268dac939a9150792d8219ec046b7a222fb0ac Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 22 Apr 2024 17:01:31 -0600 Subject: [PATCH 15/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../processor/DistributionRunStatusUpdateProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java index 30ee2b48..98e6ceda 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java @@ -75,7 +75,7 @@ private Map updateBackStudentRecords(List Date: Mon, 22 Apr 2024 17:06:44 -0600 Subject: [PATCH 16/20] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../processor/DistributionRunStatusUpdateProcessor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java index 98e6ceda..d76f2ace 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java @@ -71,11 +71,11 @@ private Map updateBackStudentRecords(List { try { - final String token = restUtils.getAccessToken(); + final String accessToken = restUtils.getAccessToken(); restUtils.updateStudentCredentialRecord(scd.getStudentID(),scd.getCredentialTypeCode(),scd.getPaperType(), - "NONGRADYERUN".equalsIgnoreCase(activityCode)? "IP" : scd.getDocumentStatusCode(),activityCode,token); + "NONGRADYERUN".equalsIgnoreCase(activityCode)? "IP" : scd.getDocumentStatusCode(),activityCode,accessToken); LOGGER.debug("Dist Job [{}] / [{}] - update {} of {} student credential record: studentID, credentials, document status [{}, {}, {}]", batchId, activityCode, processedCount[0] + 1, totalCount, scd.getStudentID(), scd.getCredentialTypeCode(), scd.getDocumentStatusCode()); - if(!StringUtils.equalsAnyIgnoreCase(jobType, "NONGRADRUN", "REGALG", "TVRRUN")) { + if(!StringUtils.equalsAnyIgnoreCase(jobType, "REGALG", "TVRRUN")) { restUtils.updateStudentGradRecord(scd.getStudentID(), batchId, activityCode); LOGGER.debug("Dist Job [{}] / [{}] - update {} of {} student grad record: studentID, credentials, document status [{}, {}, {}]", batchId, activityCode, processedCount[0] + 1, totalCount, scd.getStudentID(), scd.getCredentialTypeCode(), scd.getDocumentStatusCode()); } From 6d805963bfe28bee6f484b2eaafd848f1ea110d9 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 23 Apr 2024 09:31:04 -0600 Subject: [PATCH 17/20] GRAD2-2377 Remove duplicated student audit records --- .../DistributionRunStatusUpdateProcessor.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java index d76f2ace..251fc968 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; @Component public class DistributionRunStatusUpdateProcessor { @@ -69,19 +70,27 @@ private Map updateBackStudentRecords(List studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).toList(); cList.forEach(scd-> { try { final String accessToken = restUtils.getAccessToken(); restUtils.updateStudentCredentialRecord(scd.getStudentID(),scd.getCredentialTypeCode(),scd.getPaperType(), "NONGRADYERUN".equalsIgnoreCase(activityCode)? "IP" : scd.getDocumentStatusCode(),activityCode,accessToken); LOGGER.debug("Dist Job [{}] / [{}] - update {} of {} student credential record: studentID, credentials, document status [{}, {}, {}]", batchId, activityCode, processedCount[0] + 1, totalCount, scd.getStudentID(), scd.getCredentialTypeCode(), scd.getDocumentStatusCode()); + processedCount[0]++; + } catch (Exception e) { + unprocessedStudents.put(scd.getStudentID().toString(), new ServiceException(e)); + } + }); + studentIDs.forEach(uuid-> { + try { if(!StringUtils.equalsAnyIgnoreCase(jobType, "REGALG", "TVRRUN")) { - restUtils.updateStudentGradRecord(scd.getStudentID(), batchId, activityCode); - LOGGER.debug("Dist Job [{}] / [{}] - update {} of {} student grad record: studentID, credentials, document status [{}, {}, {}]", batchId, activityCode, processedCount[0] + 1, totalCount, scd.getStudentID(), scd.getCredentialTypeCode(), scd.getDocumentStatusCode()); + restUtils.updateStudentGradRecord(uuid, batchId, activityCode); + LOGGER.debug("Dist Job [{}] / [{}] - update {} of {} student grad record: studentID [{}]", batchId, activityCode, processedCount[0] + 1, totalCount, uuid); } processedCount[0]++; } catch (Exception e) { - unprocessedStudents.put(scd.getStudentID().toString(), new ServiceException(e)); + unprocessedStudents.put(uuid.toString(), new ServiceException(e)); } }); return unprocessedStudents; From ff26bc38d17094ea5ef5a268c94f1b9db9e69662 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 23 Apr 2024 09:38:23 -0600 Subject: [PATCH 18/20] GRAD2-2377 Remove duplicated student audit records --- .../UserReqDistributionRunCompletionNotificationListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java index 4715f750..f00e5040 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java @@ -128,7 +128,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId, DistributionResponse disres = null; String activityCode = null; if(credentialType != null) { - if(credentialType.equalsIgnoreCase("OC")) { + if("OC".equalsIgnoreCase(credentialType)) { activityCode = "USERDISTOC"; /** GRADT-553 * User Request Distribution Run - Original Certificate OC @@ -136,7 +136,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId, */ addTranscriptsToDistributionRequest(cList,summaryDTO,batchId,properName); } else { - activityCode = credentialType.equalsIgnoreCase("OT")?"USERDISTOT":"USERDISTRC"; + activityCode = "OT".equalsIgnoreCase(credentialType) ? "USERDISTOT" : "USERDISTRC"; } if(!cList.isEmpty()) { DistributionRequest distributionRequest = DistributionRequest.builder().mapDist(mapDist).activityCode(activityCode).studentSearchRequest(summaryDTO.getStudentSearchRequest()).build(); From f676ca62316e331aa40471d77e52691a6ed61cb0 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 23 Apr 2024 08:59:23 -0700 Subject: [PATCH 19/20] GRAD2-2570: the batch history creation issue with zero student processed is fixed for cert_regen. GRAD2-2570: the batch history creation issue with zero student processed is fixed for cert_regen. --- .../batchgraduation/reader/RegenerateCertificatePartitioner.java | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java index 71e0707d..a79cf92a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateCertificatePartitioner.java @@ -32,6 +32,7 @@ public class RegenerateCertificatePartitioner extends BasePartitioner { @Override public Map partition(int gridSize) { + createBatchJobHistory(); List credentialList = new ArrayList<>(); JobParameters jobParameters = context.getJobParameters(); String searchRequest = jobParameters.getString(SEARCH_REQUEST); From b95c2828eda599fe961d42e4b558f23bb9dcd1d4 Mon Sep 17 00:00:00 2001 From: githubmamatha <106563495+githubmamatha@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:35:26 -0700 Subject: [PATCH 20/20] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 4cb180d3..a8c712c6 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-batch-graduation-api - 1.8.60 + 1.8.61 educ-grad-batch-graduation-api Ministry of Education GRAD BATCH GRADUATION API