use of ca.bc.gov.educ.penreg.api.struct.Student in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchRepostReportsOrchestrator method saveReportsWithoutPDF.
private void saveReportsWithoutPDF(Event event, Saga saga, PenRequestBatchRepostReportsFilesSagaData penRequestBatchRepostReportsFilesSagaData) throws IOException, TimeoutException, InterruptedException {
SagaEvent eventStates = this.createEventState(saga, event.getEventType(), event.getEventOutcome(), event.getEventPayload());
saga.setSagaState(SAVE_REPORTS.toString());
List<Student> students = obMapper.readValue(event.getEventPayload(), new TypeReference<>() {
});
penRequestBatchRepostReportsFilesSagaData.setStudents(event, students);
// save the updated payload to DB...
saga.setPayload(JsonUtil.getJsonStringFromObject(penRequestBatchRepostReportsFilesSagaData));
this.getSagaService().updateAttachedSagaWithEvents(saga, eventStates);
this.getResponseFileGeneratorService().saveReports(mapper.toModel(penRequestBatchRepostReportsFilesSagaData.getPenRequestBatch()), penRequestBatchRepostReportsFilesSagaData.getPenRequestBatchStudents(), penRequestBatchRepostReportsFilesSagaData.getStudents(), reportMapper.toReportData(penRequestBatchRepostReportsFilesSagaData));
val nextEvent = Event.builder().sagaId(saga.getSagaId()).eventType(SAVE_REPORTS).eventOutcome(REPORTS_SAVED).build();
this.handleEvent(nextEvent);
}
use of ca.bc.gov.educ.penreg.api.struct.Student in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenReqBatchUserMatchOrchestrator method addPossibleMatchToStudent.
/**
* this method expects that the twin ids provided in the payload here is already validated.
* Add twin records to student.
*
* @param event the event
* @param saga the saga
* @param penRequestBatchUserActionsSagaData the pen request batch user actions saga data
* @throws JsonProcessingException the json processing exception
*/
protected void addPossibleMatchToStudent(final Event event, final Saga saga, final PenRequestBatchUserActionsSagaData penRequestBatchUserActionsSagaData) throws JsonProcessingException {
final SagaEvent eventStates = this.createEventState(saga, event.getEventType(), event.getEventOutcome(), event.getEventPayload());
// set current event as saga state.
saga.setSagaState(ADD_POSSIBLE_MATCH.toString());
this.getSagaService().updateAttachedSagaWithEvents(saga, eventStates);
final var possibleMatches = penRequestBatchUserActionsSagaData.getMatchedStudentIDList().stream().map(matchedStudentID -> PossibleMatch.builder().createUser(penRequestBatchUserActionsSagaData.getCreateUser()).updateUser(penRequestBatchUserActionsSagaData.getUpdateUser()).studentID(penRequestBatchUserActionsSagaData.getStudentID()).matchedStudentID(matchedStudentID).matchReasonCode(TwinReasonCodes.PEN_MATCH.getCode()).build()).collect(Collectors.toList());
final Event nextEvent = Event.builder().sagaId(saga.getSagaId()).eventType(ADD_POSSIBLE_MATCH).replyTo(this.getTopicToSubscribe()).eventPayload(JsonUtil.getJsonStringFromObject(possibleMatches)).build();
this.postMessageToTopic(PEN_MATCH_API_TOPIC.toString(), nextEvent);
log.info("message sent to PEN_MATCH_API_TOPIC for ADD_POSSIBLE_MATCH Event.");
}
use of ca.bc.gov.educ.penreg.api.struct.Student 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;
}
use of ca.bc.gov.educ.penreg.api.struct.Student 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