Skip to content

Commit

Permalink
Merge pull request #673 from bcgov/develop/alex-GRAD2-2283
Browse files Browse the repository at this point in the history
Develop/alex grad2 2283
  • Loading branch information
githubmamatha authored Aug 16, 2024
2 parents 243684b + 8ea8e0f commit c731c23
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ca.bc.gov.educ.api.gradstudent.model.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.persistence.*;
import java.util.Date;
import java.util.UUID;

Expand Down Expand Up @@ -78,6 +78,12 @@ public GraduationStudentRecordEntity() {
@Column(name = "STUDENT_PROJECTED_GRAD_DATA", columnDefinition="CLOB")
private String studentProjectedGradData;

@Column(name = "SCHOOL_OF_RECORD_ID", nullable = true)
private UUID schoolOfRecordId;

@Column(name = "SCHOOL_AT_GRADUATION_ID", nullable = true)
private UUID schoolAtGraduationId;

@Transient
private String legalFirstName;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ca.bc.gov.educ.api.gradstudent.model.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;
import java.util.Date;
import java.util.UUID;

Expand Down Expand Up @@ -75,6 +75,12 @@ public class GraduationStudentRecordHistoryEntity extends BaseEntity {
@Column(name = "ADULT_START_DATE", nullable = true)
private Date adultStartDate;

@Column(name = "SCHOOL_OF_RECORD_ID", nullable = true)
private UUID schoolOfRecordId;

@Column(name = "SCHOOL_AT_GRADUATION_ID", nullable = true)
private UUID schoolAtGraduationId;

//@Lob
//@Column(name = "STUDENT_PROJECTED_GRAD_DATA", columnDefinition="CLOB")
@Transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface GraduationStudentRecordView {
public String getStudentCitizenship();
public Date getAdultStartDate();
public String getStudentProjectedGradData() ;
public UUID getSchoolOfRecordId();
public UUID getSchoolAtGraduationId();
public LocalDateTime getCreateDate();
public LocalDateTime getUpdateDate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -1234,17 +1234,16 @@ public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID,
}

@Retry(name = "generalpostcall")
public void saveStudentHistoryRecordDistributionRun(UUID studentID, Long batchId, String activityCode, String studentStatus) {
Optional<GraduationStudentRecordEntity> gradStatusOptional = graduationStatusRepository.findById(studentID);
if (gradStatusOptional.isPresent()) {
GraduationStudentRecordEntity gradEntity = gradStatusOptional.get();
if(StringUtils.isNotBlank(studentStatus)) {
gradEntity.setStudentStatus(studentStatus);
}
gradEntity.setUpdateUser(null);
gradEntity.setUpdateDate(null);
gradEntity.setBatchId(batchId);
historyService.createStudentHistory(gradEntity, activityCode);
public void saveStudentHistoryRecordArchiveStudentsRun(UUID studentID, Long batchId, String activityCode) {
List<GraduationStudentRecordView> graduationStudentRecordViews = graduationStatusRepository.findByStudentIDIn(List.of(studentID));
for(GraduationStudentRecordView st: graduationStudentRecordViews) {
GraduationStudentRecordEntity toBeSaved = new GraduationStudentRecordEntity();
BeanUtils.copyProperties(st, toBeSaved);
toBeSaved.setStudentStatus("ARC");
toBeSaved.setUpdateUser(null);
toBeSaved.setUpdateDate(null);
toBeSaved.setBatchId(batchId);
historyService.createStudentHistory(toBeSaved, activityCode);
}
}

Expand Down Expand Up @@ -1320,6 +1319,7 @@ private List<UUID> processStudentDataList(Page<UUID> studentGuids) {
return result;
}

@Generated
private void processUUIDDataTasksAsync(List<Callable<Object>> tasks, List<UUID> result) {
if(tasks.isEmpty()) return;
List<Future<Object>> executionResult;
Expand Down Expand Up @@ -1395,19 +1395,21 @@ public Long countBySchoolOfRecordsAndStudentStatus(List<String> schoolOfRecords,
@Transactional
public Integer archiveStudents(long batchId, List<String> schoolOfRecords, String studentStatus) {
String recordStudentStatus = StringUtils.defaultString(studentStatus, "CUR");
Integer archivedStudentsCount = 0;
if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
List<UUID> graduationStudentRecordGuids = graduationStatusRepository.findBySchoolOfRecordInAndStudentStatus(schoolOfRecords, recordStudentStatus);
for(UUID graduationStudentRecordGuid: graduationStudentRecordGuids) {
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC", "ARC");
saveStudentHistoryRecordArchiveStudentsRun(graduationStudentRecordGuid, batchId, "USERSTUDARC");
}
return graduationStatusRepository.archiveStudents(schoolOfRecords, recordStudentStatus, "ARC", batchId);
archivedStudentsCount = graduationStatusRepository.archiveStudents(schoolOfRecords, recordStudentStatus, "ARC", batchId);
} else {
List<UUID> graduationStudentRecordGuids = graduationStatusRepository.findByStudentStatus(recordStudentStatus);
for(UUID graduationStudentRecordGuid: graduationStudentRecordGuids) {
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC", "ARC");
saveStudentHistoryRecordArchiveStudentsRun(graduationStudentRecordGuid, batchId, "USERSTUDARC");
}
return graduationStatusRepository.archiveStudents(recordStudentStatus, "ARC", batchId);
archivedStudentsCount = graduationStatusRepository.archiveStudents(recordStudentStatus, "ARC", batchId);
}
return archivedStudentsCount;
}

public void updateStudentFlagReadyForBatchJobByStudentIDs(String batchJobType, List<UUID> studentIDs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createStudentHistory(GraduationStudentRecordEntity curStudentEntity,
graduationStudentRecordHistoryEntity.setCreateDate(curStudentEntity.getCreateDate());
graduationStudentRecordHistoryEntity.setActivityCode(historyActivityCode);
graduationStudentRecordHistoryEntity.setStudentGradData("{ EMPTY CLOB }");
graduationStudentRecordHistoryRepository.save(graduationStudentRecordHistoryEntity);
graduationStudentRecordHistoryRepository.saveAndFlush(graduationStudentRecordHistoryEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ public String getStudentProjectedGradData() {
return null;
}

@Override
public UUID getSchoolOfRecordId() {
return null;
}

@Override
public UUID getSchoolAtGraduationId() {
return null;
}

@Override
public LocalDateTime getCreateDate() {
return null;
Expand All @@ -432,10 +442,10 @@ public LocalDateTime getUpdateDate() {
return null;
}
};

List<UUID> studentSubList = new ArrayList<>();
studentSubList.add(graduationStatusView.getStudentID());


when(this.graduationStatusRepository.findByStudentID(studentID)).thenReturn(graduationStatusEntity);
when(this.graduationStatusTransformer.transformToDTOWithModifiedProgramCompletionDate(graduationStatusEntity)).thenReturn(graduationStatus);
when(this.graduationStatusRepository.findByStudentIDIn(studentSubList)).thenReturn(List.of(graduationStatusView));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2224,21 +2224,117 @@ public void testSaveStudentRecord_DistributionRun_2() {

UUID studentID = new UUID(1, 1);
Long batchId = null;
GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
graduationStatusEntity.setStudentID(studentID);
graduationStatusEntity.setPen("12321321");
graduationStatusEntity.setStudentStatus("A");
graduationStatusEntity.setSchoolOfRecord("12345678");
GraduationStudentRecordView graduationStatusEntity = new GraduationStudentRecordView() {

when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
@Override
public String getProgram() {
return null;
}

doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");
graduationStatusServiceMock.saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");
Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");
@Override
public java.util.Date getProgramCompletionDate() {
return null;
}

@Override
public String getGpa() {
return null;
}

@Override
public String getHonoursStanding() {
return null;
}

@Override
public String getRecalculateGradStatus() {
return null;
}

@Override
public String getSchoolOfRecord() {
return "12345678";
}

@Override
public String getStudentGrade() {
return null;
}

@Override
public String getStudentStatus() {
return "A";
}

@Override
public UUID getStudentID() {
return studentID;
}

@Override
public String getSchoolAtGrad() {
return null;
}

@Override
public String getRecalculateProjectedGrad() {
return null;
}

@Override
public Long getBatchId() {
return null;
}

@Override
public String getConsumerEducationRequirementMet() {
return null;
}

@Override
public String getStudentCitizenship() {
return null;
}

@Override
public java.util.Date getAdultStartDate() {
return null;
}

@Override
public String getStudentProjectedGradData() {
return null;
}

@Override
public UUID getSchoolOfRecordId() {
return null;
}

@Override
public UUID getSchoolAtGraduationId() {
return null;
}

@Override
public LocalDateTime getCreateDate() {
return null;
}

@Override
public LocalDateTime getUpdateDate() {
return null;
}
};

when(graduationStatusRepository.findByStudentIDIn(List.of(studentID))).thenReturn(List.of(graduationStatusEntity));

doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
graduationStatusServiceMock.saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");

graduationStatusService.saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");

doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
graduationStatusServiceMock.saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
}

@Test
Expand Down Expand Up @@ -2336,6 +2432,16 @@ public String getStudentProjectedGradData() {
return null;
}

@Override
public UUID getSchoolOfRecordId() {
return null;
}

@Override
public UUID getSchoolAtGraduationId() {
return null;
}

@Override
public LocalDateTime getCreateDate() {
return null;
Expand Down Expand Up @@ -2810,6 +2916,16 @@ public String getStudentProjectedGradData() {
return null;
}

@Override
public UUID getSchoolOfRecordId() {
return null;
}

@Override
public UUID getSchoolAtGraduationId() {
return null;
}

@Override
public LocalDateTime getCreateDate() {
return null;
Expand Down Expand Up @@ -3058,6 +3174,16 @@ public String getStudentProjectedGradData() {
return jsonTransformer.marshall(projectedRunClob);
}

@Override
public UUID getSchoolOfRecordId() {
return null;
}

@Override
public UUID getSchoolAtGraduationId() {
return null;
}

@Override
public LocalDateTime getCreateDate() {
return null;
Expand Down

0 comments on commit c731c23

Please sign in to comment.