|
10 | 10 | import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentLightWithEnrolledProgramCodesEntity;
|
11 | 11 | import ca.bc.gov.educ.studentdatacollection.api.rest.RestUtils;
|
12 | 12 | import ca.bc.gov.educ.studentdatacollection.api.service.v1.SdcSchoolCollectionStudentSearchService;
|
| 13 | +import ca.bc.gov.educ.studentdatacollection.api.struct.external.institute.v1.FacilityTypeCode; |
13 | 14 | import ca.bc.gov.educ.studentdatacollection.api.struct.external.institute.v1.SchoolTombstone;
|
14 | 15 | import ca.bc.gov.educ.studentdatacollection.api.struct.v1.reports.DownloadableReportResponse;
|
15 | 16 | import lombok.extern.slf4j.Slf4j;
|
@@ -436,11 +437,12 @@ private List<Object> prepareStudentDataWithErrorsAndWarningsForCsv(SdcSchoolColl
|
436 | 437 | if (Boolean.TRUE.equals(isDistrict)) {
|
437 | 438 | UUID schoolID = student.getSdcSchoolCollection().getSchoolID();
|
438 | 439 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
439 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 440 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
440 | 441 |
|
441 | 442 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
442 | 443 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
443 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 444 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 445 | + |
444 | 446 | csvRowData.add(schoolCode);
|
445 | 447 | csvRowData.add(schoolName);
|
446 | 448 | csvRowData.add(finalFacilityType);
|
@@ -518,11 +520,12 @@ private List<Object> prepareStudentDataForCsv(SdcSchoolCollectionStudentLightEnt
|
518 | 520 | if (Boolean.TRUE.equals(isDistrict)) {
|
519 | 521 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
520 | 522 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
521 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 523 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
522 | 524 |
|
523 | 525 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
524 | 526 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
525 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 527 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 528 | + |
526 | 529 | csvRowData.add(schoolCode);
|
527 | 530 | csvRowData.add(schoolName);
|
528 | 531 | csvRowData.add(finalFacilityType);
|
@@ -579,11 +582,11 @@ private List<Object> prepareFrenchStudentDataForCsv(SdcSchoolCollectionStudentLi
|
579 | 582 | if (Boolean.TRUE.equals(isDistrict)) {
|
580 | 583 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
581 | 584 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
582 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 585 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
583 | 586 |
|
584 | 587 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
585 | 588 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
586 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 589 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
587 | 590 |
|
588 | 591 | csvRowData.add(schoolCode);
|
589 | 592 | csvRowData.add(schoolName);
|
@@ -617,11 +620,11 @@ private List<Object> prepareCareerStudentDataForCsv(SdcSchoolCollectionStudentLi
|
617 | 620 | if (Boolean.TRUE.equals(isDistrict)) {
|
618 | 621 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
619 | 622 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
620 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 623 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
621 | 624 |
|
622 | 625 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
623 | 626 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
624 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 627 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
625 | 628 |
|
626 | 629 | csvRowData.add(schoolCode);
|
627 | 630 | csvRowData.add(schoolName);
|
@@ -656,11 +659,11 @@ private List<Object> prepareIndigenousStudentDataForCsv(SdcSchoolCollectionStude
|
656 | 659 | if (Boolean.TRUE.equals(isDistrict)) {
|
657 | 660 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
658 | 661 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
659 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 662 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
660 | 663 |
|
661 | 664 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
662 | 665 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
663 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 666 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
664 | 667 |
|
665 | 668 | csvRowData.add(schoolCode);
|
666 | 669 | csvRowData.add(schoolName);
|
@@ -696,11 +699,11 @@ private List<Object> prepareInclusiveStudentDataForCsv(SdcSchoolCollectionStuden
|
696 | 699 | if (Boolean.TRUE.equals(isDistrict)) {
|
697 | 700 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
698 | 701 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
699 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 702 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
700 | 703 |
|
701 | 704 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
702 | 705 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
703 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 706 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
704 | 707 |
|
705 | 708 | csvRowData.add(schoolCode);
|
706 | 709 | csvRowData.add(schoolName);
|
@@ -730,11 +733,11 @@ private List<Object> prepareEllStudentDataForCsv(SdcSchoolCollectionStudentLight
|
730 | 733 | if (Boolean.TRUE.equals(isDistrict)) {
|
731 | 734 | UUID schoolID = student.getSdcSchoolCollectionEntitySchoolID();
|
732 | 735 | Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolID.toString());
|
733 |
| - var facilityType = restUtils.getFacilityTypeCode(school.get().getFacilityTypeCode()); |
| 736 | + Optional<FacilityTypeCode> facilityType = school.map(schoolTombstone -> restUtils.getFacilityTypeCode(schoolTombstone.getFacilityTypeCode())).orElse(null); |
734 | 737 |
|
735 | 738 | String schoolCode = school.isPresent() ? school.get().getMincode() : NO_SCHOOL_CODE_FOUND;
|
736 | 739 | String schoolName = school.map(SchoolTombstone::getDisplayName).orElse(NO_SCHOOL_NAME_FOUND);
|
737 |
| - String finalFacilityType = facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
| 740 | + String finalFacilityType = facilityType != null && facilityType.isPresent() ? facilityType.get().getLabel() : NO_FACILITY_TYPE_FOUND; |
738 | 741 |
|
739 | 742 | csvRowData.add(schoolCode);
|
740 | 743 | csvRowData.add(schoolName);
|
|
0 commit comments