Search in sources :

Example 1 with ReportUserMatchedListItem

use of ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchReportDataDecorator method toReportData.

/**
 * To pen request batch student entity pen request batch student entity.
 *
 * @param data the saga data
 * @return the pen request batch report data entity
 */
@Override
public PenRequestBatchReportData toReportData(final BasePenRequestBatchReturnFilesSagaData data) {
    final var reportData = this.delegate.toReportData(data);
    final List<ReportListItem> pendingList = new ArrayList<>();
    final List<ReportListItem> newPenList = new ArrayList<>();
    final List<ReportListItem> sysMatchedList = new ArrayList<>();
    final List<ReportUserMatchedListItem> diffList = new ArrayList<>();
    final List<ReportUserMatchedListItem> confirmedList = new ArrayList<>();
    if (data != null && !CollectionUtils.isEmpty(data.getPenRequestBatchStudents())) {
        final Map<String, Student> students = this.setStudents(data.getStudents());
        for (final PenRequestBatchStudent penRequestBatchStudent : data.getPenRequestBatchStudents()) {
            switch(Objects.requireNonNull(PenRequestBatchStudentStatusCodes.valueOfCode(penRequestBatchStudent.getPenRequestBatchStudentStatusCode()))) {
                case DUPLICATE:
                case ERROR:
                case REPEAT:
                case INFOREQ:
                case FIXABLE:
                    val issues = data.getPenRequestBatchStudentValidationIssues().get(penRequestBatchStudent.getPenRequestBatchStudentID());
                    val pendingItem = listItemMapper.toReportListItem(penRequestBatchStudent, issues);
                    if (!"Duplicate".equals(pendingItem.getPen())) {
                        pendingItem.setPen("Pending");
                    }
                    pendingList.add(pendingItem);
                    break;
                case SYS_NEW_PEN:
                case USR_NEW_PEN:
                    this.populateForNewPenStatus(newPenList, students, penRequestBatchStudent);
                    break;
                case SYS_MATCHED:
                    this.populateForSystemMatchedStatus(sysMatchedList, diffList, students, penRequestBatchStudent);
                    break;
                case USR_MATCHED:
                    this.populateForUserMatchedStatus(sysMatchedList, diffList, students, penRequestBatchStudent);
                    break;
                default:
                    log.error("Unexpected pen request batch student status code encountered while attempting generate report data :: " + penRequestBatchStudent.getPenRequestBatchStudentStatusCode());
                    break;
            }
        }
        val processDateTime = data.getPenRequestBatch() == null || data.getPenRequestBatch().getProcessDate() == null ? LocalDateTime.now() : LocalDateTime.parse(data.getPenRequestBatch().getProcessDate());
        reportData.setProcessDate(processDateTime.format(DateTimeFormatter.ofPattern("yyyy/MM/dd")));
        reportData.setProcessTime(processDateTime.format(DateTimeFormatter.ofPattern("HH:mm")));
        reportData.setReportDate(processDateTime.format(DateTimeFormatter.ofPattern("yyyy-MMM-dd")).toUpperCase().replace(".", ""));
        reportData.setReviewer(this.setReviewer(data.getPenCoordinator()));
    }
    reportData.setSysMatchedList(sysMatchedList);
    reportData.setPendingList(pendingList);
    reportData.setNewPenList(newPenList);
    reportData.setDiffList(diffList);
    reportData.setConfirmedList(confirmedList);
    return reportData;
}
Also used : lombok.val(lombok.val) ReportUserMatchedListItem(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem) ReportListItem(ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportListItem) PenRequestBatchStudent(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent) Student(ca.bc.gov.educ.penreg.api.struct.Student) PenRequestBatchStudent(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent)

Aggregations

Student (ca.bc.gov.educ.penreg.api.struct.Student)1 PenRequestBatchStudent (ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent)1 ReportListItem (ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportListItem)1 ReportUserMatchedListItem (ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem)1 lombok.val (lombok.val)1