Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2546: task is completed. #329

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void handleEvent(@NonNull final Event event) {
final TraxGraduationUpdateDTO updateGrad = JsonUtil.getJsonObjectFromString(TraxGraduationUpdateDTO.class, event.getEventPayload());
this.eventServiceMap.get(UPD_GRAD.toString()).processEvent(updateGrad, event);
break;
case "UPD_STD_STATUS":
case "UPD_STD_STATUS": // UPD_STD_STATUS will be deprecated
log.debug("Processing UPD_STD_STATUS event record :: {} ", event);
final TraxStudentStatusUpdateDTO updateStudentStatus = JsonUtil.getJsonObjectFromString(TraxStudentStatusUpdateDTO.class, event.getEventPayload());
this.eventServiceMap.get(UPD_STD_STATUS.toString()).processEvent(updateStudentStatus, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum EventType {
NEWSTUDENT,
UPD_DEMOG,
UPD_GRAD,
UPD_STD_STATUS,
UPD_STD_STATUS, // UPD_STD_STATUS will be deprecated
XPROGRAM,
ASSESSMENT,
COURSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ public String getUpToDateSchoolOfRecord() {
return StringUtils.isNotBlank(newSchoolOfRecord)? newSchoolOfRecord : this.getSchoolOfRecord();
}

@Override
public boolean isArchived() {
if (StringUtils.isNotBlank(newStudentStatus) && "ARC".equalsIgnoreCase(newStudentStatus)) { // Student Status from TRAX
return true;
} else {
return super.isArchived(); // Student Status from GRAD
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class TraxGraduationUpdateDTO extends TraxStudentUpdateDTO {
private String slpDate;
// STUD_CITIZ
private String citizenship;
// STUD_STATUS
private String studentStatus;
// ARCHIVE_FLAG
private String archiveFlag;

public String getSlpDateWithDefaultFormat() {
if (StringUtils.isBlank(slpDate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
// UPD_STD_STATUS will be deprecated
public class TraxStudentStatusUpdateDTO extends TraxStudentUpdateDTO {

// STUD_STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventT
requestDTO.setEventType(eventType);
// UPD_GRAD ====================================================
if (eventType == EventType.UPD_GRAD) {
// Student Status
if (StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) {
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
.type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(gradStudent.getNewStudentStatus())
.build();
requestDTO.getUpdateFields().add(field);
}
// School of Record
if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) {
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
Expand Down Expand Up @@ -483,7 +490,7 @@ public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventT
requestDTO.getUpdateFields().add(field);
}
}
// UPD_GRAD ====================================================
// UPD_STD_STATUS will be deprecated
// Student Status
if (eventType == EventType.UPD_STD_STATUS && StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) {
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,91 +73,105 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu
boolean isChanged = false;

log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen());
if (currentStudent.isArchived() && currentStudent.isGraduated()) {
return;
}
// Order is important for first 3 items below!!!
// 1. School of record
if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) {
currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord());
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
if (!currentStudent.isArchived()) {
// Processing order is important for the first 3 fields below.
String newStudentStatus = getGradStudentStatus(updateGrad.getStudentStatus(), updateGrad.getArchiveFlag());
// 0. 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");
}
log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord());
log.info(" => student status : current = {}, request = {}", currentStudent.getStudentStatus(), currentStudent.getNewStudentStatus());
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())) {
if (!currentStudent.isArchived() || !currentStudent.isGraduated()) {
// 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(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram());
log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord());
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");
// 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);
}
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()) {
// 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");
}
} else {
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade());
isChanged = true;
}
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()) {
// 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");
}
} else {
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship());
isChanged = true;
}
log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship());
isChanged = true;
}

if (isChanged) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@Service
@Slf4j
// UPD_STD_STATUS will be deprecated
public class StudentStatusUpdateEventService extends StudentBaseService implements EventService {

private final EventRepository eventRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,43 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC
assertThat(exceptionIsThrown).isFalse();
}

@Test
public void testSaveGraduationStudent_whenStudentStatus_isChanged_then_returnAPICallSuccess() {
String program = "2018-EN";
String pen = "111222333";
UUID studentID = UUID.randomUUID();

GraduationStudentRecord graduationStudentRecord = new GraduationStudentRecord();
graduationStudentRecord.setStudentID(studentID);
graduationStudentRecord.setProgram(program);
graduationStudentRecord.setStudentGrade("11");
graduationStudentRecord.setStudentStatus("CUR");
graduationStudentRecord.setSchoolOfRecord("222336");

when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(graduationStudentRecord);

StudentGradDTO requestStudent = new StudentGradDTO();
requestStudent.setStudentID(studentID);
requestStudent.setProgram(program);
requestStudent.setNewProgram("1950");
requestStudent.setNewStudentGrade("AD");
requestStudent.setNewSchoolOfRecord("333456");
requestStudent.setNewStudentStatus("ARC");
requestStudent.setNewRecalculateGradStatus("Y");
requestStudent.setNewRecalculateProjectedGrad("Y");
requestStudent.setNewAdultStartDate("2010-01-01");
requestStudent.setNewCitizenship("C");
requestStudent.setNewGradDate("2022/06/01");

boolean exceptionIsThrown = false;
try {
studentProcess.saveGraduationStudent(pen, requestStudent, EventType.UPD_STD_STATUS, "123");
} catch (Exception e) {
exceptionIsThrown = true;
}
assertThat(exceptionIsThrown).isFalse();
}

@Test
public void testLoadStudentData_whenPENStudentAPIisDown_returnsNull() {
// ID
Expand Down
Loading
Loading