diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 20a21005..c7d87d13 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -732,20 +732,20 @@ private synchronized List getNextPageStudentsFromGradStud if(studentsInBatch != null && !schools.isEmpty()) { boolean isDistrictSchool = schools.get(0).length() == 3; if(isDistrictSchool) { - studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); - studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); } boolean isSchoolSchool = schools.get(0).length() > 3; if(isSchoolSchool) { - studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); - studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); } } for(SchoolReportEntity e: students.getContent()) { String paperType = e.getPaperType(); String certificateTypeCode = e.getCertificateTypeCode(); //either transcript or certificate codes ReportGradStudentData s = getReportGradStudentDataByGraduationStudentRecordIdFromList(e.getGraduationStudentRecordId(), studentsInBatch); - if(s != null) { + if(s != null && "CUR".equalsIgnoreCase(s.getStudentStatus())) { ReportGradStudentData dataResult = SerializationUtils.clone(s); dataResult.setPaperType(paperType); if ("YED4".equalsIgnoreCase(paperType)) { @@ -753,12 +753,7 @@ private synchronized List getNextPageStudentsFromGradStud } else { dataResult.setCertificateTypeCode(certificateTypeCode); } - if("YED4".equalsIgnoreCase(paperType) && "CUR".equalsIgnoreCase(s.getStudentStatus())) { - result.add(dataResult); - } - if (!"YED4".equalsIgnoreCase(paperType)) { - result.add(dataResult); - } + result.add(dataResult); } } return result; diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 26a54240..6791bbc9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1470,6 +1470,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); reportGradStudentData.setMincode("12345678"); + reportGradStudentData.setStudentStatus("CUR"); GradCertificateTypes certificateTypes = new GradCertificateTypes(); certificateTypes.setCode("E"); @@ -1480,6 +1481,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1488,6 +1490,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); reportGradStudentData.setMincode("12345678"); reportGradStudentData.setMincodeAtGrad("09876543"); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1688,6 +1691,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); reportGradStudentData.setMincode(mincode); + reportGradStudentData.setStudentStatus("CUR"); GradCertificateTypes certificateTypes = new GradCertificateTypes(); certificateTypes.setCode("E"); @@ -1698,6 +1702,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1706,6 +1711,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); reportGradStudentData.setMincode(mincode); reportGradStudentData.setMincodeAtGrad("09876543"); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData);