-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from bcgov/feature/EDX-2163
school aged indigenous support rule
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...studentdatacollection/api/rules/validationrules/impl/SchoolAgedIndigenousSupportRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package ca.bc.gov.educ.studentdatacollection.api.rules.validationrules.impl; | ||
|
||
import ca.bc.gov.educ.studentdatacollection.api.calculator.FteCalculatorUtils; | ||
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.EnrolledProgramCodes; | ||
import ca.bc.gov.educ.studentdatacollection.api.rules.ValidationBaseRule; | ||
import ca.bc.gov.educ.studentdatacollection.api.service.v1.ValidationRulesService; | ||
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData; | ||
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudentValidationIssue; | ||
import ca.bc.gov.educ.studentdatacollection.api.util.DOBUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* | ID | Severity | Rule | Dependent On | | ||
* |-----|----------|------------------------------------------------------------------------------|--------------| | ||
* | V77 | WARNING | Only school-aged students should be reported with Indigenous Support | V04, V30 | | ||
* Programs. | ||
* | ||
*/ | ||
@Component | ||
@Slf4j | ||
@Order(690) | ||
public class SchoolAgedIndigenousSupportRule implements ValidationBaseRule { | ||
private final ValidationRulesService validationRulesService; | ||
|
||
public SchoolAgedIndigenousSupportRule(ValidationRulesService validationRulesService) { | ||
this.validationRulesService = validationRulesService; | ||
} | ||
|
||
@Override | ||
public boolean shouldExecute(StudentRuleData studentRuleData, List<SdcSchoolCollectionStudentValidationIssue> validationErrorsMap) { | ||
log.debug("In shouldExecute of AdultIndigenousFundingRule-V77: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , FteCalculatorUtils.getCollectionTypeCode(studentRuleData), | ||
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); | ||
|
||
var shouldExecute = isValidationDependencyResolved("V77", validationErrorsMap); | ||
|
||
log.debug("In shouldExecute of AdultIndigenousFundingRule-V77: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" , | ||
shouldExecute, | ||
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); | ||
|
||
return shouldExecute; | ||
} | ||
|
||
@Override | ||
public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(StudentRuleData studentRuleData) { | ||
log.debug("In executeValidation of AdultIndigenousFundingRule-V77 for sdcSchoolCollectionStudentID ::" + studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); | ||
|
||
final List<SdcSchoolCollectionStudentValidationIssue> errors = new ArrayList<>(); | ||
var student = studentRuleData.getSdcSchoolCollectionStudentEntity(); | ||
List<String> studentPrograms = validationRulesService.splitString(student.getEnrolledProgramCodes()); | ||
|
||
log.debug("AdultIndigenousFundingRule-V77: Invalid age for Indigenous Support Programs for sdcSchoolCollectionStudentID:: {}", studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID()); | ||
if (EnrolledProgramCodes.getIndigenousProgramCodes().stream().anyMatch(studentPrograms::contains) | ||
&& DOBUtil.isAdult(student.getDob())) { | ||
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_PROGRAM_CODE, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT)); | ||
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.DOB, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT)); | ||
} | ||
|
||
return errors; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters