Skip to content

Commit

Permalink
Merge pull request #392 from bcgov/fix/EDX-2147
Browse files Browse the repository at this point in the history
EDX-2147: Fix for KH grade code
  • Loading branch information
mightycox authored Jan 15, 2024
2 parents 53eb98b + b347799 commit 5d99bdb
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,26 @@ public static List<String> getGrades10toSU() {
codes.add(SECONDARY_UNGRADED.getCode());
return codes;
}

public static List<String> getNonIndependentSchoolGrades() {
List<String> codes = new ArrayList<>();
codes.add(KINDFULL.getCode());
codes.add(GRADE01.getCode());
codes.add(GRADE02.getCode());
codes.add(GRADE03.getCode());
codes.add(GRADE04.getCode());
codes.add(GRADE05.getCode());
codes.add(GRADE06.getCode());
codes.add(GRADE07.getCode());
codes.add(ELEMUNGR.getCode());
codes.add(GRADE08.getCode());
codes.add(GRADE09.getCode());
codes.add(GRADE10.getCode());
codes.add(GRADE11.getCode());
codes.add(GRADE12.getCode());
codes.add(SECONDARY_UNGRADED.getCode());
codes.add(GRADUATED_ADULT.getCode());
codes.add(HOMESCHOOL.getCode());
return codes;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ca.bc.gov.educ.studentdatacollection.api.helpers;

import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionEntity;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.School;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.*;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -32,7 +34,14 @@ public CsfFrenchHeadcountHelper(SdcSchoolCollectionRepository sdcSchoolCollectio
headcountMethods = getHeadcountMethods();
sectionTitles = getSelectionTitles();
rowTitles = getRowTitles();
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
}

public void setGradeCodes(Optional<School> school) {
if(school.isPresent() && (school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDEPEND.getCode()) || school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDP_FNS.getCode()))) {
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
} else {
gradeCodes = SchoolGradeCodes.getNonIndependentSchoolGrades();
}
}
public void setComparisonValues(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, List<HeadcountHeader> headcountHeaderList) {
UUID previousCollectionID = getPreviousSeptemberCollectionID(sdcSchoolCollectionEntity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.studentdatacollection.api.helpers;

import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionEntity;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
Expand Down Expand Up @@ -56,7 +57,14 @@ public EllHeadcountHelper(
headcountMethods = getHeadcountMethods();
sectionTitles = getSelectionTitles();
rowTitles = getRowTitles();
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
}

public void setGradeCodes(Optional<School> school) {
if(school.isPresent() && (school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDEPEND.getCode()) || school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDP_FNS.getCode()))) {
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
} else {
gradeCodes = SchoolGradeCodes.getNonIndependentSchoolGrades();
}
}

public void setComparisonValues(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ca.bc.gov.educ.studentdatacollection.api.helpers;

import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionEntity;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.School;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.EnrollmentHeadcountResult;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.HeadcountHeader;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.HeadcountHeaderColumn;
Expand Down Expand Up @@ -42,9 +44,15 @@ public EnrollmentHeadcountHelper(SdcSchoolCollectionRepository sdcSchoolCollecti
headcountMethods = getHeadcountMethods();
sectionTitles = getSelectionTitles();
rowTitles = getRowTitles();
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
}

public void setGradeCodes(Optional<School> school) {
if(school.isPresent() && (school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDEPEND.getCode()) || school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDP_FNS.getCode()))) {
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
} else {
gradeCodes = SchoolGradeCodes.getNonIndependentSchoolGrades();
}
}

public void setComparisonValues(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, List<HeadcountHeader> headcountHeaderList) {
UUID previousCollectionID = getPreviousSeptemberCollectionID(sdcSchoolCollectionEntity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ca.bc.gov.educ.studentdatacollection.api.helpers;

import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
import ca.bc.gov.educ.studentdatacollection.api.exception.StudentDataCollectionAPIRuntimeException;
import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionEntity;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.School;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.FrenchHeadcountHeaderResult;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.FrenchHeadcountResult;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.HeadcountHeader;
Expand Down Expand Up @@ -48,7 +50,14 @@ public FrenchHeadcountHelper(SdcSchoolCollectionRepository sdcSchoolCollectionRe
headcountMethods = getHeadcountMethods();
sectionTitles = getSelectionTitles();
rowTitles = getRowTitles();
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
}

public void setGradeCodes(Optional<School> school) {
if(school.isPresent() && (school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDEPEND.getCode()) || school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDP_FNS.getCode()))) {
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
} else {
gradeCodes = SchoolGradeCodes.getNonIndependentSchoolGrades();
}
}

public void setComparisonValues(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, List<HeadcountHeader> headcountHeaderList) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ca.bc.gov.educ.studentdatacollection.api.helpers;

import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
import ca.bc.gov.educ.studentdatacollection.api.exception.StudentDataCollectionAPIRuntimeException;
import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionEntity;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.School;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.*;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -60,7 +62,14 @@ public SpecialEdHeadcountHelper(SdcSchoolCollectionRepository sdcSchoolCollectio
headcountMethods = getHeadcountMethods();
sectionTitles = getSelectionTitles();
rowTitles = getRowTitles();
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
}

