Skip to content

Commit

Permalink
Merge pull request #491 from bcgov/feature/GRAD2-2325
Browse files Browse the repository at this point in the history
Worked on performance to remove nongrad reason fileds for nograd stud…
  • Loading branch information
infstar authored Oct 24, 2023
2 parents 63336c9 + 4d95386 commit 4bf576d
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ public class EdwGraduationSnapshot {
private BigDecimal gpa;
private String graduatedDate;

private String nonGradReason1;
private String nonGradReason2;
private String nonGradReason3;
private String nonGradReason4;
private String nonGradReason5;
private String nonGradReason6;
private String nonGradReason7;
private String nonGradReason8;
private String nonGradReason9;
private String nonGradReason10;
private String nonGradReason11;
private String nonGradReason12;

@JsonFormat(pattern=DEFAULT_DATE_FORMAT)
private LocalDate runDate;
@JsonFormat(pattern=DEFAULT_DATE_FORMAT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,42 +95,18 @@ private EdwGraduationSnapshot runHypotheticalGradAlgorithm(String pen, Integer g
} else {
// non-graduated student
log.debug(" ==> Not Graduated!");
List<ProgramRequirementCode> programRequirementCodes = getAllProgramRequirementCodeList(accessToken);
StudentNonGradReason studentNonGradReason = getStudentNonGradReason(pen, accessToken);
snapshot = populateSnapshot(gradYear, pen, null, "N", null, BigDecimal.ZERO, schoolOfRecord);
if (studentNonGradReason != null) {
setNonGradReasons(snapshot, studentNonGradReason, programRequirementCodes);
}
}
return snapshot;
}

public StudentNonGradReason getStudentNonGradReason(String pen, String accessToken) {
StudentNonGradReason response = null;
try {
response = this.restService.get(String.format(constants.getStudentNonGradReasonByPenUrl(), pen),
StudentNonGradReason.class,
accessToken);
} catch (Exception e) {
log.error("StudentNonGradReason is not found for pen # = {}", pen);
}
return response;
}

public void saveEdwSnapshotOfGraduationStatus(String accessToken, EdwGraduationSnapshot requestObj) {
this.restService.post(constants.getEdwSnapshotOfGraduationStatus(),
requestObj,
EdwGraduationSnapshot.class,
accessToken);
}

@SuppressWarnings("rawtypes")
public List<ProgramRequirementCode> getAllProgramRequirementCodeList(String accessToken) {
List response = this.restService.get(constants.getProgramRequirementsEndpoint(),
List.class, accessToken);
return jsonTransformer.convertValue(response, new TypeReference<>(){});
}

public UUID getStudentID(String pen, String accessToken) {
GradSearchStudent penStudent = getStudentByPenFromStudentApi(pen, accessToken);
if (penStudent != null) {
Expand Down Expand Up @@ -162,60 +138,4 @@ private EdwGraduationSnapshot populateSnapshot(Integer gradYear, String pen, Str
obj.setSchoolOfRecord(schoolOfRecord);
return obj;
}

private void setNonGradReasons(EdwGraduationSnapshot snapshot, StudentNonGradReason studentNonGradReason, List<ProgramRequirementCode> programRequirementCodes) {
// nonGradReason1
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule1())) {
snapshot.setNonGradReason1(getTraxRequirementCode(studentNonGradReason.getGradRule1(), programRequirementCodes));
}
// nonGradReason2
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule2())) {
snapshot.setNonGradReason2(getTraxRequirementCode(studentNonGradReason.getGradRule2(), programRequirementCodes));
}
// nonGradReason3
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule3())) {
snapshot.setNonGradReason3(getTraxRequirementCode(studentNonGradReason.getGradRule3(), programRequirementCodes));
}
// nonGradReason4
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule4())) {
snapshot.setNonGradReason4(getTraxRequirementCode(studentNonGradReason.getGradRule4(), programRequirementCodes));
}
// nonGradReason5
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule5())) {
snapshot.setNonGradReason5(getTraxRequirementCode(studentNonGradReason.getGradRule5(), programRequirementCodes));
}
// nonGradReason6
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule6())) {
snapshot.setNonGradReason6(getTraxRequirementCode(studentNonGradReason.getGradRule6(), programRequirementCodes));
}
// nonGradReason7
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule7())) {
snapshot.setNonGradReason7(getTraxRequirementCode(studentNonGradReason.getGradRule7(), programRequirementCodes));
}
// nonGradReason8
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule8())) {
snapshot.setNonGradReason8(getTraxRequirementCode(studentNonGradReason.getGradRule8(), programRequirementCodes));
}
// nonGradReason9
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule9())) {
snapshot.setNonGradReason9(getTraxRequirementCode(studentNonGradReason.getGradRule9(), programRequirementCodes));
}
// nonGradReason10
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule10())) {
snapshot.setNonGradReason10(getTraxRequirementCode(studentNonGradReason.getGradRule10(), programRequirementCodes));
}
// nonGradReason11
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule11())) {
snapshot.setNonGradReason11(getTraxRequirementCode(studentNonGradReason.getGradRule11(), programRequirementCodes));
}
// nonGradReason12
if (StringUtils.isNotBlank(studentNonGradReason.getGradRule12())) {
snapshot.setNonGradReason12(getTraxRequirementCode(studentNonGradReason.getGradRule12(), programRequirementCodes));
}
}

