From 54a136e5dfaf8a1616a2ef973e70cdcded798b98 Mon Sep 17 00:00:00 2001 From: Avisha Sodhi <38086281+SodhiA1@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:02:22 -0800 Subject: [PATCH] Remove ENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE report --- .../MinistryHeadcountReportsController.java | 1 - .../SdcSchoolCollectionStudentRepository.java | 250 ------------------ .../service/v1/reports/CSVReportService.java | 58 ---- .../v1/MinistryReportsControllerTest.java | 101 ------- 4 files changed, 410 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryHeadcountReportsController.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryHeadcountReportsController.java index 61e924c20..c78e180a3 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryHeadcountReportsController.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryHeadcountReportsController.java @@ -70,7 +70,6 @@ public DownloadableReportResponse getMinistryDownloadableReport(UUID collectionI case INDY_INCLUSIVE_ED_FUNDING_HEADCOUNTS -> ministryReportsService.generateIndySpecialEducationFundingHeadcounts(collectionID); case ENROLLED_HEADCOUNTS_AND_FTE_REPORT -> ministryReportsService.generateEnrolledHeadcountsAndFteReport(collectionID); case INCLUSIVE_EDUCATION_VARIANCES_ALL -> ministryReportsService.generateInclusiveEducationVarianceReport(collectionID); - case ENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE_SCHOOLS -> ministryReportsService.generateEnrolmentHeadcountsAndFteReportForCEAndOLSchools(collectionID); case INDY_FUNDING_REPORT_ALL -> ministryReportsService.generateIndyFundingReport(collectionID, false, false, false); case INDY_FUNDING_REPORT_FUNDED -> ministryReportsService.generateIndyFundingReport(collectionID, false, false, true); case ONLINE_INDY_FUNDING_REPORT -> ministryReportsService.generateIndyFundingReport(collectionID, true, false, false); diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java index 9b58e2e52..71274daef 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentRepository.java @@ -1809,256 +1809,6 @@ WHERE sscs.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED') GROUP BY sscs.sdcSchoolCollection.schoolID, sscs.sdcSchoolCollection.sdcSchoolCollectionID """) List getEnrolmentHeadcountsAndFteByFebCollectionId(@Param("collectionID") UUID collectionID); - @Query(value = """ - SELECT - sscs.sdcSchoolCollection.schoolID as schoolID, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KH' THEN sscs.sdcSchoolCollectionStudentID END) as khTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KH' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS khRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KH' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS khEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KF' THEN sscs.sdcSchoolCollectionStudentID END) as kfTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KF' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS kfRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'KF' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS kfEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '01' THEN sscs.sdcSchoolCollectionStudentID END) as gradeOneTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '01' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeOneRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '01' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeOneEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '02' THEN sscs.sdcSchoolCollectionStudentID END) as gradeTwoTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '02' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeTwoRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '02' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeTwoEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '03' THEN sscs.sdcSchoolCollectionStudentID END) as gradeThreeTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '03' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeThreeRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '03' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeThreeEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '04' THEN sscs.sdcSchoolCollectionStudentID END) as gradeFourTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '04' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeFourRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '04' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeFourEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '05' THEN sscs.sdcSchoolCollectionStudentID END) as gradeFiveTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '05' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeFiveRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '05' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeFiveEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '06' THEN sscs.sdcSchoolCollectionStudentID END) as gradeSixTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '06' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeSixRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '06' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeSixEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '07' THEN sscs.sdcSchoolCollectionStudentID END) as gradeSevenTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '07' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeSevenRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '07' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeSevenEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '08' THEN sscs.sdcSchoolCollectionStudentID END) as gradeEightTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '08' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeEightRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '08' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeEightEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '09' THEN sscs.sdcSchoolCollectionStudentID END) as gradeNineTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '09' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeNineRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '09' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeNineEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '10' THEN sscs.sdcSchoolCollectionStudentID END) as gradeTenTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '10' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeTenRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '10' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeTenEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '11' THEN sscs.sdcSchoolCollectionStudentID END) as gradeElevenTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '11' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeElevenRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '11' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeElevenEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '12' THEN sscs.sdcSchoolCollectionStudentID END) as gradeTwelveTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '12' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeTwelveRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = '12' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeTwelveEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'EU' THEN sscs.sdcSchoolCollectionStudentID END) as gradeEuTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'EU' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeEuRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'EU' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeEuEllCount, - - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'SU' THEN sscs.sdcSchoolCollectionStudentID END) as gradeSuTotalCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'SU' AND sscs.schoolFundingCode = '16' THEN sscs.sdcSchoolCollectionStudentID ELSE NULL END) AS gradeSuRefugeeCount, - COUNT(DISTINCT CASE WHEN sscs.enrolledGradeCode = 'SU' AND ep.enrolledProgramCode = '17' AND sscs.ellNonEligReasonCode IS NULL THEN sscs.sdcSchoolCollectionStudentID END) AS gradeSuEllCount, - - COUNT(DISTINCT CASE WHEN sscs.isAdult = true AND sscs.isGraduated = true THEN sscs.sdcSchoolCollectionStudentID END) as gradAdultCount, - COUNT(DISTINCT CASE WHEN sscs.isAdult = true AND sscs.isGraduated = false THEN sscs.sdcSchoolCollectionStudentID END) as nonGradAdultCount, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'KH' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as khTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'KH' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) - as khRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'KF' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as kfTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'KF' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) - as kfRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '01' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeOneTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '01' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeOneRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '02' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTwoTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '02' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTwoRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '03' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeThreeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '03' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeThreeRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '04' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeFourTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '04' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeFourRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '05' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeFiveTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '05' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeFiveRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '06' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSixTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '06' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSixRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '07' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSevenTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '07' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSevenRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '08' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeEightTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '08' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeEightRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '09' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeNineTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '09' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeNineRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '10' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTenTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '10' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTenRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '11' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeElevenTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '11' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeElevenRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '12' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTwelveTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = '12' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeTwelveRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'EU' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeEuTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'EU' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeEuRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'SU' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSuTotalFte, - - (SELECT SUM(CASE WHEN s.enrolledGradeCode = 'SU' AND s.schoolFundingCode = '16' AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradeSuRefugeeTotalFte, - - (SELECT SUM(CASE WHEN s.isAdult = true AND s.isGraduated = true AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as gradAdultTotalFte, - - (SELECT SUM(CASE WHEN s.isAdult = true AND s.isGraduated = false AND s.fte IS NOT NULL THEN s.fte ELSE 0 END ) FROM SdcSchoolCollectionStudentEntity s - WHERE s.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND s.sdcSchoolCollection.sdcSchoolCollectionID = sscs.sdcSchoolCollection.sdcSchoolCollectionID - AND s.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED')) as nonGradAdultTotalFte - - FROM SdcSchoolCollectionStudentEntity sscs - LEFT JOIN sscs.sdcStudentEnrolledProgramEntities ep - WHERE sscs.sdcSchoolCollectionStudentStatusCode NOT IN ('ERROR', 'DELETED') - AND sscs.sdcSchoolCollection.collectionEntity.collectionID = :collectionID - AND sscs.sdcSchoolCollection.sdcDistrictCollectionID is not null - GROUP BY sscs.sdcSchoolCollection.schoolID, sscs.sdcSchoolCollection.sdcSchoolCollectionID""") - List getEnrolmentHeadcountsAndFteWithRefugeeByCollectionId(@Param("collectionID") UUID collectionID); - @Query("SELECT " + " sscs.sdcSchoolCollection.schoolID as schoolID, " + diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java index 411a9628e..bca812829 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/reports/CSVReportService.java @@ -1036,55 +1036,6 @@ private boolean shouldIncludeSchoolForEnrolledHeadcountsAndFteReport(SchoolTombs return Arrays.stream(invalidSchoolCategories).noneMatch(categoryCode::equals) && Arrays.stream(invalidFacilityTypes).noneMatch(facilityType::equals); } - // Enroled Headcounts and FTEs For CE and OL Schools report - public DownloadableReportResponse generateEnrolmentHeadcountsAndFteReportForCEAndOLSchools(UUID collectionID) { - var collectionOpt = collectionRepository.findById(collectionID); - - if(collectionOpt.isEmpty()){ - throw new EntityNotFoundException(Collection.class, COLLECTION_ID, collectionID.toString()); - } - - CollectionEntity collection = collectionOpt.get(); - if(!collection.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.MAY.getTypeCode()) && !collection.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.FEBRUARY.getTypeCode())) { - throw new InvalidPayloadException(createError(HEADCOUNTS_INVALID_COLLECTION_TYPE)); - } - - List results = sdcSchoolCollectionStudentRepository.getEnrolmentHeadcountsAndFteWithRefugeeByCollectionId(collectionID); - var mappedSeptData = getEnrolmentHeadcountFteResultForLastSeptCollection(collectionID); - - List headers = Arrays.stream(CEAndOLEnrolmentAndFteHeader.values()).map(CEAndOLEnrolmentAndFteHeader::getCode).toList(); - CSVFormat csvFormat = CSVFormat.DEFAULT.builder() - .setHeader(headers.toArray(String[]::new)) - .build(); - try { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(byteArrayOutputStream)); - CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat); - - for (EnrolmentHeadcountFteResult result : results) { - var septCollectionRecord = mappedSeptData.get(result.getSchoolID()); - - var schoolOpt = restUtils.getSchoolBySchoolID(result.getSchoolID()); - if(schoolOpt.isPresent() && - (schoolOpt.get().getFacilityTypeCode().equalsIgnoreCase(FacilityTypeCodes.CONT_ED.getCode()) || - schoolOpt.get().getFacilityTypeCode().equalsIgnoreCase(FacilityTypeCodes.DISTONLINE.getCode()) || - schoolOpt.get().getFacilityTypeCode().equalsIgnoreCase(FacilityTypeCodes.DIST_LEARN.getCode()))) { - List csvRowData = prepareEnrolmentFteDataForCEAndOLSchools(result, septCollectionRecord, schoolOpt.get()); - csvPrinter.printRecord(csvRowData); - } - } - csvPrinter.flush(); - - var downloadableReport = new DownloadableReportResponse(); - downloadableReport.setReportType(ENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE_SCHOOLS.getCode()); - downloadableReport.setDocumentData(Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray())); - - return downloadableReport; - } catch (IOException e) { - throw new StudentDataCollectionAPIRuntimeException(e); - } - } - // Refugee Enroled Headcounts and FTEs report public DownloadableReportResponse generateRefugeeEnrolmentHeadcountsAndFteReport(UUID collectionID) { var collectionOpt = collectionRepository.findById(collectionID); @@ -1132,15 +1083,6 @@ public DownloadableReportResponse generateRefugeeEnrolmentHeadcountsAndFteReport } } - private Map getEnrolmentHeadcountFteResultForLastSeptCollection(UUID collectionID){ - var lastSeptCollectionOpt = sdcSchoolCollectionRepository.findLastCollectionByType(CollectionTypeCodes.SEPTEMBER.getTypeCode(), collectionID); - if(lastSeptCollectionOpt.isEmpty()) { - throw new EntityNotFoundException(CollectionEntity.class, COLLECTION_ID, collectionID.toString()); - } - List lastSeptCollectionRawData = sdcSchoolCollectionStudentRepository.getEnrolmentHeadcountsAndFteWithRefugeeByCollectionId(lastSeptCollectionOpt.get().getCollectionID()); - return lastSeptCollectionRawData.stream().collect(Collectors.toMap(EnrolmentHeadcountFteResult::getSchoolID, item -> item)); - } - private ApiError createError(String message) { return ApiError.builder().timestamp(LocalDateTime.now()).message(message).status(BAD_REQUEST).build(); } diff --git a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryReportsControllerTest.java b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryReportsControllerTest.java index c8ee8918c..56f9bc6d3 100644 --- a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryReportsControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/MinistryReportsControllerTest.java @@ -1151,107 +1151,6 @@ void testGetMinistryReportCSV_TypeENROLLED_HEADCOUNTS_AND_FTE_REPORT_ShouldRetur assertThat(summary1.getReportType()).isEqualTo(ENROLLED_HEADCOUNTS_AND_FTE_REPORT.getCode()); } - @Test - void testGetMinistryReportCSV_TypeENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE_SCHOOLS_ShouldReturnReportData() throws Exception { - final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_MINISTRY_REPORTS"; - final OidcLoginRequestPostProcessor mockAuthority = oidcLogin().authorities(grantedAuthority); - - var school = this.createMockSchool(); - school.setSchoolCategoryCode(SchoolCategoryCodes.PUBLIC.getCode()); - school.setFacilityTypeCode(FacilityTypeCodes.DIST_LEARN.getCode()); - when(this.restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(school)); - - CollectionEntity collectionSept = createMockCollectionEntity(); - collectionSept.setCloseDate(LocalDateTime.now().minusDays(20)); - collectionSept.setCollectionTypeCode(CollectionTypeCodes.SEPTEMBER.getTypeCode()); - var savedSeptColl = collectionRepository.save(collectionSept); - - SdcDistrictCollectionEntity sdcMockDistrictSept = createMockSdcDistrictCollectionEntity(savedSeptColl, null); - sdcDistrictCollectionRepository.save(sdcMockDistrictSept).getSdcDistrictCollectionID(); - - school.setDistrictId(sdcMockDistrictSept.getDistrictID().toString()); - SdcSchoolCollectionEntity sdcSchoolCollectionEntitySept = createMockSdcSchoolCollectionEntity(savedSeptColl, UUID.fromString(school.getSchoolId())); - sdcSchoolCollectionRepository.save(sdcSchoolCollectionEntitySept); - - var sdcSchoolCollectionStudentSept1 = createMockSchoolStudentEntity(sdcSchoolCollectionEntitySept); - sdcSchoolCollectionStudentRepository.saveAll(List.of(sdcSchoolCollectionStudentSept1)); - - CollectionEntity collection = createMockCollectionEntity(); - collection.setCollectionTypeCode(CollectionTypeCodes.MAY.getTypeCode()); - collection.setCloseDate(LocalDateTime.now().plusDays(2)); - collection = collectionRepository.save(collection); - - SdcDistrictCollectionEntity sdcMockDistrict = createMockSdcDistrictCollectionEntity(collection, null); - sdcDistrictCollectionRepository.save(sdcMockDistrict); - - SdcDistrictCollectionEntity sdcMockDistrict2 = createMockSdcDistrictCollectionEntity(collection, null); - sdcDistrictCollectionRepository.save(sdcMockDistrict2); - - SdcSchoolCollectionEntity sdcSchoolCollectionEntity1 = createMockSdcSchoolCollectionEntity(collection, UUID.fromString(school.getSchoolId())); - - SchoolTombstone school2 = createMockSchool(); - school2.setSchoolCategoryCode(SchoolCategoryCodes.PUBLIC.getCode()); - school2.setFacilityTypeCode(FacilityTypeCodes.DIST_LEARN.getCode()); - school2.setDistrictId(sdcMockDistrict2.getDistrictID().toString()); - SdcSchoolCollectionEntity sdcSchoolCollectionEntity2 = createMockSdcSchoolCollectionEntity(collection, UUID.fromString(school2.getSchoolId())); - - sdcSchoolCollectionRepository.saveAll(List.of(sdcSchoolCollectionEntity1, sdcSchoolCollectionEntity2)); - - var sdcSchoolCollectionStudent1 = createMockSchoolStudentEntity(sdcSchoolCollectionEntity1); - var sdcSchoolCollectionStudent2 = createMockSchoolStudentEntity(sdcSchoolCollectionEntity2); - sdcSchoolCollectionStudentRepository.saveAll(List.of(sdcSchoolCollectionStudent1, sdcSchoolCollectionStudent2)); - - var resultActions1 = this.mockMvc.perform( - get(URL.BASE_MINISTRY_HEADCOUNTS + "/" + collection.getCollectionID() + "/enrolment-fte-headcounts-for-ce-ol-schools/download").with(mockAuthority)) - .andDo(print()).andExpect(status().isOk()); - - val summary1 = objectMapper.readValue(resultActions1.andReturn().getResponse().getContentAsByteArray(), new TypeReference() { - }); - - assertThat(summary1).isNotNull(); - assertThat(summary1.getReportType()).isEqualTo(ENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE_SCHOOLS.getCode()); - } - - @Test - void testGetMinistryReportCSV_TypeENROLMENT_HEADCOUNTS_AND_FTE_REPORT_FOR_OL_AND_CE_SCHOOLS_ShouldReturnBadRequest() throws Exception { - final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_MINISTRY_REPORTS"; - final OidcLoginRequestPostProcessor mockAuthority = oidcLogin().authorities(grantedAuthority); - - var school = this.createMockSchool(); - school.setSchoolCategoryCode(SchoolCategoryCodes.PUBLIC.getCode()); - school.setFacilityTypeCode(FacilityTypeCodes.DIST_LEARN.getCode()); - when(this.restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(school)); - - CollectionEntity collection = createMockCollectionEntity(); - collection.setCollectionTypeCode("JULY"); - collection.setCloseDate(LocalDateTime.now().plusDays(2)); - collection = collectionRepository.save(collection); - - SdcDistrictCollectionEntity sdcMockDistrict = createMockSdcDistrictCollectionEntity(collection, null); - sdcDistrictCollectionRepository.save(sdcMockDistrict); - - SdcDistrictCollectionEntity sdcMockDistrict2 = createMockSdcDistrictCollectionEntity(collection, null); - sdcDistrictCollectionRepository.save(sdcMockDistrict2); - - SchoolTombstone school1 = createMockSchool(); - school1.setDistrictId(sdcMockDistrict.getDistrictID().toString()); - SdcSchoolCollectionEntity sdcSchoolCollectionEntity1 = createMockSdcSchoolCollectionEntity(collection, UUID.fromString(school1.getSchoolId())); - - SchoolTombstone school2 = createMockSchool(); - school2.setDistrictId(sdcMockDistrict2.getDistrictID().toString()); - SdcSchoolCollectionEntity sdcSchoolCollectionEntity2 = createMockSdcSchoolCollectionEntity(collection, UUID.fromString(school2.getSchoolId())); - - sdcSchoolCollectionRepository.saveAll(List.of(sdcSchoolCollectionEntity1, sdcSchoolCollectionEntity2)); - - var sdcSchoolCollectionStudent1 = createMockSchoolStudentEntity(sdcSchoolCollectionEntity1); - var sdcSchoolCollectionStudent2 = createMockSchoolStudentEntity(sdcSchoolCollectionEntity2); - sdcSchoolCollectionStudentRepository.saveAll(List.of(sdcSchoolCollectionStudent1, sdcSchoolCollectionStudent2)); - - this.mockMvc.perform( - get(URL.BASE_MINISTRY_HEADCOUNTS + "/" + collection.getCollectionID() + "/enrolment-fte-headcounts-for-ce-ol-schools/download").with(mockAuthority)) - .andDo(print()).andExpect(status().isBadRequest()); - } - @Test void testGetMinistryReportCSV_IndyFundingResult_ShouldReturnReportData() throws Exception { final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_MINISTRY_REPORTS";