From 4d953862b290191ca2893c10f09ff8ca4a259f16 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 24 Oct 2023 14:11:25 -0700 Subject: [PATCH] Worked on performance to remove nongrad reason fileds for nograd student. Worked on performance to remove nongrad reason fileds for nograd student. --- .../model/dto/EdwGraduationSnapshot.java | 13 --- .../service/EdwSnapshotService.java | 80 ------------------- .../util/EducGraduationApiConstants.java | 3 - api/src/main/resources/application.yaml | 3 +- .../service/EdwSnapshotServiceTest.java | 27 ------- api/src/test/resources/application.yaml | 3 +- 6 files changed, 2 insertions(+), 127 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/EdwGraduationSnapshot.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/EdwGraduationSnapshot.java index 1afcca77..98b4fd5f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/EdwGraduationSnapshot.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/EdwGraduationSnapshot.java @@ -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) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotService.java index f920482e..29d0bdf6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotService.java @@ -95,28 +95,11 @@ private EdwGraduationSnapshot runHypotheticalGradAlgorithm(String pen, Integer g } else { // non-graduated student log.debug(" ==> Not Graduated!"); - List 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, @@ -124,13 +107,6 @@ public void saveEdwSnapshotOfGraduationStatus(String accessToken, EdwGraduationS accessToken); } - @SuppressWarnings("rawtypes") - public List 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) { @@ -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 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 programRequirementCodes) { - return programRequirementCodes.stream().filter(c -> gradRule.equalsIgnoreCase(c.getProReqCode())).findAny() - .map(ProgramRequirementCode::getTraxReqChar).orElse(null); - } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java index 866fe472..2cea7f93 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java @@ -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; diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index becabf9d..5af2a1b0 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -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: diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotServiceTest.java index 3cfc37ed..4c5b135f 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/EdwSnapshotServiceTest.java @@ -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()); @@ -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 diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 5e986d8b..f5b1abbd 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -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: