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-2034 - Issue with Last Issued Date on GRAD, NOT-YET GRADUATED a… #612

Merged
merged 2 commits into from
Aug 17, 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 @@ -73,6 +73,8 @@ public class ReportData implements Serializable {
private String reportNumber;
private String reportTitle;
private String reportSubTitle;
@JsonIgnore
private String reportIdentity;

@JsonDeserialize(using = NonGradReasonListDeserializer.class)
private List<NonGradReason> nonGradReasons = new ArrayList<>();
Expand Down Expand Up @@ -237,6 +239,14 @@ public void setReportSubTitle(String reportSubTitle) {
this.reportSubTitle = reportSubTitle;
}

public String getReportIdentity() {
return reportIdentity;
}

public void setReportIdentity(String reportIdentity) {
this.reportIdentity = reportIdentity;
}

public List<NonGradReason> getNonGradReasons() {
return nonGradReasons;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class GradDataConvertionBean extends BaseServiceImpl implements Serializa
@Autowired
StudentCertificateRepository studentCertificateRepository;

@Autowired
StudentReportRepository studentReportRepository;

public StudentInfo getStudentInfo(ReportData reportData) {
Student student = getStudent(reportData);
School school = getSchool(reportData);
Expand Down Expand Up @@ -441,9 +444,6 @@ public Pair<List<Student>, TotalCounts> getStudents(ReportData reportData) {
}
StudentImpl student = new StudentImpl();
BeanUtils.copyProperties(st, student);
if(st.getLastUpdateDate() != null) {
student.setLastUpdateDate(Date.from(st.getLastUpdateDate().atZone(ZoneId.systemDefault()).toInstant()));
}
PersonalEducationNumberObject pen = new PersonalEducationNumberObject(st.getPen().getPen());
pen.setEntityId(st.getPen().getEntityID());
student.setPen(pen);
Expand Down Expand Up @@ -479,6 +479,11 @@ public Pair<List<Student>, TotalCounts> getStudents(ReportData reportData) {
student.setGraduationStatus(gradStatus);
}

Date updateDate = null;
if(st.getLastUpdateDate() != null) {
updateDate = Date.from(st.getLastUpdateDate().atZone(ZoneId.systemDefault()).toInstant());
}

if(!StringUtils.isBlank(pen.getEntityId())) {
Optional<Date> distributionDate = studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(pen.getEntityId()));
distributionDate.ifPresent(student::setCertificateDistributionDate);
Expand All @@ -490,7 +495,15 @@ public Pair<List<Student>, TotalCounts> getStudents(ReportData reportData) {
List<TranscriptTypeCodeEntity> transcriptTypes = transcriptTypeCodeRepository.getStudentTranscriptTypes(UUID.fromString(pen.getEntityId()));
student.setTranscriptTypes(transcriptTypes.stream().map(TranscriptTypeCodeEntity::getLabel).collect(Collectors.toList()));
totals.countTranscript(transcriptTypes.size());

if("buildStudentNonGradProjectedReport()".equalsIgnoreCase(reportData.getReportIdentity())) {
Optional<Date> reportUpdatedTimestamp = studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(pen.getEntityId()));
if(reportUpdatedTimestamp.isPresent()) {
updateDate = reportUpdatedTimestamp.get();
}
}
}
student.setLastUpdateDate(updateDate);
}
return Pair.of(new ArrayList<>(result), totals);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import ca.bc.gov.educ.grad.report.entity.StudentReportEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.Optional;
import java.util.UUID;

public interface StudentReportRepository extends JpaRepository<StudentReportEntity, UUID> {

@Query("select max(c.updatedTimestamp) as UpdatedTimestamp from StudentReportEntity c where c.graduationStudentRecordId=:graduationStudentRecordId")
Optional<Date> getReportUpdatedTimestamp(UUID graduationStudentRecordId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class StudentReportEntity extends BaseEntity {
@Column(name = "REPORT_TYPE_CODE", nullable = false)
private String reportTypeCode;

@Column(name = "GRADUATION_STUDENT_RECORD_ID", nullable = false)
private String graduationStudentRecordId;
@Column(name = "GRADUATION_STUDENT_RECORD_ID", nullable = false, columnDefinition = "uuid")
private UUID graduationStudentRecordId;

@Column(name = "DOCUMENT_STATUS_CODE")
private String documentStatusCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ ReportData getReportData(String methodName) {
LOG.throwing(CLASSNAME, methodName, dse);
throw dse;
}

reportData.setReportIdentity(methodName);
return reportData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public abstract class GradReportBaseTest {
@MockBean
protected ProgramCertificateTranscriptRepository programCertificateTranscriptRepository;
@MockBean
protected StudentReportRepository studentReportRepository;
@MockBean
protected SignatureBlockTypeRepository signatureBlockTypeRepository;
@MockBean
protected DocumentStatusCodeRepository documentStatusCodeRepository;
Expand Down Expand Up @@ -182,6 +184,7 @@ protected GraduationStudentRecord mockGraduationStudentRecord(String pen, String

when(this.studentTranscriptRepository.findByGraduationStudentRecordId(graduationStudentRecord.getStudentID())).thenReturn(studentTranscriptEntity);
when(this.studentCertificateRepository.getCertificateDistributionDate(graduationStudentRecord.getStudentID())).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(graduationStudentRecord.getStudentID())).thenReturn(Optional.of(new Date()));

return graduationStudentRecord;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void createSchoolDistributionReport() throws Exception {
String entityId = "ac339d70-7649-1a2e-8176-4a2e693008cf";

when(this.studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(entityId))).thenReturn(List.of(
CertificateTypeCodeEntity.builder().label("Dogwood (Public)").build(),
CertificateTypeCodeEntity.builder().label("diplôme (Programme francophone)").build()
Expand Down Expand Up @@ -92,6 +93,7 @@ public void createDistrictDistributionYearEndReport() throws Exception {
String entityId = "ac339d70-7649-1a2e-8176-4a2e693008cf";

when(this.studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(entityId))).thenReturn(List.of(
CertificateTypeCodeEntity.builder().label("Dogwood (Public)").build(),
CertificateTypeCodeEntity.builder().label("diplôme (Programme francophone)").build()
Expand Down Expand Up @@ -125,6 +127,7 @@ public void createDistrictDistributionYearEndNonGradReport() throws Exception {
String entityId = "ac339d70-7649-1a2e-8176-4a2e693008cf";

when(this.studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(entityId))).thenReturn(List.of(
CertificateTypeCodeEntity.builder().label("Dogwood (Public)").build(),
CertificateTypeCodeEntity.builder().label("diplôme (Programme francophone)").build()
Expand Down Expand Up @@ -158,6 +161,7 @@ public void createSchoolDistributionYearEndReport() throws Exception {
String entityId = "ac339d70-7649-1a2e-8176-4a2e693008cf";

when(this.studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(entityId))).thenReturn(List.of(
CertificateTypeCodeEntity.builder().label("Dogwood (Public)").build(),
CertificateTypeCodeEntity.builder().label("diplôme (Programme francophone)").build()
Expand Down Expand Up @@ -191,6 +195,7 @@ public void createSchoolDistributionReport_NOSTUDENTS() throws Exception {
String entityId = "ac339d70-7649-1a2e-8176-4a2e693008cf";

when(this.studentCertificateRepository.getCertificateDistributionDate(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.studentReportRepository.getReportUpdatedTimestamp(UUID.fromString(entityId))).thenReturn(Optional.of(new Date()));
when(this.certificateTypeCodeRepository.getStudentCertificateTypes(UUID.fromString(entityId))).thenReturn(List.of(
CertificateTypeCodeEntity.builder().label("Dogwood (Public)").build(),
CertificateTypeCodeEntity.builder().label("diplôme (Programme francophone)").build()
Expand Down Expand Up @@ -392,6 +397,11 @@ public void createStudentNonGradProjectedReport() throws Exception {
assertNotNull(reportRequest.getData());

mockTraxSchool(adaptTraxSchool(getReportDataSchool(reportRequest.getData())));
for(Student st: reportRequest.getData().getSchool().getStudents()) {
if(!StringUtils.isBlank(st.getPen().getEntityID())) {
mockGraduationStudentRecord(st.getPen().getPen(), st.getPen().getEntityID());
}
}
ReportRequestDataThreadLocal.setReportData(reportRequest.getData());

byte[] response = apiReportService.getStudentNonGradProjectedReport(reportRequest);
Expand Down
Loading
Loading