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-2398, 2390, 2412: task is complete. #292

Merged
merged 3 commits into from
Nov 30, 2023
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 @@ -84,7 +84,7 @@ public void handleEvent(@NonNull final Event event) {
break;
}
} catch (final Exception exception) {
log.error("Exception while processing event :: {}", event, exception);
log.error("Exception while processing event :: {} - {}", event, exception.getMessage());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ca.bc.gov.educ.api.dataconversion.constant;

public enum FieldName {
SCHOOL_OF_RECORD,
GRAD_PROGRAM,
ADULT_START_DATE,
SLP_DATE,
STUDENT_GRADE,
CITIZENSHIP,
STUDENT_STATUS,

RECALC_GRAD_ALG,
RECALC_TVR

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ca.bc.gov.educ.api.dataconversion.constant;

public enum FieldType {
STRING,
DATE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ca.bc.gov.educ.api.dataconversion.model;

import ca.bc.gov.educ.api.dataconversion.constant.FieldName;
import ca.bc.gov.educ.api.dataconversion.constant.FieldType;
import lombok.Builder;
import lombok.Data;

import java.util.Objects;

@Builder
@Data
public class OngoingUpdateFieldDTO {
private FieldType type;
private FieldName name;
private Object value;

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OngoingUpdateFieldDTO that = (OngoingUpdateFieldDTO) o;
return getName() == that.getName();
}

@Override
public int hashCode() {
return Objects.hash(getName());
}

@Override
public String toString() {
return "OngoingUpdateField{" +
"type=" + type +
", name=" + name +
", value=" + value +
'}';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ca.bc.gov.educ.api.dataconversion.model;

import ca.bc.gov.educ.api.dataconversion.constant.EventType;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Data
public class OngoingUpdateRequestDTO {
private String studentID;
private String pen;
private EventType eventType;
private List<OngoingUpdateFieldDTO> updateFields = new ArrayList<>();
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ConvGradStudent process(String pen) throws Exception {
return null;
}
// convert
responseStudent = studentProcess.convertStudent(students.get(0), summaryDTO, StringUtils.equalsIgnoreCase(reload, "Y"));
responseStudent = studentProcess.convertStudent(students.get(0), summaryDTO, StringUtils.equalsIgnoreCase(reload, "Y"), false);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public <T extends Object> void processEvent(T request, Event event) {
ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO();
summary.setAccessToken(accessToken);
try {
studentProcess.convertStudent(convStudent, summary, false);
studentProcess.convertStudent(convStudent, summary, false, true);
} catch (Exception e) {
ConversionAlert error = new ConversionAlert();
error.setItem(convStudent.getPen());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public <T extends Object> void processEvent(T request, Event event) {

public void processAssessment(TraxStudentUpdateDTO studentAssessmentUpdate, StudentGradDTO currentStudent, String accessToken) {
log.info(" Process Assessment : studentID = {}, pen = {} ", currentStudent.getStudentID(),studentAssessmentUpdate.getPen());
studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken);
studentProcess.triggerGraduationBatchRun(ASSESSMENT, currentStudent.getStudentID(), studentAssessmentUpdate.getPen(), "Y", "Y", accessToken);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class StudentBaseService {
// Optional Program Codes
private static final List<String> OPTIONAL_PROGRAM_CODES = Arrays.asList("AD", "BC", "BD");
private static final List<String> OPTIONAL_PROGRAM_CODES_FOR_RECREATION = Arrays.asList("AD", "BC", "BD", "CP");
private static final List<String> OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION = Arrays.asList("FR", "CP");

protected void handleException(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, String pen, ConversionResultType type, String reason) {
ConversionAlert error = new ConversionAlert();
Expand Down Expand Up @@ -144,8 +145,8 @@ public boolean isOptionalProgramCode(String code) {
return OPTIONAL_PROGRAM_CODES.contains(code);
}

public boolean isOptionalProgramRecreationRequired(String code) {
return OPTIONAL_PROGRAM_CODES_FOR_RECREATION.contains(code);
public boolean isOptionalProgramRecreationRequired(String code, String program) {
return "SCCP".equalsIgnoreCase(program)? OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION.contains(code) : OPTIONAL_PROGRAM_CODES_FOR_RECREATION.contains(code);
}

// GRAD2-2103: applied to 2023 & 2018 programs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public <T extends Object> void processEvent(T request, Event event) {

public void processCourse(TraxStudentUpdateDTO studentCourseUpdate, StudentGradDTO currentStudent, String accessToken) {
log.info(" Process Course : studentID = {}, pen = {} ", currentStudent.getStudentID(), studentCourseUpdate.getPen());
studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken);
studentProcess.triggerGraduationBatchRun(COURSE, currentStudent.getStudentID(), studentCourseUpdate.getPen(), "Y", "Y", accessToken);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St

if (isChanged) {
log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateDemog.getPen());
studentProcess.saveGraduationStudent(currentStudent, accessToken);
studentProcess.saveGraduationStudent(updateDemog.getPen(), currentStudent, UPD_DEMOG, accessToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public <T extends Object> void processEvent(T request, Event event) {
public void processFrenchImmersion(TraxFrenchImmersionUpdateDTO frenchImmersionUpdate, StudentGradDTO currentStudent, String accessToken) {
log.info(" Process French Immersion : studentID = {}", currentStudent.getStudentID());
if (studentProcess.hasAnyFrenchImmersionCourse(currentStudent.getProgram(), frenchImmersionUpdate.getPen(), accessToken)) {
log.info(" => create FI optional program");
log.info(" => [FI] optional program will be added if not exist for {}.", currentStudent.getProgram());
studentProcess.addStudentOptionalProgram("FI", currentStudent, false, accessToken);
studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), "Y", "Y", accessToken);
studentProcess.triggerGraduationBatchRun(FI10ADD, currentStudent.getStudentID(), frenchImmersionUpdate.getPen(), "Y", "Y", accessToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu

if (isChanged) {
log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen());
studentProcess.saveGraduationStudent(currentStudent, accessToken);
studentProcess.saveGraduationStudent(updateGrad.getPen(), currentStudent, UPD_GRAD, accessToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void processStudent(TraxStudentStatusUpdateDTO studentStatusUpdate, Stude

if (isChanged) {
log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), studentStatusUpdate.getPen());
studentProcess.saveGraduationStudent(currentStudent, accessToken);
studentProcess.saveGraduationStudent(studentStatusUpdate.getPen(), currentStudent, UPD_STD_STATUS, accessToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,39 @@ public void processOptionalAndCareerPrograms(TraxXProgramDTO xprogram, StudentGr

currentStudent.getRemovedProgramCodes().forEach(p -> {
if (isOptionalProgramCode(p)) {
log.info(" => removed optional program code : {}", p);
log.info(" => [{}] optional program will be removed if exist for {}.", p, currentStudent.getProgram());
studentProcess.removeStudentOptionalProgram(p, currentStudent, accessToken);
} else {
log.info(" => removed career program code : {}", p);
log.info(" => [{}] career program will be removed if exist for {}.", p, currentStudent.getProgram());
studentProcess.removeStudentCareerProgram(p, currentStudent, accessToken);
}
});

currentStudent.getAddedProgramCodes().forEach(p -> {
if (isOptionalProgramCode(p)) {
log.info(" => new optional program code : {}", p);
log.info(" => [{}] optional program will be added if not exist for {}.", p, currentStudent.getProgram());
studentProcess.addStudentOptionalProgram(p, currentStudent, false, accessToken);
} else {
log.info(" => new career program code : {}", p);
log.info(" => [{}] career program will be added if not exist for {}.", p, currentStudent.getProgram());
studentProcess.addStudentCareerProgram(p, currentStudent.getStudentID(), accessToken);
}
});

// No Career Program? then remove CP optional program
if (studentProcess.existsCareerProgram(currentStudent.getStudentID(), accessToken)) {
log.info(" => [CP] optional program will be added if not exist.");
log.info(" => [CP] optional program will be added if not exist for {}.", currentStudent.getProgram());
studentProcess.addStudentOptionalProgram("CP", currentStudent, false, accessToken);
} else {
log.info(" => [CP] optional program will be removed if exist.");
log.info(" => [CP] optional program will be removed if exist for {}.", currentStudent.getProgram());
studentProcess.removeStudentOptionalProgram("CP", currentStudent, accessToken);
}

// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
studentProcess.triggerGraduationBatchRun(currentStudent.getStudentID(), currentStudent.getNewRecalculateGradStatus(), currentStudent.getNewRecalculateProjectedGrad(), accessToken);

studentProcess.triggerGraduationBatchRun(XPROGRAM, currentStudent.getStudentID(), xprogram.getPen(), currentStudent.getNewRecalculateGradStatus(), currentStudent.getNewRecalculateProjectedGrad(), accessToken);
}

private void handleOptionalAndCareerProgramChange(List<String> reqProgramCodes, List<String> curProgramCodes, StudentGradDTO currentStudent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public class EducGradDataConversionApiConstants {
@Value("${endpoint.grad-student-api.save-grad-student-record}")
private String saveGraduationStudentRecord;

@Value("${endpoint.grad-student-api.save-grad-student-record-for-ongoing-updates}")
private String saveGraduationStudentRecordForOngoingUpdates;

@Value("${endpoint.grad-student-api.read-student-optional-programs}")
private String readStudentOptionalPrograms;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ca.bc.gov.educ.api.dataconversion.util;

import ca.bc.gov.educ.api.dataconversion.exception.ServiceException;
import ca.bc.gov.educ.api.dataconversion.model.*;
import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment;
import ca.bc.gov.educ.api.dataconversion.model.StudentCourse;
import ca.bc.gov.educ.api.dataconversion.model.*;
import ca.bc.gov.educ.api.dataconversion.model.tsw.*;
import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportRequest;
import io.github.resilience4j.retry.annotation.Retry;
Expand Down Expand Up @@ -545,6 +545,17 @@ public GraduationStudentRecord saveStudentGradStatus(String studentID, Graduatio
}).body(BodyInserters.fromValue(toBeSaved)).retrieve().bodyToMono(GraduationStudentRecord.class).block();
}

// Update GraduationStudentRecord - POST /student/conv/studentid/{id}?ongoingUpdate=true&eventType=UPD_GRAD
@Retry(name = "rt-updateStudentGradStatus", fallbackMethod = "rtUpdateStudentGradStatusFallback")
public GraduationStudentRecord updateStudentGradStatusByFields(OngoingUpdateRequestDTO requestDTO, String accessToken) {
return webClient.post()
.uri(constants.getSaveGraduationStudentRecordForOngoingUpdates())
.headers(h -> {
h.setBearerAuth(accessToken);
h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
}).body(BodyInserters.fromValue(requestDTO)).retrieve().bodyToMono(GraduationStudentRecord.class).block();
}

// Remove All Student Related Data - DELETE /student/conv/studentid/{id}
public void removeAllStudentRelatedData(UUID studentID, String accessToken) {
webClient.delete().uri(String.format(constants.getSaveGraduationStudentRecord(),studentID))
Expand Down Expand Up @@ -621,4 +632,9 @@ public ConvGradStudent rtSaveStudentGradStatusFallback(HttpServerErrorException
log.error("STUDENT GRAD STATUS NOT Saved after many attempts: {}", exception);
return null;
}

public ConvGradStudent rtUpdateStudentGradStatusFallback(HttpServerErrorException exception){
log.error("STUDENT GRAD STATUS NOT Updated after many attempts: {}", exception);
return null;
}
}
8 changes: 8 additions & 0 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ resilience4j.retry:
- org.springframework.web.client.HttpServerErrorException
ignoreExceptions:
- java.lang.NullPointerException
rt-updateStudentGradStatus:
maxAttempts: ${MAX_RETRY_ATTEMPTS}
waitDuration: 5s
retryExceptions:
- org.springframework.web.client.HttpServerErrorException
ignoreExceptions:
- java.lang.NullPointerException
rt-conversionStatus:
maxAttempts: ${MAX_RETRY_ATTEMPTS}
waitDuration: 5s
Expand Down Expand Up @@ -223,6 +230,7 @@ endpoint:
save-student-career-program: ${GRAD_STUDENT_API}api/v1/student/conv/studentcareerprogram
remove-student-career-program: ${GRAD_STUDENT_API}api/v1/student/conv/studentcareerprogram/%s/%s
read-student-career-programs: ${GRAD_STUDENT_API}api/v1/student/studentcareerprogram/studentid/%s
save-grad-student-record-for-ongoing-updates: ${GRAD_STUDENT_API}api/v1/student/conv/ongoingupdate/gradstatus
grad-assessment-api:
assessment-requirement:
url: ${GRAD_ASSESSMENT_API}api/v1/assessment/requirement
Expand Down
Loading
Loading