From c5a5f30c0632f129cb051bfd2eeee5fc5a811426 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 11 Sep 2024 15:58:47 -0600 Subject: [PATCH 1/4] GRAD2-2591 Optional Program Completion Date is not being reset when a User UNGRADS a student --- .../api/gradstudent/service/GraduationStatusService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 46045085..aa1dc479 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -1118,6 +1118,13 @@ public Pair undoCompletionStudent(UUID if (gradStatusEvent != null) { gradStatusEventRepository.save(gradStatusEvent); } + List studentOptionalProgramEntities = gradStudentOptionalProgramRepository.findByStudentID(studentID); + for(StudentOptionalProgramEntity studentOptionalProgramEntity: studentOptionalProgramEntities) { + studentOptionalProgramEntity.setOptionalProgramCompletionDate(null); + studentOptionalProgramEntity.setStudentOptionalProgramData(null); + gradStudentOptionalProgramRepository.save(studentOptionalProgramEntity); + historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,USER_UNDO_CMPL); + } return Pair.of(graduationStatusTransformer.transformToDTOWithModifiedProgramCompletionDate(gradEntity), gradStatusEvent); } else { validation.addErrorAndStop(String.format("Student ID [%s] does not exists", studentID)); From 487fc5c99093eef90d16e86718e79fd679c05cc4 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 12 Sep 2024 12:57:19 -0600 Subject: [PATCH 2/4] GRAD2-2591 Optional Program Completion Date is not being reset when a User UNGRADS a student --- .../gradstudent/service/GraduationStatusServiceTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java index b2268093..a023c4a3 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java @@ -2030,6 +2030,13 @@ public void testUgradStudent() throws JsonProcessingException { when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity)); when(graduationStatusRepository.save(responseGraduationStatus)).thenReturn(responseGraduationStatus); + StudentOptionalProgramEntity studentOptionalProgramEntity = new StudentOptionalProgramEntity(); + studentOptionalProgramEntity.setId(UUID.randomUUID()); + studentOptionalProgramEntity.setStudentID(studentID); + studentOptionalProgramEntity.setOptionalProgramCompletionDate(new Date(System.currentTimeMillis())); + + when(gradStudentOptionalProgramRepository.findByStudentID(studentID)).thenReturn(List.of(studentOptionalProgramEntity)); + var response = graduationStatusService.undoCompletionStudent(studentID, ungradReasonCode,ungradReasonDesc, "accessToken"); assertThat(response).isNotNull(); From 927c3d8af322d0d52cfe489afb5aedda1ac36135 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 12 Sep 2024 13:17:10 -0600 Subject: [PATCH 3/4] GRAD2-2591 Optional Program Completion Date is not being reset when a User UNGRADS a student --- .../api/gradstudent/service/GraduationStatusServiceTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java index a023c4a3..c70a33f2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java @@ -2036,6 +2036,7 @@ public void testUgradStudent() throws JsonProcessingException { studentOptionalProgramEntity.setOptionalProgramCompletionDate(new Date(System.currentTimeMillis())); when(gradStudentOptionalProgramRepository.findByStudentID(studentID)).thenReturn(List.of(studentOptionalProgramEntity)); + doNothing().when(historyService).createStudentOptionalProgramHistory(any(), any()); var response = graduationStatusService.undoCompletionStudent(studentID, ungradReasonCode,ungradReasonDesc, "accessToken"); assertThat(response).isNotNull(); From c0820436f25d1579d049b884ed1eea01b6441f8d Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 12 Sep 2024 13:27:55 -0600 Subject: [PATCH 4/4] Added history tracking info --- .../educ/api/gradstudent/service/GraduationStatusService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index aa1dc479..2573f43b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -1122,6 +1122,8 @@ public Pair undoCompletionStudent(UUID for(StudentOptionalProgramEntity studentOptionalProgramEntity: studentOptionalProgramEntities) { studentOptionalProgramEntity.setOptionalProgramCompletionDate(null); studentOptionalProgramEntity.setStudentOptionalProgramData(null); + studentOptionalProgramEntity.setUpdateDate(LocalDateTime.now()); + studentOptionalProgramEntity.setUpdateUser(ThreadLocalStateUtil.getCurrentUser()); gradStudentOptionalProgramRepository.save(studentOptionalProgramEntity); historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,USER_UNDO_CMPL); }