private String getTraxRequirementCode(String gradRule, List<ProgramRequirementCode> programRequirementCodes) {
return programRequirementCodes.stream().filter(c -> gradRule.equalsIgnoreCase(c.getProReqCode())).findAny()
.map(ProgramRequirementCode::getTraxReqChar).orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ public class EducGraduationApiConstants {
@Value("${endpoint.grad-student-api.edw-snapshot-of-grad-status}")
private String edwSnapshotOfGraduationStatus;

@Value("${endpoint.grad-student-api.get-student-nongrad-reason-by-pen}")
private String studentNonGradReasonByPenUrl;

@Value("${endpoint.pen-student-api.by-pen.url}")
private String penStudentApiByPenUrl;

Expand Down
3 changes: 1 addition & 2 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ endpoint:
student-nongrad-report-data: ${GRAD_STUDENT_API}api/v1/student/studentnongradreportdata
student-nongrad-report-data-mincode: ${GRAD_STUDENT_API}api/v1/student/studentnongradreportdata/%s
edw-snapshot-of-grad-status: ${GRAD_STUDENT_API}api/v1/student/edw/snapshot
get-student-nongrad-reason-by-pen: ${GRAD_STUDENT_API}api/v1/student/pen/%s/nongrad-reason
grad-program-api:
grad-program-api:
program_name_by_program_code:
url: ${GRAD_PROGRAM_API}api/v1/program/programs/%s
program_requirement_codes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,6 @@ public void testProcessSnapshotForNonGradStudent() {
GraduationData graduationData = new GraduationData();
graduationData.setGraduated(false);

StudentNonGradReason nonGradReason = new StudentNonGradReason();
nonGradReason.setPen(snapshotRequest.getPen());
nonGradReason.setGraduationStudentRecordId(snapshotRequest.getStudentID());
nonGradReason.setGradRule1("a");
nonGradReason.setGradRule2("b");
nonGradReason.setGradRule3("a");
nonGradReason.setGradRule4("b");
nonGradReason.setGradRule5("a");
nonGradReason.setGradRule6("b");
nonGradReason.setGradRule7("a");
nonGradReason.setGradRule8("b");
nonGradReason.setGradRule9("a");
nonGradReason.setGradRule10("b");
nonGradReason.setGradRule11("a");
nonGradReason.setGradRule12("b");

ProgramRequirementCode proReqCode1 = new ProgramRequirementCode();
proReqCode1.setProReqCode("a");
proReqCode1.setTraxReqChar("A");

ProgramRequirementCode proReqCode2 = new ProgramRequirementCode();
proReqCode2.setProReqCode("b");
proReqCode2.setTraxReqChar("B");

GradSearchStudent penStudent = new GradSearchStudent();
penStudent.setPen(snapshotRequest.getPen());
penStudent.setStudentID(snapshotRequest.getStudentID().toString());
Expand All @@ -136,15 +112,12 @@ public void testProcessSnapshotForNonGradStudent() {
when(gradAlgorithmService.runHypotheticalGraduatedAlgorithm(snapshotRequest.getStudentID(), gradResponse.getProgram(), snapshotRequest.getGradYear().toString(), "123")).thenReturn(graduationData);

when(restService.get(String.format(constants.getPenStudentApiByPenUrl(), snapshotRequest.getPen()), List.class, "123")).thenReturn(List.of(penStudent));
when(restService.get(String.format(constants.getStudentNonGradReasonByPenUrl(), snapshotRequest.getPen()), StudentNonGradReason.class, "123")).thenReturn(nonGradReason);
when(restService.get(constants.getProgramRequirementsEndpoint(), List.class, "123")).thenReturn(Arrays.asList(proReqCode1, proReqCode2));

var result = edwSnapshotService.processSnapshot(snapshotRequest, "123");
assertNotNull(result);
assertThat(result.getPen()).isEqualTo(snapshotRequest.getPen());
assertThat(result.getGraduationFlag()).isEqualTo("N");
assertThat(result.getGraduationFlag()).isEqualTo("N");
assertThat(result.getNonGradReason1()).isEqualTo("A");
}

@Test
Expand Down
3 changes: 1 addition & 2 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ endpoint:
student-nongrad-report-data: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentnongradreportdata
student-nongrad-report-data-mincode: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentnongradreportdata/%s
edw-snapshot-of-grad-status: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/edw/snapshot
get-student-nongrad-reason-by-pen: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/pen/%s/nongrad-reason
grad-program-api:
grad-program-api:
program_name_by_program_code:
url: https://educ-grad-program-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/program/programs/%s
program_requirement_codes:
Expand Down

0 comments on commit 4bf576d

Please sign in to comment.