diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index 003568c3..6f7b3bd3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -160,12 +160,15 @@ public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto. try { School schoolAtGrad = getSchoolAtGradData(graduationDataStatus, accessToken, exception); School schoolOfRecord = getSchoolData(graduationDataStatus.getSchool()); - //GRAD2-1847 + //--> Revert code back to school of record GRAD2-2758 + /** SchoolTrax traxSchool = null; if(schoolAtGrad != null) { String mincode = schoolAtGrad.getMincode(); traxSchool = schoolService.getTraxSchoolDetails(mincode, accessToken, exception); - } + } **/ + SchoolTrax traxSchool = schoolService.getTraxSchoolDetails(schoolOfRecord.getMincode(), accessToken, exception); + //<-- GraduationStatus graduationStatus = getGraduationStatus(graduationDataStatus, schoolAtGrad, schoolOfRecord); GraduationData graduationData = getGraduationData(graduationDataStatus, gradResponse, accessToken); graduationStatus.setProgramCompletionDate(EducGraduationApiUtils.getSimpleDateFormat(graduationData.getGraduationDate())); @@ -825,7 +828,10 @@ private GraduationStatus getGraduationStatus(ca.bc.gov.educ.api.graduation.model if (schoolAtGrad != null && schoolOfRecord != null && !StringUtils.equalsIgnoreCase(schoolOfRecord.getMincode(), schoolAtGrad.getMincode())) { - gradMessage = StringUtils.replace(gradMessage, schoolOfRecord.getName(), schoolAtGrad.getName()); + //--> Revert code back to school of record GRAD2-2758 + /** gradMessage = StringUtils.replace(gradMessage, schoolOfRecord.getName(), schoolAtGrad.getName());**/ + //<-- + log.debug("Replace school of record {} to school at graduation {}", schoolOfRecord.getName(), schoolAtGrad.getName()); } gradStatus.setGraduationMessage(gradMessage); return gradStatus; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java index 640b696b..2fd32b0f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java @@ -159,13 +159,24 @@ public Integer createAndStoreSchoolDistrictYearEndReports(String accessToken, St if(schools != null && !schools.isEmpty()) { boolean isDistrictSchool = schools.get(0).length() == 3; if(isDistrictSchool) { + //--> Revert code back to school of record GRAD2-2758 + /** reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); + **/ + reportGradStudentDataList.removeIf(st->schools != null && !schools.isEmpty() && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3))); + //<-- + } boolean isSchoolSchool = schools.get(0).length() > 3; if(isSchoolSchool) { + //--> Revert code back to school of record GRAD2-2758 + /** reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); + **/ + reportGradStudentDataList.removeIf(st->schools != null && !schools.isEmpty() && !schools.contains(st.getMincode())); + //<-- } } return createAndStoreReports(reportGradStudentDataList, accessToken, slrt, drt, srt, null); @@ -457,7 +468,10 @@ private String getReportOrgCode(String mincode) { private School populateDistrictObjectByReportGradStudentData(Map> districtSchoolsMap, ReportGradStudentData reportGradStudentData) { //district data, not school - String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad(); + //--> Revert code back to school of record GRAD2-2758 + /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + String mincode = reportGradStudentData.getMincode(); + //<-- String distcode = StringUtils.substring(mincode, 0, 3); boolean addNewDistrict = true; School district = null; @@ -480,7 +494,10 @@ private School populateDistrictObjectByReportGradStudentData(Map Revert code back to school of record GRAD2-2758 + /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + String mincode = reportGradStudentData.getMincode(); + //<-- SchoolTrax traxSchool = schoolService.getTraxSchoolDetails(mincode); School school = new School(); school.setStudents(new ArrayList<>()); @@ -503,7 +520,10 @@ private School populateSchoolObjectByReportGradStudentData(ReportGradStudentData } private School populateSchoolObjectByReportGradStudentData(Map schoolMap, ReportGradStudentData reportGradStudentData) { - String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad(); + //--> Revert code back to school of record GRAD2-2758 + /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + String mincode = reportGradStudentData.getMincode(); + //<-- School school = schoolMap.get(mincode); if (school == null) { school = populateSchoolObjectByReportGradStudentData(reportGradStudentData); @@ -514,7 +534,10 @@ private School populateSchoolObjectByReportGradStudentData(Map s private void processDistrictSchoolMap(List schools, ReportGradStudentData reportGradStudentData) { boolean addNewSchool = true; - String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad(); + //--> Revert code back to school of record GRAD2-2758 + /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + String mincode = reportGradStudentData.getMincode(); + //<-- String distNo = StringUtils.substring(mincode, 0, 3); for (School school : schools) { if (StringUtils.equals(school.getMincode(), mincode)) { @@ -593,7 +616,10 @@ private Student populateStudentObjectByReportGradStudentData(ReportGradStudentDa GraduationStatus gradStatus = new GraduationStatus(); gradStatus.setProgramCompletionDate(reportGradStudentData.getProgramCompletionDate()); - gradStatus.setSchoolOfRecord(StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad()); + //--> Revert code back to school of record GRAD2-2758 + /** gradStatus.setSchoolOfRecord(StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad()); **/ + gradStatus.setSchoolOfRecord(reportGradStudentData.getMincode()); + //<-- gradStatus.setSchoolAtGrad(reportGradStudentData.getMincodeAtGrad()); gradStatus.setProgramName(reportGradStudentData.getProgramCode()); gradStatus.setCertificates(reportGradStudentData.getCertificateTypeCode());