Skip to content

Commit

Permalink
GRAD2-2761: replace minCode with schoolId for School cob.
Browse files Browse the repository at this point in the history
GRAD2-2761: replace minCode with schoolId for School cob.
  • Loading branch information
infstar committed Nov 20, 2024
1 parent d73d728 commit f47cb1f
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class School implements Serializable {

private String schoolId = "";
private String mincode = "";
private String name = "";
private String typeIndicator = "";
Expand All @@ -24,6 +25,14 @@ public class School implements Serializable {

private List<Student> students = new ArrayList<>();

public String getSchoolId() {
return schoolId;
}

public void setSchoolId(String value) {
this.schoolId = value;
}

public String getMincode() {
return mincode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
+ "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public StudentInfoImpl() {
* @param schoolPostalCode
* @param schoolPhone
* @param schlIndType
* @param schoolId
*/
public StudentInfoImpl(
final String studNo,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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());

Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public List<BusinessReport> 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(
Expand All @@ -122,7 +122,7 @@ public List<BusinessReport> buildReport() throws DomainServiceException {
throw dse;
}
if(StringUtils.isBlank(school.getSchoolCategoryCode())) {
((SchoolImpl) school).setSchoolCategoryCode(traxSchool.getSchoolCategoryCode());
((SchoolImpl) school).setSchoolCategoryCode(traxSchool.getSchoolCategoryLegacyCode());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f47cb1f

Please sign in to comment.