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-2761: replace minCode with schoolId for School cob. #694

Merged
merged 2 commits into from
Nov 21, 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class EducGradReportApiConstants {
@Value("${endpoint.educ-grad-trax-api.get-district-details.url}")
private String districtDetails;

@Value("${endpoint.educ-grad-trax-api.school-by-min-code.url}")
@Value("${endpoint.educ-grad-trax-api.school-by-school-id.url}")
private String schoolDetails;

@Value("${endpoint.educ-grad-trax-api.country-by-code.url}")
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ 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
school-by-min-code:
url: ${GRAD_TRAX_API}api/v2/trax/district?distNo=%s
school-by-school-id:
url: ${GRAD_TRAX_API}api/v2/trax/school-clob/%s
country-by-code:
url: ${GRAD_TRAX_API}api/v1/trax/code/country/%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ protected School getReportDataSchool(ReportData reportData) {

protected TraxSchool adaptTraxSchool(School school) {
TraxSchool traxSchool = new TraxSchool();
traxSchool.setSchoolId(school.getSchoolId());
traxSchool.setMinCode(school.getMincode());
traxSchool.setSchoolName(school.getName());
if(school.getAddress() != null) {
Expand All @@ -123,7 +124,7 @@ protected TraxSchool adaptTraxSchool(School school) {

protected void mockTraxSchool(TraxSchool traxSchool) {
when(this.webClient.get()).thenReturn(this.requestHeadersUriMock);
when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolDetails(),traxSchool.getMinCode()))).thenReturn(this.requestHeadersMock);
when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolDetails(),traxSchool.getSchoolId()))).thenReturn(this.requestHeadersMock);
when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock);
when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock);
when(this.responseMock.bodyToMono(TraxSchool.class)).thenReturn(Mono.just(traxSchool));
Expand Down
4 changes: 2 additions & 2 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ 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
school-by-min-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district?distNo=%s
school-by-school-id:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school-clob/%s
country-by-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/code/country/%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"data" : {
"student" : null,
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode" : "02828034",
"name" : "CORRELIEU SECONDARY",
"typeIndicator" : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
}
},
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode" : "06398007",
"name" : "SOUTH ISLAND DISTANCE EDUCATION SCHOOL",
"typeIndicator" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"nonGradReasons" : [ ]
},
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode" : "00502001",
"name" : "ROBERT EDGELL",
"typeIndicator" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"nonGradReasons" : [ ]
},
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode" : "00502001",
"name" : "Ecole Secondaire Mark R. Isfeld Secondary",
"typeIndicator" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"nonGradReasons" : [ ]
},
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode" : "00502001",
"name" : "ROBERT EDGELL",
"typeIndicator" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"frenchCert": "F"
},
"school" : {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode": "03699064",
"name": "Ecole Secondaire Mark R. Isfeld Secondary",
"typeIndicator": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"frenchCert": "F"
},
"school": {
"schoolId" : "b69bc244-b93b-2a9f-d2b1-3d8ffae92866",
"mincode": "03939008",
"name": "LORD BYNG SECONDARY",
"typeIndicator": "",
Expand Down
Loading