Skip to content

Commit

Permalink
Merge pull request #353 from bcgov/fix/EDX-1857
Browse files Browse the repository at this point in the history
Fix/edx 1857
  • Loading branch information
mightycox authored Oct 31, 2023
2 parents 5c47019 + 62d9015 commit 0298c3a
Show file tree
Hide file tree
Showing 76 changed files with 273 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum CollectionTypeCodes {
SEPTEMBER("SEPTEMBER", new String[]{SchoolCategoryCodes.PUBLIC.getCode(), SchoolCategoryCodes.INDEPEND.getCode(), SchoolCategoryCodes.OFFSHORE.getCode()}),
FEBRUARY("FEBRUARY", new String[]{SchoolCategoryCodes.PUBLIC.getCode(), SchoolCategoryCodes.INDEPEND.getCode(), SchoolCategoryCodes.OFFSHORE.getCode()}),
MAY("MAY", new String[]{SchoolCategoryCodes.PUBLIC.getCode(), SchoolCategoryCodes.INDEPEND.getCode(), SchoolCategoryCodes.OFFSHORE.getCode()}),
JULY("JULY", new String[]{SchoolCategoryCodes.PUBLIC.getCode()});
SEPTEMBER("SEPTEMBER"),
FEBRUARY("FEBRUARY"),
MAY("MAY"),
JULY("JULY");

private final String typeCode;
private final String[] schoolCode;
CollectionTypeCodes(String typeCode, String[] schoolCode) {
CollectionTypeCodes(String typeCode) {
this.typeCode = typeCode;
this.schoolCode = schoolCode;
}

public static Optional<CollectionTypeCodes> findByValue(String collectionTypeCode, String schoolTypeCode) {
return Arrays.stream(values()).filter(code -> code.typeCode.equalsIgnoreCase(collectionTypeCode) && Arrays.asList(code.schoolCode).contains(schoolTypeCode)).findFirst();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
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.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.service.v1.ValidationRulesService;
Expand Down Expand Up @@ -39,17 +40,16 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of AdultGraduatesRule-V48: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

log.debug("In shouldExecute of AdultGraduatesRule-V48: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent()
&& !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V48", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob()),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent()
var shouldExecute = studentRuleData.getSchool().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.PUBLIC.getCode())
&& !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V48", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());

log.debug("In shouldExecute of AdultGraduatesRule-V48: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return shouldExecute;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of AdultOLGradeRule-V57: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V57", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());

log.debug("In shouldExecute of AdultOLGradeRule-V57: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V57", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob()),
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V57", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());
return shouldExecute;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of ZeroCoursesReportedRule-V34: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V34", validationErrorsMap);

log.debug("In shouldExecute of ZeroCoursesReportedRule-V34: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
isValidationDependencyResolved("V34", validationErrorsMap),
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return isValidationDependencyResolved("V34", validationErrorsMap);
return shouldExecute;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of AdultStudentCoursesRule-V33: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V33", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());

log.debug("In shouldExecute of AdultStudentCoursesRule-V33: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V33", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob()),
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V33", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());
return shouldExecute;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
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.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
Expand Down Expand Up @@ -33,17 +32,15 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of AdultStudentGradeRule-V45: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V45", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());

log.debug("In shouldExecute of AdultStudentGradeRule-V45: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V45", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob()),
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V45", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());
return shouldExecute;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
import ca.bc.gov.educ.studentdatacollection.api.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudentValidationIssue;
Expand All @@ -30,9 +31,10 @@ public class AdultStudentInSummerSchoolRule implements ValidationBaseRule {
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) {
log.debug("In shouldExecute of AdultStudentInSummerSchoolRule-V54: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
studentRuleData.getSchool().getFacilityTypeCode().equalsIgnoreCase(FacilityTypeCodes.SUMMER.getCode()) &&
studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode()) && isValidationDependencyResolved("V54", validationErrorsMap);
return studentRuleData.getSchool().getFacilityTypeCode().equalsIgnoreCase(FacilityTypeCodes.SUMMER.getCode())
&& studentRuleData.getSchool().getSchoolCategoryCode().equalsIgnoreCase(SchoolCategoryCodes.PUBLIC.getCode())
&& studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V54", validationErrorsMap);
}
@Override
public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(StudentRuleData studentRuleData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolColl
log.debug("In shouldExecute of AdultStudentSupportBlockRule-V68: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

var shouldExecute = !studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V68", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());

log.debug("In shouldExecute of AdultStudentSupportBlockRule-V68: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V68", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob()),
shouldExecute,
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
!studentRuleData.getCollectionTypeCode().equalsIgnoreCase(CollectionTypeCodes.JULY.getTypeCode())
&& isValidationDependencyResolved("V68", validationErrorsMap)
&& DOBUtil.isAdult(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob());
return shouldExecute;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationFieldCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolFundingCodes;
import ca.bc.gov.educ.studentdatacollection.api.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
Expand Down Expand Up @@ -31,8 +30,7 @@ public class BandCodeFundingRule implements ValidationBaseRule {
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) {
log.debug("In shouldExecute of BandCodeFundingRule-V40: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent() &&
isValidationDependencyResolved("V40", validationErrorsMap);
return isValidationDependencyResolved("V40", validationErrorsMap);
}
@Override
public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(StudentRuleData studentRuleData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationFieldCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.rules.ValidationBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudentValidationIssue;
Expand Down Expand Up @@ -38,7 +37,7 @@ public class BirthDateRule implements ValidationBaseRule {
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) {
log.debug("In shouldExecute of BirthDateRule-V04: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , studentRuleData.getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
return CollectionTypeCodes.findByValue(studentRuleData.getCollectionTypeCode(), studentRuleData.getSchool().getSchoolCategoryCode()).isPresent();
return true;
}

@Override
Expand All @@ -52,7 +51,7 @@ public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(Student
} else {
try {
LocalDate dob = LocalDate.parse(studentRuleData.getSdcSchoolCollectionStudentEntity().getDob(), format);
LocalDate date = LocalDate.of(1900, Month.JANUARY, 01);
LocalDate date = LocalDate.of(1900, Month.JANUARY, 02);
if (dob.isAfter(LocalDate.now()) || dob.isBefore(date)) {
log.debug("BirthDateRule-V04: DOB - {} is either before 01-01-1900 or is in the future for sdcSchoolCollectionStudentID :: {}", dob, studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
errors.add(setValidationError());
Expand Down
Loading

0 comments on commit 0298c3a

Please sign in to comment.