From 42626a4dea093dbe55f5e9316ab2387fe4f89543 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 24 Jun 2024 12:33:30 -0600 Subject: [PATCH 1/8] GRAD2-2799-P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates- edit summary P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates --- .../educ/api/ruleengine/rule/BaseRule.java | 15 +++++++++++ .../rule/ExcludeAfterProgramCutoffRule.java | 4 +-- .../rule/ExcludeValidationCoursesRule.java | 13 ++++++++-- .../rule/IncompleteCoursesRule.java | 4 +-- .../api/ruleengine/rule/MatchCreditsRule.java | 4 +-- .../ruleengine/rule/MinAdultCoursesRule.java | 6 ++--- .../rule/RegistrationsDuplicateAssmtRule.java | 6 ++--- .../rule/RegistrationsDuplicateCrseRule.java | 6 ++--- .../rule/RegistrationsFailedCrseRule.java | 4 +-- .../ruleengine/rule/RegistrationsRule.java | 4 +-- .../ruleengine/util/RuleEngineApiUtils.java | 26 +++++++++++-------- .../util/RuleProcessorRuleUtils.java | 13 ++++++++-- 12 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java new file mode 100644 index 0000000..d6f7bad --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java @@ -0,0 +1,15 @@ +package ca.bc.gov.educ.api.ruleengine.rule; + +import java.util.Calendar; +import java.util.Date; + +public abstract class BaseRule implements Rule { + + Date toLastDayOfMonth(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java index ee8960c..f9de997 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class ExcludeAfterProgramCutoffRule implements Rule { +public class ExcludeAfterProgramCutoffRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(ExcludeAfterProgramCutoffRule.class); @Autowired @@ -40,7 +40,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); 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 d4af81c..a909d76 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 @@ -3,6 +3,7 @@ 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; @@ -12,13 +13,15 @@ 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 @NoArgsConstructor @AllArgsConstructor -public class ExcludeValidationCoursesRule implements Rule { +public class ExcludeValidationCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(ExcludeValidationCoursesRule.class); @@ -33,8 +36,14 @@ public RuleData fire() { for (StudentCourse studentCourse : studentCourseList) { String sessionDate = studentCourse.getSessionDate() + "/01"; + try { + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); + sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy/MM/dd"); + } catch (ParseException pe) { + logger.error("ERROR: {}",pe.getMessage()); + } String cName = studentCourse.getCourseCode()+studentCourse.getCourseLevel(); - if (studentCourse.getProvExamCourse().compareTo("Y")==0 && sessionDate.equalsIgnoreCase("2005/06/01") && (cName.compareTo("SS11") == 0 + if (studentCourse.getProvExamCourse().compareTo("Y")==0 && sessionDate.equalsIgnoreCase("2005/06/30") && (cName.compareTo("SS11") == 0 || cName.compareTo("SCH11") == 0 || cName.compareTo("FNS12") == 0)) { studentCourse.setValidationCourse(true); 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 77fe894..5413228 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 @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class IncompleteCoursesRule implements Rule { +public class IncompleteCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(IncompleteCoursesRule.class); @Autowired @@ -36,7 +36,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}" , pe.getMessage()); 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 21a7b20..5a2fb91 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 @@ -19,7 +19,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class MatchCreditsRule implements Rule { +public class MatchCreditsRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(MatchCreditsRule.class); @@ -140,7 +140,7 @@ public void splitSortStudentCourses(List studentCourses, Date adu String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } 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 5a940d7..78c1306 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 @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class MinAdultCoursesRule implements Rule { +public class MinAdultCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(MinAdultCoursesRule.class); @@ -66,7 +66,7 @@ public RuleData fire() { String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } @@ -137,7 +137,7 @@ public RuleData fire() { String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } 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 51b837c..1d16118 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 @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsDuplicateAssmtRule implements Rule { +public class RegistrationsDuplicateAssmtRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsDuplicateAssmtRule.class); @@ -44,8 +44,8 @@ public RuleData fire() { && !studentAssessmentsList.get(i).isDuplicate() && !studentAssessmentsList.get(j).isDuplicate()) { try { - Date sessionDate1 = RuleEngineApiUtils.parseDate(studentAssessmentsList.get(i).getSessionDate() + "/01", "yyyy/MM/dd"); - Date sessionDate2 = RuleEngineApiUtils.parseDate(studentAssessmentsList.get(j).getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentAssessmentsList.get(i).getSessionDate() + "/01", "yyyy/MM/dd")); + Date sessionDate2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentAssessmentsList.get(j).getSessionDate() + "/01", "yyyy/MM/dd")); String sDate1 = RuleEngineApiUtils.formatDate(sessionDate1, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String sDate2 = RuleEngineApiUtils.formatDate(sessionDate2, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); 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 78ec763..3a0fc9a 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 @@ -20,7 +20,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsDuplicateCrseRule implements Rule { +public class RegistrationsDuplicateCrseRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsDuplicateCrseRule.class); @@ -51,8 +51,8 @@ public RuleData fire() { continue; } try { - Date sessionDate1 = RuleEngineApiUtils.parseDate(studentCourseList.get(i).getSessionDate() + "/01", "yyyy/MM/dd"); - Date sessionDate2 = RuleEngineApiUtils.parseDate(studentCourseList.get(j).getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourseList.get(i).getSessionDate() + "/01", "yyyy/MM/dd")); + Date sessionDate2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourseList.get(j).getSessionDate() + "/01", "yyyy/MM/dd")); String sDate1 = RuleEngineApiUtils.formatDate(sessionDate1, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String sDate2 = RuleEngineApiUtils.formatDate(sessionDate2, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); 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 3212289..62333a8 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 @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsFailedCrseRule implements Rule { +public class RegistrationsFailedCrseRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsFailedCrseRule.class); @@ -36,7 +36,7 @@ public RuleData fire() { boolean inProgressCourse = false; for (StudentCourse studentCourse : studentCourseList) { try { - Date sessionDate = RuleEngineApiUtils.parseDate(studentCourse.getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourse.getSessionDate() + "/01", "yyyy/MM/dd")); String sDate = RuleEngineApiUtils.formatDate(sessionDate, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String today = RuleEngineApiUtils.formatDate(cal.getTime(), RuleEngineApiConstants.DEFAULT_DATE_FORMAT); int diff = RuleEngineApiUtils.getDifferenceInMonths(sDate,today); 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 d56c605..d4b630b 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 @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsRule implements Rule { +public class RegistrationsRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsRule.class); @@ -37,7 +37,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java index f84598c..3225008 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java @@ -14,10 +14,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.Period; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; public class RuleEngineApiUtils { @@ -50,7 +47,7 @@ public static Date parsingTraxDate(String sessionDate) { Date temp; Date sDate = null; try { - temp = RuleEngineApiUtils.parseDate(actualSessionDate, RuleEngineApiConstants.DATE_FORMAT); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(actualSessionDate, RuleEngineApiConstants.DATE_FORMAT)); String sDates = RuleEngineApiUtils.formatDate(temp, RuleEngineApiConstants.DATE_FORMAT); sDate = RuleEngineApiUtils.parseDate(sDates, RuleEngineApiConstants.DATE_FORMAT); } catch (ParseException pe) { @@ -140,12 +137,12 @@ public static List getCloneOptionalProgramRule(List< public static boolean checkDateForRestrictedCourses(String startDate,String endDate,String currentSessionDate) { try { - Date sDate = parseDate(startDate+"/01",RuleEngineApiConstants.DATE_FORMAT); + Date sDate = toLastDayOfMonth(parseDate(startDate+"/01",RuleEngineApiConstants.DATE_FORMAT)); if(endDate != null) { - Date eDate = parseDate(endDate + "/01", RuleEngineApiConstants.DATE_FORMAT); - return parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT).after(sDate) && parseDate(currentSessionDate + "/01", "yyyy/MM/dd").before(eDate); + Date eDate = toLastDayOfMonth(parseDate(endDate + "/01", RuleEngineApiConstants.DATE_FORMAT)); + return toLastDayOfMonth(parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT)).after(sDate) && toLastDayOfMonth(parseDate(currentSessionDate + "/01", "yyyy/MM/dd")).before(eDate); }else { - return parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT).after(sDate); + return toLastDayOfMonth(parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT)).after(sDate); } } catch (ParseException e) { logger.error(ERROR_MSG,e.getMessage()); @@ -159,9 +156,9 @@ public static boolean compareCourseSessionDates(String sessionDate1,String sessi sessionDate2 = sessionDate2 + "/01"; try { - Date temp1 = RuleEngineApiUtils.parseDate(sessionDate1, "yyyy/MM/dd"); + Date temp1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate1, "yyyy/MM/dd")); sessionDate1 = RuleEngineApiUtils.formatDate(temp1, "yyyy-MM-dd"); - Date temp2 = RuleEngineApiUtils.parseDate(sessionDate2, "yyyy/MM/dd"); + Date temp2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate2, "yyyy/MM/dd")); sessionDate2 = RuleEngineApiUtils.formatDate(temp2, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); @@ -183,4 +180,11 @@ public static boolean isCompletedCourse(String finalGrade, Double finalPercentag } return false; } + + private static Date toLastDayOfMonth(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } } 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 024e2f8..233eda0 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 @@ -11,6 +11,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -162,8 +163,9 @@ public static String getGradDate(List studentCourses) { for (StudentCourse studentCourse : studentCourses) { try { - if (dateFormat.parse(studentCourse.getSessionDate() + "/01").compareTo(gradDate) > 0) { - gradDate = dateFormat.parse(studentCourse.getSessionDate() + "/01"); + Date dateTocompare = toLastDayOfMonth(dateFormat.parse(studentCourse.getSessionDate() + "/01")); + if (dateTocompare.compareTo(gradDate) > 0) { + gradDate = dateTocompare; } } catch (ParseException e) { logger.debug("Error {}",e.getMessage()); @@ -193,4 +195,11 @@ public static void updateCourseLevelForCLC(List studentCourses, S } }); } + + private static Date toLastDayOfMonth(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } } From f19c491ad22d0955c5af985f7b0a7749b3856027 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 25 Jun 2024 09:52:23 -0700 Subject: [PATCH 2/8] GRAD2-2509: task is complete. GRAD2-2509: task is complete. --- .../bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 297dd92..32d01ae 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 @@ -58,7 +58,7 @@ public RuleData fire() { StudentCourse sc = studentCourseIterator.next(); for(OptionalProgramRequirement pR:careerProgramRulesMatch) { - if((pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) && (sc.getWorkExpFlag() != null && sc.getWorkExpFlag().equalsIgnoreCase("Y"))) { + if(pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { requiredCredits = Integer.parseInt(pR.getOptionalProgramRequirementCode().getRequiredCredits()); if (totalCredits + sc.getCredits() <= requiredCredits) { totalCredits += sc.getCredits(); From 5fbeb6a52a1447da6827ee24546bf3194e598717 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 26 Jun 2024 10:05:08 -0600 Subject: [PATCH 3/8] GRAD2-2799-P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates- edit summary P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates --- api/src/test/resources/SCCP-130319387-fail.json | 2 +- api/src/test/resources/SCCP-130319387.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/test/resources/SCCP-130319387-fail.json b/api/src/test/resources/SCCP-130319387-fail.json index 441b53b..46c7a55 100644 --- a/api/src/test/resources/SCCP-130319387-fail.json +++ b/api/src/test/resources/SCCP-130319387-fail.json @@ -23,7 +23,7 @@ "statusCode": "A", "memo": null, "trueStudentID": null, - "program": "2018-EN", + "program": "SCCP", "schoolOfRecord": "01919003", "schoolOfRecordName": "REVELSTOKE SECONDARY", "schoolOfRecordindependentAffiliation": "", diff --git a/api/src/test/resources/SCCP-130319387.json b/api/src/test/resources/SCCP-130319387.json index 08d92ac..78eb58c 100644 --- a/api/src/test/resources/SCCP-130319387.json +++ b/api/src/test/resources/SCCP-130319387.json @@ -23,7 +23,7 @@ "statusCode": "A", "memo": null, "trueStudentID": null, - "program": "2018-EN", + "program": "SCCP", "schoolOfRecord": "01919003", "schoolOfRecordName": "REVELSTOKE SECONDARY", "schoolOfRecordindependentAffiliation": "", From 3435874093faff6d1261e11dcbcf87a3cec6b2b5 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 26 Jun 2024 10:48:03 -0600 Subject: [PATCH 4/8] GRAD2-2799-P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates- edit summary P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates --- .../rule/RegistrationsDuplicateCrseRule.java | 4 +- .../ruleengine/util/RuleEngineApiUtils.java | 2 +- .../test/resources/SCCP-130319387-fail.json | 72 +++++++++++++++++-- api/src/test/resources/SCCP-130319387.json | 27 +++++-- 4 files changed, 91 insertions(+), 14 deletions(-) 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 3a0fc9a..93c91a4 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 @@ -37,8 +37,10 @@ public RuleData fire() { boolean inProgressCourse2 = false; boolean isCompletedCourse1 = false; boolean isCompletedCourse2 = false; - for (int i = 0; i < studentCourseList.size() - 1; i++) { + studentCourseList.sort(Comparator.comparing(StudentCourse::getCourseCode)); + + for (int i = 0; i < studentCourseList.size() - 1; i++) { for (int j = i + 1; j < studentCourseList.size(); j++) { if (studentCourseList.get(i).getCourseCode().equals(studentCourseList.get(j).getCourseCode()) && !studentCourseList.get(i).isDuplicate() diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java index 3225008..749ae5a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java @@ -176,7 +176,7 @@ public static boolean compareCourseSessionDates(String sessionDate1,String sessi // Courses with both finalLG(Letter Grade) & finalPercentage have some values public static boolean isCompletedCourse(String finalGrade, Double finalPercentage) { if (finalGrade != null && finalPercentage != null) { - return !"".equalsIgnoreCase(finalGrade.trim()) && finalPercentage.compareTo(0.0) > 0; + return !"".equalsIgnoreCase(finalGrade.trim()) && finalPercentage.compareTo(0.0D) > 0; } return false; } diff --git a/api/src/test/resources/SCCP-130319387-fail.json b/api/src/test/resources/SCCP-130319387-fail.json index 46c7a55..6c95cd6 100644 --- a/api/src/test/resources/SCCP-130319387-fail.json +++ b/api/src/test/resources/SCCP-130319387-fail.json @@ -199,6 +199,19 @@ "isActiveRule": "Y" } }, + { + "programAlgoRuleID": "c70b587f-af3d-d11b-e053-9ae9228eda21", + "graduationProgramCode": "SCCP", + "sortOrder": 22, + "algorithmRuleCode": { + "algoRuleCode": "CRSE_REGISTRATION_DUPLICATE_RULE", + "ruleImplementation": "RegistrationsDuplicateCrseRule", + "label": "Course Registrations rule", + "description": "Checks if the student achievement record (e.g., course) session date is still current or future dated (e.g. from today YYYYMM) or later) and no final result or special case exists.", + "displayOrder": 30, + "isActiveRule": "Y" + } + }, { "programAlgoRuleID": "c70b587f-af82-d11b-e053-9ae9228eda21", "graduationProgramCode": "SCCP", @@ -443,9 +456,9 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 92.0, + "completedCoursePercentage": 0.0, "completedCourseLetterGrade": "A", - "interimPercent": 92.0, + "interimPercent": 0.0, "interimLetterGrade": "A", "bestSchoolPercent": null, "bestExamPercent": null, @@ -492,9 +505,58 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 90.0, + "completedCoursePercentage": 0.0, "completedCourseLetterGrade": "A", - "interimPercent": 90.0, + "interimPercent": 0.0, + "interimLetterGrade": "A", + "bestSchoolPercent": null, + "bestExamPercent": null, + "equivOrChallenge": "", + "fineArtsAppliedSkills": "", + "metLitNumRequirement": null, + "credits": 4, + "creditsUsedForGrad": 0, + "relatedCourse": "", + "relatedCourseName": null, + "relatedLevel": "", + "hasRelatedCourse": "N", + "genericCourseType": "", + "language": "", + "workExpFlag": " ", + "specialCase": null, + "toWriteFlag": null, + "provExamCourse": "N", + "leftOverCredits": null, + "projected": false, + "failed": false, + "duplicate": false, + "used": false, + "notCompleted": false, + "grade10Course": false, + "usedInMatchRule": false, + "restricted": false, + "locallyDeveloped": false, + "cutOffCourse": false, + "careerPrep": false, + "lessCreditCourse": false, + "validationCourse": false, + "boardAuthorityAuthorized": false, + "independentDirectedStudies": false, + "notEligibleForElective": false + }, + { + "pen": "130319387", + "courseCode": "TEAD", + "courseName": "ENGINE AND DRIVETRAIN 12", + "originalCredits": 4, + "courseLevel": "12", + "sessionDate": "2021/06", + "customizedCourseName": "", + "gradReqMet": "", + "gradReqMetDetail": "", + "completedCoursePercentage": 0.0, + "completedCourseLetterGrade": "A", + "interimPercent": 0.0, "interimLetterGrade": "A", "bestSchoolPercent": null, "bestExamPercent": null, @@ -3272,7 +3334,7 @@ "requirementsMet": null, "gradStatus": { "pen": null, - "program": "2018-EN", + "program": "SCCP", "programCompletionDate": null, "gpa": null, "honoursStanding": null, diff --git a/api/src/test/resources/SCCP-130319387.json b/api/src/test/resources/SCCP-130319387.json index 78eb58c..c62efab 100644 --- a/api/src/test/resources/SCCP-130319387.json +++ b/api/src/test/resources/SCCP-130319387.json @@ -199,6 +199,19 @@ "isActiveRule": "Y" } }, + { + "programAlgoRuleID": "c70b587f-af3d-d11b-e053-9ae9228eda21", + "graduationProgramCode": "SCCP", + "sortOrder": 22, + "algorithmRuleCode": { + "algoRuleCode": "CRSE_REGISTRATION_DUPLICATE_RULE", + "ruleImplementation": "RegistrationsDuplicateCrseRule", + "label": "Course Registrations rule", + "description": "Checks if the student achievement record (e.g., course) session date is still current or future dated (e.g. from today YYYYMM) or later) and no final result or special case exists.", + "displayOrder": 30, + "isActiveRule": "Y" + } + }, { "programAlgoRuleID": "c70b587f-af82-d11b-e053-9ae9228eda21", "graduationProgramCode": "SCCP", @@ -369,9 +382,9 @@ "leftOverCredits": null, "projected": false, "failed": false, - "duplicate": false, + "duplicate": true, "used": false, - "notCompleted": false, + "notCompleted": true, "grade10Course": false, "usedInMatchRule": false, "restricted": false, @@ -420,7 +433,7 @@ "failed": false, "duplicate": false, "used": false, - "notCompleted": false, + "notCompleted": true, "grade10Course": false, "usedInMatchRule": false, "restricted": false, @@ -443,7 +456,7 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 92.0, + "completedCoursePercentage": 80.0, "completedCourseLetterGrade": "A", "interimPercent": 92.0, "interimLetterGrade": "A", @@ -879,13 +892,13 @@ "courseCode": "TSITA", "courseName": "EXPLORE: TRADES SAMPLER (ITA) 12B", "originalCredits": 4, - "courseLevel": "12B", + "courseLevel": "12A", "sessionDate": "2021/06", "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", "completedCoursePercentage": 80.0, - "completedCourseLetterGrade": "B", + "completedCourseLetterGrade": "A", "interimPercent": 80.0, "interimLetterGrade": "B", "bestSchoolPercent": null, @@ -3272,7 +3285,7 @@ "requirementsMet": null, "gradStatus": { "pen": null, - "program": "2018-EN", + "program": "SCCP", "programCompletionDate": "2022/05", "gpa": null, "honoursStanding": null, From 4c398095cf87b2667773ed7d2bc449c871fdb613 Mon Sep 17 00:00:00 2001 From: "chris.ditcher" Date: Wed, 26 Jun 2024 14:46:12 -0700 Subject: [PATCH 5/8] Updated to Ubuntu 22.04 --- .github/workflows/build.from.developer.branch.deploy.to.dev.yml | 2 +- .github/workflows/build.from.main.branch.deploy.to.dev.yml | 2 +- .github/workflows/build.from.release.branch.deploy.to.dev.yml | 2 +- .github/workflows/create_tag.yml | 2 +- .github/workflows/deploy_prod.yml | 2 +- .github/workflows/deploy_test.yml | 2 +- .github/workflows/on.pr.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml index 03bae86..2c584b7 100644 --- a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml +++ b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml @@ -48,7 +48,7 @@ on: jobs: openshift-ci-cd: name: Build and deploy to OpenShift DEV from developer branch - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: dev steps: diff --git a/.github/workflows/build.from.main.branch.deploy.to.dev.yml b/.github/workflows/build.from.main.branch.deploy.to.dev.yml index 245fd94..f9264be 100644 --- a/.github/workflows/build.from.main.branch.deploy.to.dev.yml +++ b/.github/workflows/build.from.main.branch.deploy.to.dev.yml @@ -36,7 +36,7 @@ on: jobs: openshift-ci-cd: name: Build and deploy to OpenShift DEV - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: dev steps: diff --git a/.github/workflows/build.from.release.branch.deploy.to.dev.yml b/.github/workflows/build.from.release.branch.deploy.to.dev.yml index 94b47a1..0ea05d6 100644 --- a/.github/workflows/build.from.release.branch.deploy.to.dev.yml +++ b/.github/workflows/build.from.release.branch.deploy.to.dev.yml @@ -43,7 +43,7 @@ on: jobs: openshift-ci-cd: name: Build and deploy to OpenShift DEV from release branch - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: dev steps: diff --git a/.github/workflows/create_tag.yml b/.github/workflows/create_tag.yml index 28501b2..10ee0f5 100644 --- a/.github/workflows/create_tag.yml +++ b/.github/workflows/create_tag.yml @@ -26,7 +26,7 @@ on: jobs: tag_image: name: Tag Image - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: dev outputs: diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index a40b6f1..b560d33 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -32,7 +32,7 @@ on: jobs: deploy-to-openshift-prod: name: Deploy to OpenShift PROD - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: prod outputs: diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index 77ff60a..98612da 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -32,7 +32,7 @@ on: jobs: deploy-to-openshift-test: name: Deploy to OpenShift TEST - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 environment: test outputs: diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml index 2eae993..4c1f2c1 100644 --- a/.github/workflows/on.pr.yml +++ b/.github/workflows/on.pr.yml @@ -10,7 +10,7 @@ on: jobs: quality_profile: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 defaults: run: From a8325aa9e656f97dfb3d5b1fd17746e974f7dcee Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 27 Jun 2024 09:03:29 -0600 Subject: [PATCH 6/8] GRAD2-2799-P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates- edit summary P3 GRAD Incident: REGALG is creating SCCP certificates for students with future completion dates --- .../bc/gov/educ/api/ruleengine/rule/BaseRule.java | 11 +++++++---- .../api/ruleengine/util/RuleEngineApiUtils.java | 13 ++++++++----- .../api/ruleengine/util/RuleProcessorRuleUtils.java | 13 ++++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java index d6f7bad..80ca022 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java @@ -6,10 +6,13 @@ public abstract class BaseRule implements Rule { Date toLastDayOfMonth(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); - return cal.getTime(); + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java index 749ae5a..472ee9f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java @@ -181,10 +181,13 @@ public static boolean isCompletedCourse(String finalGrade, Double finalPercentag return false; } - private static Date toLastDayOfMonth(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); - return cal.getTime(); + static Date toLastDayOfMonth(Date date) { + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; } } 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 233eda0..796f44d 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 @@ -196,10 +196,13 @@ public static void updateCourseLevelForCLC(List studentCourses, S }); } - private static Date toLastDayOfMonth(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); - return cal.getTime(); + static Date toLastDayOfMonth(Date date) { + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; } } From 2f429f714c2367bc79edc49ce1d2569a70020ef2 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 27 Jun 2024 09:22:27 -0700 Subject: [PATCH 7/8] GRAD2-2509: matching student course with optional program requirement thru the rule code is implemented after workExpFlag check is removed. GRAD2-2509: matching student course with optional program requirement thru the rule code is implemented after workExpFlag check is removed. --- .../ruleengine/rule/CareerProgramMatchRule.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 32d01ae..6ca78b0 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 @@ -38,6 +38,11 @@ public RuleData fire() { List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); + List courseRequirements = ruleProcessorData.getCourseRequirements(); + if(courseRequirements == null) { + courseRequirements = new ArrayList<>(); + } + List courseList = RuleProcessorRuleUtils.getUniqueStudentCourses( obj.getStudentCoursesOptionalProgram(), ruleProcessorData.isProjected()); List careerProgramRulesMatch = obj.getOptionalProgramRules() @@ -57,8 +62,16 @@ public RuleData fire() { while (studentCourseIterator.hasNext()) { StudentCourse sc = studentCourseIterator.next(); - for(OptionalProgramRequirement pR:careerProgramRulesMatch) { - if(pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) { + List matchedCourseRequirements = courseRequirements.stream() + .filter(cr -> sc.getCourseCode().compareTo(cr.getCourseCode()) == 0 + && sc.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) + .toList(); + + for(OptionalProgramRequirement pR:careerProgramRulesMatch) { + long matchedCount = matchedCourseRequirements.stream() + .filter(cr -> cr.getRuleCode().getCourseRequirementCode().compareTo(pR.getOptionalProgramRequirementCode().getOptProReqCode()) == 0) + .count(); + if(matchedCount > 0 && (pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0)) { requiredCredits = Integer.parseInt(pR.getOptionalProgramRequirementCode().getRequiredCredits()); if (totalCredits + sc.getCredits() <= requiredCredits) { totalCredits += sc.getCredits(); From acc2e7037997a4d22a558cb7c98f7ca48adddbf5 Mon Sep 17 00:00:00 2001 From: githubmamatha <106563495+githubmamatha@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:26:04 -0700 Subject: [PATCH 8/8] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 23e3a22..685722a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -10,7 +10,7 @@ ca.bc.gov.educ educ-grad-rule-engine-api - 1.8.57 + 1.8.58 educ-grad-rule-engine-api Rule Engine API for GRAD team