From f47cb1f7312da65ef88a6ed57e70f97bda12e0da Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Wed, 20 Nov 2024 14:52:53 -0800 Subject: [PATCH] GRAD2-2761: replace minCode with schoolId for School cob. GRAD2-2761: replace minCode with schoolId for School cob. --- .../gov/educ/grad/report/api/client/School.java | 9 +++++++++ .../educ/grad/report/api/client/TraxSchool.java | 4 ++-- .../grad/report/dao/GradDataConvertionBean.java | 3 ++- .../gov/educ/grad/report/dto/impl/SchoolImpl.java | 10 ++++++++++ .../grad/report/dto/impl/StudentInfoImpl.java | 6 ++++-- .../gov/educ/grad/report/model/school/School.java | 7 +++++++ .../service/impl/GradReportServiceImpl.java | 15 +++++++++------ .../impl/StudentCertificateServiceImpl.java | 6 +++--- api/src/main/resources/application.yaml | 2 +- api/src/test/resources/application.yaml | 2 +- 10 files changed, 48 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/School.java b/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/School.java index ba0aa2c6..9e4de729 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/School.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/School.java @@ -8,6 +8,7 @@ public class School implements Serializable { + private String schoolId = ""; private String mincode = ""; private String name = ""; private String typeIndicator = ""; @@ -24,6 +25,14 @@ public class School implements Serializable { private List students = new ArrayList<>(); + public String getSchoolId() { + return schoolId; + } + + public void setSchoolId(String value) { + this.schoolId = value; + } + public String getMincode() { return mincode; } diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/TraxSchool.java b/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/TraxSchool.java index d9b7a074..1cba0732 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/TraxSchool.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/api/client/TraxSchool.java @@ -18,8 +18,8 @@ public class TraxSchool { private String countryCode; private String postal; private String openFlag; + private String schoolCategoryLegacyCode; private String schoolCategoryCode; - private String schoolCategoryCodeInstitute; public String getSchoolName() { return schoolName != null ? schoolName.trim() : null; @@ -47,7 +47,7 @@ public String getPostal() { @Override public String toString() { - return "School [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryCodeInstitute=" + schoolCategoryCodeInstitute + return "School [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryLegacyCode=" + schoolCategoryLegacyCode + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolName=" + schoolName + ", districtName=" + districtName + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" + certificateEligibility + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" + provCode + ", countryCode=" + countryCode + ", postal=" + postal + ", openFlag=" + openFlag + "]"; diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java index 27321421..ecfa60d9 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dao/GradDataConvertionBean.java @@ -110,7 +110,8 @@ public StudentInfo getStudentInfo(ReportData reportData) { school.getAddress() != null ? school.getAddress().getRegion() : "",// String schoolProv, school.getAddress() != null ? school.getAddress().getPostalCode() : "",// String schoolPostalCode, school.getPhoneNumber(),// String schoolPhone, - school.getTypeIndicator()// Character schlIndType + school.getTypeIndicator(),// Character schlIndType, + school.getSchoolId()// String schoolId ); result.setNonGradReasons(this.getNongradReasons(reportData)); result.setHasOtherProgram(student.getHasOtherProgram()); diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/SchoolImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/SchoolImpl.java index fa058e8d..a062a89c 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/SchoolImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/SchoolImpl.java @@ -34,6 +34,7 @@ public class SchoolImpl extends DistrictImpl implements School { private static final long serialVersionUID = 4L; + private String schoolId = ""; private String mincode = ""; private String schlno = ""; private String schoolCategoryCode = ""; @@ -49,6 +50,15 @@ public void setMincode(final String mincode) { this.mincode = mincode; } + @Override + public String getSchoolId() { + return schoolId; + } + + public void setSchoolId(String schoolId) { + this.schoolId = schoolId; + } + @JsonProperty("minCode") public String getMincode() { return mincode; diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/StudentInfoImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/StudentInfoImpl.java index 47519fb0..8d2cad14 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/StudentInfoImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/dto/impl/StudentInfoImpl.java @@ -139,6 +139,7 @@ public StudentInfoImpl() { * @param schoolPostalCode * @param schoolPhone * @param schlIndType + * @param schoolId */ public StudentInfoImpl( final String studNo, @@ -178,7 +179,8 @@ public StudentInfoImpl( final String schoolProv, final String schoolPostalCode, final String schoolPhone, - final String schlIndType) { + final String schlIndType, + final String schoolId) { this.pen = trimSafe(studNo); this.firstName = trimSafe(firstName); @@ -214,7 +216,7 @@ public StudentInfoImpl( this.schoolPostalCode = trimSafe(schoolPostalCode); this.schoolPhone = trimSafe(schoolPhone); this.schoolTypeIndicator = trimSafe(schlIndType); - + this.schoolId = schoolId; //setSchoolTypeBanner(); this.academicProgram.add(trimSafe(prgmCode)); diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/model/school/School.java b/api/src/main/java/ca/bc/gov/educ/grad/report/model/school/School.java index c6dfefc5..e2fae497 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/model/school/School.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/model/school/School.java @@ -26,6 +26,13 @@ */ public interface School extends District { + /** + * Returns the schoolId the Institute uses to uniquely identify this school. + * + * @return schoolId + */ + String getSchoolId(); + /** * Returns the code the Ministry uses to uniquely identify this school. * diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/GradReportServiceImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/GradReportServiceImpl.java index a2b9dc13..c495a4ec 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/GradReportServiceImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/GradReportServiceImpl.java @@ -340,7 +340,7 @@ School adaptSchool(final StudentInfo studentInfo, String accessToken, boolean ch SchoolImpl school = new SchoolImpl(); if(checkEligibility) { - TraxSchool traxSchool = getSchool(studentInfo.getMincode(), accessToken); + TraxSchool traxSchool = getSchool(studentInfo.getSchoolId(), accessToken); if (traxSchool != null && "N".equalsIgnoreCase(traxSchool.getTranscriptEligibility())) { EntityNotFoundException dse = new EntityNotFoundException( getClass(), @@ -365,6 +365,7 @@ School adaptSchool(final StudentInfo studentInfo, String accessToken, boolean ch } void populateSchoolFromStudentInfo(SchoolImpl school, StudentInfo studentInfo) { + school.setSchoolId(studentInfo.getSchoolId()); school.setMincode(studentInfo.getMincode()); school.setName(studentInfo.getSchoolName()); @@ -382,9 +383,11 @@ void populateSchoolFromStudentInfo(SchoolImpl school, StudentInfo studentInfo) { } void populateSchoolFromTraxSchool(SchoolImpl school, TraxSchool traxSchool) { - school.setSchoolCategoryCode(traxSchool.getSchoolCategoryCode()); + school.setSchoolCategoryCode(traxSchool.getSchoolCategoryLegacyCode()); + school.setSchoolId(traxSchool.getSchoolId()); school.setMincode(traxSchool.getMinCode()); school.setName(traxSchool.getSchoolName()); + school.setSchoolCategoryCode(traxSchool.getSchoolCategoryLegacyCode()); final CanadianPostalAddressImpl address = new CanadianPostalAddressImpl(); address.setStreetLine1(traxSchool.getAddress1()); address.setStreetLine2(traxSchool.getAddress2()); @@ -420,18 +423,18 @@ int parseCredits(final String credits) { } - TraxSchool getSchool(String minCode, String accessToken) { + TraxSchool getSchool(String schoolId, String accessToken) { TraxSchool traxSchool = null; - if(!StringUtils.isBlank(minCode)) { + if(!StringUtils.isBlank(schoolId)) { try { traxSchool = webClient.get() - .uri(String.format(constants.getSchoolDetails(), minCode)) + .uri(String.format(constants.getSchoolDetails(), schoolId)) .headers(h -> h.setBearerAuth(accessToken)) .retrieve() .bodyToMono(TraxSchool.class) .block(); } catch (Exception e) { - LOG.log(Level.WARNING, "Unable to get TRAX school by {0} code. Reason {1}", new String[]{minCode, e.getMessage()}); + LOG.log(Level.WARNING, "Unable to get TRAX school by schoolId={0}. Reason {1}", new String[]{schoolId, e.getMessage()}); } } return traxSchool; diff --git a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentCertificateServiceImpl.java b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentCertificateServiceImpl.java index 349c357b..c9a75e46 100644 --- a/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentCertificateServiceImpl.java +++ b/api/src/main/java/ca/bc/gov/educ/grad/report/service/impl/StudentCertificateServiceImpl.java @@ -110,8 +110,8 @@ public List buildReport() throws DomainServiceException { final Student student = getStudent(reportData); //validated final School school = getSchool(reportData); //validated - if(school != null && !StringUtils.isBlank(school.getMinistryCode())) { - TraxSchool traxSchool = getSchool(school.getMinistryCode(), accessToken); + if(school != null && !StringUtils.isBlank(school.getSchoolId())) { + TraxSchool traxSchool = getSchool(school.getSchoolId(), accessToken); if(traxSchool != null) { if ("N".equalsIgnoreCase(traxSchool.getCertificateEligibility())) { EntityNotFoundException dse = new EntityNotFoundException( @@ -122,7 +122,7 @@ public List buildReport() throws DomainServiceException { throw dse; } if(StringUtils.isBlank(school.getSchoolCategoryCode())) { - ((SchoolImpl) school).setSchoolCategoryCode(traxSchool.getSchoolCategoryCode()); + ((SchoolImpl) school).setSchoolCategoryCode(traxSchool.getSchoolCategoryLegacyCode()); } } } diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index a8010047..bb7bc867 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -100,7 +100,7 @@ endpoint: url: ${GRAD_REPORT_API}api/v1/reports/signatures educ-grad-trax-api: get-district-details: - url: ${GRAD_TRAX_API}api/v2/trax/district/%s + url: ${GRAD_TRAX_API}api/v2/trax/district?distNo=%s school-by-min-code: url: ${GRAD_TRAX_API}api/v2/trax/school-clob/%s country-by-code: diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 67a5cacc..e0dcaeb7 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -113,7 +113,7 @@ endpoint: url: https://educ-grad-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/reports/signatures educ-grad-trax-api: get-district-details: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district/%s + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district?distNo=%s school-by-min-code: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school-clob/%s country-by-code: