Search in sources :

Example 1 with PenRequestBatchSubmissionResult

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

the class PenRequestBatchResultDataDecorator method toResult.

@Override
public PenRequestBatchSubmissionResult toResult(final PenRequestBatchEntity penRequestBatch, final Map<String, Student> studentMap) {
    final var requestBatchSubmissionResult = this.delegate.toResult(penRequestBatch, studentMap);
    final List<ListItem> pendingList = new ArrayList<>();
    final List<ListItem> newPenAssignedList = new ArrayList<>();
    final List<ListItem> exactMatchList = new ArrayList<>();
    final List<SchoolMinListItem> differencesList = new ArrayList<>();
    final List<SchoolMinListItem> confirmedList = new ArrayList<>();
    for (final PenRequestBatchStudentEntity penRequestBatchStudent : penRequestBatch.getPenRequestBatchStudentEntities()) {
        switch(Objects.requireNonNull(PenRequestBatchStudentStatusCodes.valueOfCode(penRequestBatchStudent.getPenRequestBatchStudentStatusCode()))) {
            case DUPLICATE:
            case ERROR:
            case REPEAT:
            case INFOREQ:
            case FIXABLE:
                val fixableItem = listItemMapper.toListItem(penRequestBatchStudent);
                fixableItem.setValidationIssues(penRequestBatchStudent.getPenRequestBatchStudentValidationIssueEntities().stream().filter(validationResult -> "ERROR".equals(validationResult.getPenRequestBatchValidationIssueSeverityCode())).map(PenRequestBatchStudentValidationIssueMapper.mapper::toStruct).collect(Collectors.toList()));
                pendingList.add(fixableItem);
                break;
            case SYS_NEW_PEN:
            case USR_NEW_PEN:
                populateForNewPenStatus(studentMap, newPenAssignedList, penRequestBatchStudent);
                break;
            case SYS_MATCHED:
                this.populateForSystemMatchedStatus(exactMatchList, differencesList, studentMap, penRequestBatchStudent);
                break;
            case USR_MATCHED:
                populateForUserMatchedStatus(studentMap, differencesList, penRequestBatchStudent);
                break;
            default:
                log.error("Unexpected pen request batch student error code encountered while attempting generate PenRequestBatchSubmissionResult data :: " + penRequestBatchStudent.getPenRequestBatchStudentStatusCode());
                break;
        }
    }
    requestBatchSubmissionResult.setPendingList(pendingList);
    requestBatchSubmissionResult.setConfirmedList(confirmedList);
    requestBatchSubmissionResult.setDifferencesList(differencesList);
    requestBatchSubmissionResult.setExactMatchList(exactMatchList);
    requestBatchSubmissionResult.setNewPenAssignedList(newPenAssignedList);
    return requestBatchSubmissionResult;
}
Also used : lombok.val(lombok.val) ListItem(ca.bc.gov.educ.penreg.api.struct.v1.external.ListItem) PenRequestBatchStudentStatusCodes(ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentStatusCodes) PenRequestBatchStudentMapper(ca.bc.gov.educ.penreg.api.mappers.v1.PenRequestBatchStudentMapper) StudentDemogCode(ca.bc.gov.educ.penreg.api.constants.StudentDemogCode) lombok.val(lombok.val) PenRequestBatchStudentValidationIssueMapper(ca.bc.gov.educ.penreg.api.mappers.PenRequestBatchStudentValidationIssueMapper) SchoolMinListItem(ca.bc.gov.educ.penreg.api.struct.v1.external.SchoolMinListItem) Collectors(java.util.stream.Collectors) PenRegBatchHelper(ca.bc.gov.educ.penreg.api.helpers.PenRegBatchHelper) PenRequestBatchEntity(ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchEntity) PenRequestBatchStudentEntity(ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchStudentEntity) ArrayList(java.util.ArrayList) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Student(ca.bc.gov.educ.penreg.api.struct.Student) Map(java.util.Map) PenRequestBatchSubmissionResult(ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmissionResult) ArrayList(java.util.ArrayList) SchoolMinListItem(ca.bc.gov.educ.penreg.api.struct.v1.external.SchoolMinListItem) ListItem(ca.bc.gov.educ.penreg.api.struct.v1.external.ListItem) SchoolMinListItem(ca.bc.gov.educ.penreg.api.struct.v1.external.SchoolMinListItem) PenRequestBatchStudentEntity(ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchStudentEntity)

Aggregations

PenRequestBatchStudentStatusCodes (ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentStatusCodes)1 StudentDemogCode (ca.bc.gov.educ.penreg.api.constants.StudentDemogCode)1 PenRegBatchHelper (ca.bc.gov.educ.penreg.api.helpers.PenRegBatchHelper)1 PenRequestBatchStudentValidationIssueMapper (ca.bc.gov.educ.penreg.api.mappers.PenRequestBatchStudentValidationIssueMapper)1 PenRequestBatchStudentMapper (ca.bc.gov.educ.penreg.api.mappers.v1.PenRequestBatchStudentMapper)1 PenRequestBatchEntity (ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchEntity)1 PenRequestBatchStudentEntity (ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchStudentEntity)1 Student (ca.bc.gov.educ.penreg.api.struct.Student)1 ListItem (ca.bc.gov.educ.penreg.api.struct.v1.external.ListItem)1 PenRequestBatchSubmissionResult (ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmissionResult)1 SchoolMinListItem (ca.bc.gov.educ.penreg.api.struct.v1.external.SchoolMinListItem)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1