Skip to content

Commit

Permalink
Merge branch 'grad-release'
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/pom.xml
  • Loading branch information
chris.ditcher authored and chris.ditcher committed Aug 29, 2023
2 parents 3384a5c + 8e87e08 commit 1c281be
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 40 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-graduation-api</artifactId>
<version>1.8.45</version>
<version>1.8.46</version>
<name>educ-grad-graduation-api</name>
<description>Ministry of Education GRAD GRADUATION API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@ public class GraduationStudentRecord extends BaseModel {

private List<GradRequirement> nonGradReasons;
private List<StudentCareerProgram> careerPrograms;

public LocalDate getAdultStartDate() {
return adultStartDate == null ? LocalDate.now() : adultStartDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

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

Expand Down Expand Up @@ -34,7 +34,7 @@ public class Student implements Comparable<Student>, Serializable {

private String localId = "";
private String hasOtherProgram = "";
private Date lastUpdateDate;
private LocalDateTime lastUpdateDate;
private List<OtherProgram> otherProgramParticipation = new ArrayList<>();
private List<NonGradReason> nonGradReasons = new ArrayList<>();
private List<CertificateType> certificateTypes = new ArrayList<>();
Expand Down Expand Up @@ -234,11 +234,11 @@ public void setGraduationStatus(GraduationStatus graduationStatus) {
}

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
public Date getLastUpdateDate() {
public LocalDateTime getLastUpdateDate() {
return lastUpdateDate;
}

public void setLastUpdateDate(Date lastUpdateDate) {
public void setLastUpdateDate(LocalDateTime lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -39,6 +40,7 @@ public ProcessorData fire(ProcessorData processorData) {
List<StudentOptionalProgram> projectedOptionalGradResponse = optionalProgramService.saveAndLogOptionalPrograms(graduationDataStatus, processorData.getStudentID(), processorData.getAccessToken(), optionalProgram);
logger.debug("**** Saved Optional Programs: ****");
GraduationStudentRecord toBeSaved = gradStatusService.prepareGraduationStatusObj(graduationDataStatus);
toBeSaved.setUpdateUser(StringUtils.isEmpty(gradResponse.getUpdateUser()) ? "" : gradResponse.getUpdateUser());
if(checkExceptions(exception,algorithmResponse,processorData)) {
return processorData;
}
Expand All @@ -62,14 +64,6 @@ public ProcessorData fire(ProcessorData processorData) {
logger.debug("**** Record Restored Due to Error: ****");
return processorData;
}
gradStatusService.prepareGraduationStatusData(graduationStatusResponse, graduationDataStatus);
tokenUtils.checkAndSetAccessToken(processorData);
gradStatusService.saveStudentGradStatus(processorData.getStudentID(), processorData.getBatchId(), processorData.getAccessToken(), graduationStatusResponse, exception);
if (checkExceptions(exception,algorithmResponse,processorData)) {
gradStatusService.restoreStudentGradStatus(processorData.getStudentID(), processorData.getAccessToken(), graduationDataStatus.isGraduated());
logger.debug("**** Record Restored Due to Error: ****");
return processorData;
}
logger.debug("**** Saved Grad Status: ****");
algorithmResponse.setGraduationStudentRecord(graduationStatusResponse);
algorithmResponse.setStudentOptionalProgram(projectedOptionalGradResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public ProcessorData fire(ProcessorData processorData) {
logger.debug("**** Record Restored Due to Error: ****");
return processorData;
}
gradStatusService.prepareGraduationStatusData(graduationStatusResponse, graduationDataStatus);
tokenUtils.checkAndSetAccessToken(processorData);
gradStatusService.saveStudentGradStatus(processorData.getStudentID(), processorData.getBatchId(), processorData.getAccessToken(), graduationStatusResponse, exception);
if (checkExceptions(exception,algorithmResponse,processorData)) {
gradStatusService.restoreStudentGradStatus(processorData.getStudentID(), processorData.getAccessToken(), graduationDataStatus.isGraduated());
logger.debug("**** Record Restored Due to Error: ****");
return processorData;
}
logger.debug("**** Saved Grad Status: ****");
algorithmResponse.setGraduationStudentRecord(graduationStatusResponse);
algorithmResponse.setStudentOptionalProgram(projectedOptionalGradResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import ca.bc.gov.educ.api.graduation.process.AlgorithmProcessFactory;
import ca.bc.gov.educ.api.graduation.process.AlgorithmProcessType;
import ca.bc.gov.educ.api.graduation.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
Expand All @@ -24,9 +24,7 @@

import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;

Expand All @@ -51,10 +49,10 @@ public class GraduationService {
RESTService restService;
EducGraduationApiConstants educGraduationApiConstants;
SchoolYearDates schoolYearDates;
ObjectMapper objectMapper;
JsonTransformer jsonTransformer;

@Autowired
public GraduationService(WebClient webClient, AlgorithmProcessFactory algorithmProcessFactory, GradStatusService gradStatusService, SchoolService schoolService, ReportService reportService, TokenUtils tokenUtils, RESTService restService, EducGraduationApiConstants educGraduationApiConstants, SchoolYearDates schoolYearDates, ObjectMapper objectMapper) {
public GraduationService(WebClient webClient, AlgorithmProcessFactory algorithmProcessFactory, GradStatusService gradStatusService, SchoolService schoolService, ReportService reportService, TokenUtils tokenUtils, RESTService restService, EducGraduationApiConstants educGraduationApiConstants, SchoolYearDates schoolYearDates, JsonTransformer jsonTransformer) {
this.webClient = webClient;
this.algorithmProcessFactory = algorithmProcessFactory;
this.gradStatusService = gradStatusService;
Expand All @@ -64,7 +62,7 @@ public GraduationService(WebClient webClient, AlgorithmProcessFactory algorithmP
this.restService = restService;
this.educGraduationApiConstants = educGraduationApiConstants;
this.schoolYearDates = schoolYearDates;
this.objectMapper = objectMapper;
this.jsonTransformer = jsonTransformer;
}

public AlgorithmResponse graduateStudent(String studentID, Long batchId, String accessToken, String projectedType) {
Expand All @@ -78,8 +76,8 @@ public AlgorithmResponse graduateStudent(String studentID, Long batchId, String
aR.setException(exception);
return aR;
}
logger.debug("**** Fetched Student Information: ****");
if (gradResponse != null && !gradResponse.getStudentStatus().equals("MER")) {
logger.debug("**** Fetched Student Information: {} ****", gradResponse.getStudentID());
ProcessorData data = new ProcessorData(gradResponse, null, accessToken, studentID, batchId, exception);
AlgorithmProcess process = algorithmProcessFactory.createProcess(pType);
data = process.fire(data);
Expand Down Expand Up @@ -245,6 +243,11 @@ public Integer createAndStoreSchoolReports(List<String> uniqueSchoolList, String

try {
List<GraduationStudentRecord> stdList = gradStatusService.getStudentListByMinCode(usl, accessToken);
if(logger.isDebugEnabled()) {
int totalStudents = ObjectUtils.defaultIfNull(stdList.size(), 0);
String listOfStudents = jsonTransformer.marshall(stdList);
logger.debug("*** Student List of {} Acquired {}", totalStudents, listOfStudents);
}
SchoolTrax schoolDetails = schoolService.getSchoolDetails(usl, accessToken, exception);
if (schoolDetails != null) {
logger.debug("*** School Details Acquired {}", schoolDetails.getSchoolName());
Expand Down Expand Up @@ -344,7 +347,7 @@ private List<Student> processStudentList(List<GraduationStudentRecord> gradStudL
std.setPen(pen);
std.setGrade(gsr.getStudentGrade());
std.setGradProgram(gsr.getProgram());
std.setLastUpdateDate(Date.from(gsr.getUpdateDate().atZone(ZoneId.systemDefault()).toInstant()));
std.setLastUpdateDate(gsr.getUpdateDate());
//Grad2-1931 - mchintha
std.setConsumerEducReqt(gsr.getConsumerEducationRequirementMet());
std.setGraduationStatus(GraduationStatus.builder()
Expand All @@ -368,7 +371,7 @@ private List<Student> processStudentList(List<GraduationStudentRecord> gradStudL
} else {
std.setGraduationData(new ca.bc.gov.educ.api.graduation.model.report.GraduationData());
if (gsr.getStudentProjectedGradData() != null) {
ProjectedRunClob projectedClob = objectMapper.readValue(gsr.getStudentProjectedGradData(), ProjectedRunClob.class);
ProjectedRunClob projectedClob = (ProjectedRunClob)jsonTransformer.unmarshall(gsr.getStudentProjectedGradData(), ProjectedRunClob.class);
std.setNonGradReasons(getNonGradReasons(projectedClob.getNonGradReasons()));
if (!projectedClob.isGraduated())
stdPrjList.add(std);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;
import java.util.*;

@Service
Expand Down Expand Up @@ -567,7 +566,7 @@ private Student populateStudentObjectByReportGradStudentData(ReportGradStudentDa
student.setMiddleName(reportGradStudentData.getMiddleName());
student.setLastName(reportGradStudentData.getLastName());
student.setGradProgram(reportGradStudentData.getProgramCode());
student.setLastUpdateDate(Date.from(reportGradStudentData.getUpdateDate().atZone(ZoneId.systemDefault()).toInstant()));
student.setLastUpdateDate(reportGradStudentData.getUpdateDate());

GraduationStatus gradStatus = new GraduationStatus();
gradStatus.setProgramCompletionDate(reportGradStudentData.getProgramCompletionDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,25 @@ public void testGraduateStudent_withProjectedTypeGS_withexception() {
sA.setStudentAssessmentList(new ArrayList<>());
graduationDataStatus.setStudentAssessments(sA);

School school = new School();
school.setMinCode("012345");
school.setSchoolName("XYZ");
school.setSchoolCategoryCode("01");
school.setSchoolPhone("123456");
school.setIndependentDesignation("2");
graduationDataStatus.setSchool(school);

GradSearchStudent gradStudent = new GradSearchStudent();
gradStudent.setStudentID("00000000-0000-0001-0000-000000000001");
gradStudent.setPen("123090109");
gradStudent.setLegalFirstName("A");
gradStudent.setEmail("[email protected]");
graduationDataStatus.setGradStudent(gradStudent);

StudentCertificatesTranscript studentCertificatesTranscript = new StudentCertificatesTranscript();
studentCertificatesTranscript.setTranscriptTypeCode("02");
graduationDataStatus.setStudentCertificatesTranscript(studentCertificatesTranscript);

ExceptionMessage ex = new ExceptionMessage();
ex.setExceptionName("ALG");
ex.setExceptionDetails("NULL POINTER");
Expand All @@ -1680,16 +1699,15 @@ public void testGraduateStudent_withProjectedTypeGS_withexception() {
GraduationMessages gM = new GraduationMessages();
gM.setGradMessage("asdad");

School schoolObj = new School();
schoolObj.setMinCode("1231123");
schoolObj.setIndependentDesignation("2");

ReportData data = new ReportData();
data.setGradMessage("ABC");
doNothing().when(this.tokenUtils).setAccessToken(any());
Mockito.when(gradStatusService.getGradStatus(studentID, accessToken,exception)).thenReturn(gradResponse);
Mockito.when(gradAlgorithmService.runGradAlgorithm(gradResponse.getStudentID(), gradResponse.getProgram(), accessToken,exception)).thenReturn(graduationDataStatus);
Mockito.when(gradStatusService.prepareGraduationStatusObj(graduationDataStatus)).thenReturn(gradResponse);
Mockito.when(reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,accessToken,exception)).thenReturn(data);
Mockito.when(gradStatusService.saveStudentGradStatus(studentID,null, accessToken,gradResponse,exception)).thenReturn(gradResponse);
Mockito.when(optionalProgramService.saveAndLogOptionalPrograms(graduationDataStatus,studentID,accessToken,new ArrayList<>())).thenReturn(list);
AlgorithmResponse response = graduationService.graduateStudent(studentID,null,accessToken,projectedType);
assertNotNull(response);
}
Expand Down

0 comments on commit 1c281be

Please sign in to comment.