use of ca.bc.gov.educ.penreg.api.struct.v1.external.ListItem in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchResultDataDecorator method populateForSystemMatchedStatus.
private void populateForSystemMatchedStatus(List<ListItem> exactMatchList, List<SchoolMinListItem> differencesList, Map<String, Student> studentMap, PenRequestBatchStudentEntity penRequestBatchStudent) {
val student = studentMap.get(penRequestBatchStudent.getStudentID().toString());
if (PenRegBatchHelper.exactMatch(PenRequestBatchStudentMapper.mapper.toStructure(penRequestBatchStudent), student)) {
exactMatchList.add(listItemMapper.toListItem(penRequestBatchStudent));
} else {
val item = new SchoolMinListItem();
item.setMin(listItemMapper.toListItem(student));
item.setSchool(listItemMapper.toDiffListItem(penRequestBatchStudent));
differencesList.add(item);
}
}
use of ca.bc.gov.educ.penreg.api.struct.v1.external.ListItem 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;
}
Aggregations