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-2934, 2922, & 2950: tasks are completed. #338

Merged
merged 2 commits into from
Sep 25, 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 @@ -185,7 +185,7 @@ private void convertStudentData(ConvGradStudent student, Student penStudent, Gra
gradStudent.setStudentGrade(student.getStudentGrade());
gradStudent.setStudentStatus(getGradStudentStatus(student.getStudentStatus(), student.getArchiveFlag()));

handleAdultStartRule(student, penStudent, gradStudent);
handleAdultStartRule(penStudent, gradStudent);

// flags
if (StringUtils.equalsIgnoreCase(gradStudent.getStudentStatus(), STUDENT_STATUS_MERGED)) {
Expand Down Expand Up @@ -610,7 +610,7 @@ public void triggerGraduationBatchRun(EventType eventType, UUID studentID, Strin
}
}

private void handleAdultStartRule(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent) {
private void handleAdultStartRule(Student penStudent, GraduationStudentRecord gradStudent) {
if ("1950".equalsIgnoreCase(gradStudent.getProgram())) {
Date dob = EducGradDataConversionApiUtils.parseDate(penStudent.getDob());
Date adultStartDate = DateUtils.addYears(dob, 18);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import java.util.Arrays;
import java.util.List;

public class StudentBaseService {
public abstract class StudentBaseService {

// NULL String => Nullify (set to NULL)
public static final String NULL_VALUE = "NULL";

// Student Status
public static final String STUDENT_STATUS_CURRENT = "CUR";
Expand Down Expand Up @@ -109,14 +112,21 @@ protected String getGradProgram(String graduationRequirementYear, String schoolO
}

protected void populateNewBatchFlags(StudentGradDTO currentStudent) {
if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudent.getStudentStatus())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
} else {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
}
case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED ->
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
default -> {
// do not set flags to Y
currentStudent.setNewRecalculateGradStatus(null);
currentStudent.setNewRecalculateProjectedGrad(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
package ca.bc.gov.educ.api.dataconversion.service.student;

import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO;
import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Date;

public abstract class StudentGraduationUpdateBaseService extends StudentBaseService {

protected abstract boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken);

protected void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) {
boolean addDualDogwood = false;
boolean addFrenchImmersion = false;

if (!currentStudent.isSCCP() && currentStudent.isGraduated()) {
currentStudent.setNewProgram(null);
return;
}

if (newGradProgram.endsWith("-PF")) {
// from EN to PF
// from PF to PF
// from 1950 to PF
// from SCCP to PF
addDualDogwood = true;
} else if (newGradProgram.endsWith("-EN") && (currentStudent.getProgram().endsWith("-PF") || hasAnyFrenchImmersionCourse(newGradProgram, pen, accessToken))) {
// from PF to EN - allowed for SD93/Yukon PF schools
// from EN to EN
// from 1950 to EN
// from SCCP to EN
addFrenchImmersion = true;
}

currentStudent.setAddDualDogwood(addDualDogwood);
currentStudent.setAddFrenchImmersion(addFrenchImmersion);

currentStudent.setNewProgram(newGradProgram);
}

protected void handleAdultStartDate(StudentGradDTO currentStudent) {
if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) {
Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday());
Date adultStartDate = DateUtils.addYears(dob, 18);
currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd
}
}

protected boolean processSchoolOfRecord(StudentGradDTO currentStudent, String value) {
boolean isChanged = false;
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
// UpdData
currentStudent.setNewSchoolOfRecord(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
isChanged = true;
}
case STUDENT_STATUS_ARCHIVED -> {
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewSchoolOfRecord(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
}
case STUDENT_STATUS_TERMINATED -> {
// UpdData
currentStudent.setNewSchoolOfRecord(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
default -> { // MER or DEC
// UpdData
currentStudent.setNewSchoolOfRecord(value);
// Do not set flags to Y
isChanged = true;
}
}
return isChanged;
}

protected boolean processStudentGrade(StudentGradDTO currentStudent, String value) {
boolean isChanged = false;
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
// UpdData
currentStudent.setNewStudentGrade(value);
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
if (!currentStudent.isGraduated()) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
}
isChanged = true;
}
case STUDENT_STATUS_ARCHIVED -> {
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewStudentGrade(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
}
case STUDENT_STATUS_TERMINATED -> {
// UpdData
currentStudent.setNewStudentGrade(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
default -> { // MER or DEC
// UpdData
currentStudent.setNewStudentGrade(value);
// Do not set flags to Y
isChanged = true;
}
}
return isChanged;
}

protected boolean processGraduationProgram(StudentGradDTO currentStudent, String pen, String gradProgram, String accessToken) {
boolean isChanged = false;
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
if (!currentStudent.isGraduated() || currentStudent.isSCCP()) {
// UpdData
handleProgramChange(gradProgram, currentStudent, pen, accessToken);
handleAdultStartDate(currentStudent);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
isChanged = true;
}
}
case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> {
if (!currentStudent.isGraduated() || currentStudent.isSCCP()) {
// UpdData
handleProgramChange(gradProgram, currentStudent, pen, accessToken);
handleAdultStartDate(currentStudent);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
}
default -> { // MER or DEC
if (!currentStudent.isGraduated() || currentStudent.isSCCP()) {
// UpdData
handleProgramChange(gradProgram, currentStudent, pen, accessToken);
handleAdultStartDate(currentStudent);
// Do not set flags to Y
isChanged = true;
}
}

}
return isChanged;
}

protected boolean processSlpDate(StudentGradDTO currentStudent, String value) {
boolean isChanged = false;
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewGradDate(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
isChanged = true;
}
}
case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> {
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewGradDate(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
}
default -> { // MER or DEC
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewGradDate(value);
// Do not set flags to Y
isChanged = true;
}
}

}
return isChanged;
}

protected boolean processCitizenship(StudentGradDTO currentStudent, String value) {
boolean isChanged = false;
switch(currentStudent.getStudentStatus()) {
case STUDENT_STATUS_CURRENT -> {
// UpdData
currentStudent.setNewCitizenship(value);
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
if (!currentStudent.isGraduated()) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
}
isChanged = true;
}
case STUDENT_STATUS_ARCHIVED -> {
if (!currentStudent.isGraduated()) {
// UpdData
currentStudent.setNewCitizenship(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
}
case STUDENT_STATUS_TERMINATED -> {
// UpdData
currentStudent.setNewCitizenship(value);
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
isChanged = true;
}
default -> { // MER or DEC
// UpdData
currentStudent.setNewCitizenship(value);
// Do not set flags to Y
isChanged = true;
}

}
return isChanged;
}

protected void processStudentStatus(StudentGradDTO currentStudent, String value) {
// UpdData
currentStudent.setNewStudentStatus(value);
switch(value) {
case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_MERGED -> {
// TVR
currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE);
}
case STUDENT_STATUS_CURRENT -> {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
}
case STUDENT_STATUS_TERMINATED -> {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE);
}
default -> { // DEC
}
}
}
}
Loading
Loading