Skip to content

Commit

Permalink
GRAD2-2283
Browse files Browse the repository at this point in the history
Student Archive Process - Backend endpoints To COMPLETE
  • Loading branch information
arybakov-cgi committed Jul 15, 2024
1 parent 1194609 commit 76da9bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public interface GraduationStudentRecordRepository extends JpaRepository<Graduat
@Procedure(value = "update_grad_stud_rcrd_status")
Integer archiveStudents(String inSor, String inStudStatFrom, String inStudStatTo, long batchId);

@Modifying
@Query(value="update graduation_student_record set student_status_code = :inStudStatTo, batch_id = :batchId, student_grad_data = json_transform(student_grad_data, SET '$.gradStatus.studentStatus' = :inStudStatTo IGNORE ON MISSING), update_date = SYSDATE, update_user = 'Batch Archive Process' where school_of_record in (:inSor) and student_status_code = :inStudStatFrom", nativeQuery=true)
Integer archiveStudents(List<String> inSor, String inStudStatFrom, String inStudStatTo, long batchId);

@Modifying
@Query(value="update graduation_student_record set student_status_code = :inStudStatTo, batch_id = :batchId, student_grad_data = json_transform(student_grad_data, SET '$.gradStatus.studentStatus' = :inStudStatTo IGNORE ON MISSING), update_date = SYSDATE, update_user = 'Batch Archive Process' where student_status_code = :inStudStatFrom", nativeQuery=true)
Integer archiveStudents(String inStudStatFrom, String inStudStatTo, long batchId);

// Data Conversion
@Modifying
@Query(value="insert into STUDENT_GUID_PEN_XREF(STUDENT_GUID, STUDENT_PEN, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE)\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ private GraduationStudentRecord processReceivedStudent(GraduationStudentRecord e
ent.setLegalFirstName(existingData.getGradStudent().getLegalFirstName());
ent.setLegalMiddleNames(existingData.getGradStudent().getLegalMiddleNames());
ent.setLegalLastName(existingData.getGradStudent().getLegalLastName());
}else {
} else {
Student stuData = webClient.get().uri(String.format(constants.getPenStudentApiByStudentIdUrl(), ent.getStudentID()))
.headers(h -> {
h.setBearerAuth(accessToken);
Expand Down Expand Up @@ -1377,9 +1377,13 @@ public Long countBySchoolOfRecordsAndStudentStatus(List<String> schoolOfRecords,
}
}

@Transactional
public Integer archiveStudents(long batchId, List<String> schoolOfRecords, String studentStatus) {
String inSor = schoolOfRecords != null && !schoolOfRecords.isEmpty() ? String.join(",", schoolOfRecords) : null;
return graduationStatusRepository.archiveStudents(inSor, StringUtils.defaultString(studentStatus, "CUR"), "ARC", batchId);
if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
return graduationStatusRepository.archiveStudents(schoolOfRecords, StringUtils.defaultString(studentStatus, "CUR"), "ARC", batchId);
} else {
return graduationStatusRepository.archiveStudents(StringUtils.defaultString(studentStatus, "CUR"), "ARC", batchId);
}
}

public void updateStudentFlagReadyForBatchJobByStudentIDs(String batchJobType, List<UUID> studentIDs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,14 @@ public void testCountBySchoolOfRecordsAndStudentStatus() {
@Test
public void testArchiveStudents() {
Mockito.when(graduationStatusRepository.archiveStudents("12345678", "CUR", "ARC", 1L)).thenReturn(1);
Mockito.when(graduationStatusRepository.archiveStudents(List.of("12345678"), "CUR", "ARC", 1L)).thenReturn(1);
Integer count = graduationStatusService.archiveStudents(1L, List.of("12345678"), "CUR");
assertThat(count).isNotNull().isEqualTo(1);
}

@Test
public void testArchiveStudentUpdates() {
Mockito.when(graduationStatusRepository.archiveStudents(List.of("12345678"), "CUR", "ARC", 1L)).thenReturn(1);
Integer count = graduationStatusService.archiveStudents(1L, List.of("12345678"), "CUR");
assertThat(count).isNotNull().isEqualTo(1);
}
Expand Down

0 comments on commit 76da9bc

Please sign in to comment.