From 27663b43e402539f6470a4e4e6830db3d70fe7fa Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 3 Sep 2024 14:23:36 -0700 Subject: [PATCH 1/6] GRAD2-2645: task is complete. GRAD2-2645: task is complete. --- .../dataconversion/constant/FieldName.java | 1 + .../dataconversion/constant/FieldType.java | 3 +- .../dataconversion/model/ConvGradStudent.java | 2 + .../model/GraduationStudentRecord.java | 1 + .../model/StudentCommonDTO.java | 2 + .../dataconversion/model/StudentGradDTO.java | 1 + .../model/TraxGraduationUpdateDTO.java | 4 ++ .../process/StudentProcess.java | 9 +++ .../StudentGraduationUpdateEventService.java | 14 +++- .../process/StudentProcessTest.java | 58 ++++++++++++---- ...udentGraduationUpdateEventServiceTest.java | 68 +++++++++++++++++++ 11 files changed, 149 insertions(+), 14 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java index 1d8cec7c..28e3c51f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldName.java @@ -2,6 +2,7 @@ public enum FieldName { SCHOOL_OF_RECORD, + SCHOOL_OF_RECORD_ID, GRAD_PROGRAM, ADULT_START_DATE, SLP_DATE, diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java index 394bc82c..fcf9ad9a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/FieldType.java @@ -2,5 +2,6 @@ public enum FieldType { STRING, - DATE + DATE, + GUID } \ No newline at end of file diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java index 6aef3af3..a01b9abf 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java @@ -9,6 +9,7 @@ import java.util.Date; import java.util.List; +import java.util.UUID; @Data @Builder @@ -25,6 +26,7 @@ public class ConvGradStudent { private String honoursStanding; // inc private String studentGradData; private String schoolOfRecord; // inc + private UUID schoolOfRecordId; // inc private String schoolAtGrad; // inc private String studentGrade; // inc private String studentStatus; // inc diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/GraduationStudentRecord.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/GraduationStudentRecord.java index 6941df22..0088ff4e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/GraduationStudentRecord.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/GraduationStudentRecord.java @@ -24,6 +24,7 @@ public class GraduationStudentRecord extends BaseModel{ private String recalculateGradStatus; private String recalculateProjectedGrad; private String schoolOfRecord; + private UUID schoolOfRecordId; private String studentGrade; private String studentStatus; private UUID studentID; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentCommonDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentCommonDTO.java index ce236428..eb543abc 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentCommonDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentCommonDTO.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; @Slf4j @Data @@ -14,6 +15,7 @@ public class StudentCommonDTO extends StudentDemographicDTO { private String program; private String gradDate; private String schoolOfRecord; + private UUID schoolOfRecordId; private String schoolAtGrad; private String studentGrade; private String studentStatus; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java index 3c364a2a..c3fb2d05 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java @@ -19,6 +19,7 @@ public class StudentGradDTO extends StudentCommonDTO { private String newProgram; private String newGradDate; private String newSchoolOfRecord; + private UUID newSchoolOfRecordId; private String newStudentGrade; private String newStudentStatus; private String newCitizenship; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java index f8a633b0..d3e912ab 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java @@ -7,6 +7,8 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.UUID; + @Data @Builder @AllArgsConstructor @@ -20,6 +22,8 @@ public class TraxGraduationUpdateDTO extends TraxStudentUpdateDTO { private String studentGrade; // MINCODE private String schoolOfRecord; + // SchoolId + private UUID schoolOfRecordId; // SLP_DATE private String slpDate; // STUD_CITIZ diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index 70f59889..7576cf54 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -182,6 +182,7 @@ private void convertStudentData(ConvGradStudent student, Student penStudent, Gra gradStudent.setSchoolAtGrad(null); gradStudent.setSchoolOfRecord(StringUtils.isNotBlank(student.getSchoolOfRecord())? student.getSchoolOfRecord() : null); + gradStudent.setSchoolOfRecordId(student.getSchoolOfRecordId()); gradStudent.setStudentGrade(student.getStudentGrade()); gradStudent.setStudentStatus(getGradStudentStatus(student.getStudentStatus(), student.getArchiveFlag())); @@ -373,6 +374,7 @@ public StudentGradDTO loadStudentData(String pen, String accessToken) { studentData.setStudentGrade(gradStudent.getStudentGrade()); studentData.setStudentStatus(gradStudent.getStudentStatus()); studentData.setSchoolOfRecord(gradStudent.getSchoolOfRecord()); + studentData.setSchoolOfRecordId(gradStudent.getSchoolOfRecordId()); studentData.setSchoolAtGrad(gradStudent.getSchoolAtGrad()); studentData.setCitizenship(gradStudent.getStudentCitizenship()); studentData.setAdultStartDate(gradStudent.getAdultStartDate()); @@ -454,6 +456,13 @@ public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventT .build(); requestDTO.getUpdateFields().add(field); } + // SchoolId + if (gradStudent.getNewSchoolOfRecordId() != null) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.GUID).name(FieldName.SCHOOL_OF_RECORD_ID).value(gradStudent.getNewSchoolOfRecordId()) + .build(); + requestDTO.getUpdateFields().add(field); + } // GRAD Program if (StringUtils.isNotBlank(gradStudent.getNewProgram())) { OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index d96b951d..b8cfa2b0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -90,7 +90,7 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu isChanged = true; } if (!currentStudent.isArchived() || !currentStudent.isGraduated()) { - // 1. School of record + // 1.1 School of record if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord()); // Transcript @@ -102,6 +102,18 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); isChanged = true; } + // 1.2 SchoolOfRecordId + if (updateGrad.getSchoolOfRecordId() != null && updateGrad.getSchoolOfRecordId() != currentStudent.getSchoolOfRecordId()) { + currentStudent.setNewSchoolOfRecordId(updateGrad.getSchoolOfRecordId()); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + if (!currentStudent.isArchived()) { + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + log.info(" => school of record id : current = {}, request = {}", currentStudent.getSchoolOfRecordId(), currentStudent.getNewSchoolOfRecordId()); + isChanged = true; + } // 2. Grad Program String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java index fce7d4e4..0f188e5c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java @@ -74,6 +74,7 @@ public void tearDown() { public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_thenReturnFailure() throws Exception { String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -82,8 +83,8 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(new ArrayList<>()); ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .programCodes(new ArrayList<>()).build(); + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("SCCP").programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); @@ -99,6 +100,7 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnFailure() throws Exception { String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -107,7 +109,8 @@ public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnF when(this.restUtils.getStudentsByPen(pen, "123")).thenThrow(new RuntimeException("Test")); ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") + .studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("SCCP") .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -126,6 +129,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -148,8 +152,8 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .programCodes(new ArrayList<>()).build(); + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("SCCP").programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); @@ -165,6 +169,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -188,7 +193,8 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1950") .studentGrade("AD").archiveFlag("A").studentStatus("A") - .schoolOfRecord(mincode).graduationRequirementYear("1950") + .schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("1950") .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -205,6 +211,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -255,7 +262,8 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers when(this.restUtils.getOptionalProgram("2018-EN", "FI", "123")).thenReturn(specialProgram); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("2018") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("2018") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -274,6 +282,7 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -330,7 +339,8 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR when(this.restUtils.getOptionalProgram("2018-EN", "FI", "123")).thenReturn(specialProgram); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("2018") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("2018") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -349,6 +359,7 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -405,7 +416,8 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .studentStatus("M").schoolOfRecord(mincode).graduationRequirementYear("1986") + .studentStatus("M").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("1986") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -424,6 +436,7 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -480,7 +493,8 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t when(this.restUtils.getOptionalProgram("1996-EN", "FI", "123")).thenReturn(specialProgram); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1996-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1996") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("1996") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -499,6 +513,7 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -556,7 +571,8 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("1986") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -575,6 +591,7 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); School school = new School(); school.setMinCode(mincode); @@ -632,7 +649,8 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .archiveFlag("I").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986") + .archiveFlag("I").studentStatus("A").schoolOfRecord(mincode).schoolOfRecordId(schoolOfRecordId) + .graduationRequirementYear("1986") .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -813,6 +831,7 @@ public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSucc graduationStudentRecord.setStudentGrade("11"); graduationStudentRecord.setStudentStatus("CUR"); graduationStudentRecord.setSchoolOfRecord("222336"); + graduationStudentRecord.setSchoolOfRecordId(UUID.randomUUID()); StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); studentOptionalProgram1.setId(UUID.randomUUID()); @@ -835,6 +854,7 @@ public void testSaveGraduationStudent_whenPFisChangedToEN_then_returnAPICallSucc requestStudent.setNewProgram("2018-EN"); requestStudent.setNewStudentGrade("12"); requestStudent.setNewSchoolOfRecord("333456"); + requestStudent.setNewSchoolOfRecordId(UUID.randomUUID()); requestStudent.setNewStudentStatus("ARC"); requestStudent.setNewRecalculateGradStatus("Y"); requestStudent.setNewRecalculateProjectedGrad("Y"); @@ -861,6 +881,7 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC graduationStudentRecord.setStudentGrade("11"); graduationStudentRecord.setStudentStatus("CUR"); graduationStudentRecord.setSchoolOfRecord("222336"); + graduationStudentRecord.setSchoolOfRecordId(UUID.randomUUID()); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(graduationStudentRecord); @@ -870,6 +891,7 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC requestStudent.setNewProgram("1950"); requestStudent.setNewStudentGrade("AD"); requestStudent.setNewSchoolOfRecord("333456"); + requestStudent.setNewSchoolOfRecordId(UUID.randomUUID()); requestStudent.setNewStudentStatus("ARC"); requestStudent.setNewRecalculateGradStatus("Y"); requestStudent.setNewRecalculateProjectedGrad("Y"); @@ -898,6 +920,7 @@ public void testSaveGraduationStudent_whenStudentStatus_isChanged_then_returnAPI graduationStudentRecord.setStudentGrade("11"); graduationStudentRecord.setStudentStatus("CUR"); graduationStudentRecord.setSchoolOfRecord("222336"); + graduationStudentRecord.setSchoolOfRecordId(UUID.randomUUID()); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(graduationStudentRecord); @@ -907,6 +930,7 @@ public void testSaveGraduationStudent_whenStudentStatus_isChanged_then_returnAPI requestStudent.setNewProgram("1950"); requestStudent.setNewStudentGrade("AD"); requestStudent.setNewSchoolOfRecord("333456"); + requestStudent.setNewSchoolOfRecordId(UUID.randomUUID()); requestStudent.setNewStudentStatus("ARC"); requestStudent.setNewRecalculateGradStatus("Y"); requestStudent.setNewRecalculateProjectedGrad("Y"); @@ -996,6 +1020,7 @@ public void testLoadStudentData_whenGradStudentAPIisDownForStudentOptionalProgra UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -1010,6 +1035,7 @@ public void testLoadStudentData_whenGradStudentAPIisDownForStudentOptionalProgra gradStudent.setHonoursStanding("Y"); gradStudent.setSchoolAtGrad(mincode); gradStudent.setSchoolOfRecord(mincode); + gradStudent.setSchoolOfRecordId(schoolOfRecordId); gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -1026,6 +1052,7 @@ public void testLoadStudentData_whenGradStudentAPIisDownForStudentCareerPrograms UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -1040,6 +1067,7 @@ public void testLoadStudentData_whenGradStudentAPIisDownForStudentCareerPrograms gradStudent.setHonoursStanding("Y"); gradStudent.setSchoolAtGrad(mincode); gradStudent.setSchoolOfRecord(mincode); + gradStudent.setSchoolOfRecordId(schoolOfRecordId); gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); OptionalProgram optionalProgram1 = new OptionalProgram(); @@ -1085,6 +1113,7 @@ public void testLoadStudentData_withGivenData_returnsStudentGradDTO_withAPICallS UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -1099,6 +1128,7 @@ public void testLoadStudentData_withGivenData_returnsStudentGradDTO_withAPICallS gradStudent.setHonoursStanding("Y"); gradStudent.setSchoolAtGrad(mincode); gradStudent.setSchoolOfRecord(mincode); + gradStudent.setSchoolOfRecordId(schoolOfRecordId); gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); OptionalProgram optionalProgram1 = new OptionalProgram(); @@ -1177,6 +1207,7 @@ public void testTriggerGraduationBatchRun_withMergedStatus_returnsNoBatchRun() { UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -1191,6 +1222,7 @@ public void testTriggerGraduationBatchRun_withMergedStatus_returnsNoBatchRun() { gradStudent.setHonoursStanding("Y"); gradStudent.setSchoolAtGrad(mincode); gradStudent.setSchoolOfRecord(mincode); + gradStudent.setSchoolOfRecordId(schoolOfRecordId); gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); @@ -1209,6 +1241,7 @@ public void testTriggerGraduationBatchRun_withCurrentStatus_returnsNoBatchRun() UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -1223,6 +1256,7 @@ public void testTriggerGraduationBatchRun_withCurrentStatus_returnsNoBatchRun() gradStudent.setHonoursStanding("Y"); gradStudent.setSchoolAtGrad(mincode); gradStudent.setSchoolOfRecord(mincode); + gradStudent.setSchoolOfRecordId(schoolOfRecordId); gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index afa2c8b3..f8f8e144 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -66,6 +66,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -75,6 +76,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -93,6 +95,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -131,8 +134,10 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -143,6 +148,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -162,6 +168,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -195,8 +202,10 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -207,6 +216,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("I"); @@ -226,6 +236,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived currentStudent.setStudentStatus("ARC"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -259,8 +270,10 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -271,6 +284,7 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("I"); @@ -290,6 +304,7 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/02"); // Optional Program Codes @@ -324,8 +339,10 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -336,6 +353,7 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("I"); @@ -355,6 +373,7 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -388,8 +407,10 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -400,6 +421,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -419,6 +441,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ currentStudent.setStudentStatus("ARC"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -452,6 +475,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newCitizenship = "C"; @@ -463,6 +487,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setCitizenship(newCitizenship); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -483,6 +508,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate(null); // Optional Program Codes @@ -517,8 +543,10 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "093444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -528,6 +556,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -546,6 +575,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -579,8 +609,10 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg // Program & School String program = "2018-PF"; String mincode = "093333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -590,6 +622,7 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -608,6 +641,7 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -641,8 +675,10 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr // Program & School String program = "1950"; String mincode = "111222"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -652,6 +688,7 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -670,6 +707,7 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -704,8 +742,10 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -715,6 +755,7 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange traxGraduationUpdate.setGraduationRequirementYear("1950"); traxGraduationUpdate.setStudentGrade("AD"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -734,6 +775,7 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -768,8 +810,10 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String newSlpDate = "202006"; String updateType = "UPD_GRAD"; @@ -780,6 +824,7 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI traxGraduationUpdate.setGraduationRequirementYear("SCCP"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setSlpDate(newSlpDate); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -800,6 +845,7 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -834,8 +880,10 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI // Program & School String program = "2018-PF"; String mincode = "093333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String newSlpDate = "202006"; String updateType = "UPD_GRAD"; @@ -846,6 +894,7 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI traxGraduationUpdate.setGraduationRequirementYear("SCCP"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setSlpDate(newSlpDate); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -866,6 +915,7 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -900,8 +950,10 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC // Program & School String program = "SCCP"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -911,6 +963,7 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -930,6 +983,7 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/01"); // Optional Program Codes @@ -995,8 +1049,10 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "093444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -1006,6 +1062,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -1024,6 +1081,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/06"); // Optional Program Codes @@ -1058,6 +1116,7 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI // Program & School String program = "SCCP"; String mincode = "093333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newSlpDate = "202006"; @@ -1069,6 +1128,7 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI traxGraduationUpdate.setGraduationRequirementYear("SCCP"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setSlpDate(newSlpDate); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -1089,6 +1149,7 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/06"); // Optional Program Codes @@ -1124,8 +1185,10 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -1136,6 +1199,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -1155,6 +1219,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/06"); // Optional Program Codes @@ -1189,6 +1254,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newCitizenship = "C"; @@ -1200,6 +1266,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setCitizenship(newCitizenship); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -1220,6 +1287,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT currentStudent.setStudentStatus("CUR"); currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/06"); // Optional Program Codes From 3205c3e514c49717c01c825cf78a4b9d8ffeb97c Mon Sep 17 00:00:00 2001 From: "chris.ditcher" Date: Thu, 12 Sep 2024 11:46:57 -0700 Subject: [PATCH 2/6] Increased header size --- api/src/main/resources/application.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index d88727a7..5b2e05e6 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -88,6 +88,7 @@ server: worker: 128 io: 16 #port: ${HTTP_PORT} + max-http-request-header-size: 20000 #API Documentation springdoc: From 71c51c20ae28fa6f68c02a6ae718b17ce8047b76 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Fri, 20 Sep 2024 16:44:12 -0700 Subject: [PATCH 3/6] GRAD2-2934, 2922, & 2950: tasks are completed. GRAD2-2934, 2922, 2950: tasks are completed. --- .../process/StudentProcess.java | 4 +- .../service/student/StudentBaseService.java | 51 +- .../StudentGraduationUpdateBaseService.java | 269 +++++++ .../StudentGraduationUpdateEventService.java | 196 ++--- ...udentGraduationUpdateEventServiceTest.java | 720 +++++++++++++++++- 5 files changed, 1044 insertions(+), 196 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index 7576cf54..25a7ef8f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -186,7 +186,7 @@ private void convertStudentData(ConvGradStudent student, Student penStudent, Gra gradStudent.setStudentGrade(student.getStudentGrade()); gradStudent.setStudentStatus(getGradStudentStatus(student.getStudentStatus(), student.getArchiveFlag())); - handleAdultStartRule(student, penStudent, gradStudent); + handleAdultStartRule(penStudent, gradStudent); // flags if (StringUtils.equalsIgnoreCase(gradStudent.getStudentStatus(), STUDENT_STATUS_MERGED)) { @@ -619,7 +619,7 @@ public void triggerGraduationBatchRun(EventType eventType, UUID studentID, Strin } } - private void handleAdultStartRule(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent) { + private void handleAdultStartRule(Student penStudent, GraduationStudentRecord gradStudent) { if ("1950".equalsIgnoreCase(gradStudent.getProgram())) { Date dob = EducGradDataConversionApiUtils.parseDate(penStudent.getDob()); Date adultStartDate = DateUtils.addYears(dob, 18); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java index c2afcb99..7d4d6bf6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java @@ -10,7 +10,10 @@ import java.util.Arrays; import java.util.List; -public class StudentBaseService { +public abstract class StudentBaseService { + + // NULL String => Nullify (set to NULL) + public static final String NULL_VALUE = "NULL"; // Student Status public static final String STUDENT_STATUS_CURRENT = "CUR"; @@ -109,14 +112,44 @@ protected String getGradProgram(String graduationRequirementYear, String schoolO } protected void populateNewBatchFlags(StudentGradDTO currentStudent) { - if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudent.getStudentStatus())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - } else { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + default -> { + // do not set flags to Y + currentStudent.setNewRecalculateGradStatus(null); + currentStudent.setNewRecalculateProjectedGrad(null); + } + } + } + + protected void validateAndAdjustNewBatchFlags(StudentGradDTO currentStudent) { + String currentStudentStatus = currentStudent.getStudentStatus(); + String newStudentStatus = currentStudent.getNewStudentStatus(); + // 1. If a student in GRAD is ARC/TER then do not set TVR flag + if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudentStatus) || STUDENT_STATUS_TERMINATED.equalsIgnoreCase(currentStudentStatus)) { + currentStudent.setNewRecalculateProjectedGrad(null); + } + // 2. If a student in GRAD is MER then do not set Transcript & TVR flags + if (STUDENT_STATUS_MERGED.equalsIgnoreCase(currentStudentStatus)) { + currentStudent.setNewRecalculateGradStatus(null); + currentStudent.setNewRecalculateProjectedGrad(null); + } + // 3. If a student in GRAD is changed to ARC/TER then set TVR flag to NULL + if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(newStudentStatus) || STUDENT_STATUS_TERMINATED.equalsIgnoreCase(newStudentStatus)) { + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); + } + // 4. If a student in GRAD is changed to MER then set Transcript & TVR flags to NULL + if (STUDENT_STATUS_MERGED.equalsIgnoreCase(newStudentStatus)) { + currentStudent.setNewRecalculateGradStatus(NULL_VALUE); + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java new file mode 100644 index 00000000..1486cfda --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java @@ -0,0 +1,269 @@ +package ca.bc.gov.educ.api.dataconversion.service.student; + +import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; +import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; + +import java.util.Date; + +public abstract class StudentGraduationUpdateBaseService extends StudentBaseService { + + protected abstract boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken); + + protected void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) { + boolean addDualDogwood = false; + boolean addFrenchImmersion = false; + + if (!currentStudent.isSCCP() && currentStudent.isGraduated()) { + currentStudent.setNewProgram(null); + return; + } + + if (newGradProgram.endsWith("-PF")) { + // from EN to PF + // from PF to PF + // from 1950 to PF + // from SCCP to PF + addDualDogwood = true; + } else if (newGradProgram.endsWith("-EN") && (currentStudent.getProgram().endsWith("-PF") || hasAnyFrenchImmersionCourse(newGradProgram, pen, accessToken))) { + // from PF to EN - allowed for SD93/Yukon PF schools + // from EN to EN + // from 1950 to EN + // from SCCP to EN + addFrenchImmersion = true; + } + + currentStudent.setAddDualDogwood(addDualDogwood); + currentStudent.setAddFrenchImmersion(addFrenchImmersion); + + currentStudent.setNewProgram(newGradProgram); + } + + protected void handleAdultStartDate(StudentGradDTO currentStudent) { + if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) { + Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday()); + Date adultStartDate = DateUtils.addYears(dob, 18); + currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd + } + } + + protected boolean processSchoolOfRecord(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Do not set flags to Y + isChanged = true; + } + } + return isChanged; + } + + protected boolean processStudentGrade(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewStudentGrade(value); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + if (!currentStudent.isGraduated()) { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + } + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewStudentGrade(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewStudentGrade(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewStudentGrade(value); + // Do not set flags to Y + isChanged = true; + } + } + return isChanged; + } + + protected boolean processGraduationProgram(StudentGradDTO currentStudent, String pen, String gradProgram, String accessToken) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> { + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + default -> { // MER or DEC + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Do not set flags to Y + isChanged = true; + } + } + + } + return isChanged; + } + + protected boolean processSlpDate(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + default -> { // MER or DEC + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Do not set flags to Y + isChanged = true; + } + } + + } + return isChanged; + } + + protected boolean processCitizenship(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewCitizenship(value); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + if (!currentStudent.isGraduated()) { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + } + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewCitizenship(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewCitizenship(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewCitizenship(value); + // Do not set flags to Y + isChanged = true; + } + + } + return isChanged; + } + + protected void processStudentStatus(StudentGradDTO currentStudent, String value) { + // UpdData + currentStudent.setNewStudentStatus(value); + switch(value) { + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_MERGED -> { + // TVR + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); + } + case STUDENT_STATUS_CURRENT -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + case STUDENT_STATUS_TERMINATED -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); + } + default -> { // DEC + } + } + } +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index b8cfa2b0..76e986da 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -6,23 +6,20 @@ import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; import ca.bc.gov.educ.api.dataconversion.service.EventService; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; -import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; import ca.bc.gov.educ.api.dataconversion.util.RestUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.util.Date; import static ca.bc.gov.educ.api.dataconversion.constant.EventStatus.PROCESSED; import static ca.bc.gov.educ.api.dataconversion.constant.EventType.UPD_GRAD; @Service @Slf4j -public class StudentGraduationUpdateEventService extends StudentBaseService implements EventService { +public class StudentGraduationUpdateEventService extends StudentGraduationUpdateBaseService implements EventService { private final EventRepository eventRepository; @@ -71,166 +68,71 @@ public void processEvent(T request, Event event) { public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO currentStudent, String accessToken) { boolean isChanged = false; + boolean isStudentStatusChanged = false; log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); // Processing order is important for the first 3 fields below. + // 1. School of record + if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { + isChanged = processSchoolOfRecord(currentStudent, updateGrad.getSchoolOfRecord()); + log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); + } + // 2. Grad Program + String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); + if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { + isChanged = processGraduationProgram(currentStudent, updateGrad.getPen(), gradProgram, accessToken); + if (isChanged && StringUtils.isNotBlank(currentStudent.getNewProgram())) { + log.info(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); + } else { + log.info(" => grad program : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getProgram(), gradProgram); + } + } + // 3. SLP Date + String slpDate = updateGrad.getSlpDateWithDefaultFormat(); + if (slpDate != null && "SCCP".equalsIgnoreCase(currentStudent.getUpToDateGradProgram()) + && !StringUtils.equals(slpDate, currentStudent.getGradDate())) { + isChanged = processSlpDate(currentStudent, slpDate); + if (isChanged) { + log.info(" => slp date : current = {}, request = {}", currentStudent.getGradDate(), slpDate); + } else { + log.info(" => slp date : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getGradDate(), slpDate); + } + } + // 4. Student Grade + if (!StringUtils.equals(updateGrad.getStudentGrade(), currentStudent.getStudentGrade())) { + isChanged = processStudentGrade(currentStudent, updateGrad.getStudentGrade()); + log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade()); + } + // 5. Citizenship + if (!StringUtils.equals(updateGrad.getCitizenship(), currentStudent.getCitizenship())) { + isChanged = processCitizenship(currentStudent, updateGrad.getCitizenship()); + log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); + } String newStudentStatus = getGradStudentStatus(updateGrad.getStudentStatus(), updateGrad.getArchiveFlag()); - // 0. Student Status + // 6. Student Status if (!StringUtils.equals(newStudentStatus, currentStudent.getStudentStatus())) { - currentStudent.setNewStudentStatus(newStudentStatus); - if (StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_CURRENT) - || StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_TERMINATED) - || StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_DECEASED)) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } + processStudentStatus(currentStudent, newStudentStatus); log.info(" => student status : current = {}, request = {}", currentStudent.getStudentStatus(), currentStudent.getNewStudentStatus()); isChanged = true; } - if (!currentStudent.isArchived() || !currentStudent.isGraduated()) { - // 1.1 School of record - if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { - currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord()); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); - isChanged = true; - } - // 1.2 SchoolOfRecordId - if (updateGrad.getSchoolOfRecordId() != null && updateGrad.getSchoolOfRecordId() != currentStudent.getSchoolOfRecordId()) { - currentStudent.setNewSchoolOfRecordId(updateGrad.getSchoolOfRecordId()); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => school of record id : current = {}, request = {}", currentStudent.getSchoolOfRecordId(), currentStudent.getNewSchoolOfRecordId()); - isChanged = true; - } - // 2. Grad Program - String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); - if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { - handleProgramChange(gradProgram, currentStudent, updateGrad.getPen(), accessToken); - handleAdultStartDate(currentStudent); - if (StringUtils.isNotBlank(currentStudent.getNewProgram())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); - isChanged = true; - } else { - log.info(" => grad program : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getProgram(), gradProgram); - } - } - // 3. SLP Date - String slpDate = updateGrad.getSlpDateWithDefaultFormat(); - if (slpDate != null && "SCCP".equalsIgnoreCase(currentStudent.getUpToDateGradProgram()) - && !StringUtils.equals(slpDate, currentStudent.getGradDate())) { - if (!currentStudent.isGraduated()) { - currentStudent.setNewGradDate(slpDate); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => slp date : current = {}, request = {}", currentStudent.getGradDate(), slpDate); - isChanged = true; - } else { - log.info(" => slp date : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getGradDate(), slpDate); - } - } - // Student Grade - if (!StringUtils.equals(updateGrad.getStudentGrade(), currentStudent.getStudentGrade())) { - currentStudent.setNewStudentGrade(updateGrad.getStudentGrade()); - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade()); - isChanged = true; - } - // Citizenship - if (!StringUtils.equals(updateGrad.getCitizenship(), currentStudent.getCitizenship())) { - currentStudent.setNewCitizenship(updateGrad.getCitizenship()); - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); - isChanged = true; - } - } if (isChanged) { + if (isStudentStatusChanged) { + validateAndAdjustNewBatchFlags(currentStudent); + } log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); studentProcess.saveGraduationStudent(updateGrad.getPen(), currentStudent, UPD_GRAD, accessToken); } } - private void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) { - boolean addDualDogwood = false; - boolean addFrenchImmersion = false; - - if (!currentStudent.isSCCP() && currentStudent.isGraduated()) { - currentStudent.setNewProgram(null); - return; - } - - if (newGradProgram.endsWith("-PF")) { - // from EN to PF - // from PF to PF - // from 1950 to PF - // from SCCP to PF - addDualDogwood = true; - } else if (newGradProgram.endsWith("-EN") && (currentStudent.getProgram().endsWith("-PF") || studentProcess.hasAnyFrenchImmersionCourse(newGradProgram, pen, accessToken))) { - // from PF to EN - allowed for SD93/Yukon PF schools - // from EN to EN - // from 1950 to EN - // from SCCP to EN - addFrenchImmersion = true; - } - - currentStudent.setAddDualDogwood(addDualDogwood); - currentStudent.setAddFrenchImmersion(addFrenchImmersion); - - currentStudent.setNewProgram(newGradProgram); - } - - private void handleAdultStartDate(StudentGradDTO currentStudent) { - if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) { - Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday()); - Date adultStartDate = DateUtils.addYears(dob, 18); - currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd - } - } - @Override public String getEventType() { return UPD_GRAD.toString(); } + + @Override + public boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken) { + return studentProcess.hasAnyFrenchImmersionCourse(gradProgramCode, pen, accessToken); + } + } diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index f8f8e144..24196585 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -330,6 +330,137 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); } + @Test + public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("TER"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/02"); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/02"); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { // ID @@ -339,10 +470,341 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ // Program & School String program = "2018-EN"; String mincode = "222333"; - UUID schoolOfRecordId = UUID.randomUUID(); + UUID schoolOfRecordId = UUID.randomUUID(); + + String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("CUR"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_STUDENT_whenGradeAndSchoolAreChangedAndStatusIsCurrent_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); + + String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChangedAndStatusIsTerminated_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); + + String newCitizenship = "C"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("CUR"); + currentStudent.setCitizenship(null); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newCitizenship = "C"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship(null); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; - String newMincode = "333444"; - UUID newSchoolOfRecordId = UUID.randomUUID(); + String newCitizenship = "C"; String updateType = "UPD_GRAD"; @@ -350,11 +812,75 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); - traxGraduationUpdate.setCitizenship("C"); - traxGraduationUpdate.setStudentGrade("11"); - traxGraduationUpdate.setSchoolOfRecord(newMincode); - traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); - traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("TER"); + currentStudent.setCitizenship(null); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newCitizenship = "C"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("D"); traxGraduationUpdate.setArchiveFlag("I"); // Event @@ -370,11 +896,11 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("CUR"); - currentStudent.setCitizenship("C"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); - currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); currentStudent.getProgramCodes().add("FI"); @@ -399,7 +925,7 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ } @Test - public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_STUDENT_whenGradeAndSchoolAreChangedAndStatusIsArchived_then_returnsAPICallSuccess() { + public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -409,7 +935,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - String newMincode = "333444"; + String newMincode = "093444"; UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -418,8 +944,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); - traxGraduationUpdate.setCitizenship("C"); - traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); @@ -438,14 +963,13 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("ARC"); - currentStudent.setCitizenship("C"); + currentStudent.setStudentStatus("CUR"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); - currentStudent.getProgramCodes().add("FI"); + currentStudent.getProgramCodes().add("DD"); // Courses StudentCourse course1 = new StudentCourse(); course1.setCourseCode("Test"); @@ -467,7 +991,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ } @Test - public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpDateAndCitizenshipAreChanged_then_returnsAPICallSuccess() { + public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -475,9 +999,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD // Program & School String program = "2018-EN"; String mincode = "222333"; - UUID schoolOfRecordId = UUID.randomUUID(); - String newCitizenship = "C"; + String newMincode = "093444"; String updateType = "UPD_GRAD"; @@ -486,11 +1009,9 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); - traxGraduationUpdate.setSchoolOfRecord(mincode); - traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); - traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setStudentStatus("A"); - traxGraduationUpdate.setArchiveFlag("A"); + traxGraduationUpdate.setArchiveFlag("I"); // Event Event event = new Event(); @@ -505,15 +1026,12 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("CUR"); - currentStudent.setCitizenship(null); + currentStudent.setStudentStatus("ARC"); currentStudent.setSchoolOfRecord(mincode); - currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); - currentStudent.setGradDate(null); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); - currentStudent.getProgramCodes().add("FI"); + currentStudent.getProgramCodes().add("DD"); // Courses StudentCourse course1 = new StudentCourse(); course1.setCourseCode("Test"); @@ -535,7 +1053,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD } @Test - public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { + public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -543,10 +1061,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg // Program & School String program = "2018-EN"; String mincode = "222333"; - UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "093444"; - UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -556,9 +1072,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); - traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); - traxGraduationUpdate.setStudentStatus("A"); - traxGraduationUpdate.setArchiveFlag("A"); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); // Event Event event = new Event(); @@ -573,9 +1088,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("CUR"); + currentStudent.setStudentStatus("DEC"); currentStudent.setSchoolOfRecord(mincode); - currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -1176,6 +1690,136 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); } + @Test + public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "SCCP"; + String mincode = "093333"; + + String newSlpDate = "208006"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("SCCP"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + currentStudent.setBirthday("2000-01-01"); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("DD"); + + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "SCCP"; + String mincode = "093333"; + + String newSlpDate = "208006"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("SCCP"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + currentStudent.setBirthday("2000-01-01"); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("DD"); + + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + @Test public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { // ID From bfba72cf7c72e6c890db1588fb3a3807f88c1518 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 23 Sep 2024 15:05:17 -0700 Subject: [PATCH 4/6] Clean up the codes. Clean up the codes. --- .../service/student/StudentBaseService.java | 23 ------------------- .../StudentGraduationUpdateEventService.java | 4 ---- 2 files changed, 27 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java index 7d4d6bf6..87654c56 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java @@ -130,29 +130,6 @@ protected void populateNewBatchFlags(StudentGradDTO currentStudent) { } } - protected void validateAndAdjustNewBatchFlags(StudentGradDTO currentStudent) { - String currentStudentStatus = currentStudent.getStudentStatus(); - String newStudentStatus = currentStudent.getNewStudentStatus(); - // 1. If a student in GRAD is ARC/TER then do not set TVR flag - if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudentStatus) || STUDENT_STATUS_TERMINATED.equalsIgnoreCase(currentStudentStatus)) { - currentStudent.setNewRecalculateProjectedGrad(null); - } - // 2. If a student in GRAD is MER then do not set Transcript & TVR flags - if (STUDENT_STATUS_MERGED.equalsIgnoreCase(currentStudentStatus)) { - currentStudent.setNewRecalculateGradStatus(null); - currentStudent.setNewRecalculateProjectedGrad(null); - } - // 3. If a student in GRAD is changed to ARC/TER then set TVR flag to NULL - if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(newStudentStatus) || STUDENT_STATUS_TERMINATED.equalsIgnoreCase(newStudentStatus)) { - currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); - } - // 4. If a student in GRAD is changed to MER then set Transcript & TVR flags to NULL - if (STUDENT_STATUS_MERGED.equalsIgnoreCase(newStudentStatus)) { - currentStudent.setNewRecalculateGradStatus(NULL_VALUE); - currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); - } - } - private void updateProgramCountsInSummary(ConversionStudentSummaryDTO summary, String programCode, boolean isGraduated) { if (summary != null) { summary.increment(programCode, isGraduated); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 76e986da..310c6b2c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -68,7 +68,6 @@ public void processEvent(T request, Event event) { public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO currentStudent, String accessToken) { boolean isChanged = false; - boolean isStudentStatusChanged = false; log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); // Processing order is important for the first 3 fields below. @@ -117,9 +116,6 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu } if (isChanged) { - if (isStudentStatusChanged) { - validateAndAdjustNewBatchFlags(currentStudent); - } log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); studentProcess.saveGraduationStudent(updateGrad.getPen(), currentStudent, UPD_GRAD, accessToken); } From eb9d90ec8b7ef6936602c7b9ee58349747bb1904 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 3 Sep 2024 14:23:36 -0700 Subject: [PATCH 5/6] GRAD2-2645: task is complete. --- api/src/main/.DS_Store | Bin 0 -> 6148 bytes .../StudentGraduationUpdateBaseService.java | 39 ++++++++++++++++++ .../StudentGraduationUpdateEventService.java | 7 +++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 api/src/main/.DS_Store diff --git a/api/src/main/.DS_Store b/api/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c4ea4fbbf828727b4e34b0f9f5e1953bc3dc42ca GIT binary patch literal 6148 zcmeHK%}T>S5T32oHi*!Jf(XKb*Q$*uB3@$EgI6PZP^pP28jV?LT6-vkJb*rncOS&p z(V5+?Sby+VRAylIo86gjxA{_bvj8CKoyY~K06-a?u;5_xg;AdTlNId9IHI6A!bF7_ z(_~vV$MCxqpm$e*2*SNYoqu?LOE22=0~Fy30=R?VL){~0-`6?Nf+l33po7sl#ls9S z|1%@(X1DgYJcYMOoV9DUXHgg{j!%?IPHD1q>R+m^-wxWHtRA$Esdu1M5)R@ZJdB&& zMrC?irR^Y2n=MUk_qfB#slW?4})2Ph#dhUi>m5VEDtNp6%xvOin zs$5@p`+cW8v#`9m-?&b0QgyF&0fGN~ZBrHp@PNS=YTWs)G*RgVW(UjxgOL?r1z3Sm zDPZ@X^5m!%LG4C-f}l2KCl~jlKdP7I9b`#`O759BI+Bm>a|lnlMyE zLlyRlAq*YIrLFTU<^~NNguQ$SyRxu16roqg`K2xg;ThzX6<`I16&N$!3Z4JE-{1d- zN!()vSb=|~fGFZFY7;EV$o<-M& { + // UpdData + currentStudent.setNewSchoolOfRecordId(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewSchoolOfRecordId(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewSchoolOfRecordId(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewSchoolOfRecordId(value); + // Do not set flags to Y + isChanged = true; + } + } + return isChanged; + } + protected boolean processStudentGrade(StudentGradDTO currentStudent, String value) { boolean isChanged = false; switch(currentStudent.getStudentStatus()) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 310c6b2c..1785b331 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -71,11 +71,16 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); // Processing order is important for the first 3 fields below. - // 1. School of record + // 1.1 School of Record if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { isChanged = processSchoolOfRecord(currentStudent, updateGrad.getSchoolOfRecord()); log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); } + // 1.2 School of Record Guid + if (updateGrad.getSchoolOfRecordId() != null && updateGrad.getSchoolOfRecordId() != currentStudent.getSchoolOfRecordId()) { + isChanged = processSchoolOfRecordId(currentStudent, updateGrad.getSchoolOfRecordId()); + log.info(" => school of record id : current = {}, request = {}", currentStudent.getSchoolOfRecordId(), currentStudent.getNewSchoolOfRecordId()); + } // 2. Grad Program String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { From 814fefef0dfc1ebe63c36865110daae2e3ce5bea Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 26 Sep 2024 12:12:33 -0700 Subject: [PATCH 6/6] More coverages on schoolOfRecordId. More coverages on schoolOfRecordId. --- ...udentGraduationUpdateEventServiceTest.java | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index 24196585..bb70697f 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -339,8 +339,10 @@ public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdat // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -351,6 +353,7 @@ public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdat traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("T"); traxGraduationUpdate.setArchiveFlag("A"); @@ -370,6 +373,7 @@ public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdat currentStudent.setStudentStatus("TER"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/02"); // Optional Program Codes @@ -404,8 +408,10 @@ public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -416,6 +422,7 @@ public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("D"); traxGraduationUpdate.setArchiveFlag("I"); @@ -435,6 +442,7 @@ public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated currentStudent.setStudentStatus("DEC"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate("2022/02"); // Optional Program Codes @@ -606,8 +614,10 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGrad // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "333444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -618,6 +628,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGrad traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("T"); traxGraduationUpdate.setArchiveFlag("A"); @@ -637,6 +648,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGrad currentStudent.setStudentStatus("ARC"); currentStudent.setCitizenship("C"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -738,6 +750,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCiti // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newCitizenship = "C"; @@ -749,6 +762,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCiti traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setCitizenship(newCitizenship); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("I"); @@ -769,6 +783,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCiti currentStudent.setStudentStatus("ARC"); currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate(null); // Optional Program Codes @@ -803,6 +818,7 @@ public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCi // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newCitizenship = "C"; @@ -814,6 +830,7 @@ public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCi traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setCitizenship(newCitizenship); traxGraduationUpdate.setStudentStatus("T"); traxGraduationUpdate.setArchiveFlag("A"); @@ -834,6 +851,7 @@ public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCi currentStudent.setStudentStatus("TER"); currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate(null); // Optional Program Codes @@ -868,6 +886,7 @@ public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCiti // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newCitizenship = "C"; @@ -879,6 +898,7 @@ public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCiti traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSchoolOfRecordId(schoolOfRecordId); traxGraduationUpdate.setCitizenship(newCitizenship); traxGraduationUpdate.setStudentStatus("D"); traxGraduationUpdate.setArchiveFlag("I"); @@ -899,6 +919,7 @@ public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCiti currentStudent.setStudentStatus("DEC"); currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); currentStudent.setGradDate(null); // Optional Program Codes @@ -999,8 +1020,10 @@ public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_w // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "093444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -1010,6 +1033,7 @@ public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_w traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("I"); @@ -1028,6 +1052,7 @@ public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_w currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("ARC"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -1061,8 +1086,10 @@ public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_w // Program & School String program = "2018-EN"; String mincode = "222333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newMincode = "093444"; + UUID newSchoolOfRecordId = UUID.randomUUID(); String updateType = "UPD_GRAD"; @@ -1072,6 +1099,7 @@ public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_w traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setSchoolOfRecordId(newSchoolOfRecordId); traxGraduationUpdate.setStudentStatus("D"); traxGraduationUpdate.setArchiveFlag("I"); @@ -1090,6 +1118,7 @@ public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_w currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("DEC"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -1529,10 +1558,6 @@ public void testProcessStudentForGrad2018ENProgram_whenException_isThrown_return // ID String pen = "111222333"; - // Program & School - String program = "2018-EN"; - String mincode = "222333"; - String updateType = "UPD_GRAD"; TraxGraduationUpdateDTO traxStudentUpdate = new TraxGraduationUpdateDTO(); @@ -1699,6 +1724,7 @@ public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC // Program & School String program = "SCCP"; String mincode = "093333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newSlpDate = "208006"; @@ -1730,6 +1756,7 @@ public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("ARC"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); @@ -1764,6 +1791,7 @@ public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC // Program & School String program = "SCCP"; String mincode = "093333"; + UUID schoolOfRecordId = UUID.randomUUID(); String newSlpDate = "208006"; @@ -1795,6 +1823,7 @@ public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("DEC"); currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolOfRecordId(schoolOfRecordId); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes currentStudent.getProgramCodes().add("XC");