public void setGradeCodes(Optional<School> school) {
if(school.isPresent() && (school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDEPEND.getCode()) || school.get().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.INDP_FNS.getCode()))) {
gradeCodes = Arrays.stream(SchoolGradeCodes.values()).map(SchoolGradeCodes::getCode).toList();
} else {
gradeCodes = SchoolGradeCodes.getNonIndependentSchoolGrades();
}
}

public void setComparisonValues(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, List<HeadcountHeader> headcountHeaderList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public class SdcSchoolCollectionStudentHeadcountService {

public SdcSchoolCollectionStudentHeadcounts getEnrollmentHeadcounts(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, boolean compare) {
var sdcSchoolCollectionID = sdcSchoolCollectionEntity.getSdcSchoolCollectionID();

Optional<School> school = this.restUtils.getSchoolBySchoolID(String.valueOf(sdcSchoolCollectionEntity.getSchoolID()));
enrollmentHeadcountHelper.setGradeCodes(school);
List<EnrollmentHeadcountResult> collectionRawData = sdcSchoolCollectionStudentRepository.getEnrollmentHeadcountsBySchoolId(sdcSchoolCollectionID);
HeadcountResultsTable collectionData = enrollmentHeadcountHelper.convertHeadcountResults(collectionRawData);

List<HeadcountHeader> headcountHeaderList = Arrays.asList(enrollmentHeadcountHelper.getStudentsHeadcountTotals(collectionData), enrollmentHeadcountHelper.getGradesHeadcountTotals(collectionData));
if (compare) {
enrollmentHeadcountHelper.setComparisonValues(sdcSchoolCollectionEntity, headcountHeaderList);
Expand All @@ -48,6 +50,7 @@ public SdcSchoolCollectionStudentHeadcounts getFrenchHeadcounts(SdcSchoolCollect
HeadcountResultsTable collectionData;
if(school.isPresent() && school.get().getSchoolReportingRequirementCode().equals(SchoolReportingRequirementCodes.CSF.getCode())) {
List<CsfFrenchHeadcountResult> collectionRawData;
csfFrenchHeadcountHelper.setGradeCodes(school);
collectionRawData = sdcSchoolCollectionStudentRepository.getCsfFrenchHeadcountsBySchoolId(sdcSchoolCollectionID);
headcountHeaderList = csfFrenchHeadcountHelper.getHeaders(sdcSchoolCollectionID);
collectionData = csfFrenchHeadcountHelper.convertHeadcountResults(collectionRawData);
Expand All @@ -56,13 +59,15 @@ public SdcSchoolCollectionStudentHeadcounts getFrenchHeadcounts(SdcSchoolCollect
}
} else {
List<FrenchHeadcountResult> collectionRawData;
frenchHeadcountHelper.setGradeCodes(school);
collectionRawData = sdcSchoolCollectionStudentRepository.getFrenchHeadcountsBySchoolId(sdcSchoolCollectionID);
headcountHeaderList = frenchHeadcountHelper.getHeaders(sdcSchoolCollectionID);
collectionData = frenchHeadcountHelper.convertHeadcountResults(collectionRawData);
if(compare) {
frenchHeadcountHelper.setComparisonValues(sdcSchoolCollectionEntity, headcountHeaderList);
}
}

return SdcSchoolCollectionStudentHeadcounts.builder().headcountHeaders(headcountHeaderList).headcountResultsTable(collectionData).build();
}

Expand Down Expand Up @@ -90,6 +95,8 @@ public SdcSchoolCollectionStudentHeadcounts getIndigenousHeadcounts(SdcSchoolCol

public SdcSchoolCollectionStudentHeadcounts getEllHeadcounts(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, boolean compare) {
var sdcSchoolCollectionID = sdcSchoolCollectionEntity.getSdcSchoolCollectionID();
Optional<School> school = this.restUtils.getSchoolBySchoolID(String.valueOf(sdcSchoolCollectionEntity.getSchoolID()));
ellHeadcountHelper.setGradeCodes(school);

List<EllHeadcountResult> collectionRawData =
sdcSchoolCollectionStudentRepository.getEllHeadcountsBySchoolId(sdcSchoolCollectionID);
Expand All @@ -104,6 +111,8 @@ public SdcSchoolCollectionStudentHeadcounts getEllHeadcounts(SdcSchoolCollection

public SdcSchoolCollectionStudentHeadcounts getSpecialEdHeadcounts(SdcSchoolCollectionEntity sdcSchoolCollectionEntity, boolean compare) {
var sdcSchoolCollectionID = sdcSchoolCollectionEntity.getSdcSchoolCollectionID();
Optional<School> school = this.restUtils.getSchoolBySchoolID(String.valueOf(sdcSchoolCollectionEntity.getSchoolID()));
specialEdHeadcountHelper.setGradeCodes(school);

List<SpecialEdHeadcountResult> result = sdcSchoolCollectionStudentRepository.getSpecialEdHeadcountsBySchoolId(sdcSchoolCollectionID);
HeadcountResultsTable headcountResultsTable = specialEdHeadcountHelper.convertHeadcountResults(result);
Expand Down
Loading

0 comments on commit 5d99bdb

Please sign in to comment.