diff --git a/api/pom.xml b/api/pom.xml index 6391bf15..a815d42b 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-student-api - 1.8.57 + 1.8.58 educ-grad-student-api Student Demographics API for GRAD team diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecordDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecordDistribution.java index d74e2e87..611365b4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecordDistribution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecordDistribution.java @@ -18,6 +18,7 @@ public class GraduationStudentRecordDistribution extends BaseModel{ private String legalMiddleNames; private String legalLastName; private String schoolOfRecord; + private String schoolAtGrad; private String programCompletionDate; private String honoursStanding; private String program; diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java index f59c1488..a2499c9c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java @@ -111,6 +111,7 @@ public GraduationStudentRecordDistribution tToDForDistribution(GraduationStudent distObj.setProgram(ent.getProgram()); distObj.setHonoursStanding(ent.getHonoursStanding()); distObj.setSchoolOfRecord(ent.getSchoolOfRecord()); + distObj.setSchoolAtGrad(ent.getSchoolAtGrad()); distObj.setProgramCompletionDate(EducGradStudentApiUtils.parseDateFromString(gradStatusEntity.getProgramCompletionDate() != null ? gradStatusEntity.getProgramCompletionDate().toString():null)); distObj.setStudentID(ent.getStudentID()); distObj.setStudentCitizenship(ent.getStudentCitizenship()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 20c51cc2..51505a9a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -54,14 +54,14 @@ public class GraduationStatusService { private static final String CREATE_USER = "createUser"; private static final String CREATE_DATE = "createDate"; - private static final String UPDATE_USER = "updateUser"; - private static final String UPDATE_DATE = "updateDate"; private static final String GRAD_ALG = "GRADALG"; private static final String USER_EDIT = "USEREDIT"; private static final String USER_CREATE = "USEREDIT"; private static final String USER_DELETE = "USERDELETE"; private static final String USER_UNDO_CMPL = "USERUNDOCMPL"; + private static final String STD_NOT_FOUND_MSG = "Student with ID: %s not found"; + final WebClient webClient; @@ -127,7 +127,7 @@ public boolean hasStudentGraduated(UUID studentID) throws EntityNotFoundExceptio GraduationStudentRecordEntity graduationStudentRecord = responseOptional.get(); return graduationStudentRecord.getProgramCompletionDate() != null; } - throw new EntityNotFoundException(String.format("Student with ID: {} not found", studentID)); + throw new EntityNotFoundException(String.format(STD_NOT_FOUND_MSG, studentID)); } @Retry(name = "generalgetcall") @@ -165,7 +165,7 @@ public GraduationStudentRecord getGraduationStatus(UUID studentID) throws Entity if (responseOptional.isPresent()) { return graduationStatusTransformer.transformToDTO(responseOptional.get()); } - throw new EntityNotFoundException(String.format("Student with ID: %s not found", studentID)); + throw new EntityNotFoundException(String.format(STD_NOT_FOUND_MSG, studentID)); } /** @@ -179,7 +179,7 @@ public GraduationStudentRecordGradStatus getGraduationStatusProjection(UUID stud if (response != null) { return response; } - throw new EntityNotFoundException(String.format("Student with ID: %s not found", studentID)); + throw new EntityNotFoundException(String.format(STD_NOT_FOUND_MSG, studentID)); } @Transactional @@ -365,12 +365,9 @@ public GraduationStudentRecordSearchResult searchGraduationStudentRecords(final if(!searchRequest.getDistricts().contains(school.getDistNo())) { it.remove(); } else { - if(searchRequest.getSchoolCategoryCodes() != null && !searchRequest.getSchoolCategoryCodes().isEmpty()) { - if(!searchRequest.getSchoolCategoryCodes().contains(school.getSchoolCategoryCode())) { - it.remove(); - } else { - searchRequest.getSchoolOfRecords().add(school.getDistNo() + school.getSchlNo()); - } + List schoolCategoryCodes = searchRequest.getSchoolCategoryCodes().stream().filter(StringUtils::isNotBlank).toList(); + if(!schoolCategoryCodes.isEmpty() && !schoolCategoryCodes.contains(school.getSchoolCategoryCode())) { + it.remove(); } else { searchRequest.getSchoolOfRecords().add(school.getDistNo() + school.getSchlNo()); } @@ -697,15 +694,19 @@ && calculateAge(studentObj.getDob()) < 18) { } - private void validateOptionalProgram(UUID optionalProgramID, String accessToken) { - if (optionalProgramID == null) { - validation.addErrorAndStop("Optional Program ID is required"); - return; - } + private void validateOptionalProgram(UUID optionalProgramID, GraduationStudentRecord graduationStudentRecord, String accessToken) { + // check if op exists OptionalProgram optionalProgram = getOptionalProgram(optionalProgramID, accessToken); if (optionalProgram == null || isPrimaryKeyNull(optionalProgram)) { validation.addNotFoundErrorAndStop(String.format("Optional Program with ID: %s not found", optionalProgramID)); + return; + } + + // check that op and program combination exists and that the op id matches + OptionalProgram optionalProgram1 = getOptionalProgram(graduationStudentRecord.getProgram(), optionalProgram.getOptProgramCode(), accessToken); + if (optionalProgram1 == null || !optionalProgram1.getOptionalProgramID().equals(optionalProgramID)) { + validation.addErrorAndStop(String.format("Cannot add optional program: %s to student as it is not available under the program: %s", optionalProgram.getOptionalProgramName(), graduationStudentRecord.getProgram())); } } @@ -779,7 +780,7 @@ private void deleteStudentOptionalPrograms(UUID studentID) { List studOpList = gradStudentOptionalProgramRepository.findByStudentID(studentID); if(!studOpList.isEmpty()) { for (StudentOptionalProgramEntity studentOptionalProgramEntity : studOpList) { - historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,"USERDELETE"); + historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,USER_DELETE); gradStudentOptionalProgramRepository.deleteById(studentOptionalProgramEntity.getId()); } } @@ -789,13 +790,6 @@ private void deleteStudentCareerPrograms(UUID studentID) { gradStudentCareerProgramRepository.deleteByStudentID(studentID); } - private String getHonoursFlag(String gPA) { - if (Float.parseFloat(gPA) > 3) - return "Y"; - else - return "N"; - } - public List getStudentGradOptionalProgram(UUID studentID, String accessToken) { List optionalProgramList = gradStudentOptionalProgramTransformer.transformToDTO(gradStudentOptionalProgramRepository.findByStudentID(studentID)); @@ -842,7 +836,7 @@ public StudentOptionalProgram createStudentOptionalProgram(UUID studentID, UUID // Validation GraduationStudentRecord graduationStudentRecord = getGraduationStatus(studentID); validateStudent(graduationStudentRecord); - validateOptionalProgram(optionalProgramID, accessToken); + validateOptionalProgram(optionalProgramID, graduationStudentRecord, accessToken); // Process StudentOptionalProgramEntity entity = persistStudentOptionalProgramWithAuditHistory(studentID, optionalProgramID); @@ -878,7 +872,6 @@ public void deleteStudentOptionalProgram(UUID studentID, UUID optionalProgramID, // Validation GraduationStudentRecord graduationStudentRecord = getGraduationStatus(studentID); validateStudent(graduationStudentRecord); - validateOptionalProgram(optionalProgramID, accessToken); // Process removeStudentOptionalProgramWithAuditHistory(studentID, optionalProgramID); diff --git a/api/src/main/resources/db/migration/1.0/V1.0.62__DDL-ALTER_TABLES-for-institution-api.sql b/api/src/main/resources/db/migration/1.0/V1.0.62__DDL-ALTER_TABLES-for-institution-api.sql new file mode 100644 index 00000000..40056475 --- /dev/null +++ b/api/src/main/resources/db/migration/1.0/V1.0.62__DDL-ALTER_TABLES-for-institution-api.sql @@ -0,0 +1,7 @@ +ALTER TABLE EDW_GRADUATION_SNAPSHOT ADD SCHOOL_OF_RECORD_ID RAW(16); + +ALTER TABLE GRADUATION_STUDENT_RECORD ADD SCHOOL_OF_RECORD_ID RAW(16); +ALTER TABLE GRADUATION_STUDENT_RECORD ADD SCHOOL_AT_GRADUATION_ID RAW(16); + +ALTER TABLE GRADUATION_STUDENT_RECORD_HISTORY ADD SCHOOL_OF_RECORD_ID RAW(16); +ALTER TABLE GRADUATION_STUDENT_RECORD_HISTORY ADD SCHOOL_AT_GRADUATION_ID RAW(16); diff --git a/api/src/main/resources/db/migration/1.0/V1.0.63__DDL-REPLACE_VIEW-REPORT_GRAD_STUDENT_DATA_VW.sql b/api/src/main/resources/db/migration/1.0/V1.0.63__DDL-REPLACE_VIEW-REPORT_GRAD_STUDENT_DATA_VW.sql new file mode 100644 index 00000000..acd418d2 --- /dev/null +++ b/api/src/main/resources/db/migration/1.0/V1.0.63__DDL-REPLACE_VIEW-REPORT_GRAD_STUDENT_DATA_VW.sql @@ -0,0 +1,42 @@ +DROP VIEW REPORT_GRAD_STUDENT_DATA_VW; + +CREATE OR REPLACE VIEW REPORT_GRAD_STUDENT_DATA_VW AS +SELECT + A1.GRADUATION_STUDENT_RECORD_ID, + A1.SCHOOL_OF_RECORD MINCODE, + A1.SCHOOL_AT_GRADUATION MINCODE_AT_GRAD, + SUBSTR(A1.SCHOOL_OF_RECORD, 0, 3) DISTRICT_CODE, + SUBSTR(A1.SCHOOL_AT_GRADUATION, 0, 3) DISTRICT_CODE_AT_GRAD, + A1.STUDENT_STATUS_CODE STATUS, + A1.UPDATE_DATE, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.pen' RETURNING VARCHAR2(10) DEFAULT 'error' ON ERROR) PEN, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.legalFirstName' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) FIRST_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.legalMiddleNames' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) MIDDLE_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.legalLastName' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) LAST_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.studentGrade' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) GRADE, + --JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStudent.studentStatus' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) STATUS, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.districtName' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) DISTRICT_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.schoolName' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.address1' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_ADDRESS1, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.address2' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_ADDRESS2, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.city' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_CITY, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.provCode' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_PROVINCE, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.countryName' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_COUNTRY, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.school.postal' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) SCHOOL_POSTAL, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradProgram.programCode' RETURNING VARCHAR2(64) DEFAULT 'error' ON ERROR) PROGRAM_CODE, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradProgram.programName' RETURNING VARCHAR2(128) DEFAULT 'error' ON ERROR) PROGRAM_NAME, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStatus.programCompletionDate' RETURNING VARCHAR2(10) DEFAULT 'error' ON ERROR) PROGRAM_COMPLETION_DATE, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.gradStatus.honoursStanding' RETURNING VARCHAR2(10) DEFAULT 'error' ON ERROR) HONORS_STANDING, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.graduated' RETURNING VARCHAR2(10) DEFAULT 'error' ON ERROR) IS_GRADUATED, + JSON_VALUE(A1.STUDENT_GRAD_DATA, '$.studentCertificatesTranscript.transcriptTypeCode' RETURNING VARCHAR2(16) DEFAULT '' ON ERROR) TRANSCRIPT_TYPE_CODE, + JSON_QUERY(A1.STUDENT_GRAD_DATA, '$.studentCertificatesTranscript.certificateTypeCodes') CERTIFICATE_TYPE_CODES, + JSON_QUERY(A1.STUDENT_GRAD_DATA, '$.studentCourses.studentCourseList.courseName' WITH WRAPPER) STUDENT_COURSES, + --DECODE(LENGTH(JSON_QUERY(A1.STUDENT_GRAD_DATA, '$.studentCourses.studentCourseList.courseName' WITH CONDITIONAL WRAPPER)), 0, 'N', 'Y') HAS_STUDENT_COURSES, + JSON_QUERY(A1.STUDENT_GRAD_DATA, '$.nonGradReasons') NON_GRAD_REASONS +FROM + API_GRAD_STUDENT.GRADUATION_STUDENT_RECORD A1 +WHERE A1.STUDENT_STATUS_CODE NOT IN ('TER', 'DEC') + +; + + diff --git a/api/src/main/resources/db/migration/1.0/V1.0.64__DDL-REPLACE_VIEW-REPORT_GRAD_SCHOOL__DISTRICT_YE_VW.sql b/api/src/main/resources/db/migration/1.0/V1.0.64__DDL-REPLACE_VIEW-REPORT_GRAD_SCHOOL__DISTRICT_YE_VW.sql new file mode 100644 index 00000000..6e63226a --- /dev/null +++ b/api/src/main/resources/db/migration/1.0/V1.0.64__DDL-REPLACE_VIEW-REPORT_GRAD_SCHOOL__DISTRICT_YE_VW.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW REPORT_GRAD_SCHOOL_YE_VW AS +SELECT + COUNT(GRADUATION_STUDENT_RECORD_ID) STUD_NUM, + SUBSTR(DECODE(A1.SCHOOL_AT_GRADUATION, NULL, A1.SCHOOL_OF_RECORD, A1.SCHOOL_AT_GRADUATION), 0, 3) MINCODE +FROM + GRADUATION_STUDENT_RECORD A1 +WHERE + A1.PROGRAM_COMPLETION_DATE is null + AND A1.STUDENT_STATUS_CODE = 'CUR' + AND (A1.STUDENT_GRADE ='AD' or A1.STUDENT_GRADE='12') +GROUP BY SUBSTR(DECODE(A1.SCHOOL_AT_GRADUATION, NULL, A1.SCHOOL_OF_RECORD, A1.SCHOOL_AT_GRADUATION), 0, 3) +ORDER BY 1 DESC; + +CREATE OR REPLACE VIEW REPORT_GRAD_DISTRICT_YE_VW AS +SELECT DISTINCT + SUBSTR(DECODE(A1.SCHOOL_AT_GRADUATION, NULL, A1.SCHOOL_OF_RECORD, A1.SCHOOL_AT_GRADUATION), 0, 3) MINCODE +FROM + GRADUATION_STUDENT_RECORD A1 +WHERE + A1.PROGRAM_COMPLETION_DATE is null + AND A1.STUDENT_STATUS_CODE = 'CUR' + AND (A1.STUDENT_GRADE ='AD' or A1.STUDENT_GRADE='12') +GROUP BY SUBSTR(DECODE(A1.SCHOOL_AT_GRADUATION, NULL, A1.SCHOOL_OF_RECORD, A1.SCHOOL_AT_GRADUATION), 0, 3) +ORDER BY 1 DESC; + + diff --git a/tools/config/override-configmap-dev.sh b/tools/config/override-configmap-dev.sh index bd33baf6..b970c5c6 100644 --- a/tools/config/override-configmap-dev.sh +++ b/tools/config/override-configmap-dev.sh @@ -56,7 +56,7 @@ oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ --from-literal=MAXIMUM_POOL_SIZE="20" \ --from-literal=MAX_RETRY_ATTEMPTS="3" \ --from-literal=PEN_API="http://student-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS="0 */10 * ? * *" \ + --from-literal=CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS="0 0 0 1 * ?" \ --dry-run=client -o yaml | oc apply -f - echo Creating config map "$APP_NAME"-flb-sc-config-map