From 6726cf80f10c4c2dc8dc2350e37a1402d65d7a86 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 3 Aug 2023 08:24:25 -0700 Subject: [PATCH] GRAD2-2265 & GRAD2-2269: tasks are completed. (#223) * GRAD2-2255 & GRAD2-2264: tasks are completed. GRAD2-2255 & GRAD2-2264: tasks are completed. * Clean up unused codes. Clean up unused codes. * GRAD2-2265 & GRAD2-2269: tasks are completed. GRAD2-2265 & GRAD2-2269: tasks are completed. * Clean up unused codes & comments Clean up unused codes & comments --- .../process/YearEndMergeProcess.java | 13 ++++++------- .../service/PostingDistributionService.java | 17 +++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/distribution/process/YearEndMergeProcess.java b/api/src/main/java/ca/bc/gov/educ/api/distribution/process/YearEndMergeProcess.java index 0c1393b..09bf419 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/distribution/process/YearEndMergeProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/distribution/process/YearEndMergeProcess.java @@ -44,17 +44,18 @@ public ProcessorData fire(ProcessorData processorData) { for (String mincode : mapDist.keySet()) { CommonSchool commonSchool = getBaseSchoolDetails(null, mincode, exception); if (commonSchool != null) { - String schoolCategoryCode = commonSchool.getSchoolCategoryCode(); - String distcode = getDistrictCodeFromMincode(mincode); - processDistrictsForLabels(districtsForLabels, distcode, exception); - int currentSlipCount = 0; schoolCounter++; + String schoolCategoryCode = commonSchool.getSchoolCategoryCode(); logger.debug("*** School Details Acquired {} category {}", mincode, schoolCategoryCode); if(StringUtils.containsAnyIgnoreCase(schoolCategoryCode, "02", "03", "09")) { processSchoolsForLabels(schoolsForLabels, mincode, exception); logger.debug("Added Independent School {} for processing", commonSchool.getSchoolName()); + } else { + // GRAD2-2269: no district for 02,03,09 school category + String distcode = getDistrictCodeFromMincode(mincode); + processDistrictsForLabels(districtsForLabels, distcode, exception); } logger.debug("{} School {}/{}", mincode, schoolCounter, mapDist.size()); List studListNonGrad = new ArrayList<>(); @@ -83,7 +84,6 @@ public ProcessorData fire(ProcessorData processorData) { mincodes.add(mincode); numberOfProcessedSchoolReports += processDistrictSchoolDistribution(processorData.getBatchId(), mincodes, null, null, NONGRADDISTREP_SC, null); logger.debug("***** Number of distributed Student NonGrad School Reports {} *****", numberOfProcessedSchoolReports); - numberOfPdfs++; } if(!NONGRADYERUN.equalsIgnoreCase(processorData.getActivityCode())) { @@ -96,7 +96,6 @@ public ProcessorData fire(ProcessorData processorData) { numberOfProcessedSchoolReports += processDistrictSchoolDistribution(processorData.getBatchId(), mincodes, null, null, DISTREP_YE_SC, null); logger.debug("***** {} School Report Created*****", mincode); logger.debug("***** Number of distributed School Reports {} *****", numberOfProcessedSchoolReports); - numberOfPdfs++; } logger.debug("PDFs Merged for School {}", commonSchool.getSchoolName()); @@ -121,7 +120,7 @@ public ProcessorData fire(ProcessorData processorData) { numberOfCreatedSchoolLabelReports += createDistrictSchoolYearEndReport(null, DISTREP_YE_SD, null, mincodes); logger.debug("***** Number of created District Reports {} *****", numberOfCreatedSchoolLabelReports); logger.debug("***** Distribute District Reports *****"); - processDistrictSchoolDistribution(batchId, mincodes, null, DISTREP_YE_SD, null, null); + numberOfProcessedSchoolReports += processDistrictSchoolDistribution(batchId, mincodes, null, DISTREP_YE_SD, null, null); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/distribution/service/PostingDistributionService.java b/api/src/main/java/ca/bc/gov/educ/api/distribution/service/PostingDistributionService.java index 258dd2f..413258b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/distribution/service/PostingDistributionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/distribution/service/PostingDistributionService.java @@ -54,18 +54,11 @@ public boolean postingProcess(DistributionResponse distributionResponse) { String download = distributionResponse.getLocalDownload(); String transmissionMode = distributionResponse.getTransmissionMode(); int numberOfPdfs = distributionResponse.getNumberOfPdfs(); - boolean forAllSchools = true; List districtCodes = extractDistrictCodes(distributionResponse); - if(NONGRADYERUN.equalsIgnoreCase(activityCode)) { - if(!districtCodes.isEmpty()) { - forAllSchools = false; - createDistrictSchoolYearEndNonGradReport(null, NONGRADDISTREP_SD, null, districtCodes); - } - // GRAD2-2264: removed the redundant logic of NONGRADDISTREP_SC, which is already processed in YearEndMergeProcess - if(forAllSchools) { - createDistrictSchoolYearEndNonGradReport(null, NONGRADDISTREP_SD, null); - } + if(NONGRADYERUN.equalsIgnoreCase(activityCode) && !districtCodes.isEmpty()) { + createDistrictSchoolYearEndNonGradReport(null, NONGRADDISTREP_SD, null, districtCodes); numberOfPdfs += processDistrictSchoolDistribution(batchId, null, NONGRADDISTREP_SD, null, transmissionMode); + // GRAD2-2264: removed the redundant logic of NONGRADDISTREP_SC because schools are already processed in YearEndMergeProcess } return zipBatchDirectory(batchId, download, numberOfPdfs, TMP_DIR); } @@ -341,8 +334,4 @@ private List extractDistrictCodes(DistributionResponse distributionRespo return distributionResponse.getDistricts().stream().map(School::getMincode).toList(); } - private List extractSchoolCodes(DistributionResponse distributionResponse) { - return distributionResponse.getSchools().stream().map(School::getMincode).toList(); - } - }