Skip to content

Commit 5af66cd

Browse files
committed
career school
1 parent c0615d2 commit 5af66cd

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/constants/v1/SchoolReportTypeCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public enum SchoolReportTypeCode {
1919
FRENCH_HEADCOUNT("FRENCH_HEADCOUNT"),
2020
ALL_STUDENT_SCHOOL_CSV("ALL_STUDENT_SCHOOL_CSV"),
2121
ALL_STUDENT_ERRORS_WARNS_SCHOOL_CSV("ALL_STUDENT_ERRORS_WARNS_SCHOOL_CSV"),
22-
ALL_STUDENT_FRENCH_SCHOOL_CSV("ALL_STUDENT_FRENCH_SCHOOL_CSV");
22+
ALL_STUDENT_FRENCH_SCHOOL_CSV("ALL_STUDENT_FRENCH_SCHOOL_CSV"),
23+
ALL_STUDENT_CAREER_SCHOOL_CSV("ALL_STUDENT_CAREER_SCHOOL_CSV"),;
2324

2425
@Getter
2526
private final String code;

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/ReportGenerationController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public DownloadableReportResponse generateSDCSchoolReport(UUID sdcSchoolCollecti
7777
case ALL_STUDENT_SCHOOL_CSV -> allStudentLightCollectionGenerateCsvService.generateFromSdcSchoolCollectionID(sdcSchoolCollectionID);
7878
case ALL_STUDENT_ERRORS_WARNS_SCHOOL_CSV -> allStudentLightCollectionGenerateCsvService.generateErrorWarnInfoReportFromSdcSchoolCollectionID(sdcSchoolCollectionID);
7979
case ALL_STUDENT_FRENCH_SCHOOL_CSV -> allStudentLightCollectionGenerateCsvService.generateFrenchFromSdcSchoolCollectionID(sdcSchoolCollectionID);
80+
case ALL_STUDENT_CAREER_SCHOOL_CSV -> allStudentLightCollectionGenerateCsvService.generateCareerFromSdcSchoolCollectionID(sdcSchoolCollectionID);
8081
default -> new DownloadableReportResponse();
8182
};
8283
}

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/reports/AllStudentLightCollectionGenerateCsvService.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,30 @@ public DownloadableReportResponse generateFrenchFromSdcSchoolCollectionID(UUID s
119119
}
120120
}
121121

122+
public DownloadableReportResponse generateCareerFromSdcSchoolCollectionID(UUID sdcSchoolCollectionID) {
123+
List<SdcSchoolCollectionStudentLightWithEnrolledProgramCodesEntity> entities = sdcSchoolCollectionStudentSearchService.findAllCareerStudentsLightBySchoolCollectionID(sdcSchoolCollectionID);
124+
CSVFormat csvFormat = CSVFormat.DEFAULT.builder()
125+
.setHeader("PEN", "Legal Name", "Usual Name", "FTE", "Program Eligible", "Local ID", "Adult", "Graduate", "Grade", "Funding Code", "Career Program", "Career Code")
126+
.build();
127+
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
128+
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(byteArrayOutputStream));
129+
CSVPrinter csvPrinter = new CSVPrinter(writer, csvFormat)) {
130+
131+
for (SdcSchoolCollectionStudentLightWithEnrolledProgramCodesEntity student : entities) {
132+
List<Object> csvRowData = prepareCareerStudentDataForCsv(student, false);
133+
csvPrinter.printRecord(csvRowData);
134+
}
135+
csvPrinter.flush();
136+
137+
var downloadableReport = new DownloadableReportResponse();
138+
downloadableReport.setReportType(SchoolReportTypeCode.ALL_STUDENT_CAREER_SCHOOL_CSV.getCode());
139+
downloadableReport.setDocumentData(Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()));
140+
141+
return downloadableReport;
142+
} catch (IOException e) {
143+
throw new StudentDataCollectionAPIRuntimeException(e);
144+
}
145+
}
122146

123147
public DownloadableReportResponse generateErrorWarnInfoReportFromSdcDistrictCollectionID(UUID sdcDistrictCollectionID) {
124148
List<SdcSchoolCollectionStudentEntity> entities = sdcSchoolCollectionStudentSearchService.findAllStudentsWithErrorsWarningInfoByDistrictCollectionID(sdcDistrictCollectionID);

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/SdcSchoolCollectionStudentSearchService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ public List<SdcSchoolCollectionStudentLightWithEnrolledProgramCodesEntity> findA
128128
}
129129
}
130130

131+
@Transactional(propagation = Propagation.SUPPORTS)
132+
public List<SdcSchoolCollectionStudentLightWithEnrolledProgramCodesEntity> findAllCareerStudentsLightBySchoolCollectionID(UUID sdcSchoolCollectionID) {
133+
try {
134+
return this.sdcSchoolCollectionStudentLightWithEnrolledProgramCodesRepository.findBySchoolCollectionIDAndStatusNotAndEnrolledProgramCodeNotIn(sdcSchoolCollectionID, "DELETED", EnrolledProgramCodes.getCareerProgramCodes());
135+
} catch (final Exception ex) {
136+
log.error("Failure querying for career light SDC school students by School Collection ID: {}", ex.getMessage());
137+
throw new CompletionException(ex);
138+
}
139+
}
140+
131141
@Transactional(propagation = Propagation.SUPPORTS)
132142
public List<SdcSchoolCollectionStudentLightEntity> findAllStudentsLightByDistrictCollectionId(UUID sdcDistrictCollectionID) {
133143
try {

0 commit comments

Comments
 (0)