Skip to content

Commit

Permalink
Merge pull request #656 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.19.0
  • Loading branch information
githubmamatha authored May 23, 2024
2 parents 23c3a6b + b700189 commit f84712f
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 50 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-student-api</artifactId>
<version>1.8.58</version>
<version>1.8.59</version>
<name>educ-grad-student-api</name>
<description>Student Demographics API for GRAD team</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Data
@Builder
public class StudentSearchRequest {
public class StudentSearchRequest implements Serializable {
String legalFirstName;
String legalLastName;
String legalMiddleNames;
Expand All @@ -27,18 +29,20 @@ public class StudentSearchRequest {
String schoolOfRecord;
String gradProgram;

List<String> schoolOfRecords;
List<String> districts;
List<String> schoolCategoryCodes;
List<String> pens;
List<String> programs;
private List<String> schoolOfRecords;
private List<String> districts;
private List<String> schoolCategoryCodes;
private List<String> pens;
private List<String> programs;
private List<UUID> studentIDs;

@JsonFormat(pattern= EducGradStudentApiConstants.DEFAULT_DATE_FORMAT)
Date gradDateFrom;
LocalDate gradDateFrom;
@JsonFormat(pattern= EducGradStudentApiConstants.DEFAULT_DATE_FORMAT)
Date gradDateTo;
LocalDate gradDateTo;

Boolean validateInput;
String activityCode;

public List<String> getSchoolOfRecords() {
if(schoolOfRecords == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ca.bc.gov.educ.api.gradstudent.model.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Immutable;

import jakarta.persistence.*;
import java.util.Date;
import java.util.UUID;

Expand All @@ -26,6 +29,9 @@ public GraduationStudentRecordSearchEntity() {

@Column(name = "SCHOOL_OF_RECORD", nullable = true)
private String schoolOfRecord;

@Column(name = "SCHOOL_AT_GRADUATION", nullable = true)
private String schoolAtGraduation;

@Column(name = "STUDENT_STATUS_CODE", nullable = false)
private String studentStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

Expand All @@ -24,8 +24,10 @@ public class GraduationStudentRecordSearchCriteria implements Serializable {
private List<String> studentIds;
private List<String> programs;

Date gradDateFrom;
Date gradDateTo;
LocalDate gradDateFrom;
LocalDate gradDateTo;

String activityCode;

public List<UUID> getStudentUUIDs() {
List<UUID> result = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package ca.bc.gov.educ.api.gradstudent.repository;

import ca.bc.gov.educ.api.gradstudent.constant.Generated;
import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordSearchEntity;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;

import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import java.util.Date;
import java.time.LocalDate;
import java.util.UUID;

public class GraduationStudentRecordSearchSpecification implements Specification<GraduationStudentRecordSearchEntity> {

private static final Logger logger = LoggerFactory.getLogger(GraduationStudentRecordSearchSpecification.class);
private static final String PROGRAM_COMPLETION_DATE = "programCompletionDate";
private static final String STUDENT_STATUS = "studentStatus";
private static final String SCHOOL_AT_GRADUATION = "schoolAtGraduation";
private static final String SCHOOL_OF_RECORD = "schoolOfRecord";

private final GraduationStudentRecordSearchCriteria searchCriteria;

Expand All @@ -26,35 +31,56 @@ public GraduationStudentRecordSearchSpecification(GraduationStudentRecordSearchC

@Override
@Nullable
@Generated
public Predicate toPredicate(Root<GraduationStudentRecordSearchEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
logger.debug("toPredicate()");
Predicate curStatusOptional;
if (searchCriteria.getStudentIds() != null && !searchCriteria.getStudentIds().isEmpty()) {
curStatusOptional = criteriaBuilder.not(root.get(STUDENT_STATUS).in("MER"));
return criteriaBuilder.and(root.get("studentID").as(UUID.class).in(searchCriteria.getStudentUUIDs()),
criteriaBuilder.notEqual(root.get("studentStatus"), "MER")
);
} else if (searchCriteria.getSchoolOfRecords() != null && !searchCriteria.getSchoolOfRecords().isEmpty()) {
Predicate curStatusOptional = criteriaBuilder.equal(root.get("studentStatus"), "CUR");
if(searchCriteria.getGradDateFrom() != null && searchCriteria.getGradDateTo() != null) {
curStatusOptional = criteriaBuilder.and(
criteriaBuilder.greaterThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(Date.class), searchCriteria.getGradDateFrom())
,criteriaBuilder.lessThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(Date.class), searchCriteria.getGradDateTo())
);
}
return criteriaBuilder.and(root.get("schoolOfRecord").in(searchCriteria.getSchoolOfRecords()),
curStatusOptional
);
} else if (searchCriteria.getPrograms() != null && !searchCriteria.getPrograms().isEmpty()) {
Predicate curStatusOptional = criteriaBuilder.equal(root.get("studentStatus"), "CUR");
if(searchCriteria.getGradDateFrom() != null && searchCriteria.getGradDateTo() != null) {
curStatusOptional = criteriaBuilder.and(
criteriaBuilder.greaterThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(Date.class), searchCriteria.getGradDateFrom())
,criteriaBuilder.lessThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(Date.class), searchCriteria.getGradDateTo())
);
}
boolean certDist = StringUtils.equalsAnyIgnoreCase(searchCriteria.activityCode, "USERDISTOC", "USERDISTRC");
if(certDist) {
curStatusOptional = criteriaBuilder.not(root.get(STUDENT_STATUS).in("MER", "DEC"));
} else {
curStatusOptional = criteriaBuilder.equal(root.get(STUDENT_STATUS), "CUR");
}

Predicate datesRangePredicate = criteriaBuilder.and();
if(searchCriteria.getGradDateFrom() != null && searchCriteria.getGradDateTo() != null) {
boolean transcriptDist = StringUtils.equalsAnyIgnoreCase(searchCriteria.activityCode, "USERDISTOT", "USERDISTRT");
if(transcriptDist) {
curStatusOptional = criteriaBuilder.not(root.get(STUDENT_STATUS).in("MER", "DEC"));
}
return criteriaBuilder.and(root.get("program").in(searchCriteria.getPrograms()),
curStatusOptional
datesRangePredicate = criteriaBuilder.and(
criteriaBuilder.greaterThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(LocalDate.class), searchCriteria.getGradDateFrom())
,criteriaBuilder.lessThanOrEqualTo(root.get(PROGRAM_COMPLETION_DATE).as(LocalDate.class), searchCriteria.getGradDateTo())
);
}
return criteriaBuilder.and();
Predicate schoolOfRecordPredicate = criteriaBuilder.and();
if (searchCriteria.getSchoolOfRecords() != null && !searchCriteria.getSchoolOfRecords().isEmpty()) {
/***
Predicate schoolAtGraduationIsNull = criteriaBuilder.isNull(root.get(SCHOOL_AT_GRADUATION));
Predicate schoolAtGraduationIsNotNull = criteriaBuilder.isNotNull(root.get(SCHOOL_AT_GRADUATION));
Predicate schoolOfRecordPredicate = criteriaBuilder.and(root.get(SCHOOL_OF_RECORD).in(searchCriteria.getSchoolOfRecords()), schoolAtGraduationIsNull);
Predicate schoolAtGraduationPredicate = criteriaBuilder.and(root.get(SCHOOL_AT_GRADUATION).in(searchCriteria.getSchoolOfRecords()), schoolAtGraduationIsNotNull);
Predicate schoolOfRecordPredicateOr = criteriaBuilder.and(criteriaBuilder.or(schoolOfRecordPredicate));
Predicate schoolAtGraduationPredicateOr = criteriaBuilder.and(criteriaBuilder.or(schoolAtGraduationPredicate));
Predicate finalPredicate = criteriaBuilder.or(schoolOfRecordPredicateOr, schoolAtGraduationPredicateOr);
schoolOfRecordPredicate = criteriaBuilder.and(curStatusOptional, datesRangePredicate, finalPredicate);
***/
if(certDist) {
schoolOfRecordPredicate = criteriaBuilder.and(root.get(SCHOOL_AT_GRADUATION).in(searchCriteria.getSchoolOfRecords()));
} else {
schoolOfRecordPredicate = criteriaBuilder.and(root.get(SCHOOL_OF_RECORD).in(searchCriteria.getSchoolOfRecords()));
}
}
Predicate programPredicate = criteriaBuilder.and();
if (searchCriteria.getPrograms() != null && !searchCriteria.getPrograms().isEmpty()) {
programPredicate = criteriaBuilder.and(root.get("program").in(searchCriteria.getPrograms()));
}
return criteriaBuilder.and(curStatusOptional, datesRangePredicate, schoolOfRecordPredicate, programPredicate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public GraduationStudentRecordSearchResult searchGraduationStudentRecords(final
.programs(searchRequest.getPrograms())
.gradDateFrom(searchRequest.getGradDateFrom())
.gradDateTo(searchRequest.getGradDateTo())
.activityCode(searchRequest.getActivityCode())
.build();

Specification<GraduationStudentRecordSearchEntity> spec = new GraduationStudentRecordSearchSpecification(searchCriteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ public class EducGradStudentApiConstants {
@Value("${endpoint.grad-graduation-report-api.archive-student-achievement.url}")
private String archiveStudentAchievements;

@Value("${endpoint.educ-school-api.get-school-by-mincode.url}")
@Value("${endpoint.grad-trax-api.commonschool-by-mincode.url}")
private String schoolByMincodeSchoolApiUrl;

@Value("${endpoint.educ-school-api.url}")
@Value("${endpoint.grad-trax-api.all-commonschools.url}")
private String schoolsSchoolApiUrl;

// Splunk LogHelper Enabled
Expand Down
11 changes: 7 additions & 4 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,15 @@ resilience4j.retry:
#Endpoint properties
endpoint:
grad-trax-api:
all-commonschools:
url: ${GRAD_TRAX_API}api/v1/trax/school/common
school-by-min-code:
url: ${GRAD_TRAX_API}api/v1/trax/school/%s
district-by-district-code:
url: ${GRAD_TRAX_API}api/v1/trax/district/%s
commonschool-by-mincode:
url: ${GRAD_TRAX_API}api/v1/trax/school/common/%s

grad-program-api:
optional_program_name_by_optional_program_id:
url: ${GRAD_PROGRAM_API}api/v1/program/optionalprograms/id/%s
Expand Down Expand Up @@ -189,10 +194,8 @@ endpoint:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentcertificates?studentID=%s
archive-student-achievement:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/archiveachievement/%s
educ-school-api:
url: ${EDUC_SCHOOL_API}api/v1/schools
get-school-by-mincode:
url: ${EDUC_SCHOOL_API}api/v1/schools/%s



#Splunk LogHelper
splunk:
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ('MER', 'DEC')

;


Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.springframework.http.ResponseEntity;

import java.sql.Date;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -327,8 +328,8 @@ public void testSearchGraduationStudentRecords() {
List<String> programs = new ArrayList<>();
programs.add("1950");

Date gradDateFrom = new Date(System.currentTimeMillis() - (1000L * 60 * 60 * 24 * 30 * 12 * 10));
Date gradDateTo = new Date(System.currentTimeMillis());
LocalDate gradDateFrom = LocalDate.of(2000, 01, 01);
LocalDate gradDateTo = LocalDate.now();

StudentSearchRequest searchRequest = StudentSearchRequest.builder()
.pens(pens)
Expand Down
7 changes: 5 additions & 2 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ cron:
#Endpoint properties
endpoint:
grad-trax-api:
all-commonschools:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common
school-by-min-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s
district-by-district-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/district/%s
commonschool-by-mincode:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common/%s
grad-program-api:
optional_program_name_by_optional_program_id:
url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/optionalprograms/id/%s
Expand Down Expand Up @@ -141,8 +145,7 @@ endpoint:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentachievement/%s
educ-school-api:
url: https://school-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/schools
get-school-by-mincode:
url: https://school-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/schools/%s


#Splunk LogHelper
splunk:
Expand Down

0 comments on commit f84712f

Please sign in to comment.