From 66e55a757731854851a780ffd36e5aab17c85802 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 18 Oct 2023 17:32:30 -0600 Subject: [PATCH 1/5] GRAD2-2366 HD-22692-P2 GRAD Incident: XML Previews no longer include Course/Assessment Registrations in GRAD/STS --- .../api/ruleengine/dto/StudentCourse.java | 61 ++++++++++++++++--- .../ruleengine/rule/AdultCPCoursesRule.java | 19 +++--- .../rule/AdultStudentGradeRule.java | 11 ++-- .../rule/AdultWorkExperienceRule.java | 33 ++++------ .../ruleengine/rule/AlgorithmSupportRule.java | 11 ++-- ...AssessmentDualDogwoodMatchCreditsRule.java | 1 - ...ssmentFrenchImmersionMatchCreditsRule.java | 1 - .../rule/AssessmentRegistrationsRule.java | 29 +++++---- .../rule/AssessmentsMatchCreditsRule.java | 11 ++-- .../api/ruleengine/rule/BAACoursesRule.java | 20 +++--- .../api/ruleengine/rule/CPCoursesRule.java | 12 ++-- .../rule/CareerProgramMatchRule.java | 28 ++++----- .../rule/DualDogwoodMatchCreditsRule.java | 1 - .../rule/DuplicateAssessmentsRule.java | 5 +- .../ruleengine/rule/DuplicateCoursesRule.java | 19 +++--- .../api/ruleengine/rule/EquivalencyRule.java | 46 +++++++------- .../rule/ExcludeAfterProgramCutoffRule.java | 4 +- .../rule/ExcludeGrade10LevelRule.java | 5 +- .../rule/ExcludeLess4CreditsCoursesRule.java | 7 +-- .../rule/ExcludeValidationCoursesRule.java | 5 +- .../rule/FailedAssessmentsRule.java | 20 +++--- .../ruleengine/rule/FailedCoursesRule.java | 22 +++---- .../rule/FrenchImmersionMatchRule.java | 1 - ...chImmersionMinElectiveCredits1986Rule.java | 10 ++- ...chImmersionMinElectiveCredits1996Rule.java | 10 ++- ...FrenchImmersionMinElectiveCreditsRule.java | 24 +++----- .../api/ruleengine/rule/IDSCoursesRule.java | 20 +++--- .../rule/IncompleteAssessmentsRule.java | 24 +++----- .../rule/IncompleteCoursesRule.java | 24 +++----- .../api/ruleengine/rule/LDCoursesRule.java | 11 ++-- .../rule/MainProgramCompleteRule.java | 6 +- .../ruleengine/rule/MatchCredit1986Rule.java | 14 ++--- .../ruleengine/rule/MatchCredit1996Rule.java | 12 ++-- .../api/ruleengine/rule/MatchCreditsRule.java | 12 ++-- .../rule/MatchIndigenousCreditsRule.java | 20 +++--- .../ruleengine/rule/MinAdultCoursesRule.java | 37 +++++------ .../ruleengine/rule/MinCredit1986Rule.java | 8 +-- .../ruleengine/rule/MinCredit1996Rule.java | 8 +-- .../rule/MinCreditsElective12OtherRule.java | 21 +++---- .../rule/MinCreditsElective12Rule.java | 27 +++----- .../api/ruleengine/rule/MinCreditsRule.java | 5 +- .../rule/MinElectiveCredits1986Rule.java | 8 +-- .../rule/MinElectiveCredits1996Rule.java | 9 +-- .../rule/MinElectiveCredits2023Rule.java | 6 +- .../MinElectiveCreditsFrench1996Rule.java | 6 +- .../rule/MinElectiveCreditsRule.java | 23 +++---- .../rule/OptionalProgramNoRule.java | 6 +- .../rule/ProgramCompletionDateRule.java | 25 ++++---- .../rule/RegistrationsDuplicateAssmtRule.java | 2 - .../rule/RegistrationsDuplicateCrseRule.java | 2 - .../rule/RegistrationsFailedCrseRule.java | 7 +-- .../ruleengine/rule/RegistrationsRule.java | 3 - .../rule/Remove2CreditCoursesRule.java | 7 +-- .../rule/RestrictedCoursesRule.java | 10 ++- .../educ/api/ruleengine/rule/RuleFactory.java | 6 +- .../ruleengine/service/RuleEngineService.java | 12 +++- .../util/RuleProcessorRuleUtils.java | 31 +++++----- 57 files changed, 368 insertions(+), 460 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java index 7418c5f9..d76e35a6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java @@ -84,15 +84,56 @@ public String getCourseLevel() { @Override public String toString() { - return "StudentCourse [pen=" + pen + ", courseCode=" + courseCode + ", courseName=" + courseName - + ", courseLevel=" + courseLevel + ", sessionDate=" + sessionDate + ", customizedCourseName=" - + customizedCourseName + ", gradReqMet=" + gradReqMet + ", gradReqMetDetail=" + gradReqMetDetail - + ", completedCoursePercentage=" + completedCoursePercentage + ", completedCourseLetterGrade=" - + completedCourseLetterGrade + ", interimPercent=" + interimPercent + ", interimLetterGrade=" - + interimLetterGrade + ", credits=" + credits + ", creditsUsedForGrad=" + creditsUsedForGrad - + ", relatedCourse=" + relatedCourse + ", relatedLevel=" + relatedLevel + ", hasRelatedCourse=" - + hasRelatedCourse + ", isNotCompleted=" + isNotCompleted + ", isProjected=" + isProjected - + ", isFailed=" + isFailed + ", isDuplicate=" + isDuplicate + ", isCareerPrep=" + isCareerPrep - + ", isLocallyDeveloped=" + isLocallyDeveloped + ", isUsed=" + isUsed + ", isRestricted=" + isRestricted +"]"; + return "StudentCourse{" + + "pen='" + pen + '\'' + + ", courseCode='" + courseCode + '\'' + + ", courseName='" + courseName + '\'' + + ", originalCredits=" + originalCredits + + ", courseLevel='" + courseLevel + '\'' + + ", sessionDate='" + sessionDate + '\'' + + ", customizedCourseName='" + customizedCourseName + '\'' + + ", gradReqMet='" + gradReqMet + '\'' + + ", gradReqMetDetail='" + gradReqMetDetail + '\'' + + ", completedCoursePercentage=" + completedCoursePercentage + + ", completedCourseLetterGrade='" + completedCourseLetterGrade + '\'' + + ", interimPercent=" + interimPercent + + ", interimLetterGrade='" + interimLetterGrade + '\'' + + ", bestSchoolPercent=" + bestSchoolPercent + + ", bestExamPercent=" + bestExamPercent + + ", schoolPercent=" + schoolPercent + + ", examPercent=" + examPercent + + ", equivOrChallenge='" + equivOrChallenge + '\'' + + ", fineArtsAppliedSkills='" + fineArtsAppliedSkills + '\'' + + ", metLitNumRequirement='" + metLitNumRequirement + '\'' + + ", credits=" + credits + + ", creditsUsedForGrad=" + creditsUsedForGrad + + ", relatedCourse='" + relatedCourse + '\'' + + ", relatedCourseName='" + relatedCourseName + '\'' + + ", relatedLevel='" + relatedLevel + '\'' + + ", hasRelatedCourse='" + hasRelatedCourse + '\'' + + ", isNotCompleted=" + isNotCompleted + + ", genericCourseType='" + genericCourseType + '\'' + + ", language='" + language + '\'' + + ", workExpFlag='" + workExpFlag + '\'' + + ", specialCase='" + specialCase + '\'' + + ", toWriteFlag='" + toWriteFlag + '\'' + + ", provExamCourse='" + provExamCourse + '\'' + + ", isProjected=" + isProjected + + ", isFailed=" + isFailed + + ", isDuplicate=" + isDuplicate + + ", isCareerPrep=" + isCareerPrep + + ", isLocallyDeveloped=" + isLocallyDeveloped + + ", isBoardAuthorityAuthorized=" + isBoardAuthorityAuthorized + + ", isIndependentDirectedStudies=" + isIndependentDirectedStudies + + ", isUsed=" + isUsed + + ", isRestricted=" + isRestricted + + ", isNotEligibleForElective=" + isNotEligibleForElective + + ", isUsedInMatchRule=" + isUsedInMatchRule + + ", isLessCreditCourse=" + isLessCreditCourse + + ", isValidationCourse=" + isValidationCourse + + ", isCutOffCourse=" + isCutOffCourse + + ", isGrade10Course=" + isGrade10Course + + ", leftOverCredits=" + leftOverCredits + + '}'; } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultCPCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultCPCoursesRule.java index 16899f2f..de46affd 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultCPCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultCPCoursesRule.java @@ -1,19 +1,19 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.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.RuleEngineApiUtils; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; @Data @Component @@ -32,8 +32,6 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding CAREER PROGRAM courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { boolean isCPWEExceptionCourse = studentCourse.getCourseCode().equalsIgnoreCase("CPWE") && studentCourse.getCourseLevel().contains("12"); if (studentCourse.getCourseCode().startsWith("CP") @@ -43,7 +41,7 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("AdultCPCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Career Program Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isCareerPrep).count()); @@ -54,6 +52,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AdultCPCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java index faa7a664..33186bd6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java @@ -1,6 +1,9 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.dto.GradRequirement; +import ca.bc.gov.educ.api.ruleengine.dto.ProgramRequirement; +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.util.RuleProcessorUtils; import lombok.AllArgsConstructor; import lombok.Data; @@ -12,7 +15,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -31,13 +33,13 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "SG".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0) - .collect(Collectors.toList()); + .toList(); if (RuleProcessorUtils.isNotEmptyOrNull(gradProgramRules)) { logger.debug("#Checking SG Rule"); for (ProgramRequirement gradProgramRule : gradProgramRules) { - logger.debug("StudentGrade:" + ruleProcessorData.getGradStudent().getStudentGrade()); + logger.debug("StudentGrade: {}", ruleProcessorData.getGradStudent().getStudentGrade()); if ("AD".compareTo(ruleProcessorData.getGradStudent().getStudentGrade()) != 0) { gradProgramRule.getProgramRequirementCode().setPassed(false); @@ -63,6 +65,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AdultStudentGradeRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java index 4f5bbab9..aaa357c5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java @@ -1,28 +1,20 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.stream.Collectors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import ca.bc.gov.educ.api.ruleengine.dto.CourseRequirement; -import ca.bc.gov.educ.api.ruleengine.dto.GradRequirement; -import ca.bc.gov.educ.api.ruleengine.dto.ProgramRequirement; -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.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; @Data @Component @@ -56,7 +48,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MWEX".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); List finalCourseList = new ArrayList<>(); for (ProgramRequirement gradProgramRule : gradProgramRules) { @@ -72,7 +64,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("Temp Course Requirement: {}",tempCourseRequirement); @@ -116,7 +108,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AdultWorkExperienceRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java index b8890ac4..bcabe95e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java @@ -280,11 +280,12 @@ public static void copyAndAddIntoOptionalProgramRulesList(OptionalProgramRequire public static void copyAndAddIntoStudentCoursesList(StudentCourse studentCourse, List finalCourseList, ObjectMapper objectMapper) { try { - StudentCourse tempSC = objectMapper.readValue(objectMapper.writeValueAsString(studentCourse), StudentCourse.class); - if (tempSC != null) - finalCourseList.add(tempSC); - logger.debug("TempSC: {}", tempSC); - logger.debug("Final course List size: {}: ", finalCourseList.size()); + StudentCourse studentCourseTmp = objectMapper.readValue(objectMapper.writeValueAsString(studentCourse), StudentCourse.class); + if (studentCourseTmp != null) { + finalCourseList.add(studentCourseTmp); + logger.debug("Added Student Course: {}", studentCourseTmp); + } + logger.debug("Final Student Course List size: {}", finalCourseList.size()); } catch (IOException e) { logger.error(ERROR_FORMAT_STR,e.getMessage()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentDualDogwoodMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentDualDogwoodMatchCreditsRule.java index 9cf17b16..125da4b3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentDualDogwoodMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentDualDogwoodMatchCreditsRule.java @@ -40,7 +40,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AssessmentDualDogwoodMatchCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentFrenchImmersionMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentFrenchImmersionMatchCreditsRule.java index 2ca24466..349a78a6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentFrenchImmersionMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentFrenchImmersionMatchCreditsRule.java @@ -40,7 +40,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AssessmentFrenchImmersionMatchCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentRegistrationsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentRegistrationsRule.java index 7146245d..c9661137 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentRegistrationsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentRegistrationsRule.java @@ -1,21 +1,23 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.text.ParseException; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.dto.OptionalProgramRuleProcessor; +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.StudentAssessment; +import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; 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.util.RuleEngineApiUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import java.text.ParseException; +import java.util.Date; +import java.util.List; +import java.util.Map; @Data @Component @@ -33,8 +35,6 @@ public RuleData fire() { List studentAssessmentList = RuleProcessorRuleUtils.getUniqueStudentAssessments(ruleProcessorData.getStudentAssessments(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding PROJECTED assessments (For Projected GRAD) ######################"); - for (StudentAssessment studentAssessment : studentAssessmentList) { String today = RuleEngineApiUtils.formatDate(new Date(), "yyyy-MM-dd"); String sessionDate = studentAssessment.getSessionDate() + "/01"; @@ -42,7 +42,7 @@ public RuleData fire() { Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { - logger.error("ERROR: {0}", pe.getMessage()); + logger.error("ERROR: {}", pe.getMessage()); } int diff = RuleEngineApiUtils.getDifferenceInMonths(sessionDate, today); @@ -75,7 +75,7 @@ public RuleData fire() { ruleProcessorData.setExcludedAssessments(RuleProcessorRuleUtils.maintainExcludedAssessments(studentAssessmentList,ruleProcessorData.getExcludedAssessments(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentAssessments(studentAssessmentList); - logger.debug("Projected Assessments (Registrations): {0} ",(int) studentAssessmentList.stream().filter(StudentAssessment::isProjected).count()); + logger.debug("Projected Assessments (Registrations): {} ",(int) studentAssessmentList.stream().filter(StudentAssessment::isProjected).count()); prepareAssessmentForOptionalPrograms(); return ruleProcessorData; } @@ -89,6 +89,5 @@ private void prepareAssessmentForOptionalPrograms() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AssessmentRegistrationsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java index 64bb1bb9..2526392a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; - import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; @@ -15,7 +14,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -40,7 +38,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (ruleProcessorData.getStudentAssessments() == null || ruleProcessorData.getStudentAssessments().isEmpty()) { logger.warn("!!!Empty list sent to Assessment Match Rule for processing"); @@ -62,7 +60,7 @@ public RuleData fire() { List tempAssessmentRequirement = assessmentRequirements.stream() .filter(ar -> tempAssessment.getAssessmentCode().compareTo(ar.getAssessmentCode()) == 0) - .collect(Collectors.toList()); + .toList(); ProgramRequirement tempProgramRule = null; @@ -92,7 +90,7 @@ public RuleData fire() { .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .collect(Collectors.toList())); + .toList()); logger.debug("Final Program rules list size 2: {}",finalProgramRulesList.size()); ruleProcessorData.setStudentAssessments(finalAssessmentList); @@ -118,7 +116,7 @@ private void processReqMetAndNotMet(List finalProgramRulesLi } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -167,7 +165,6 @@ private void processAssessments(List tempAssessmentRequir @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("AssessmentsMatchCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BAACoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BAACoursesRule.java index 451021fa..a34b1d5c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BAACoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BAACoursesRule.java @@ -1,19 +1,18 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.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; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; @Data @Component @@ -32,15 +31,13 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding Board/Authority Authorized (BAA) courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { if (studentCourse.getCourseCode().startsWith("Y")) { studentCourse.setBoardAuthorityAuthorized(true); } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("BAACoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Board/Authority Authorized: {}",(int) studentCourseList.stream().filter(StudentCourse::isBoardAuthorityAuthorized).count()); @@ -51,6 +48,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("BAACoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CPCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CPCoursesRule.java index 3254979e..cb220f6f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CPCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CPCoursesRule.java @@ -1,5 +1,8 @@ package ca.bc.gov.educ.api.ruleengine.rule; +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; @@ -9,10 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -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 java.util.List; @Data @@ -32,15 +31,13 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding CAREER PROGRAM courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { if (studentCourse.getCourseCode().startsWith("CP")) { studentCourse.setCareerPrep(true); } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("CPCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Career Program Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isCareerPrep).count()); @@ -51,6 +48,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("CPCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java index ec911e86..3d5085a3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java @@ -1,24 +1,21 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -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 com.fasterxml.jackson.databind.ObjectMapper; - import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; @Data @Component @@ -48,7 +45,7 @@ public RuleData fire() { .filter(gradOptionalProgramRule -> "M".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("#### Career Program Rule size: {}", careerProgramRulesMatch.size()); @@ -108,7 +105,7 @@ public RuleData fire() { obj.setRequirementsMetOptionalProgram(resMet); List failedRules = careerProgramRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the Career Program Match rules met!"); @@ -134,7 +131,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("CareerProgramMatchRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DualDogwoodMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DualDogwoodMatchCreditsRule.java index 0f9d38af..1883c140 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DualDogwoodMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DualDogwoodMatchCreditsRule.java @@ -39,7 +39,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("DualDogwoodMatchCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DuplicateAssessmentsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DuplicateAssessmentsRule.java index 268c0309..ecffe039 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DuplicateAssessmentsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/DuplicateAssessmentsRule.java @@ -31,8 +31,6 @@ public class DuplicateAssessmentsRule implements Rule { @Override public RuleData fire() { - logger.debug("###################### Finding DUPLICATE Assessments ######################"); - List studentAssessmentList = RuleProcessorRuleUtils.getUniqueStudentAssessments(ruleProcessorData.getStudentAssessments(),ruleProcessorData.isProjected()); getModifiedAndSortedData(studentAssessmentList); @@ -79,7 +77,7 @@ public RuleData fire() { ruleProcessorData.setExcludedAssessments(RuleProcessorRuleUtils.maintainExcludedAssessments(studentAssessmentList,ruleProcessorData.getExcludedAssessments(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentAssessments(studentAssessmentList); - logger.debug("Duplicate Assessments: {0}", + logger.debug("Duplicate Assessments: {}", (int) studentAssessmentList.stream().filter(StudentAssessment::isDuplicate).count()); if(ruleProcessorData.getGradProgram().getProgramCode().equalsIgnoreCase("SCCP") || ruleProcessorData.getGradProgram().getProgramCode().equalsIgnoreCase("1950") @@ -151,6 +149,5 @@ public void compareSpecialCases(char specialCase1, char specialCase2, List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); for (int i = 0; i < studentCourseList.size() - 1; i++) { @@ -60,7 +58,7 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("DuplicateCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Duplicate Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isDuplicate).count()); return ruleProcessorData; @@ -80,6 +78,5 @@ private void compareSessionDates(List studentCourseList, int i, i @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("DuplicateCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java index aaa25c3f..a18bd9d6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Data @Component @@ -52,7 +51,7 @@ private void handleProgramRulesForAssessmentEquivalency() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("Matched Program rules list size {}", gradProgramRulesMatch.size()); // 1. check assessment is empty or failed @@ -72,7 +71,7 @@ private void handleProgramRulesForAssessmentEquivalency() { List matchedCourseRequirements = courseRequirementsForEquivalency.stream() .filter(equivCr -> equivCr.getCourseCode().compareTo(st.getCourseCode()) == 0 && equivCr.getCourseLevel().compareTo(st.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); matchedCourseRequirements.stream().forEach(courseRequirement -> { ProgramRequirement programRule = null; if (courseRequirement != null) { @@ -95,7 +94,7 @@ private void handleProgramRulesForAssessmentEquivalency() { // merge studentAssessments with finalAssessmentList // => if any of finalAssessments already exists in studentAssessments, remove the current one and add the new one. List tempAssessments = ruleProcessorData.getStudentAssessments().stream() - .filter(sa -> !finalAssessmentList.contains(sa)).collect(Collectors.toList()); + .filter(sa -> !finalAssessmentList.contains(sa)).toList(); tempAssessments.addAll(finalAssessmentList); ruleProcessorData.setStudentAssessments(tempAssessments); } @@ -105,7 +104,7 @@ private void handleProgramRulesForAssessmentEquivalency() { .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .collect(Collectors.toList())); + .toList()); ruleProcessorData.setGradProgramRules(finalProgramRulesList); } @@ -113,7 +112,7 @@ private void handleProgramRulesForAssessmentEquivalency() { private void handleFailedRules(List finalProgramRulesList, List requirementsMet, List gradProgramRulesMatch) { List successfulRules = finalProgramRulesList.stream() .filter(pr -> pr.getProgramRequirementCode().isPassed()) - .collect(Collectors.toList()); + .toList(); if(gradProgramRulesMatch.size() != finalProgramRulesList.size()) { List unusedRules = RuleEngineApiUtils.getCloneProgramRule(gradProgramRulesMatch); @@ -122,7 +121,7 @@ private void handleFailedRules(List finalProgramRulesList, L } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the failed assessment match rules met the assessment equivalency requirement!"); @@ -135,9 +134,9 @@ private void handleFailedRules(List finalProgramRulesList, L // if any failed assessments from the previous processors meet the assessment equivalency requirement, // then remove it from nonGradReason. if (!successfulRules.isEmpty()) { - List successfulRuleCodes = successfulRules.stream().map(pr -> pr.getProgramRequirementCode().getProReqCode()).collect(Collectors.toList()); + List successfulRuleCodes = successfulRules.stream().map(pr -> pr.getProgramRequirementCode().getProReqCode()).toList(); List nonGradReasons = ruleProcessorData.getNonGradReasons().stream() - .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).collect(Collectors.toList()); + .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).toList(); ruleProcessorData.setNonGradReasons(nonGradReasons); } @@ -191,7 +190,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram .filter(gradOptionalProgramRule -> "M".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); // 1. check assessment is empty or failed List studentAssessments = RuleProcessorRuleUtils.getUniqueStudentAssessments( @@ -212,7 +211,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram List matchedCourseRequirements = courseRequirementsForEquivalency.stream() .filter(equivCr -> equivCr.getCourseCode().compareTo(st.getCourseCode()) == 0 && equivCr.getCourseLevel().compareTo(st.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); matchedCourseRequirements.stream().forEach(courseRequirement -> { OptionalProgramRequirement optionalProgramRule = null; if (courseRequirement != null) { @@ -235,7 +234,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram // merge studentAssessments with finalAssessmentList // => if any of finalAssessments already exists in studentAssessments, remove the current one and add the new one. List tempAssessments = obj.getStudentAssessmentsOptionalProgram().stream() - .filter(sa -> !finalAssessmentList.contains(sa)).collect(Collectors.toList()); + .filter(sa -> !finalAssessmentList.contains(sa)).toList(); tempAssessments.addAll(finalAssessmentList); obj.setStudentAssessmentsOptionalProgram(tempAssessments); } @@ -245,7 +244,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram .stream() .filter(optionalProgramRule -> "M".compareTo(optionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(optionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) != 0) - .collect(Collectors.toList())); + .toList()); obj.setOptionalProgramRules(finalOptionalProgramRulesList); } @@ -261,7 +260,7 @@ private void processAssessmentEquivalencyOptionalProgram(StudentCourse studentCo private void handleFailedRules(OptionalProgramRuleProcessor obj, List finalOptionalProgramRulesList, List requirementsMet, List gradOptionalProgramRulesMatch) { List successfulRules = finalOptionalProgramRulesList.stream() .filter(opr -> opr.getOptionalProgramRequirementCode().isPassed()) - .collect(Collectors.toList()); + .toList(); if(gradOptionalProgramRulesMatch.size() != finalOptionalProgramRulesList.size()) { List unusedRules = RuleEngineApiUtils.getCloneOptionalProgramRule(gradOptionalProgramRulesMatch); @@ -270,7 +269,7 @@ private void handleFailedRules(OptionalProgramRuleProcessor obj, List failedRules = finalOptionalProgramRulesList.stream() - .filter(opr -> !opr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(opr -> !opr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the failed assessment match rules met the assessment equivalency requirement for optional program!"); @@ -283,9 +282,9 @@ private void handleFailedRules(OptionalProgramRuleProcessor obj, List successfulRuleCodes = successfulRules.stream().map(opr -> opr.getOptionalProgramRequirementCode().getOptProReqCode()).collect(Collectors.toList()); + List successfulRuleCodes = successfulRules.stream().map(opr -> opr.getOptionalProgramRequirementCode().getOptProReqCode()).toList(); List nonGradReasons = obj.getNonGradReasonsOptionalProgram().stream() - .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).collect(Collectors.toList()); + .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).toList(); obj.setNonGradReasonsOptionalProgram(nonGradReasons); } @@ -309,14 +308,14 @@ private List getCourseRequirementsForAssessmentEquivalency(Li // Rule# 115,116,118,303,304 List failedRuleCodes = gradProgramRulesMatch .stream() - .filter((pr -> !pr.getProgramRequirementCode().isPassed())).collect(Collectors.toList()) + .filter((pr -> !pr.getProgramRequirementCode().isPassed())).toList() .stream() - .map(fr -> fr.getProgramRequirementCode().getProReqCode()).collect(Collectors.toList()); + .map(fr -> fr.getProgramRequirementCode().getProReqCode()).toList(); return courseRequirements .stream() .filter(cr -> failedRuleCodes.contains(cr.getRuleCode().getCourseRequirementCode())) - .collect(Collectors.toList()); + .toList(); } private List getCourseRequirementsForAssessmentsEquivalency(List gradOptionalProgramRulesMatch) { @@ -328,14 +327,14 @@ private List getCourseRequirementsForAssessmentsEquivalency(L // Rule# 203, 403, 404 List failedRuleCodes = gradOptionalProgramRulesMatch .stream() - .filter((opr -> !opr.getOptionalProgramRequirementCode().isPassed())).collect(Collectors.toList()) + .filter((opr -> !opr.getOptionalProgramRequirementCode().isPassed())).toList() .stream() - .map(fr -> fr.getOptionalProgramRequirementCode().getOptProReqCode()).collect(Collectors.toList()); + .map(fr -> fr.getOptionalProgramRequirementCode().getOptProReqCode()).toList(); return courseRequirements .stream() .filter(cr -> failedRuleCodes.contains(cr.getRuleCode().getCourseRequirementCode())) - .collect(Collectors.toList()); + .toList(); } private boolean validateAssessmentsEmptyOrFailed(List gradProgramRulesMatch, List studentAssessments) { @@ -361,6 +360,5 @@ private boolean validateAssessmentsEmptyOrFailedForOptionalProgram(List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding Course Taken after program cutoff courses ######################"); if(ruleProcessorData.getGradProgram().getExpiryDate() == null) { return ruleProcessorData; } @@ -54,7 +53,7 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("ExcludeAfterProgramCutoffRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Cut-off Courses: {}", @@ -69,6 +68,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("ExcludeAfterProgramCutoffRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeGrade10LevelRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeGrade10LevelRule.java index 455fe5f1..fc6922a5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeGrade10LevelRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeGrade10LevelRule.java @@ -31,15 +31,13 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding CAREER PROGRAM courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { if (studentCourse.getCourseLevel().compareTo("10")==0) { studentCourse.setGrade10Course(true); } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("ExcludeGrade10LevelRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Grade Level 10 Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isGrade10Course).count()); @@ -50,6 +48,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("ExcludeGrade10LevelRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeLess4CreditsCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeLess4CreditsCoursesRule.java index c756bbc7..d54737d9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeLess4CreditsCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeLess4CreditsCoursesRule.java @@ -28,8 +28,6 @@ public class ExcludeLess4CreditsCoursesRule implements Rule { @Override public RuleData fire() { - logger.debug("###################### Finding 2 Credit Courses ######################"); - List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); @@ -40,10 +38,10 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("ExcludeLess4CreditsCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); - logger.debug( "Removed 2 Credit Courses: {0} ", + logger.debug( "Removed 2 Credit Courses: {} ", (int) studentCourseList.stream().filter(StudentCourse::isLessCreditCourse).count()); return ruleProcessorData; @@ -52,6 +50,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("ExcludeLess4CreditsCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java index 4ce428f6..d4af81cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java @@ -31,8 +31,6 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - logger.debug("###################### Finding CAREER PROGRAM courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { String sessionDate = studentCourse.getSessionDate() + "/01"; String cName = studentCourse.getCourseCode()+studentCourse.getCourseLevel(); @@ -43,7 +41,7 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("ExcludeValidationCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Validation Courses: {}", @@ -58,6 +56,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("ExcludeValidationCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedAssessmentsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedAssessmentsRule.java index c831b292..3e6a3c97 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedAssessmentsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedAssessmentsRule.java @@ -1,19 +1,18 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.RuleData; import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData; import ca.bc.gov.educ.api.ruleengine.dto.StudentAssessment; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; @Data @Component @@ -31,8 +30,6 @@ public RuleData fire() { List studentAssessmentList = RuleProcessorRuleUtils.getUniqueStudentAssessments(ruleProcessorData.getStudentAssessments(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding FAILED assessments ######################"); - for (StudentAssessment studentAssessment : studentAssessmentList) { boolean failed = ruleProcessorData.getSpecialCaseList().stream() @@ -58,7 +55,7 @@ public RuleData fire() { ruleProcessorData.setExcludedAssessments(RuleProcessorRuleUtils.maintainExcludedAssessments(studentAssessmentList,ruleProcessorData.getExcludedAssessments(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentAssessments(studentAssessmentList); - logger.debug("Failed Assessments: {0}", + logger.debug("Failed Assessments: {}", (int) studentAssessmentList.stream().filter(StudentAssessment::isFailed).count()); return ruleProcessorData; @@ -66,6 +63,5 @@ public RuleData fire() { public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FailedAssessmentsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedCoursesRule.java index 47413f37..b07de924 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FailedCoursesRule.java @@ -1,19 +1,18 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.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; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; @Data @Component @@ -31,8 +30,6 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding FAILED courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { String finalLetterGrade = studentCourse.getCompletedCourseLetterGrade(); if(finalLetterGrade != null) { @@ -44,10 +41,10 @@ public RuleData fire() { studentCourse.setFailed(true); } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("FailedCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); - logger.debug("Failed Courses: {0} ", + logger.debug("Failed Courses: {} ", (int) studentCourseList.stream().filter(StudentCourse::isFailed).count()); return ruleProcessorData; @@ -55,6 +52,5 @@ public RuleData fire() { public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FailedCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMatchRule.java index 5a1017c4..8a3595ae 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMatchRule.java @@ -40,7 +40,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FrenchImmersionMatchRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java index ccf0949b..bdcdcbde 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java @@ -12,7 +12,6 @@ import org.springframework.stereotype.Component; import java.util.*; -import java.util.stream.Collectors; @Data @Component @@ -39,12 +38,12 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); ObjectMapper objectMapper = new ObjectMapper(); - List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList())); + List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList()); List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); @@ -74,10 +73,10 @@ public RuleProcessorData fire() { resMet.addAll(requirementsMet); obj.setRequirementsMetOptionalProgram(resMet); - finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).collect(Collectors.toList())); + finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).toList()); obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); @@ -134,7 +133,6 @@ public int processCredits(OptionalProgramRequirement pR, int totalCredits, Stude @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FrenchImmersionMinElectiveCredits1986Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java index 1f90a516..17278387 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java @@ -12,7 +12,6 @@ import org.springframework.stereotype.Component; import java.util.*; -import java.util.stream.Collectors; @Data @Component @@ -39,12 +38,12 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); ObjectMapper objectMapper = new ObjectMapper(); - List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList())); + List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList()); List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); @@ -74,10 +73,10 @@ public RuleProcessorData fire() { resMet.addAll(requirementsMet); obj.setRequirementsMetOptionalProgram(resMet); - finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).collect(Collectors.toList())); + finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).toList()); obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); @@ -134,7 +133,6 @@ public int processCredits(OptionalProgramRequirement pR, int totalCredits, Stude @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FrenchImmersionMinElectiveCreditRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java index b4cb7896..0f4d51d0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java @@ -1,21 +1,18 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.*; -import java.util.stream.Collectors; - import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.databind.ObjectMapper; - -import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import java.util.*; @Data @Component @@ -47,7 +44,7 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); List finalCourseList = new ArrayList<>(); @@ -56,9 +53,9 @@ public RuleProcessorData fire() { List matchedList = courseList .stream() .filter(StudentCourse::isUsed) - .collect(Collectors.toList()); + .toList(); - List modifiedList = courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList()); + List modifiedList = courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList(); ListIterator studentCourseIterator = modifiedList.listIterator(); int totalCredits = 0; int requiredCredits = 0; @@ -129,7 +126,7 @@ public RuleProcessorData fire() { obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); @@ -186,7 +183,6 @@ public int processCredits(OptionalProgramRequirement pR, int totalCredits, Stude @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("FrenchImmersionMinElectiveCreditRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IDSCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IDSCoursesRule.java index 7c85fb43..af63ad08 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IDSCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IDSCoursesRule.java @@ -1,19 +1,18 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.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; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; @Data @Component @@ -31,15 +30,13 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding Independent Directed Studies (IDS) courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { if (studentCourse.getCourseCode().startsWith("IDS")) { studentCourse.setIndependentDirectedStudies(true); } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("IDSCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Independent Directed Studies Courses: {}", (int) studentCourseList.stream().filter(StudentCourse::isIndependentDirectedStudies).count()); @@ -50,6 +47,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("IDSCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteAssessmentsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteAssessmentsRule.java index cfcb832a..4bcdcccd 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteAssessmentsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteAssessmentsRule.java @@ -1,22 +1,21 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.text.ParseException; -import java.util.Date; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.RuleData; import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData; import ca.bc.gov.educ.api.ruleengine.dto.StudentAssessment; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.util.Date; +import java.util.List; @Data @Component @@ -32,9 +31,7 @@ public RuleData fire() { List studentAssessmentList = RuleProcessorRuleUtils.getUniqueStudentAssessments(ruleProcessorData.getStudentAssessments(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding INCOMPLETE Assessments ######################"); - - for (StudentAssessment studentAssessment : studentAssessmentList) { + for (StudentAssessment studentAssessment : studentAssessmentList) { String today = RuleEngineApiUtils.formatDate(new Date(), "yyyy-MM-dd"); String sessionDate = studentAssessment.getSessionDate() + "/01"; try { @@ -82,6 +79,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("IncompleteAssessmentsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java index ad5cebdc..77fe8941 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java @@ -1,22 +1,21 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.text.ParseException; -import java.util.Date; -import java.util.List; - -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -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.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.RuleEngineApiUtils; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.util.Date; +import java.util.List; @Data @Component @@ -32,8 +31,6 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding INCOMPLETE courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { String today = RuleEngineApiUtils.formatDate(new Date(), "yyyy-MM-dd"); String sessionDate = studentCourse.getSessionDate() + "/01"; @@ -56,7 +53,7 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("IncompleteCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Not Completed Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isNotCompleted).count()); return ruleProcessorData; @@ -65,6 +62,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("IncompleteCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/LDCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/LDCoursesRule.java index ab56509b..6a0e8644 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/LDCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/LDCoursesRule.java @@ -1,5 +1,8 @@ package ca.bc.gov.educ.api.ruleengine.rule; +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; @@ -9,9 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -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 java.util.List; @Data @@ -30,14 +30,12 @@ public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding LOCALLY DEVELOPED courses ######################"); - for (StudentCourse studentCourse : studentCourseList) { if (studentCourse.getCourseCode().startsWith("X")) studentCourse.setLocallyDeveloped(true); } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("LDCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Locally Developed Courses: {}",(int) studentCourseList.stream().filter(StudentCourse::isLocallyDeveloped) .count()); @@ -48,6 +46,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("LDCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java index c07bdba6..aac22976 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Data @Component @@ -45,7 +44,7 @@ private void processMainProgramCompleteRules(List nonGradReason .stream() .filter(gradOptionalProgramRule -> "SR".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0) - .collect(Collectors.toList()); + .toList(); for(OptionalProgramRequirement opReq:optionalProgramNoRule) { if(opReq.getOptionalProgramRequirementCode().getOptProReqCode().compareTo("957")==0) { if (nonGradReasons == null || nonGradReasons.isEmpty()) { @@ -56,7 +55,7 @@ private void processMainProgramCompleteRules(List nonGradReason opReq.getOptionalProgramRequirementCode().setPassed(false); } List failedRules = obj.getOptionalProgramRules().stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -87,6 +86,5 @@ private void processMainProgramCompleteRules(List nonGradReason @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MainProgramCompleteRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java index 9318dafa..e3502120 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java @@ -12,8 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; @Data @Component @@ -41,7 +42,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Credit 1986 Rule for processing"); @@ -69,7 +70,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("Temp Course Requirement: {}", tempCourseRequirement); @@ -130,7 +131,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis }); List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -155,7 +156,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(ruleProcessorData.getGradProgramRules() .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0 || "4".compareTo(gradProgramRule.getProgramRequirementCode().getRequiredCredits()) != 0) - .collect(Collectors.toList())); + .toList()); logger.debug("Final Program rules list size 2: {}",finalProgramRulesList.size()); @@ -196,7 +197,6 @@ public void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement te @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MatchCredit1986Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java index 667b2063..e7854a1d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java @@ -14,7 +14,6 @@ import org.springframework.stereotype.Component; import java.util.*; -import java.util.stream.Collectors; @Data @Component @@ -46,7 +45,7 @@ public RuleData fire() { .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()) .stream().filter(studentCourse -> studentCourse.getFineArtsAppliedSkills() != null && studentCourse.getFineArtsAppliedSkills().length() > 0) - .collect(Collectors.toList()); + .toList(); fineArtsCourseList.sort(Comparator.comparing(StudentCourse::getCourseLevel) .thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder())); @@ -54,7 +53,7 @@ public RuleData fire() { .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()) .stream().filter(studentCourse -> studentCourse.getFineArtsAppliedSkills() == null || studentCourse.getFineArtsAppliedSkills().length() <= 0) - .collect(Collectors.toList()); + .toList(); courseList.sort(Comparator.comparing(StudentCourse::getCourseLevel) .thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder())); @@ -63,7 +62,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Credit 1996 Rule for processing"); @@ -89,7 +88,7 @@ public RuleData fire() { List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("Temp Course Requirement: {}", tempCourseRequirements); @@ -140,7 +139,7 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode()) List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("Temp Course Requirement: {}", tempCourseRequirements); @@ -357,6 +356,5 @@ private boolean isFineArtsOrAppliedSkillsRule(String programRequirementCode) { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("Match4Credit1996Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java index 38da33f0..63fe3ed0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java @@ -14,7 +14,6 @@ import java.text.ParseException; import java.util.*; -import java.util.stream.Collectors; @Data @Component @@ -64,7 +63,7 @@ public RuleData fire() { && (LA2_REQNO_1950.compareTo(gradProgramRule.getProgramRequirementCode().getTraxReqNumber()) == 0 || MA11_MA12_REQNO_1950.compareTo(gradProgramRule.getProgramRequirementCode().getTraxReqNumber()) == 0) ) - .collect(Collectors.toList()); + .toList(); processRule(courseList, gradProgramRulesMatch, requirementsMet, requirementsNotMet); splitSortStudentCourses(courseList, ruleProcessorData.getGradStatus().getAdultStartDate()); @@ -75,7 +74,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); processRule(courseList, gradProgramRulesMatch, requirementsMet, requirementsNotMet); } @@ -104,7 +103,7 @@ private void processRule(List courseList, List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); ProgramRequirement tempProgramRule = null; @@ -210,7 +209,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(unusedRules); } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -235,7 +234,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(ruleProcessorData.getGradProgramRules() .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .collect(Collectors.toList())); + .toList()); ruleProcessorData.setStudentCourses(finalCourseList); ruleProcessorData.setGradProgramRules(finalProgramRulesList); @@ -286,7 +285,6 @@ public void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement te @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MatchRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java index 43fc8ab1..ac2b6582 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java @@ -13,7 +13,6 @@ import org.springframework.stereotype.Component; import java.util.*; -import java.util.stream.Collectors; @Data @Component @@ -39,7 +38,7 @@ public RuleData fire() { .filter(gradProgramRule -> "MI".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (courseList == null || courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Indigenous Credits Rule for processing"); @@ -64,7 +63,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); ProgramRequirement tempProgramRule = null; @@ -102,7 +101,7 @@ private void processCourse(StudentCourse tempCourse, List tem && rm.getRule().equals(finalTempProgramRule.getProgramRequirementCode().getProReqCode())) .findAny() .orElse(null) == null) { - setDetailsForCourses(tempCourse, tempProgramRule, requirementsMet, gradProgramRulesMatch, null, courseCreditException); + setDetailsForCourses(tempCourse, tempProgramRule, requirementsMet, courseCreditException); } else { logger.debug("!!! Program Rule met Already: {}", tempProgramRule); } @@ -119,8 +118,7 @@ private void processCourse(StudentCourse tempCourse, List tem .findAny() .orElse(null); if (tempProgramRule != null) { - setDetailsForCourses(tempCourse, tempProgramRule, requirementsMet, gradProgramRulesMatch, - "ExceptionalCase", courseCreditException); + setDetailsForCourses(tempCourse, tempProgramRule, requirementsMet, courseCreditException); } } } @@ -137,7 +135,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(unusedRules); } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -165,7 +163,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis .filter(gradProgramRule -> "MI".compareTo(gradProgramRule.getProgramRequirementCode() .getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .collect(Collectors.toList())); + .toList()); ruleProcessorData.setStudentCourses(finalCourseList); ruleProcessorData.setGradProgramRules(finalProgramRulesList); @@ -180,9 +178,8 @@ public void processReqMetAndNotMet(List finalProgramRulesLis ruleProcessorData.setRequirementsMet(reqsMet); } - public void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement tempProgramRule, - List requirementsMet, List gradProgramRulesMatch, - String exceptionalCase, Map courseCreditException) { + private void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement tempProgramRule, + List requirementsMet, Map courseCreditException) { tempCourse.setUsed(true); tempCourse.setUsedInMatchRule(true); if (courseCreditException.get(tempProgramRule.getProgramRequirementCode().getProReqCode()) == null) { @@ -218,7 +215,6 @@ public void setDetailsForCourses(StudentCourse tempCourse, ProgramRequirement te @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MatchIndigenousCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java index dc91b893..7b720768 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java @@ -1,26 +1,20 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -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.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Data @Component @@ -50,7 +44,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MAC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); for (ProgramRequirement gradProgramRule : gradProgramRules) { requiredCredits = Integer.parseInt(gradProgramRule.getProgramRequirementCode().getRequiredCredits().trim()); // list @@ -59,12 +53,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).collect(Collectors.toList()); + tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).toList(); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> sc.isUsed() && sc.getCourseLevel().compareTo(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim()) == 0) - .collect(Collectors.toList()); + .toList(); } for (StudentCourse sc : tempStudentCourseList) { @@ -120,7 +114,7 @@ public RuleData fire() { ruleProcessorData.getRequirementsMet() .stream() .filter(gpr -> gpr.getRule() != null && "4".compareTo(gpr.getRule()) == 0) - .collect(Collectors.toList()); + .toList(); if(reqMetList.size() == 2) { List delNonGradReason = ruleProcessorData.getNonGradReasons(); if(delNonGradReason != null) @@ -136,7 +130,7 @@ public RuleData fire() { Remove them if any. */ int carryForwardCoursesCount = 0; - List tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).collect(Collectors.toList()); + List tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).toList(); for (StudentCourse sc : tempStudentCourseList) { String courseSessionDate = sc.getSessionDate() + "/01"; @@ -172,7 +166,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinAdultCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java index 1bd04299..0ce6b4f9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -31,14 +30,14 @@ public RuleData fire() { List tempStudentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).collect(Collectors.toList()); + List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).toList(); List gradProgramRules = ruleProcessorData.getGradProgramRules() .stream() .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (tempStudentCourseList.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); @@ -87,7 +86,7 @@ public RuleData fire() { logger.debug("Min Credits -> Required: {} Has : {}",requiredCredits,totalCredits); } - studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).collect(Collectors.toList())); + studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).toList()); ruleProcessorData.setStudentCourses(studentCourses); return ruleProcessorData; } @@ -117,6 +116,5 @@ public void processReqMet(StudentCourse sc, ProgramRequirement gradProgramRule) @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinCredit1986Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java index 04da3379..7b5e323d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -31,14 +30,14 @@ public RuleData fire() { List tempStudentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).collect(Collectors.toList()); + List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).toList(); List gradProgramRules = ruleProcessorData.getGradProgramRules() .stream() .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (tempStudentCourseList.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); @@ -96,7 +95,7 @@ public RuleData fire() { logger.debug("Min Credits -> Required: {} Has : {}",requiredCredits,totalCredits); } - studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).collect(Collectors.toList())); + studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).toList()); ruleProcessorData.setStudentCourses(studentCourses); return ruleProcessorData; } @@ -126,6 +125,5 @@ public void processReqMet(StudentCourse sc, ProgramRequirement gradProgramRule) @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinCredit1996Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java index aa185ff8..b7ce12e9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java @@ -1,19 +1,17 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; 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.util.RuleProcessorRuleUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; @Data @Component @@ -42,7 +40,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCEOTHER".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -62,12 +60,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).collect(Collectors.toList()); + tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).toList(); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> !sc.isUsed() && sc.getCourseLevel().compareTo(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim()) == 0) - .collect(Collectors.toList()); + .toList(); } int courseFound = 0; @@ -189,7 +187,6 @@ private boolean existsRule505WithoutRule502(List reqsMet) { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinCreditsElective12Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java index 4699f9f4..f06a9510 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java @@ -1,23 +1,17 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - +import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; 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; -import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; @Data @Component @@ -40,7 +34,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE12".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -54,12 +48,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).collect(Collectors.toList()); + tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).toList(); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> !sc.isUsed() && sc.getCourseLevel().contains(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim())) - .collect(Collectors.toList()); + .toList(); } for (StudentCourse sc : tempStudentCourseList) { @@ -120,7 +114,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinCreditsElective12Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java index bf5f049f..15ecb8e6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java @@ -5,7 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; - import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,7 +13,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -39,7 +37,7 @@ public RuleData fire() { .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); @@ -128,6 +126,5 @@ public void processReqMet(StudentCourse sc, ProgramRequirement gradProgramRule) @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java index 479084b4..7d4e0e60 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java @@ -10,8 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; @Data @Component @@ -38,7 +39,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -92,7 +93,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinElectiveCredits1986Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java index 7bfc70c9..051d6395 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java @@ -10,8 +10,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; @Data @Component @@ -40,7 +42,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -113,7 +115,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinElectiveCredits1996Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java index a886323d..9598d3e2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -38,7 +37,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -110,7 +109,7 @@ private boolean hasMatchTypeRule(String gradReqMet) { List matchProgramRequirements = ruleProcessorData.getGradProgramRules().stream() .filter(pr -> "M".compareTo(pr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0) - .collect(Collectors.toList()); + .toList(); for (ProgramRequirement pr : matchProgramRequirements) { if (Arrays.asList(gradReqMetList).contains(pr.getProgramRequirementCode().getTraxReqNumber())) @@ -123,6 +122,5 @@ private boolean hasMatchTypeRule(String gradReqMet) { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinElectiveCredits2023Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java index f5fcb678..0ad42a80 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Data @Component @@ -44,7 +43,7 @@ public RuleProcessorData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); for (ProgramRequirement gradProgramRule : gradProgramRules) { if(gradProgramRule.getProgramRequirementCode().getRequiredLevel() != null && gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("11 or 12") == 0 ) { @@ -56,7 +55,7 @@ public RuleProcessorData fire() { && (sc.getCourseLevel().contains("11") || sc.getCourseLevel().contains("12")) && sc.getLanguage() != null && sc.getLanguage().trim().compareTo("F")==0) - .collect(Collectors.toList()); + .toList(); for (StudentCourse sc : tempStudentCourseList) { @@ -113,7 +112,6 @@ public RuleProcessorData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinElectiveCreditsFrench1996Rule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java index 90f8492e..0490c7c0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java @@ -1,23 +1,17 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - +import ca.bc.gov.educ.api.ruleengine.dto.*; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; 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; -import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; @Data @Component @@ -41,7 +35,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .collect(Collectors.toList()); + .toList(); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -100,7 +94,6 @@ private int processLeftOverCredits(StudentCourse sc, int requiredCredits, int to @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("MinElectiveCreditsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java index d15577d7..e1a77e26 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Data @Component @@ -34,7 +33,7 @@ public RuleData fire() { if(program.compareTo("1996-PF")==0 && mapOptional.get("DD") != null) { obj = mapOptional.get("DD"); processOptionalProgramNoRules("DD",obj,mapOptional); - }else if(program.compareTo("2018-EN")==0 || program.compareTo("2004-EN")==0 || program.compareTo("2018-PF")==0 + } else if(program.compareTo("2018-EN")==0 || program.compareTo("2004-EN")==0 || program.compareTo("2018-PF")==0 ||program.compareTo("2004-PF")==0 || program.compareTo("1996-EN")==0 || program.compareTo("2023-EN")==0 || program.compareTo("2023-PF")==0) { if(mapOptional.get("AD") != null) { @@ -87,7 +86,7 @@ private void processOptionalProgramNoRules(String opPrgCode,OptionalProgramRuleP .stream() .filter(gradOptionalProgramRule -> "SR".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0) - .collect(Collectors.toList()); + .toList(); for(OptionalProgramRequirement opReq:optionalProgramNoRule) { if (opReq.getOptionalProgramRequirementCode().getOptProReqCode().compareTo("957") != 0) { logger.debug("{} Passed", opReq.getOptionalProgramRequirementCode().getLabel()); @@ -107,6 +106,5 @@ private void processOptionalProgramNoRules(String opPrgCode,OptionalProgramRuleP @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("OptionalProgramNoRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java index a05dc0a3..33d3c56f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java @@ -1,21 +1,19 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.ArrayList; -import java.util.Date; -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.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Data @Component @@ -34,7 +32,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "PCD".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0) - .collect(Collectors.toList()); + .toList(); List studentCourses = RuleProcessorRuleUtils .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); ruleProcessorData.setStudentCourses(studentCourses); @@ -70,7 +68,6 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { - ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("ProgramCompletionDateRule: Rule Processor Data set."); - } + ruleProcessorData = (RuleProcessorData) inputData; + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java index bedf56d2..51b837ca 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java @@ -32,7 +32,6 @@ public class RegistrationsDuplicateAssmtRule implements Rule { public RuleData fire() { List studentAssessmentsList = ruleProcessorData.getStudentAssessments(); - logger.debug("###################### Finding Duplicate Registrations ######################"); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA); String today = RuleEngineApiUtils.formatDate(cal.getTime(), RuleEngineApiConstants.DEFAULT_DATE_FORMAT); boolean inProgressCourse1 = false; @@ -86,6 +85,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("RegistrationsDuplicateAssmtRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java index c33f0c3e..78ec7636 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java @@ -31,7 +31,6 @@ public class RegistrationsDuplicateCrseRule implements Rule { public RuleData fire() { List studentCourseList = ruleProcessorData.getStudentCourses(); - logger.debug("###################### Finding Duplicate Registrations ######################"); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA); String today = RuleEngineApiUtils.formatDate(cal.getTime(), RuleEngineApiConstants.DEFAULT_DATE_FORMAT); boolean inProgressCourse1 = false; @@ -99,6 +98,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("RegistrationsDuplicateCrseRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java index 99141e0c..3212289f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java @@ -32,7 +32,6 @@ public class RegistrationsFailedCrseRule implements Rule { public RuleData fire() { List studentCourseList = ruleProcessorData.getStudentCourses(); - logger.debug("###################### Finding Failed Registrations ######################"); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA); boolean inProgressCourse = false; for (StudentCourse studentCourse : studentCourseList) { @@ -53,13 +52,14 @@ public RuleData fire() { .anyMatch(lg -> lg.getGrade().compareTo(finalLetterGrade) == 0 && lg.getPassFlag().compareTo("N") == 0); - if (failed) + if (failed) { studentCourse.setFailed(true); + } } } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("RegistrationsFailedCrseRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); logger.debug("Registrations but Failed Courses: {}",(int) studentCourseList.stream().filter(sc-> sc.isDuplicate() && sc.isProjected()).count()); @@ -70,6 +70,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("RegistrationsDuplicateCrseRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java index f4f19203..d56c6056 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java @@ -32,8 +32,6 @@ public class RegistrationsRule implements Rule { public RuleData fire() { List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses(ruleProcessorData.getStudentCourses(),ruleProcessorData.isProjected()); - logger.debug("###################### Finding PROJECTED courses (For Projected GRAD) ######################"); - for (StudentCourse studentCourse : studentCourseList) { String today = RuleEngineApiUtils.formatDate(new Date(), "yyyy-MM-dd"); String sessionDate = studentCourse.getSessionDate() + "/01"; @@ -67,6 +65,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("RegistrationsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Remove2CreditCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Remove2CreditCoursesRule.java index 57f39bee..c99361db 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Remove2CreditCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Remove2CreditCoursesRule.java @@ -28,8 +28,6 @@ public class Remove2CreditCoursesRule implements Rule { @Override public RuleData fire() { - logger.debug("###################### Finding 2 Credit Courses ######################"); - List studentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); @@ -40,10 +38,10 @@ public RuleData fire() { } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("Remove2CreditCoursesRule", studentCourseList,ruleProcessorData.getExcludedCourses(),ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourseList); - logger.debug("Removed 2 Credit Courses: {0} ", + logger.debug("Removed 2 Credit Courses: {} ", (int) studentCourseList.stream().filter(StudentCourse::isLessCreditCourse).count()); return ruleProcessorData; @@ -52,6 +50,5 @@ public RuleData fire() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("DuplicateAssessmentsRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java index 0973af3d..83c28458 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Data @Component @@ -66,10 +65,10 @@ public RuleData fire() { } } } - ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses(studentCourses, ruleProcessorData.getExcludedCourses(), ruleProcessorData.isProjected())); + ruleProcessorData.setExcludedCourses(RuleProcessorRuleUtils.maintainExcludedCourses("RestrictedCoursesRule", studentCourses, ruleProcessorData.getExcludedCourses(), ruleProcessorData.isProjected())); ruleProcessorData.setStudentCourses(studentCourses); prepareCoursesForOptionalPrograms(); - logger.debug("Restricted Courses: {0} ", (int) studentCourses.stream().filter(StudentCourse::isRestricted).count()); + logger.debug("Restricted Courses: {} ", (int) studentCourses.stream().filter(StudentCourse::isRestricted).count()); return ruleProcessorData; } @@ -82,13 +81,13 @@ private List getMinimizedRestrictedCourses(String programCode && courseLevel.compareTo(cR.getMainCourseLevel()) == 0 && is1950AndSameLevel(programCode, cR.getMainCourseLevel(), cR.getRestrictedCourseLevel()) && RuleEngineApiUtils.checkDateForRestrictedCourses(cR.getRestrictionStartDate(), cR.getRestrictionEndDate(), sessionDate)) - .collect(Collectors.toList()); + .toList(); } else { shortenedList = restrictedCourses.stream() .filter(cR -> courseCode.compareTo(cR.getMainCourse()) == 0 && is1950AndSameLevel(programCode, cR.getMainCourseLevel(), cR.getRestrictedCourseLevel()) && RuleEngineApiUtils.checkDateForRestrictedCourses(cR.getRestrictionStartDate(), cR.getRestrictionEndDate(), sessionDate)) - .collect(Collectors.toList()); + .toList(); } return shortenedList; } @@ -132,6 +131,5 @@ private void prepareCoursesForOptionalPrograms() { @Override public void setInputData(RuleData inputData) { ruleProcessorData = (RuleProcessorData) inputData; - logger.debug("RestrictedCoursesRule: Rule Processor Data set."); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RuleFactory.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RuleFactory.java index d53fc698..2a4dbc55 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RuleFactory.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RuleFactory.java @@ -1,12 +1,11 @@ package ca.bc.gov.educ.api.ruleengine.rule; -import java.util.Arrays; - +import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData; +import java.util.Arrays; @Component public class RuleFactory { @@ -23,7 +22,6 @@ public static Rule createRule(String ruleImplementation, RuleProcessorData data) try { clazz = (Class) Class.forName("ca.bc.gov.educ.api.ruleengine.rule." + ruleImplementation); rule = clazz.getDeclaredConstructor(RuleProcessorData.class).newInstance(data); - logger.debug("Class Created: {}" , rule.getClass()); } catch (Exception e) { logger.debug("ERROR: No Such Class: {}" , ruleImplementation); logger.debug("Message: {}" , Arrays.toString(e.getStackTrace())); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java index efd27800..b2e30096 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java @@ -2,14 +2,18 @@ import ca.bc.gov.educ.api.ruleengine.dto.ProgramAlgorithmRule; 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.rule.Rule; import ca.bc.gov.educ.api.ruleengine.rule.RuleFactory; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.SneakyThrows; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class RuleEngineService { @@ -28,9 +32,15 @@ public RuleProcessorData processGradAlgorithmRules(RuleProcessorData ruleProcess RuleProcessorData originalData = RuleProcessorRuleUtils.cloneObject(ruleProcessorData); ruleProcessorData.setGraduated(true); for (ProgramAlgorithmRule gradAlgorithmRule : originalData.getAlgorithmRules()) { - Rule rule = RuleFactory.createRule(gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), ruleProcessorData); + Rule rule = RuleFactory.createRule(gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), ruleProcessorData); rule.setInputData(ruleProcessorData); + List beforeRuleCourses = ruleProcessorData.getStudentCourses(); ruleProcessorData = (RuleProcessorData)rule.fire(); + List afterRuleCourses = ruleProcessorData.getStudentCourses(); + List courseDifference = beforeRuleCourses.stream().filter(element -> !afterRuleCourses.contains(element)).toList(); + if(logger.isDebugEnabled() && !courseDifference.isEmpty()) { + logger.debug("The course excluded by the {}/{} rule: {}", gradAlgorithmRule.getAlgorithmRuleCode().getAlgoRuleCode(), gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), StringUtils.join(courseDifference, ",")); + } } if(ruleProcessorData.getNonGradReasons() == null || ruleProcessorData.getNonGradReasons().isEmpty()) { ruleProcessorData.setGraduated(ruleProcessorData.getRequirementsMet() != null && !ruleProcessorData.getRequirementsMet().isEmpty()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java index 00bb6532..d191b38a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.stream.Collectors; public class RuleProcessorRuleUtils { @@ -37,14 +36,14 @@ public static List getUniqueStudentCourses(List st && !sc.isValidationCourse() && !sc.isCutOffCourse() && !sc.isGrade10Course()) - .collect(Collectors.toList()); + .toList(); if (!projected) { logger.debug("Excluding Registrations!"); uniqueStudentCourseList = uniqueStudentCourseList .stream() .filter(sc -> !sc.isProjected()) - .collect(Collectors.toList()); + .toList(); } else logger.debug("Including Registrations!"); @@ -67,7 +66,7 @@ public static List getExcludedStudentCourses(List || sc.isCutOffCourse() || sc.isGrade10Course() || (!projected && sc.isProjected())) - .collect(Collectors.toList()); + .toList(); } @SuppressWarnings("unchecked") @@ -79,18 +78,20 @@ public static T cloneObject(T input) throws IOException { .readValue(objectMapper.writeValueAsString(input), input.getClass()); } - public static List maintainExcludedCourses(List currentList,List existingExcludedList, boolean projected) { - List exclList = getExcludedStudentCourses(currentList, projected); - if(existingExcludedList == null) + public static List maintainExcludedCourses(String ruleName, List currentList, List existingExcludedList, boolean projected) { + List excludedStudentCourses = getExcludedStudentCourses(currentList, projected); + if(existingExcludedList == null) { existingExcludedList = new ArrayList<>(); + } - if(!exclList.isEmpty()) { - for(StudentCourse sc:exclList) { + if(!excludedStudentCourses.isEmpty()) { + for(StudentCourse sc:excludedStudentCourses) { StudentCourse tempCourse = existingExcludedList.stream() .filter(sp -> sp.getCourseCode().compareTo(sc.getCourseCode()) == 0 && sp.getCourseLevel().compareTo(sc.getCourseLevel())==0 && sp.getSessionDate().compareTo(sc.getSessionDate())==0 ) .findAny() .orElse(null); if(tempCourse == null) { + logger.debug("{} added the course to the excluded list {}", ruleName, sc); existingExcludedList.add(sc); } } @@ -100,12 +101,12 @@ public static List maintainExcludedCourses(List cu } public static List maintainExcludedAssessments(List currentList,List existingExcludedList, boolean projected) { - List exclList = getExcludedStudentAssessments(currentList, projected); + List excludedStudentAssessments = getExcludedStudentAssessments(currentList, projected); if(existingExcludedList == null) existingExcludedList = new ArrayList<>(); - if(!exclList.isEmpty()) { - for(StudentAssessment sc:exclList) { + if(!excludedStudentAssessments.isEmpty()) { + for(StudentAssessment sc:excludedStudentAssessments) { StudentAssessment tempAssmt = existingExcludedList.stream() .filter(sp -> sp.getAssessmentCode().compareTo(sc.getAssessmentCode()) == 0 && sp.getSessionDate().compareTo(sc.getSessionDate())==0) .findAny() @@ -127,14 +128,14 @@ public static List getUniqueStudentAssessments(List !sc.isNotCompleted() && !sc.isDuplicate() && !sc.isFailed()) - .collect(Collectors.toList()); + .toList(); if (!projected) { logger.debug("Excluding Registrations!"); uniqueStudentAssessmentList = uniqueStudentAssessmentList .stream() .filter(sc -> !sc.isProjected()) - .collect(Collectors.toList()); + .toList(); } else logger.debug("Including Registrations!"); @@ -148,7 +149,7 @@ public static List getExcludedStudentAssessments(List studentCourses) { From 339048ef7500eb8cc56b0d970739bad1f3848e37 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 18 Oct 2023 17:32:58 -0600 Subject: [PATCH 2/5] GRAD2-2366 HD-22692-P2 GRAD Incident: XML Previews no longer include Course/Assessment Registrations in GRAD/STS --- .../api/ruleengine/rule/OptionalProgramMatchRule.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java index 0fa2dbea..ffd1128c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java @@ -12,7 +12,6 @@ import java.util.HashMap; import java.util.List; import java.util.ListIterator; -import java.util.stream.Collectors; @Component public class OptionalProgramMatchRule { @@ -34,7 +33,7 @@ public static void processOptionalProgramAssessmentMatchRule(OptionalProgramRule && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0 && !gradOptionalProgramRule.getOptionalProgramRequirementCode().isPassed()) - .collect(Collectors.toList()); + .toList(); List assessmentRequirements = ruleProcessorData.getAssessmentRequirements(); if (assessmentRequirements == null) { assessmentRequirements = new ArrayList<>(); @@ -55,7 +54,7 @@ public static void processOptionalProgramAssessmentMatchRule(OptionalProgramRule List tempAssessmentRequirement = assessmentRequirements.stream() .filter(ar -> tempAssessment.getAssessmentCode().compareTo(ar.getAssessmentCode()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("TempAssmtReq: {}", tempAssessmentRequirement); OptionalProgramRequirement tempOptionalProgramRule = handleOptionalProgramRule(tempAssessmentRequirement, gradOptionalProgramRulesMatch, requirementsMet, tempAssessment, null); @@ -216,7 +215,7 @@ public static void processOptionalProgramCourseMatchRule(OptionalProgramRuleProc && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0 && !gradOptionalProgramRule.getOptionalProgramRequirementCode().isPassed()) - .collect(Collectors.toList()); + .toList(); List courseRequirements = ruleProcessorData.getCourseRequirements(); if (courseRequirements == null) { courseRequirements = new ArrayList<>(); @@ -239,7 +238,7 @@ public static void processOptionalProgramCourseMatchRule(OptionalProgramRuleProc List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .collect(Collectors.toList()); + .toList(); logger.debug("TempCrseReq: {}", tempCourseRequirements); @@ -260,7 +259,7 @@ public static void handleRule(List gradOptionalProgr finalOptionalProgramRulesList.addAll(unusedRules); } List failedRules = finalOptionalProgramRulesList.stream().filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()) - .collect(Collectors.toList()); + .toList(); handleFailedRules(failedRules, requirementsNotMet, obj); From 75e3810917b112e542b90b4e15c620a818c836f2 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 19 Oct 2023 11:37:18 -0600 Subject: [PATCH 3/5] GRAD2-2366 HD-22692-P2 GRAD Incident: XML Previews no longer include Course/Assessment Registrations in GRAD/STS --- .../educ/api/ruleengine/dto/Assessment.java | 8 +- .../ruleengine/dto/AssessmentRequirement.java | 8 +- .../dto/AssessmentRequirementCode.java | 8 +- .../api/ruleengine/dto/CourseRequirement.java | 8 +- .../dto/CourseRequirementCodeDTO.java | 10 +- .../ruleengine/dto/CourseRequirements.java | 3 +- .../api/ruleengine/dto/CourseRestriction.java | 8 +- .../dto/GradAlgorithmGraduationStatus.java | 6 +- .../api/ruleengine/dto/GradProgramRule.java | 8 +- .../api/ruleengine/dto/GradProgramRules.java | 3 +- .../api/ruleengine/dto/GradRequirement.java | 3 +- .../api/ruleengine/dto/GradSearchStudent.java | 4 +- .../educ/api/ruleengine/dto/GradStudent.java | 4 +- .../ruleengine/dto/GraduationProgramCode.java | 10 +- .../educ/api/ruleengine/dto/LetterGrade.java | 5 +- ...OptionalGradAlgorithmGraduationStatus.java | 10 +- .../api/ruleengine/dto/OptionalProgram.java | 10 +- .../dto/OptionalProgramRequirement.java | 8 +- .../dto/OptionalProgramRequirementCode.java | 5 +- .../dto/OptionalProgramRuleProcessor.java | 3 +- .../ruleengine/dto/ProgramAlgorithmRule.java | 8 +- .../ruleengine/dto/ProgramRequirement.java | 8 +- .../dto/ProgramRequirementCode.java | 5 +- .../ruleengine/dto/RequirementTypeCode.java | 8 +- .../gov/educ/api/ruleengine/dto/RuleData.java | 4 +- .../gov/educ/api/ruleengine/dto/School.java | 5 +- .../educ/api/ruleengine/dto/SpecialCase.java | 8 +- .../api/ruleengine/dto/StudentAssessment.java | 3 +- .../ruleengine/dto/StudentCareerProgram.java | 3 +- .../api/ruleengine/dto/StudentCourse.java | 4 +- .../api/ruleengine/dto/StudentCourses.java | 3 +- .../dto/StudentOptionalProgram.java | 8 +- .../rule/AdultStudentGradeRule.java | 3 +- .../rule/AdultWorkExperienceRule.java | 7 +- .../ruleengine/rule/AlgorithmSupportRule.java | 119 ++++++++---------- .../rule/AssessmentsMatchCreditsRule.java | 13 +- .../rule/CareerProgramMatchRule.java | 7 +- .../api/ruleengine/rule/EquivalencyRule.java | 47 +++---- ...chImmersionMinElectiveCredits1986Rule.java | 9 +- ...chImmersionMinElectiveCredits1996Rule.java | 9 +- ...FrenchImmersionMinElectiveCreditsRule.java | 13 +- .../rule/MainProgramCompleteRule.java | 5 +- .../ruleengine/rule/MatchCredit1986Rule.java | 13 +- .../ruleengine/rule/MatchCredit1996Rule.java | 25 ++-- .../api/ruleengine/rule/MatchCreditsRule.java | 15 +-- .../rule/MatchIndigenousCreditsRule.java | 17 ++- .../ruleengine/rule/MinAdultCoursesRule.java | 11 +- .../ruleengine/rule/MinCredit1986Rule.java | 7 +- .../ruleengine/rule/MinCredit1996Rule.java | 7 +- .../rule/MinCreditsElective12OtherRule.java | 11 +- .../rule/MinCreditsElective12Rule.java | 7 +- .../api/ruleengine/rule/MinCreditsRule.java | 3 +- .../rule/MinElectiveCredits1986Rule.java | 3 +- .../rule/MinElectiveCredits1996Rule.java | 3 +- .../rule/MinElectiveCredits2023Rule.java | 5 +- .../MinElectiveCreditsFrench1996Rule.java | 5 +- .../rule/MinElectiveCreditsRule.java | 3 +- .../rule/OptionalProgramMatchRule.java | 19 +-- .../rule/OptionalProgramNoRule.java | 3 +- .../rule/ProgramCompletionDateRule.java | 3 +- .../rule/RestrictedCoursesRule.java | 5 +- .../bc/gov/educ/api/ruleengine/rule/Rule.java | 5 +- .../ruleengine/service/RuleEngineService.java | 3 +- .../util/RuleProcessorRuleUtils.java | 13 +- 64 files changed, 324 insertions(+), 293 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/Assessment.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/Assessment.java index 994a749e..d37f6df2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/Assessment.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/Assessment.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.sql.Date; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.sql.Date; @Data @Component -public class Assessment { +public class Assessment implements Serializable { private String assessmentCode; private String assessmentName; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirement.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirement.java index 3638d956..8d7d5cf4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirement.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirement.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class AssessmentRequirement { +public class AssessmentRequirement implements Serializable { private UUID assessmentRequirementId; private String assessmentCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirementCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirementCode.java index abe13a04..a3fd1ff1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirementCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AssessmentRequirementCode.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.sql.Date; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.sql.Date; @Data @Component -public class AssessmentRequirementCode { +public class AssessmentRequirementCode implements Serializable { private String assmtRequirementCode; private String label; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirement.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirement.java index 4f12a4f1..9b575029 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirement.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirement.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class CourseRequirement { +public class CourseRequirement implements Serializable { private UUID courseRequirementId; private String courseCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirementCodeDTO.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirementCodeDTO.java index 0544a9dd..937f0fc1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirementCodeDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirementCodeDTO.java @@ -1,16 +1,16 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.sql.Date; - -import org.springframework.stereotype.Component; - import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.sql.Date; @Data @EqualsAndHashCode(callSuper = false) @Component -public class CourseRequirementCodeDTO { +public class CourseRequirementCodeDTO implements Serializable { private String courseRequirementCode; private String label; private String description; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirements.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirements.java index a887fc5e..0fa3bea1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirements.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRequirements.java @@ -3,10 +3,11 @@ import lombok.Data; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.List; @Data @Component -public class CourseRequirements { +public class CourseRequirements implements Serializable { List courseRequirementList; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRestriction.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRestriction.java index a78aa4f9..a7da32e2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRestriction.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/CourseRestriction.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class CourseRestriction { +public class CourseRestriction implements Serializable { private UUID courseRestrictionId; private String mainCourse; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradAlgorithmGraduationStatus.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradAlgorithmGraduationStatus.java index 1e52e852..68da52e5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradAlgorithmGraduationStatus.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradAlgorithmGraduationStatus.java @@ -1,15 +1,15 @@ package ca.bc.gov.educ.api.ruleengine.dto; import lombok.Data; +import org.springframework.stereotype.Component; +import java.io.Serializable; import java.sql.Date; import java.util.UUID; -import org.springframework.stereotype.Component; - @Data @Component -public class GradAlgorithmGraduationStatus { +public class GradAlgorithmGraduationStatus implements Serializable { private String pen; private String program; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRule.java index 8a7e0ce5..632851d1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRule.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class GradProgramRule { +public class GradProgramRule implements Serializable { private UUID id; private String ruleCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRules.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRules.java index 3169122a..bc5f4904 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRules.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradProgramRules.java @@ -3,10 +3,11 @@ import lombok.Data; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.List; @Component @Data -public class GradProgramRules { +public class GradProgramRules implements Serializable { List gradProgramRuleList; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradRequirement.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradRequirement.java index 87e85fc5..e46a389a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradRequirement.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradRequirement.java @@ -5,13 +5,14 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.Objects; @Component @Data @NoArgsConstructor @AllArgsConstructor -public class GradRequirement { +public class GradRequirement implements Serializable { String transcriptRule; String description; String rule; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradSearchStudent.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradSearchStudent.java index 07155123..503a3eff 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradSearchStudent.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradSearchStudent.java @@ -5,11 +5,13 @@ import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import java.io.Serializable; + @Data @SuperBuilder @AllArgsConstructor @NoArgsConstructor -public class GradSearchStudent { +public class GradSearchStudent implements Serializable { private String studentID; private String pen; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradStudent.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradStudent.java index b490e3b3..0751ff22 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradStudent.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradStudent.java @@ -6,6 +6,8 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; +import java.io.Serializable; + /** * The type for Grad Student. */ @@ -14,7 +16,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class GradStudent { +public class GradStudent implements Serializable { private String pen; private String archiveFlag; private String studSurname; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GraduationProgramCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GraduationProgramCode.java index 21d6d897..30f4e66b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GraduationProgramCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GraduationProgramCode.java @@ -1,16 +1,16 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.Date; - -import org.springframework.stereotype.Component; - import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @Component -public class GraduationProgramCode { +public class GraduationProgramCode implements Serializable { private String programCode; private String programName; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/LetterGrade.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/LetterGrade.java index f6e91f69..f9e2f0fb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/LetterGrade.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/LetterGrade.java @@ -1,12 +1,13 @@ package ca.bc.gov.educ.api.ruleengine.dto; +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; @Data @Component -public class LetterGrade { +public class LetterGrade implements Serializable { private String grade; private String gpaMarkValue; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalGradAlgorithmGraduationStatus.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalGradAlgorithmGraduationStatus.java index 36e2cfc1..a407b223 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalGradAlgorithmGraduationStatus.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalGradAlgorithmGraduationStatus.java @@ -1,15 +1,15 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.List; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.List; +import java.util.UUID; @Data @Component -public class OptionalGradAlgorithmGraduationStatus { +public class OptionalGradAlgorithmGraduationStatus implements Serializable { private String pen; private UUID optionalProgramID; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgram.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgram.java index 30a249b0..85fdabc1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgram.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgram.java @@ -1,15 +1,15 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.Date; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.Date; +import java.util.UUID; @Data @Component -public class OptionalProgram { +public class OptionalProgram implements Serializable { private UUID optionalProgramID; private String optProgramCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirement.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirement.java index cef19f91..3307f5ba 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirement.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirement.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class OptionalProgramRequirement { +public class OptionalProgramRequirement implements Serializable { private UUID optionalProgramRequirementID; private OptionalProgram optionalProgramID; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirementCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirementCode.java index 3d42672d..b50dce96 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirementCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRequirementCode.java @@ -1,12 +1,13 @@ package ca.bc.gov.educ.api.ruleengine.dto; +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; @Data @Component -public class OptionalProgramRequirementCode { +public class OptionalProgramRequirementCode implements Serializable { private String optProReqCode; private String label; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRuleProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRuleProcessor.java index 030858b3..232bd46c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRuleProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/OptionalProgramRuleProcessor.java @@ -3,12 +3,13 @@ import lombok.Data; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.List; import java.util.UUID; @Data @Component -public class OptionalProgramRuleProcessor { +public class OptionalProgramRuleProcessor implements Serializable { private UUID optionalProgramID; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramAlgorithmRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramAlgorithmRule.java index 13114966..b0efc263 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramAlgorithmRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramAlgorithmRule.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class ProgramAlgorithmRule { +public class ProgramAlgorithmRule implements Serializable { private UUID programAlgoRuleID; private String graduationProgramCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirement.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirement.java index 68306da2..554050d8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirement.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirement.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class ProgramRequirement { +public class ProgramRequirement implements Serializable { private UUID programRequirementID; private String graduationProgramCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirementCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirementCode.java index 5bdd2957..12c2bebf 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirementCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/ProgramRequirementCode.java @@ -1,12 +1,13 @@ package ca.bc.gov.educ.api.ruleengine.dto; +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; @Data @Component -public class ProgramRequirementCode { +public class ProgramRequirementCode implements Serializable { private String proReqCode; private String label; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RequirementTypeCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RequirementTypeCode.java index abb6f44a..65fb0fca 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RequirementTypeCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RequirementTypeCode.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.Date; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.Date; @Data @Component -public class RequirementTypeCode { +public class RequirementTypeCode implements Serializable { private String reqTypeCode; private String label; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RuleData.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RuleData.java index fb818f51..689f520a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RuleData.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/RuleData.java @@ -1,5 +1,7 @@ package ca.bc.gov.educ.api.ruleengine.dto; -public interface RuleData { +import java.io.Serializable; + +public interface RuleData extends Serializable { } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/School.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/School.java index 5bbcd167..c977ff45 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/School.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/School.java @@ -1,12 +1,13 @@ package ca.bc.gov.educ.api.ruleengine.dto; +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; @Data @Component -public class School { +public class School implements Serializable { private String minCode; private String schoolName; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/SpecialCase.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/SpecialCase.java index b5a76ce6..348a4bcb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/SpecialCase.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/SpecialCase.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.sql.Date; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.sql.Date; @Data @Component -public class SpecialCase { +public class SpecialCase implements Serializable { private String spCase; private String label; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentAssessment.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentAssessment.java index d54ba4c2..6f4d1812 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentAssessment.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentAssessment.java @@ -3,11 +3,12 @@ import lombok.Data; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.Objects; @Data @Component -public class StudentAssessment { +public class StudentAssessment implements Serializable { private String pen; private String assessmentCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCareerProgram.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCareerProgram.java index 2644741e..f7ecb8b3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCareerProgram.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCareerProgram.java @@ -4,12 +4,13 @@ import lombok.EqualsAndHashCode; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.UUID; @Data @EqualsAndHashCode(callSuper = false) @Component -public class StudentCareerProgram { +public class StudentCareerProgram implements Serializable { private UUID id; private String careerProgramCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java index d76e35a6..ac99ca82 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourse.java @@ -6,12 +6,14 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; +import java.io.Serializable; + @Component @Data @Builder @AllArgsConstructor @NoArgsConstructor -public class StudentCourse { +public class StudentCourse implements Serializable { private String pen; private String courseCode; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourses.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourses.java index 351418d0..2b84fb80 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourses.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentCourses.java @@ -3,11 +3,12 @@ import lombok.Data; import org.springframework.stereotype.Component; +import java.io.Serializable; import java.util.List; @Data @Component -public class StudentCourses { +public class StudentCourses implements Serializable { private List studentCourseList; @Override diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentOptionalProgram.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentOptionalProgram.java index 98fcf481..4be74b65 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentOptionalProgram.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/StudentOptionalProgram.java @@ -1,14 +1,14 @@ package ca.bc.gov.educ.api.ruleengine.dto; -import java.util.UUID; - +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; +import java.util.UUID; @Data @Component -public class StudentOptionalProgram { +public class StudentOptionalProgram implements Serializable { private UUID id; private String pen; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java index 33186bd6..41f2132d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultStudentGradeRule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -33,7 +34,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "SG".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0) - .toList(); + .collect(Collectors.toList()); if (RuleProcessorUtils.isNotEmptyOrNull(gradProgramRules)) { logger.debug("#Checking SG Rule"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java index aaa357c5..345629db 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.ListIterator; +import java.util.stream.Collectors; @Data @Component @@ -48,7 +49,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MWEX".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); List finalCourseList = new ArrayList<>(); for (ProgramRequirement gradProgramRule : gradProgramRules) { @@ -64,7 +65,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("Temp Course Requirement: {}",tempCourseRequirement); @@ -87,7 +88,7 @@ public RuleData fire() { tempCourse.setNotEligibleForElective(true); } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); } if(numberOfWExCourses > 1L) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java index bcabe95e..b0d3cfa1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AlgorithmSupportRule.java @@ -2,14 +2,14 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.SerializationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Component public class AlgorithmSupportRule { @@ -28,7 +28,7 @@ public static void processEmptyCourseCondition(RuleProcessorData ruleProcessorDa && pr.getProgramRequirementCode().getRequirementCategory() != null && pr.getProgramRequirementCode().getRequirementCategory().equalsIgnoreCase("C") && "N/A".compareToIgnoreCase(pr.getProgramRequirementCode().getNotMetDesc()) != 0) - .toList(); + .collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -61,7 +61,7 @@ public static void processEmptyAssessmentCondition(RuleProcessorData ruleProcess ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); ruleProcessorData.setStudentCourses(courseList); List failedRules = gradProgramRulesMatch.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed() && pr.getProgramRequirementCode().getRequirementCategory().equalsIgnoreCase("A")).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed() && pr.getProgramRequirementCode().getRequirementCategory().equalsIgnoreCase("A")).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -224,82 +224,65 @@ public static void checkCredits1996(int totalCredits, int requiredCredits, Progr } } - public static void copyAndAddIntoProgramRulesList(ProgramRequirement programRule, List finalProgramRulesList, ObjectMapper objectMapper) { - try { - ProgramRequirement tempPR = objectMapper.readValue(objectMapper.writeValueAsString(programRule), ProgramRequirement.class); - if (tempPR != null && !finalProgramRulesList.contains(tempPR)) { - finalProgramRulesList.add(tempPR); - - //See if there are duplicates - List duplicateProgramRules = finalProgramRulesList.stream() - .filter(fprl -> fprl.getProgramRequirementCode().getProReqCode().compareTo(tempPR.getProgramRequirementCode().getProReqCode()) == 0) - .toList(); - - if (duplicateProgramRules.size() > 1) { - finalProgramRulesList.removeAll( - duplicateProgramRules.stream().filter(dpr -> !dpr.getProgramRequirementCode().isPassed()).toList() - ); - } + public static void copyAndAddIntoProgramRulesList(ProgramRequirement programRule, List finalProgramRulesList) { + ProgramRequirement tempPR = SerializationUtils.clone(programRule); + if (tempPR != null && !finalProgramRulesList.contains(tempPR)) { + finalProgramRulesList.add(tempPR); + + //See if there are duplicates + List duplicateProgramRules = finalProgramRulesList.stream() + .filter(fprl -> fprl.getProgramRequirementCode().getProReqCode().compareTo(tempPR.getProgramRequirementCode().getProReqCode()) == 0) + .collect(Collectors.toList()); + + if (duplicateProgramRules.size() > 1) { + finalProgramRulesList.removeAll( + duplicateProgramRules.stream().filter(dpr -> !dpr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()) + ); } - logger.debug("TempPR: {}",tempPR); - logger.debug("Final Program rules list size: {}",finalProgramRulesList.size()); - } catch (IOException e) { - logger.error(ERROR_FORMAT_STR,e.getMessage()); } + logger.debug("TempPR: {}",tempPR); + logger.debug("Final Program rules list size: {}",finalProgramRulesList.size()); } - public static void copyAndAddIntoOptionalProgramRulesList(OptionalProgramRequirement optionalProgramRule, List finalOptionalProgramRulesList, ObjectMapper objectMapper) { - try { - OptionalProgramRequirement tempSPR = objectMapper.readValue(objectMapper.writeValueAsString(optionalProgramRule), - OptionalProgramRequirement.class); - if (tempSPR != null && !finalOptionalProgramRulesList.contains(optionalProgramRule)) { - //If Rule already exists in the list then remove and replace - OptionalProgramRequirement opr = finalOptionalProgramRulesList.stream() - .filter(pr -> pr.getOptionalProgramRequirementID().compareTo(tempSPR.getOptionalProgramRequirementID()) == 0) - .findAny().orElse(null); - - if (opr != null) { - // If Rule already added before, check if the added rule is failed, then replace with current one - // Otherwise, do not add anything - if (!opr.getOptionalProgramRequirementCode().isPassed()) { - finalOptionalProgramRulesList.remove(opr); - finalOptionalProgramRulesList.add(tempSPR); - } - } - // If rule not added yet, just add it - else { + public static void copyAndAddIntoOptionalProgramRulesList(OptionalProgramRequirement optionalProgramRule, List finalOptionalProgramRulesList) { + OptionalProgramRequirement tempSPR = SerializationUtils.clone(optionalProgramRule); + if (tempSPR != null && !finalOptionalProgramRulesList.contains(optionalProgramRule)) { + //If Rule already exists in the list then remove and replace + OptionalProgramRequirement opr = finalOptionalProgramRulesList.stream() + .filter(pr -> pr.getOptionalProgramRequirementID().compareTo(tempSPR.getOptionalProgramRequirementID()) == 0) + .findAny().orElse(null); + + if (opr != null) { + // If Rule already added before, check if the added rule is failed, then replace with current one + // Otherwise, do not add anything + if (!opr.getOptionalProgramRequirementCode().isPassed()) { + finalOptionalProgramRulesList.remove(opr); finalOptionalProgramRulesList.add(tempSPR); } } - logger.debug("TempPR: {}", tempSPR); - logger.debug("Final Program rules list size: {}", finalOptionalProgramRulesList.size()); - } catch (IOException e) { - logger.error(ERROR_FORMAT_STR,e.getMessage()); + // If rule not added yet, just add it + else { + finalOptionalProgramRulesList.add(tempSPR); + } } + logger.debug("TempPR: {}", tempSPR); + logger.debug("Final Program rules list size: {}", finalOptionalProgramRulesList.size()); } - public static void copyAndAddIntoStudentCoursesList(StudentCourse studentCourse, List finalCourseList, ObjectMapper objectMapper) { - try { - StudentCourse studentCourseTmp = objectMapper.readValue(objectMapper.writeValueAsString(studentCourse), StudentCourse.class); - if (studentCourseTmp != null) { - finalCourseList.add(studentCourseTmp); - logger.debug("Added Student Course: {}", studentCourseTmp); - } - logger.debug("Final Student Course List size: {}", finalCourseList.size()); - } catch (IOException e) { - logger.error(ERROR_FORMAT_STR,e.getMessage()); + public static void copyAndAddIntoStudentCoursesList(StudentCourse studentCourse, List finalCourseList) { + StudentCourse studentCourseTmp = SerializationUtils.clone(studentCourse); + if (studentCourseTmp != null) { + finalCourseList.add(studentCourseTmp); + logger.debug("Added Student Course: {}", studentCourseTmp); } + logger.debug("Final Student Course List size: {}", finalCourseList.size()); } - public static void copyAndAddIntoStudentAssessmentsList(StudentAssessment studentAssessment, List finalAssessmentList, ObjectMapper objectMapper) { - try { - StudentAssessment tempSA = objectMapper.readValue(objectMapper.writeValueAsString(studentAssessment), StudentAssessment.class); - if (tempSA != null) - finalAssessmentList.add(tempSA); - logger.debug("TempSC: {}",tempSA); - logger.debug("Final Assessment List size: : {}",finalAssessmentList.size()); - } catch (IOException e) { - logger.error(ERROR_FORMAT_STR,e.getMessage()); - } + public static void copyAndAddIntoStudentAssessmentsList(StudentAssessment studentAssessment, List finalAssessmentList) { + StudentAssessment tempSA = SerializationUtils.clone(studentAssessment); + if (tempSA != null) + finalAssessmentList.add(tempSA); + logger.debug("TempSC: {}",tempSA); + logger.debug("Final Assessment List size: : {}",finalAssessmentList.size()); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java index 2526392a..42c72d80 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -38,7 +39,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (ruleProcessorData.getStudentAssessments() == null || ruleProcessorData.getStudentAssessments().isEmpty()) { logger.warn("!!!Empty list sent to Assessment Match Rule for processing"); @@ -60,7 +61,7 @@ public RuleData fire() { List tempAssessmentRequirement = assessmentRequirements.stream() .filter(ar -> tempAssessment.getAssessmentCode().compareTo(ar.getAssessmentCode()) == 0) - .toList(); + .collect(Collectors.toList()); ProgramRequirement tempProgramRule = null; @@ -77,8 +78,8 @@ public RuleData fire() { logger.debug("Temp Program Rule: {}",tempProgramRule); processAssessments(tempAssessmentRequirement,tempProgramRule,requirementsMet,tempAssessment); - AlgorithmSupportRule.copyAndAddIntoStudentAssessmentsList(tempAssessment, finalAssessmentList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentAssessmentsList(tempAssessment, finalAssessmentList); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList); } logger.debug("Final Program rules list: {}",finalProgramRulesList); @@ -90,7 +91,7 @@ public RuleData fire() { .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); logger.debug("Final Program rules list size 2: {}",finalProgramRulesList.size()); ruleProcessorData.setStudentAssessments(finalAssessmentList); @@ -116,7 +117,7 @@ private void processReqMetAndNotMet(List finalProgramRulesLi } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java index 3d5085a3..71ea1d46 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -45,7 +46,7 @@ public RuleData fire() { .filter(gradOptionalProgramRule -> "M".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("#### Career Program Rule size: {}", careerProgramRulesMatch.size()); @@ -87,7 +88,7 @@ public RuleData fire() { sc.setUsed(true); } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList); if ((totalCredits >= requiredCredits) && totalCredits != 0) { break; @@ -105,7 +106,7 @@ public RuleData fire() { obj.setRequirementsMetOptionalProgram(resMet); List failedRules = careerProgramRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the Career Program Match rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java index a18bd9d6..1d1c9d1e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -51,7 +52,7 @@ private void handleProgramRulesForAssessmentEquivalency() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("Matched Program rules list size {}", gradProgramRulesMatch.size()); // 1. check assessment is empty or failed @@ -71,7 +72,7 @@ private void handleProgramRulesForAssessmentEquivalency() { List matchedCourseRequirements = courseRequirementsForEquivalency.stream() .filter(equivCr -> equivCr.getCourseCode().compareTo(st.getCourseCode()) == 0 && equivCr.getCourseLevel().compareTo(st.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); matchedCourseRequirements.stream().forEach(courseRequirement -> { ProgramRequirement programRule = null; if (courseRequirement != null) { @@ -83,7 +84,7 @@ private void handleProgramRulesForAssessmentEquivalency() { if (programRule != null && !programRule.getProgramRequirementCode().isPassed()) { logger.debug("Pseudo Assessment ==> Program rule[{}] - course code[{}] / [{}]", programRule.getProgramRequirementCode().getProReqCode(), st.getCourseCode(), st.getCourseLevel()); processAssessmentEquivalency(st, programRule, courseRequirement, ruleProcessorData.getGradStudent().getPen(), requirementsMet, finalAssessmentList); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(programRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(programRule, finalProgramRulesList); } }); } @@ -94,7 +95,7 @@ private void handleProgramRulesForAssessmentEquivalency() { // merge studentAssessments with finalAssessmentList // => if any of finalAssessments already exists in studentAssessments, remove the current one and add the new one. List tempAssessments = ruleProcessorData.getStudentAssessments().stream() - .filter(sa -> !finalAssessmentList.contains(sa)).toList(); + .filter(sa -> !finalAssessmentList.contains(sa)).collect(Collectors.toList()); tempAssessments.addAll(finalAssessmentList); ruleProcessorData.setStudentAssessments(tempAssessments); } @@ -104,7 +105,7 @@ private void handleProgramRulesForAssessmentEquivalency() { .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); ruleProcessorData.setGradProgramRules(finalProgramRulesList); } @@ -112,7 +113,7 @@ private void handleProgramRulesForAssessmentEquivalency() { private void handleFailedRules(List finalProgramRulesList, List requirementsMet, List gradProgramRulesMatch) { List successfulRules = finalProgramRulesList.stream() .filter(pr -> pr.getProgramRequirementCode().isPassed()) - .toList(); + .collect(Collectors.toList()); if(gradProgramRulesMatch.size() != finalProgramRulesList.size()) { List unusedRules = RuleEngineApiUtils.getCloneProgramRule(gradProgramRulesMatch); @@ -121,7 +122,7 @@ private void handleFailedRules(List finalProgramRulesList, L } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the failed assessment match rules met the assessment equivalency requirement!"); @@ -134,9 +135,9 @@ private void handleFailedRules(List finalProgramRulesList, L // if any failed assessments from the previous processors meet the assessment equivalency requirement, // then remove it from nonGradReason. if (!successfulRules.isEmpty()) { - List successfulRuleCodes = successfulRules.stream().map(pr -> pr.getProgramRequirementCode().getProReqCode()).toList(); + List successfulRuleCodes = successfulRules.stream().map(pr -> pr.getProgramRequirementCode().getProReqCode()).collect(Collectors.toList()); List nonGradReasons = ruleProcessorData.getNonGradReasons().stream() - .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).toList(); + .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).collect(Collectors.toList()); ruleProcessorData.setNonGradReasons(nonGradReasons); } @@ -190,7 +191,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram .filter(gradOptionalProgramRule -> "M".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); // 1. check assessment is empty or failed List studentAssessments = RuleProcessorRuleUtils.getUniqueStudentAssessments( @@ -211,7 +212,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram List matchedCourseRequirements = courseRequirementsForEquivalency.stream() .filter(equivCr -> equivCr.getCourseCode().compareTo(st.getCourseCode()) == 0 && equivCr.getCourseLevel().compareTo(st.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); matchedCourseRequirements.stream().forEach(courseRequirement -> { OptionalProgramRequirement optionalProgramRule = null; if (courseRequirement != null) { @@ -223,7 +224,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram if (optionalProgramRule != null && !optionalProgramRule.getOptionalProgramRequirementCode().isPassed()) { logger.debug("Pseudo Assessment ==> Optional Program rule[{}] - course code[{}] / [{}]", optionalProgramRule.getOptionalProgramRequirementCode().getOptProReqCode(), st.getCourseCode(), st.getCourseLevel()); processAssessmentEquivalencyOptionalProgram(st, optionalProgramRule, courseRequirement, ruleProcessorData.getGradStudent().getPen(), requirementsMet, finalAssessmentList); - AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(optionalProgramRule, finalOptionalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(optionalProgramRule, finalOptionalProgramRulesList); } }); } @@ -234,7 +235,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram // merge studentAssessments with finalAssessmentList // => if any of finalAssessments already exists in studentAssessments, remove the current one and add the new one. List tempAssessments = obj.getStudentAssessmentsOptionalProgram().stream() - .filter(sa -> !finalAssessmentList.contains(sa)).toList(); + .filter(sa -> !finalAssessmentList.contains(sa)).collect(Collectors.toList()); tempAssessments.addAll(finalAssessmentList); obj.setStudentAssessmentsOptionalProgram(tempAssessments); } @@ -244,7 +245,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram .stream() .filter(optionalProgramRule -> "M".compareTo(optionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "A".compareTo(optionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); obj.setOptionalProgramRules(finalOptionalProgramRulesList); } @@ -260,7 +261,7 @@ private void processAssessmentEquivalencyOptionalProgram(StudentCourse studentCo private void handleFailedRules(OptionalProgramRuleProcessor obj, List finalOptionalProgramRulesList, List requirementsMet, List gradOptionalProgramRulesMatch) { List successfulRules = finalOptionalProgramRulesList.stream() .filter(opr -> opr.getOptionalProgramRequirementCode().isPassed()) - .toList(); + .collect(Collectors.toList()); if(gradOptionalProgramRulesMatch.size() != finalOptionalProgramRulesList.size()) { List unusedRules = RuleEngineApiUtils.getCloneOptionalProgramRule(gradOptionalProgramRulesMatch); @@ -269,7 +270,7 @@ private void handleFailedRules(OptionalProgramRuleProcessor obj, List failedRules = finalOptionalProgramRulesList.stream() - .filter(opr -> !opr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(opr -> !opr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the failed assessment match rules met the assessment equivalency requirement for optional program!"); @@ -282,9 +283,9 @@ private void handleFailedRules(OptionalProgramRuleProcessor obj, List successfulRuleCodes = successfulRules.stream().map(opr -> opr.getOptionalProgramRequirementCode().getOptProReqCode()).toList(); + List successfulRuleCodes = successfulRules.stream().map(opr -> opr.getOptionalProgramRequirementCode().getOptProReqCode()).collect(Collectors.toList()); List nonGradReasons = obj.getNonGradReasonsOptionalProgram().stream() - .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).toList(); + .filter(gr -> !successfulRuleCodes.contains(gr.getRule())).collect(Collectors.toList()); obj.setNonGradReasonsOptionalProgram(nonGradReasons); } @@ -308,14 +309,14 @@ private List getCourseRequirementsForAssessmentEquivalency(Li // Rule# 115,116,118,303,304 List failedRuleCodes = gradProgramRulesMatch .stream() - .filter((pr -> !pr.getProgramRequirementCode().isPassed())).toList() + .filter((pr -> !pr.getProgramRequirementCode().isPassed())).collect(Collectors.toList()) .stream() - .map(fr -> fr.getProgramRequirementCode().getProReqCode()).toList(); + .map(fr -> fr.getProgramRequirementCode().getProReqCode()).collect(Collectors.toList()); return courseRequirements .stream() .filter(cr -> failedRuleCodes.contains(cr.getRuleCode().getCourseRequirementCode())) - .toList(); + .collect(Collectors.toList()); } private List getCourseRequirementsForAssessmentsEquivalency(List gradOptionalProgramRulesMatch) { @@ -329,12 +330,12 @@ private List getCourseRequirementsForAssessmentsEquivalency(L .stream() .filter((opr -> !opr.getOptionalProgramRequirementCode().isPassed())).toList() .stream() - .map(fr -> fr.getOptionalProgramRequirementCode().getOptProReqCode()).toList(); + .map(fr -> fr.getOptionalProgramRequirementCode().getOptProReqCode()).collect(Collectors.toList()); return courseRequirements .stream() .filter(cr -> failedRuleCodes.contains(cr.getRuleCode().getCourseRequirementCode())) - .toList(); + .collect(Collectors.toList()); } private boolean validateAssessmentsEmptyOrFailed(List gradProgramRulesMatch, List studentAssessments) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java index bdcdcbde..19b756d2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -38,12 +39,12 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); ObjectMapper objectMapper = new ObjectMapper(); - List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList()); + List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList())); List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); @@ -59,7 +60,7 @@ public RuleProcessorData fire() { totalCreditsGrade11or12 = processCredits(pR,totalCreditsGrade11or12,sc,requirementsMet); } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2); if ((totalCreditsGrade11or12 == requiredCreditsGrad11or12) && totalCreditsGrade11or12 != 0) { break; @@ -76,7 +77,7 @@ public RuleProcessorData fire() { finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).toList()); obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java index 17278387..181c73aa 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -38,7 +39,7 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); ObjectMapper objectMapper = new ObjectMapper(); @@ -59,7 +60,7 @@ public RuleProcessorData fire() { totalCreditsGrade11or12 = processCredits(pR,totalCreditsGrade11or12,sc,requirementsMet); } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2); if ((totalCreditsGrade11or12 == requiredCreditsGrad11or12) && totalCreditsGrade11or12 != 0) { break; @@ -73,10 +74,10 @@ public RuleProcessorData fire() { resMet.addAll(requirementsMet); obj.setRequirementsMetOptionalProgram(resMet); - finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).toList()); + finalCourseList2.addAll(courseList.stream().filter(StudentCourse::isUsed).collect(Collectors.toList())); obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java index 0f4d51d0..56346b6c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -44,7 +45,7 @@ public RuleProcessorData fire() { .filter(gradOptionalProgramRule -> "MCE".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); List finalCourseList = new ArrayList<>(); @@ -53,9 +54,9 @@ public RuleProcessorData fire() { List matchedList = courseList .stream() .filter(StudentCourse::isUsed) - .toList(); + .collect(Collectors.toList()); - List modifiedList = courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList(); + List modifiedList = courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList()); ListIterator studentCourseIterator = modifiedList.listIterator(); int totalCredits = 0; int requiredCredits = 0; @@ -71,7 +72,7 @@ public RuleProcessorData fire() { } } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList); if ((totalCredits == requiredCredits) && totalCredits != 0) { requirementAchieved = true; } @@ -106,7 +107,7 @@ public RuleProcessorData fire() { } } } - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(sc, finalCourseList2); if ((totalCreditsGrade11or12 == requiredCreditsGrad11or12) && totalCreditsGrade11or12 != 0) { requirementAchieved = true; @@ -126,7 +127,7 @@ public RuleProcessorData fire() { obj.setStudentCoursesOptionalProgram(RuleEngineApiUtils.getClone(finalCourseList2)); List failedRules = gradOptionalProgramMinCreditElectiveRulesMatch.stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the Min Elective Credit rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java index aac22976..32239feb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MainProgramCompleteRule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -44,7 +45,7 @@ private void processMainProgramCompleteRules(List nonGradReason .stream() .filter(gradOptionalProgramRule -> "SR".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0) - .toList(); + .collect(Collectors.toList()); for(OptionalProgramRequirement opReq:optionalProgramNoRule) { if(opReq.getOptionalProgramRequirementCode().getOptProReqCode().compareTo("957")==0) { if (nonGradReasons == null || nonGradReasons.isEmpty()) { @@ -55,7 +56,7 @@ private void processMainProgramCompleteRules(List nonGradReason opReq.getOptionalProgramRequirementCode().setPassed(false); } List failedRules = obj.getOptionalProgramRules().stream() - .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java index e3502120..dbbe0aa1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -42,7 +43,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Credit 1986 Rule for processing"); @@ -70,7 +71,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("Temp Course Requirement: {}", tempCourseRequirement); @@ -89,8 +90,8 @@ public RuleData fire() { logger.debug("Temp Program Rule: {}", tempProgramRule); processCourse(tempCourse, tempCourseRequirement, tempProgramRule, requirementsMet); - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList); } logger.debug("Final Program rules list: {}",finalProgramRulesList); @@ -131,7 +132,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis }); List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -156,7 +157,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(ruleProcessorData.getGradProgramRules() .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0 || "4".compareTo(gradProgramRule.getProgramRequirementCode().getRequiredCredits()) != 0) - .toList()); + .collect(Collectors.toList())); logger.debug("Final Program rules list size 2: {}",finalProgramRulesList.size()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java index e7854a1d..53bb90f0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -45,7 +46,7 @@ public RuleData fire() { .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()) .stream().filter(studentCourse -> studentCourse.getFineArtsAppliedSkills() != null && studentCourse.getFineArtsAppliedSkills().length() > 0) - .toList(); + .collect(Collectors.toList()); fineArtsCourseList.sort(Comparator.comparing(StudentCourse::getCourseLevel) .thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder())); @@ -53,7 +54,7 @@ public RuleData fire() { .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()) .stream().filter(studentCourse -> studentCourse.getFineArtsAppliedSkills() == null || studentCourse.getFineArtsAppliedSkills().length() <= 0) - .toList(); + .collect(Collectors.toList()); courseList.sort(Comparator.comparing(StudentCourse::getCourseLevel) .thenComparing(StudentCourse::getCompletedCoursePercentage, Comparator.reverseOrder())); @@ -62,7 +63,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Credit 1996 Rule for processing"); @@ -88,7 +89,7 @@ public RuleData fire() { List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("Temp Course Requirement: {}", tempCourseRequirements); @@ -126,8 +127,8 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode()) logger.debug("Temp Program Rule: {}", tempProgramRule); processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch, map1996); - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList); } logger.debug("Final Program rules list: {}",finalProgramRulesList); processReqMet(finalProgramRulesList,finalCourseList,originalCourseRequirements,requirementsMet,gradProgramRulesMatch); @@ -139,7 +140,7 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode()) List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("Temp Course Requirement: {}", tempCourseRequirements); @@ -173,8 +174,8 @@ && isFineArtsOrAppliedSkillsRule(pr.getProgramRequirementCode().getProReqCode()) logger.debug("Temp Program Rule: {}", tempProgramRule); processCourse(tempCourse, tempCourseRequirements, tempProgramRule, requirementsMet, gradProgramRulesMatch, map1996); - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList); } logger.debug("Final Program rules list: {}",finalProgramRulesList); @@ -272,7 +273,7 @@ public void processReqMet(List finalProgramRulesList, List "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); logger.debug("Final Program rules list size 2: {}", finalProgramRulesList.size()); @@ -295,7 +296,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(unusedRules); } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -321,7 +322,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); logger.debug("Final Program rules list size 2: {}",finalProgramRulesList.size()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java index 63fe3ed0..5aa000e8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java @@ -14,6 +14,7 @@ import java.text.ParseException; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -63,7 +64,7 @@ public RuleData fire() { && (LA2_REQNO_1950.compareTo(gradProgramRule.getProgramRequirementCode().getTraxReqNumber()) == 0 || MA11_MA12_REQNO_1950.compareTo(gradProgramRule.getProgramRequirementCode().getTraxReqNumber()) == 0) ) - .toList(); + .collect(Collectors.toList()); processRule(courseList, gradProgramRulesMatch, requirementsMet, requirementsNotMet); splitSortStudentCourses(courseList, ruleProcessorData.getGradStatus().getAdultStartDate()); @@ -74,7 +75,7 @@ public RuleData fire() { .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); processRule(courseList, gradProgramRulesMatch, requirementsMet, requirementsNotMet); } @@ -103,7 +104,7 @@ private void processRule(List courseList, List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); ProgramRequirement tempProgramRule = null; @@ -119,8 +120,8 @@ private void processRule(List courseList, List finalProgramRulesLis finalProgramRulesList.addAll(unusedRules); } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -234,7 +235,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(ruleProcessorData.getGradProgramRules() .stream() .filter(gradProgramRule -> "M".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); ruleProcessorData.setStudentCourses(finalCourseList); ruleProcessorData.setGradProgramRules(finalProgramRulesList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java index ac2b6582..5f26e181 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; -import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; @@ -13,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.*; +import java.util.stream.Collectors; @Data @Component @@ -30,15 +30,14 @@ public RuleData fire() { List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); - List courseList = RuleProcessorRuleUtils.getUniqueStudentCourses( - ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); + List courseList = ruleProcessorData.getStudentCourses(); List gradProgramRulesMatchIndigenous = ruleProcessorData.getGradProgramRules() .stream() .filter(gradProgramRule -> "MI".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradProgramRule.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (courseList == null || courseList.isEmpty()) { logger.warn("!!!Empty list sent to Match Indigenous Credits Rule for processing"); @@ -63,7 +62,7 @@ public RuleData fire() { List tempCourseRequirement = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); ProgramRequirement tempProgramRule = null; @@ -81,8 +80,8 @@ public RuleData fire() { processCourse(tempCourse, tempCourseRequirement, tempProgramRule, requirementsMet, gradProgramRulesMatchIndigenous, courseCreditException); - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); + AlgorithmSupportRule.copyAndAddIntoProgramRulesList(tempProgramRule, finalProgramRulesList); } processReqMetAndNotMet(finalProgramRulesList, requirementsNotMet, finalCourseList, originalCourseRequirements, requirementsMet, gradProgramRulesMatchIndigenous); @@ -135,7 +134,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis finalProgramRulesList.addAll(unusedRules); } List failedRules = finalProgramRulesList.stream() - .filter(pr -> !pr.getProgramRequirementCode().isPassed()).toList(); + .filter(pr -> !pr.getProgramRequirementCode().isPassed()).collect(Collectors.toList()); if (failedRules.isEmpty()) { logger.debug("All the match rules met!"); @@ -163,7 +162,7 @@ public void processReqMetAndNotMet(List finalProgramRulesLis .filter(gradProgramRule -> "MI".compareTo(gradProgramRule.getProgramRequirementCode() .getRequirementTypeCode().getReqTypeCode()) != 0 || "C".compareTo(gradProgramRule.getProgramRequirementCode().getRequirementCategory()) != 0) - .toList()); + .collect(Collectors.toList())); ruleProcessorData.setStudentCourses(finalCourseList); ruleProcessorData.setGradProgramRules(finalProgramRulesList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java index 7b720768..6fe0b38d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -44,7 +45,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MAC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); for (ProgramRequirement gradProgramRule : gradProgramRules) { requiredCredits = Integer.parseInt(gradProgramRule.getProgramRequirementCode().getRequiredCredits().trim()); // list @@ -53,12 +54,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).toList(); + tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).collect(Collectors.toList()); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> sc.isUsed() && sc.getCourseLevel().compareTo(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim()) == 0) - .toList(); + .collect(Collectors.toList()); } for (StudentCourse sc : tempStudentCourseList) { @@ -114,7 +115,7 @@ public RuleData fire() { ruleProcessorData.getRequirementsMet() .stream() .filter(gpr -> gpr.getRule() != null && "4".compareTo(gpr.getRule()) == 0) - .toList(); + .collect(Collectors.toList()); if(reqMetList.size() == 2) { List delNonGradReason = ruleProcessorData.getNonGradReasons(); if(delNonGradReason != null) @@ -130,7 +131,7 @@ public RuleData fire() { Remove them if any. */ int carryForwardCoursesCount = 0; - List tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).toList(); + List tempStudentCourseList = studentCourses.stream().filter(StudentCourse::isUsed).collect(Collectors.toList()); for (StudentCourse sc : tempStudentCourseList) { String courseSessionDate = sc.getSessionDate() + "/01"; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java index 0ce6b4f9..d6454d18 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1986Rule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -30,14 +31,14 @@ public RuleData fire() { List tempStudentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).toList(); + List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).collect(Collectors.toList()); List gradProgramRules = ruleProcessorData.getGradProgramRules() .stream() .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (tempStudentCourseList.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); @@ -86,7 +87,7 @@ public RuleData fire() { logger.debug("Min Credits -> Required: {} Has : {}",requiredCredits,totalCredits); } - studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).toList()); + studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).collect(Collectors.toList())); ruleProcessorData.setStudentCourses(studentCourses); return ruleProcessorData; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java index 7b5e323d..d07624f6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCredit1996Rule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -30,14 +31,14 @@ public RuleData fire() { List tempStudentCourseList = RuleProcessorRuleUtils.getUniqueStudentCourses( ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); - List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).toList(); + List studentCourses = tempStudentCourseList.stream().filter(sc -> !sc.isUsedInMatchRule()).collect(Collectors.toList()); List gradProgramRules = ruleProcessorData.getGradProgramRules() .stream() .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (tempStudentCourseList.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); @@ -95,7 +96,7 @@ public RuleData fire() { logger.debug("Min Credits -> Required: {} Has : {}",requiredCredits,totalCredits); } - studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).toList()); + studentCourses.addAll(tempStudentCourseList.stream().filter(StudentCourse::isUsedInMatchRule).collect(Collectors.toList())); ruleProcessorData.setStudentCourses(studentCourses); return ruleProcessorData; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java index b7ce12e9..e6a44396 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12OtherRule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -40,7 +41,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCEOTHER".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -48,7 +49,7 @@ public RuleData fire() { return ruleProcessorData; } - List socialStudiesCourseCodeList = ruleProcessorData.getCourseRequirements().stream().filter(cr -> "502".equals(cr.getRuleCode().getCourseRequirementCode())).map(CourseRequirement::getCourseCode).toList(); + List socialStudiesCourseCodeList = ruleProcessorData.getCourseRequirements().stream().filter(cr -> "502".equals(cr.getRuleCode().getCourseRequirementCode())).map(CourseRequirement::getCourseCode).collect(Collectors.toList()); if (socialStudiesCourseCodeList.isEmpty()) { socialStudiesCourseCodeList = List.of(COURSE_CODE_SOCIAL_STUDIES); } @@ -60,12 +61,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).toList(); + tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).collect(Collectors.toList()); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> !sc.isUsed() && sc.getCourseLevel().compareTo(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim()) == 0) - .toList(); + .collect(Collectors.toList()); } int courseFound = 0; @@ -180,7 +181,7 @@ public RuleData fire() { } private boolean existsRule505WithoutRule502(List reqsMet) { - List list = reqsMet.stream().filter(r -> "502".equalsIgnoreCase(r.getRule()) || "505".equalsIgnoreCase(r.getRule())).toList(); + List list = reqsMet.stream().filter(r -> "502".equalsIgnoreCase(r.getRule()) || "505".equalsIgnoreCase(r.getRule())).collect(Collectors.toList()); return list.size() == 1 && "505".equalsIgnoreCase(list.get(0).getRule()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java index f06a9510..678a11e1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsElective12Rule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -34,7 +35,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE12".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -48,12 +49,12 @@ public RuleData fire() { if (gradProgramRule.getProgramRequirementCode().getRequiredLevel() == null || gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { - tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).toList(); + tempStudentCourseList = studentCourses.stream().filter(sc -> !sc.isUsed()).collect(Collectors.toList()); } else { tempStudentCourseList = studentCourses.stream() .filter(sc -> !sc.isUsed() && sc.getCourseLevel().contains(gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim())) - .toList(); + .collect(Collectors.toList()); } for (StudentCourse sc : tempStudentCourseList) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java index 15ecb8e6..533fc1e5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinCreditsRule.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -37,7 +38,7 @@ public RuleData fire() { .filter(gpr -> "MC".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Credits Rule for processing"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java index 7d4e0e60..c5f00b17 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1986Rule.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -39,7 +40,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java index 051d6395..d7cc6b8e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits1996Rule.java @@ -14,6 +14,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -42,7 +43,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java index 9598d3e2..48da8339 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCredits2023Rule.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -37,7 +38,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); @@ -109,7 +110,7 @@ private boolean hasMatchTypeRule(String gradReqMet) { List matchProgramRequirements = ruleProcessorData.getGradProgramRules().stream() .filter(pr -> "M".compareTo(pr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0) - .toList(); + .collect(Collectors.toList()); for (ProgramRequirement pr : matchProgramRequirements) { if (Arrays.asList(gradReqMetList).contains(pr.getProgramRequirementCode().getTraxReqNumber())) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java index 0ad42a80..3b5562ed 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsFrench1996Rule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -43,7 +44,7 @@ public RuleProcessorData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); for (ProgramRequirement gradProgramRule : gradProgramRules) { if(gradProgramRule.getProgramRequirementCode().getRequiredLevel() != null && gradProgramRule.getProgramRequirementCode().getRequiredLevel().trim().compareTo("11 or 12") == 0 ) { @@ -55,7 +56,7 @@ public RuleProcessorData fire() { && (sc.getCourseLevel().contains("11") || sc.getCourseLevel().contains("12")) && sc.getLanguage() != null && sc.getLanguage().trim().compareTo("F")==0) - .toList(); + .collect(Collectors.toList()); for (StudentCourse sc : tempStudentCourseList) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java index 0490c7c0..cd8a14ea 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinElectiveCreditsRule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -35,7 +36,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "MCE".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gpr.getProgramRequirementCode().getRequirementCategory()) == 0) - .toList(); + .collect(Collectors.toList()); if (studentCourses == null || studentCourses.isEmpty()) { logger.warn("!!!Empty list sent to Min Elective Credits Rule for processing"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java index ffd1128c..505e267e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.ListIterator; +import java.util.stream.Collectors; @Component public class OptionalProgramMatchRule { @@ -33,7 +34,7 @@ public static void processOptionalProgramAssessmentMatchRule(OptionalProgramRule && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "A".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0 && !gradOptionalProgramRule.getOptionalProgramRequirementCode().isPassed()) - .toList(); + .collect(Collectors.toList()); List assessmentRequirements = ruleProcessorData.getAssessmentRequirements(); if (assessmentRequirements == null) { assessmentRequirements = new ArrayList<>(); @@ -54,13 +55,13 @@ public static void processOptionalProgramAssessmentMatchRule(OptionalProgramRule List tempAssessmentRequirement = assessmentRequirements.stream() .filter(ar -> tempAssessment.getAssessmentCode().compareTo(ar.getAssessmentCode()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("TempAssmtReq: {}", tempAssessmentRequirement); OptionalProgramRequirement tempOptionalProgramRule = handleOptionalProgramRule(tempAssessmentRequirement, gradOptionalProgramRulesMatch, requirementsMet, tempAssessment, null); - AlgorithmSupportRule.copyAndAddIntoStudentAssessmentsList(tempAssessment, finalAssessmentList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(tempOptionalProgramRule, finalOptionalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentAssessmentsList(tempAssessment, finalAssessmentList); + AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(tempOptionalProgramRule, finalOptionalProgramRulesList); } obj.setStudentAssessmentsOptionalProgram(finalAssessmentList); @@ -215,7 +216,7 @@ public static void processOptionalProgramCourseMatchRule(OptionalProgramRuleProc && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0 && "C".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementCategory()) == 0 && !gradOptionalProgramRule.getOptionalProgramRequirementCode().isPassed()) - .toList(); + .collect(Collectors.toList()); List courseRequirements = ruleProcessorData.getCourseRequirements(); if (courseRequirements == null) { courseRequirements = new ArrayList<>(); @@ -238,15 +239,15 @@ public static void processOptionalProgramCourseMatchRule(OptionalProgramRuleProc List tempCourseRequirements = courseRequirements.stream() .filter(cr -> tempCourse.getCourseCode().compareTo(cr.getCourseCode()) == 0 && tempCourse.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) - .toList(); + .collect(Collectors.toList()); logger.debug("TempCrseReq: {}", tempCourseRequirements); OptionalProgramRequirement tempOptionalProgramRule = handleOptionalProgramCourseMatchRule(tempCourseRequirements, null, requirementsMet, tempCourse, gradOptionalProgramRulesMatch); - AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList, objectMapper); - AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(tempOptionalProgramRule, finalOptionalProgramRulesList, objectMapper); + AlgorithmSupportRule.copyAndAddIntoStudentCoursesList(tempCourse, finalCourseList); + AlgorithmSupportRule.copyAndAddIntoOptionalProgramRulesList(tempOptionalProgramRule, finalOptionalProgramRulesList); } obj.setStudentCoursesOptionalProgram(finalCourseList); handleRule(gradOptionalProgramRulesMatch, finalOptionalProgramRulesList, requirementsNotMet, obj, requirementsMet); @@ -259,7 +260,7 @@ public static void handleRule(List gradOptionalProgr finalOptionalProgramRulesList.addAll(unusedRules); } List failedRules = finalOptionalProgramRulesList.stream().filter(pr -> !pr.getOptionalProgramRequirementCode().isPassed()) - .toList(); + .collect(Collectors.toList()); handleFailedRules(failedRules, requirementsNotMet, obj); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java index e1a77e26..d98eb765 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramNoRule.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -86,7 +87,7 @@ private void processOptionalProgramNoRules(String opPrgCode,OptionalProgramRuleP .stream() .filter(gradOptionalProgramRule -> "SR".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gradOptionalProgramRule.getOptionalProgramRequirementCode().getActiveRequirement()) == 0) - .toList(); + .collect(Collectors.toList()); for(OptionalProgramRequirement opReq:optionalProgramNoRule) { if (opReq.getOptionalProgramRequirementCode().getOptProReqCode().compareTo("957") != 0) { logger.debug("{} Passed", opReq.getOptionalProgramRequirementCode().getLabel()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java index 33d3c56f..1765e4f4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ProgramCompletionDateRule.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Data @Component @@ -32,7 +33,7 @@ public RuleData fire() { List gradProgramRules = ruleProcessorData .getGradProgramRules().stream().filter(gpr -> "PCD".compareTo(gpr.getProgramRequirementCode().getRequirementTypeCode().getReqTypeCode()) == 0 && "Y".compareTo(gpr.getProgramRequirementCode().getActiveRequirement()) == 0) - .toList(); + .collect(Collectors.toList()); List studentCourses = RuleProcessorRuleUtils .getUniqueStudentCourses(ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); ruleProcessorData.setStudentCourses(studentCourses); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java index 83c28458..1d41bc23 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RestrictedCoursesRule.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Data @Component @@ -81,13 +82,13 @@ private List getMinimizedRestrictedCourses(String programCode && courseLevel.compareTo(cR.getMainCourseLevel()) == 0 && is1950AndSameLevel(programCode, cR.getMainCourseLevel(), cR.getRestrictedCourseLevel()) && RuleEngineApiUtils.checkDateForRestrictedCourses(cR.getRestrictionStartDate(), cR.getRestrictionEndDate(), sessionDate)) - .toList(); + .collect(Collectors.toList()); } else { shortenedList = restrictedCourses.stream() .filter(cR -> courseCode.compareTo(cR.getMainCourse()) == 0 && is1950AndSameLevel(programCode, cR.getMainCourseLevel(), cR.getRestrictedCourseLevel()) && RuleEngineApiUtils.checkDateForRestrictedCourses(cR.getRestrictionStartDate(), cR.getRestrictionEndDate(), sessionDate)) - .toList(); + .collect(Collectors.toList()); } return shortenedList; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Rule.java index 17ade00d..f18bd808 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/Rule.java @@ -1,11 +1,12 @@ package ca.bc.gov.educ.api.ruleengine.rule; +import ca.bc.gov.educ.api.ruleengine.dto.RuleData; import org.springframework.stereotype.Component; -import ca.bc.gov.educ.api.ruleengine.dto.RuleData; +import java.io.Serializable; @Component -public interface Rule { +public interface Rule extends Serializable { RuleData fire(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java index b2e30096..707f4d1a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; @Service public class RuleEngineService { @@ -37,7 +38,7 @@ public RuleProcessorData processGradAlgorithmRules(RuleProcessorData ruleProcess List beforeRuleCourses = ruleProcessorData.getStudentCourses(); ruleProcessorData = (RuleProcessorData)rule.fire(); List afterRuleCourses = ruleProcessorData.getStudentCourses(); - List courseDifference = beforeRuleCourses.stream().filter(element -> !afterRuleCourses.contains(element)).toList(); + List courseDifference = beforeRuleCourses.stream().filter(element -> !afterRuleCourses.contains(element)).collect(Collectors.toList()); if(logger.isDebugEnabled() && !courseDifference.isEmpty()) { logger.debug("The course excluded by the {}/{} rule: {}", gradAlgorithmRule.getAlgorithmRuleCode().getAlgoRuleCode(), gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), StringUtils.join(courseDifference, ",")); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java index d191b38a..d56b2f41 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; public class RuleProcessorRuleUtils { @@ -36,14 +37,14 @@ public static List getUniqueStudentCourses(List st && !sc.isValidationCourse() && !sc.isCutOffCourse() && !sc.isGrade10Course()) - .toList(); + .collect(Collectors.toList()); if (!projected) { logger.debug("Excluding Registrations!"); uniqueStudentCourseList = uniqueStudentCourseList .stream() .filter(sc -> !sc.isProjected()) - .toList(); + .collect(Collectors.toList()); } else logger.debug("Including Registrations!"); @@ -66,7 +67,7 @@ public static List getExcludedStudentCourses(List || sc.isCutOffCourse() || sc.isGrade10Course() || (!projected && sc.isProjected())) - .toList(); + .collect(Collectors.toList()); } @SuppressWarnings("unchecked") @@ -128,14 +129,14 @@ public static List getUniqueStudentAssessments(List !sc.isNotCompleted() && !sc.isDuplicate() && !sc.isFailed()) - .toList(); + .collect(Collectors.toList()); if (!projected) { logger.debug("Excluding Registrations!"); uniqueStudentAssessmentList = uniqueStudentAssessmentList .stream() .filter(sc -> !sc.isProjected()) - .toList(); + .collect(Collectors.toList()); } else logger.debug("Including Registrations!"); @@ -149,7 +150,7 @@ public static List getExcludedStudentAssessments(List studentCourses) { From 01727bf5223ecd44043598b1ea08a28abb6faf8d Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 19 Oct 2023 12:11:14 -0600 Subject: [PATCH 4/5] Code clean up and performance improvement --- .../educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java index 5f26e181..c144eb0c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java @@ -2,6 +2,7 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; +import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; @@ -30,7 +31,8 @@ public RuleData fire() { List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); - List courseList = ruleProcessorData.getStudentCourses(); + List courseList = RuleProcessorRuleUtils.getUniqueStudentCourses( + ruleProcessorData.getStudentCourses(), ruleProcessorData.isProjected()); List gradProgramRulesMatchIndigenous = ruleProcessorData.getGradProgramRules() .stream() From dd99491ea3a64e8f86131710e6cc973f311112de Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 19 Oct 2023 12:59:18 -0600 Subject: [PATCH 5/5] Code clean up and performance improvement --- .../educ/api/ruleengine/dto/AlgorithmRuleCode.java | 5 +++-- .../ruleengine/rule/AdultWorkExperienceRule.java | 3 +-- .../rule/AssessmentsMatchCreditsRule.java | 3 +-- .../api/ruleengine/rule/CareerProgramMatchRule.java | 3 +-- .../educ/api/ruleengine/rule/EquivalencyRule.java | 5 ++--- .../FrenchImmersionMinElectiveCredits1986Rule.java | 3 +-- .../FrenchImmersionMinElectiveCredits1996Rule.java | 3 +-- .../rule/FrenchImmersionMinElectiveCreditsRule.java | 3 +-- .../api/ruleengine/rule/MatchCredit1986Rule.java | 3 +-- .../api/ruleengine/rule/MatchCredit1996Rule.java | 3 +-- .../educ/api/ruleengine/rule/MatchCreditsRule.java | 3 +-- .../ruleengine/rule/MatchIndigenousCreditsRule.java | 3 +-- .../ruleengine/rule/OptionalProgramMatchRule.java | 5 ++--- .../api/ruleengine/service/RuleEngineService.java | 13 +------------ .../api/ruleengine/util/RuleProcessorRuleUtils.java | 12 ++++-------- 15 files changed, 22 insertions(+), 48 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AlgorithmRuleCode.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AlgorithmRuleCode.java index e706e5dd..9bcbc9e9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AlgorithmRuleCode.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/AlgorithmRuleCode.java @@ -1,12 +1,13 @@ package ca.bc.gov.educ.api.ruleengine.dto; +import lombok.Data; import org.springframework.stereotype.Component; -import lombok.Data; +import java.io.Serializable; @Data @Component -public class AlgorithmRuleCode { +public class AlgorithmRuleCode implements Serializable { private String algoRuleCode; private String ruleImplementation; diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java index 345629db..05ef1284 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AdultWorkExperienceRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -55,7 +54,7 @@ public RuleData fire() { for (ProgramRequirement gradProgramRule : gradProgramRules) { int numberOfWExCourses = 0; ListIterator courseIterator = studentCourses.listIterator(); - ObjectMapper objectMapper = new ObjectMapper(); + while (courseIterator.hasNext()) { StudentCourse tempCourse = courseIterator.next(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java index 42c72d80..2d06a67b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/AssessmentsMatchCreditsRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -55,7 +54,7 @@ public RuleData fire() { List finalAssessmentList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + for (StudentAssessment tempAssessment : assessmentList) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java index 71ea1d46..297dd923 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -54,7 +53,7 @@ public RuleData fire() { int totalCredits = 0; int requiredCredits = 0; List finalCourseList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + while (studentCourseIterator.hasNext()) { StudentCourse sc = studentCourseIterator.next(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java index 1d1c9d1e..aea5720f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/EquivalencyRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -66,7 +65,7 @@ private void handleProgramRulesForAssessmentEquivalency() { List finalAssessmentList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + for (StudentCourse st : courseList) { List matchedCourseRequirements = courseRequirementsForEquivalency.stream() @@ -206,7 +205,7 @@ private void processOptionalProgramRulesForAssessmentEquivalency(OptionalProgram List finalAssessmentList = new ArrayList<>(); List finalOptionalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + for (StudentCourse st : courseList) { List matchedCourseRequirements = courseRequirementsForEquivalency.stream() diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java index 19b756d2..5a3a0501 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1986Rule.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -42,7 +41,7 @@ public RuleProcessorData fire() { .collect(Collectors.toList()); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); - ObjectMapper objectMapper = new ObjectMapper(); + List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).collect(Collectors.toList())); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java index 181c73aa..aad73089 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCredits1996Rule.java @@ -2,7 +2,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -42,7 +41,7 @@ public RuleProcessorData fire() { .collect(Collectors.toList()); logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); - ObjectMapper objectMapper = new ObjectMapper(); + List modifiedList = RuleEngineApiUtils.getClone(courseList.stream().filter(sc -> !sc.isUsed()).sorted(Comparator.comparing(StudentCourse::getCourseLevel).reversed()).toList()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java index 56346b6c..72147a24 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/FrenchImmersionMinElectiveCreditsRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -50,7 +49,7 @@ public RuleProcessorData fire() { logger.debug("#### French Immersion Min Credit Elective Optional Program Rule size: {}",gradOptionalProgramMinCreditElectiveRulesMatch.size()); List finalCourseList = new ArrayList<>(); List finalCourseList2 = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + List matchedList = courseList .stream() .filter(StudentCourse::isUsed) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java index dbbe0aa1..5154a8d6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1986Rule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -60,7 +59,7 @@ public RuleData fire() { List finalCourseList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + for (StudentCourse tempCourse : courseList) { logger.debug("Processing Course: Code= {} Level = {}", tempCourse.getCourseCode(), tempCourse.getCourseLevel()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java index 53bb90f0..3f6dd3b9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCredit1996Rule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -80,7 +79,7 @@ public RuleData fire() { List finalCourseList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + for (StudentCourse tempCourse : fineArtsCourseList) { logger.debug("Processing Course: Code= {} Level = {}", tempCourse.getCourseCode(), tempCourse.getCourseLevel()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java index 5aa000e8..21a7b206 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -94,7 +93,7 @@ private void processRule(List courseList, List finalCourseList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + ListIterator courseIterator = courseList.listIterator(); Map courseCreditException = new HashMap<>(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java index c144eb0c..078d2bfe 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchIndigenousCreditsRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -54,7 +53,6 @@ public RuleData fire() { List finalCourseList = new ArrayList<>(); List finalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); ListIterator courseIterator = courseList.listIterator(); Map courseCreditException = new HashMap<>(); @@ -88,6 +86,7 @@ public RuleData fire() { processReqMetAndNotMet(finalProgramRulesList, requirementsNotMet, finalCourseList, originalCourseRequirements, requirementsMet, gradProgramRulesMatchIndigenous); + ruleProcessorData.getStudentCourses().addAll(ruleProcessorData.getExcludedCourses()); return ruleProcessorData; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java index 505e267e..ba20fb2d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/OptionalProgramMatchRule.java @@ -3,7 +3,6 @@ import ca.bc.gov.educ.api.ruleengine.dto.*; import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; -import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -45,7 +44,7 @@ public static void processOptionalProgramAssessmentMatchRule(OptionalProgramRule List finalAssessmentList = new ArrayList<>(); List finalOptionalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + while (assessmentIterator.hasNext()) { StudentAssessment tempAssessment = assessmentIterator.next(); @@ -228,7 +227,7 @@ public static void processOptionalProgramCourseMatchRule(OptionalProgramRuleProc List finalCourseList = new ArrayList<>(); List finalOptionalProgramRulesList = new ArrayList<>(); - ObjectMapper objectMapper = new ObjectMapper(); + while (courseIterator.hasNext()) { StudentCourse tempCourse = courseIterator.next(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java index 707f4d1a..efd27800 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/service/RuleEngineService.java @@ -2,19 +2,14 @@ import ca.bc.gov.educ.api.ruleengine.dto.ProgramAlgorithmRule; 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.rule.Rule; import ca.bc.gov.educ.api.ruleengine.rule.RuleFactory; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.SneakyThrows; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.stream.Collectors; - @Service public class RuleEngineService { @@ -33,15 +28,9 @@ public RuleProcessorData processGradAlgorithmRules(RuleProcessorData ruleProcess RuleProcessorData originalData = RuleProcessorRuleUtils.cloneObject(ruleProcessorData); ruleProcessorData.setGraduated(true); for (ProgramAlgorithmRule gradAlgorithmRule : originalData.getAlgorithmRules()) { - Rule rule = RuleFactory.createRule(gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), ruleProcessorData); + Rule rule = RuleFactory.createRule(gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), ruleProcessorData); rule.setInputData(ruleProcessorData); - List beforeRuleCourses = ruleProcessorData.getStudentCourses(); ruleProcessorData = (RuleProcessorData)rule.fire(); - List afterRuleCourses = ruleProcessorData.getStudentCourses(); - List courseDifference = beforeRuleCourses.stream().filter(element -> !afterRuleCourses.contains(element)).collect(Collectors.toList()); - if(logger.isDebugEnabled() && !courseDifference.isEmpty()) { - logger.debug("The course excluded by the {}/{} rule: {}", gradAlgorithmRule.getAlgorithmRuleCode().getAlgoRuleCode(), gradAlgorithmRule.getAlgorithmRuleCode().getRuleImplementation(), StringUtils.join(courseDifference, ",")); - } } if(ruleProcessorData.getNonGradReasons() == null || ruleProcessorData.getNonGradReasons().isEmpty()) { ruleProcessorData.setGraduated(ruleProcessorData.getRequirementsMet() != null && !ruleProcessorData.getRequirementsMet().isEmpty()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java index d56b2f41..024e2f85 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java @@ -2,11 +2,11 @@ import ca.bc.gov.educ.api.ruleengine.dto.StudentAssessment; import ca.bc.gov.educ.api.ruleengine.dto.StudentCourse; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.SerializationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; +import java.io.Serializable; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -71,12 +71,8 @@ public static List getExcludedStudentCourses(List } @SuppressWarnings("unchecked") - public static T cloneObject(T input) throws IOException { - - ObjectMapper objectMapper = new ObjectMapper(); - - return (T) objectMapper - .readValue(objectMapper.writeValueAsString(input), input.getClass()); + public static T cloneObject(T input) { + return (T) SerializationUtils.clone((Serializable) input); } public static List maintainExcludedCourses(String ruleName, List currentList, List existingExcludedList, boolean projected) {