Skip to content

Commit

Permalink
Merge pull request #449 from bcgov/feature/GRAD2-2336
Browse files Browse the repository at this point in the history
GRAD2-2336: task is completed.
  • Loading branch information
kamal-mohammed authored Sep 25, 2023
2 parents faceaa0 + fa0a0b6 commit fdd2c75
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
import java.util.List;
import java.util.stream.Collectors;

import ca.bc.gov.educ.api.ruleengine.dto.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ca.bc.gov.educ.api.ruleengine.dto.ProgramRequirement;
import ca.bc.gov.educ.api.ruleengine.dto.GradRequirement;
import ca.bc.gov.educ.api.ruleengine.dto.RuleData;
import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData;
import ca.bc.gov.educ.api.ruleengine.dto.StudentCourse;
import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down Expand Up @@ -54,6 +50,11 @@ public RuleData fire() {
return ruleProcessorData;
}

List<String> socialStudiesCourseCodeList = ruleProcessorData.getCourseRequirements().stream().filter(cr -> "502".equals(cr.getRuleCode().getCourseRequirementCode())).map(CourseRequirement::getCourseCode).toList();
if (socialStudiesCourseCodeList.isEmpty()) {
socialStudiesCourseCodeList = List.of(COURSE_CODE_SOCIAL_STUDIES);
}

for (ProgramRequirement gradProgramRule : gradProgramRules) {
requiredCredits = Integer.parseInt(gradProgramRule.getProgramRequirementCode().getRequiredCredits().trim()); // list

Expand All @@ -71,14 +72,12 @@ public RuleData fire() {

int courseFound = 0;
for (StudentCourse sc : tempStudentCourseList) {
/*
/*
Match course with grade level 12 or social studies grade level 11
The course also has to be one that's eligible to be counted towards electives
*/
if( (sc.getCourseLevel().contains(COURSE_LEVEL_12)
|| (sc.getCourseLevel().contains(COURSE_LEVEL_11)
&& sc.getCourseCode().contains(COURSE_CODE_SOCIAL_STUDIES))
)
|| (sc.getCourseLevel().contains(COURSE_LEVEL_11) && socialStudiesCourseCodeList.contains(sc.getCourseCode())) )
&& !sc.isNotEligibleForElective()
) {
courseFound++;
Expand Down Expand Up @@ -109,49 +108,49 @@ public RuleData fire() {
if(reqCourseFound) {
gradProgramRule.getProgramRequirementCode().setPassed(true);
List<GradRequirement> reqsMet = ruleProcessorData.getRequirementsMet();

if (reqsMet == null)
reqsMet = new ArrayList<>();

reqsMet.add(new GradRequirement(gradProgramRule.getProgramRequirementCode().getTraxReqNumber(), gradProgramRule.getProgramRequirementCode().getLabel(),gradProgramRule.getProgramRequirementCode().getProReqCode()));
ruleProcessorData.setRequirementsMet(reqsMet);
List<GradRequirement> delReqsMet = ruleProcessorData.getRequirementsMet();
if(delReqsMet != null)
delReqsMet.removeIf(e -> e.getRule() != null && e.getRule().compareTo("502") == 0);
}else {
ruleProcessorData.setGraduated(false);

List<GradRequirement> nonGradReasons = ruleProcessorData.getNonGradReasons();

if (nonGradReasons == null)
nonGradReasons = new ArrayList<>();

nonGradReasons.add(new GradRequirement(gradProgramRule.getProgramRequirementCode().getTraxReqNumber(), gradProgramRule.getProgramRequirementCode().getNotMetDesc(),gradProgramRule.getProgramRequirementCode().getProReqCode()));
ruleProcessorData.setNonGradReasons(nonGradReasons);
}

}else {
if (totalCredits >= requiredCredits) {
logger.debug("{} Passed",gradProgramRule.getProgramRequirementCode().getLabel());
gradProgramRule.getProgramRequirementCode().setPassed(true);
List<GradRequirement> reqsMet = ruleProcessorData.getRequirementsMet();

if (reqsMet == null)
reqsMet = new ArrayList<>();

reqsMet.add(new GradRequirement(gradProgramRule.getProgramRequirementCode().getTraxReqNumber(), gradProgramRule.getProgramRequirementCode().getLabel(),gradProgramRule.getProgramRequirementCode().getProReqCode()));
ruleProcessorData.setRequirementsMet(reqsMet);
logger.debug("Min Credits Elective 12 Rule: Total- {} Required- {}",totalCredits,requiredCredits);

} else {
logger.debug("{} Failed!",gradProgramRule.getProgramRequirementCode().getDescription());
ruleProcessorData.setGraduated(false);

List<GradRequirement> nonGradReasons = ruleProcessorData.getNonGradReasons();

if (nonGradReasons == null)
nonGradReasons = new ArrayList<>();

nonGradReasons.add(new GradRequirement(gradProgramRule.getProgramRequirementCode().getTraxReqNumber(), gradProgramRule.getProgramRequirementCode().getNotMetDesc(),gradProgramRule.getProgramRequirementCode().getProReqCode()));
ruleProcessorData.setNonGradReasons(nonGradReasons);
}
Expand Down

0 comments on commit fdd2c75

Please sign in to comment.