Skip to content

Commit

Permalink
Interim commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Jan 27, 2024
1 parent 97d167b commit e278c77
Show file tree
Hide file tree
Showing 24 changed files with 367 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import ca.bc.gov.educ.penreg.api.properties.ApplicationProperties;
import ca.bc.gov.educ.penreg.api.rest.RestUtils;
import ca.bc.gov.educ.penreg.api.service.NotificationService;
import ca.bc.gov.educ.penreg.api.service.PenCoordinatorService;
import ca.bc.gov.educ.penreg.api.service.StudentRegistrationContactService;
import ca.bc.gov.educ.penreg.api.struct.School;
import com.google.common.base.Stopwatch;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -130,7 +130,7 @@ public class PenRegBatchProcessor {
/**
* The Pen coordinator service.
*/
private final PenCoordinatorService penCoordinatorService;
private final StudentRegistrationContactService penCoordinatorService;

/**
* The Duplicate file check service map.
Expand All @@ -153,7 +153,7 @@ public class PenRegBatchProcessor {
* @param penRequestBatchFileValidator the pen request batch file validator
*/
@Autowired
public PenRegBatchProcessor(final PenRegBatchStudentRecordsProcessor penRegBatchStudentRecordsProcessor, final PenRequestBatchFileService penRequestBatchFileService, final ApplicationProperties applicationProperties, final NotificationService notificationService, final PenCoordinatorService penCoordinatorService, final List<DuplicateFileCheckService> duplicateFileCheckServiceList, final PenRequestBatchFileValidator penRequestBatchFileValidator, final RestUtils restUtils) {
public PenRegBatchProcessor(final PenRegBatchStudentRecordsProcessor penRegBatchStudentRecordsProcessor, final PenRequestBatchFileService penRequestBatchFileService, final ApplicationProperties applicationProperties, final NotificationService notificationService, final StudentRegistrationContactService penCoordinatorService, final List<DuplicateFileCheckService> duplicateFileCheckServiceList, final PenRequestBatchFileValidator penRequestBatchFileValidator, final RestUtils restUtils) {
this.penRegBatchStudentRecordsProcessor = penRegBatchStudentRecordsProcessor;
this.penRequestBatchFileService = penRequestBatchFileService;
this.applicationProperties = applicationProperties;
Expand Down Expand Up @@ -305,7 +305,7 @@ private Optional<CompletableFuture<Boolean>> notifySchoolForFileFormatErrors(fin
Optional<CompletableFuture<Boolean>> isSchoolNotifiedFutureOptional = Optional.empty();
if (this.isNotificationToSchoolRequired(fileUnProcessableException)) {
log.info("notification to school is required :: {}", guid);
val coordinatorEmailOptional = this.penCoordinatorService.getPenCoordinatorEmailByMinCode(penWebBlobEntity.getMincode());
val coordinatorEmailOptional = this.penCoordinatorService.getStudentRegistrationContactEmailsByMincode(penWebBlobEntity.getMincode());
if (coordinatorEmailOptional.isPresent()) {
log.info("pen coordinator email found :: {}, for guid :: {}", coordinatorEmailOptional.get(), guid);
isSchoolNotifiedFutureOptional = Optional.ofNullable(this.notificationService.notifySchoolForLoadFailed(guid, penWebBlobEntity.getFileName(), penWebBlobEntity.getSubmissionNumber(), fileUnProcessableException.getReason(), coordinatorEmailOptional.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ca.bc.gov.educ.penreg.api.struct.v1.BasePenRequestBatchReturnFilesSagaData;
import ca.bc.gov.educ.penreg.api.struct.v1.PenCoordinator;
import ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStudent;
import ca.bc.gov.educ.penreg.api.struct.v1.SchoolContact;
import ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.PenRequestBatchReportData;
import ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportListItem;
import ca.bc.gov.educ.penreg.api.struct.v1.reportstructs.ReportUserMatchedListItem;
Expand Down Expand Up @@ -54,20 +55,15 @@ public PenRequestBatchReportData toReportData(final BasePenRequestBatchReturnFil
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:
case DUPLICATE,ERROR,REPEAT,INFOREQ,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:
case SYS_NEW_PEN, USR_NEW_PEN:
this.populateForNewPenStatus(newPenList, students, penRequestBatchStudent);
break;
case SYS_MATCHED:
Expand All @@ -85,7 +81,7 @@ public PenRequestBatchReportData toReportData(final BasePenRequestBatchReturnFil
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.setReviewer(this.setReviewer(data.getStudentRegistrationContacts()));
}


Expand Down Expand Up @@ -149,8 +145,8 @@ private void addToSysMatchOrDiffList(final List<ReportListItem> sysMatchedList,
}


private String setReviewer(final PenCoordinator penCoordinator) {
return (penCoordinator != null && StringUtils.isNotBlank(penCoordinator.getPenCoordinatorName())) ? penCoordinator.getPenCoordinatorName() : "School PEN Coordinator";
private String setReviewer(final List<SchoolContact> schoolContacts) {
return (schoolContacts != null && !schoolContacts.isEmpty()) ? schoolContacts.get(0).getFirstName() + " " + schoolContacts.get(0).getLastName() : "School PEN Coordinator";
}

private Map<String, Student> setStudents(final List<Student> students) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface PenRequestBatchReportDataMapper {
@Mapping(target = "penCordinatorEmail", source = "fromEmail")
@Mapping(target = "mincode", expression = "java(data.getPenRequestBatch() == null || data.getPenRequestBatch().getMincode() == null || data.getPenRequestBatch().getMincode().isEmpty() || data.getPenRequestBatch().getMincode().length()<3 ? \"\" : data.getPenRequestBatch().getMincode().substring(0, 3) + \" \" + data.getPenRequestBatch().getMincode().substring(3))")
@Mapping(target = "submissionNumber", source = "data.penRequestBatch.submissionNumber")
@Mapping(target = "reviewer", source = "data.penCoordinator.penCoordinatorName")
@Mapping(target = "reviewer", ignore = true)
@Mapping(target = "processDate", ignore = true)
@Mapping(target = "processTime", ignore = true)
@Mapping(target = "reportDate", ignore = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
import static lombok.AccessLevel.PROTECTED;

import ca.bc.gov.educ.penreg.api.constants.EventOutcome;
import ca.bc.gov.educ.penreg.api.constants.EventType;
import ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentValidationIssueSeverityCode;
Expand All @@ -32,7 +31,7 @@
import ca.bc.gov.educ.penreg.api.orchestrator.base.BaseOrchestrator;
import ca.bc.gov.educ.penreg.api.properties.PenCoordinatorProperties;
import ca.bc.gov.educ.penreg.api.rest.RestUtils;
import ca.bc.gov.educ.penreg.api.service.PenCoordinatorService;
import ca.bc.gov.educ.penreg.api.service.StudentRegistrationContactService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchStudentValidationIssueService;
import ca.bc.gov.educ.penreg.api.service.ResponseFileGeneratorService;
Expand Down Expand Up @@ -72,7 +71,7 @@ public abstract class BaseReturnFilesOrchestrator<T> extends BaseOrchestrator<T>
@Getter(PROTECTED)
private final PenRequestBatchService penRequestBatchService;
@Getter(PROTECTED)
private final PenCoordinatorService penCoordinatorService;
private final StudentRegistrationContactService studentRegistrationContactService;
@Getter(PROTECTED)
private final ResponseFileGeneratorService responseFileGeneratorService;
@Getter(PROTECTED)
Expand All @@ -91,20 +90,20 @@ public abstract class BaseReturnFilesOrchestrator<T> extends BaseOrchestrator<T>
* @param sagaName the saga name
* @param topicToSubscribe the topic to subscribe
* @param penRequestBatchService the pen request batch service
* @param penCoordinatorService the pen coordinator service
* @param studentRegistrationContactService the pen coordinator service
* @param penCoordinatorProperties the pen coordinator properties
*/
protected BaseReturnFilesOrchestrator(final SagaService sagaService, final MessagePublisher messagePublisher,
final Class<T> clazz, final String sagaName, final String topicToSubscribe,
final PenRequestBatchService penRequestBatchService,
final PenCoordinatorService penCoordinatorService,
final StudentRegistrationContactService studentRegistrationContactService,
final PenCoordinatorProperties penCoordinatorProperties,
final ResponseFileGeneratorService responseFileGeneratorService,
final PenRequestBatchStudentValidationIssueService penRequestBatchStudentValidationIssueService,
final RestUtils restUtils) {
super(sagaService, messagePublisher, clazz, sagaName, topicToSubscribe);
this.penRequestBatchService = penRequestBatchService;
this.penCoordinatorService = penCoordinatorService;
this.studentRegistrationContactService = studentRegistrationContactService;
this.penCoordinatorProperties = penCoordinatorProperties;
this.responseFileGeneratorService = responseFileGeneratorService;
this.penRequestBatchStudentValidationIssueService = penRequestBatchStudentValidationIssueService;
Expand All @@ -124,7 +123,7 @@ protected void gatherReportData(final Event event, final Saga saga, final BasePe
final List<PenRequestBatchStudent> studentRequests = penRequestBatch.get().getPenRequestBatchStudentEntities().stream().map(studentMapper::toStructure).collect(Collectors.toList());
penRequestBatchReturnFilesSagaData.setPenRequestBatchStudents(studentRequests);
penRequestBatchReturnFilesSagaData.setPenRequestBatch(mapper.toStructure(penRequestBatch.get()));
penRequestBatchReturnFilesSagaData.setPenCoordinator(this.getPenCoordinator(penRequestBatch.get()));
penRequestBatchReturnFilesSagaData.setStudentRegistrationContacts(this.getStudentRegistrationContacts(penRequestBatch.get()));
penRequestBatchReturnFilesSagaData.setFromEmail(this.penCoordinatorProperties.getFromEmail());
penRequestBatchReturnFilesSagaData.setTelephone(this.penCoordinatorProperties.getTelephone());
penRequestBatchReturnFilesSagaData.setFacsimile(this.penCoordinatorProperties.getFacsimile());
Expand Down Expand Up @@ -249,7 +248,7 @@ protected void sendArchivedEmail(final Event event, final Saga saga, final BaseP
penRequestBatchArchivedEmailEvent.setToEmail(this.getPenCoordinatorProperties().getFromEmail());
} else {
nextEvent.setEventType(NOTIFY_PEN_REQUEST_BATCH_ARCHIVE_HAS_CONTACT);
penRequestBatchArchivedEmailEvent.setToEmail(penRequestBatchReturnFilesSagaData.getPenCoordinator().getPenCoordinatorEmail());
penRequestBatchArchivedEmailEvent.setToEmail(penRequestBatchReturnFilesSagaData.getStudentRegistrationContacts().getPenCoordinatorEmail());
}
nextEvent.setEventPayload(JsonUtil.getJsonStringFromObject(penRequestBatchArchivedEmailEvent));

Expand All @@ -275,9 +274,9 @@ protected boolean hasPenCoordinatorEmail(final BasePenRequestBatchReturnFilesSag
}

protected boolean hasNoPenCoordinatorEmail(final BasePenRequestBatchReturnFilesSagaData penRequestBatchReturnFilesSagaData) {
return penRequestBatchReturnFilesSagaData.getPenCoordinator() == null ||
penRequestBatchReturnFilesSagaData.getPenCoordinator().getPenCoordinatorEmail() == null ||
penRequestBatchReturnFilesSagaData.getPenCoordinator().getPenCoordinatorEmail().isEmpty();
return penRequestBatchReturnFilesSagaData.getStudentRegistrationContacts() == null ||
penRequestBatchReturnFilesSagaData.getStudentRegistrationContacts().getPenCoordinatorEmail() == null ||
penRequestBatchReturnFilesSagaData.getStudentRegistrationContacts().getPenCoordinatorEmail().isEmpty();
}

protected boolean isSupportingPDFGeneration(final BasePenRequestBatchReturnFilesSagaData penRequestBatchReturnFilesSagaData) {
Expand All @@ -302,9 +301,9 @@ protected void sendHasCoordinatorEmail(final Event event, final Saga saga, final
this.sendArchivedEmail(event, saga, penRequestBatchReturnFilesSagaData, NOTIFY_PEN_REQUEST_BATCH_ARCHIVE_HAS_CONTACT);
}

protected PenCoordinator getPenCoordinator(final PenRequestBatchEntity penRequestBatchEntity) {
protected List<SchoolContact> getStudentRegistrationContacts(final PenRequestBatchEntity penRequestBatchEntity) {
try {
final var penCoordinatorOptional = this.getPenCoordinatorService().getPenCoordinatorByMinCode(penRequestBatchEntity.getMincode());
final var penCoordinatorOptional = this.getStudentRegistrationContactService().getStudentRegistrationContactsByMincode(penRequestBatchEntity.getMincode());
return penCoordinatorOptional.orElse(null);
} catch (final NullPointerException e) {
log.error("Error while trying to get get pen coordinator. The pen coordinator map is null", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import ca.bc.gov.educ.penreg.api.model.v1.SagaEvent;
import ca.bc.gov.educ.penreg.api.properties.PenCoordinatorProperties;
import ca.bc.gov.educ.penreg.api.rest.RestUtils;
import ca.bc.gov.educ.penreg.api.service.PenCoordinatorService;
import ca.bc.gov.educ.penreg.api.service.StudentRegistrationContactService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchStudentValidationIssueService;
import ca.bc.gov.educ.penreg.api.service.ResponseFileGeneratorService;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class PenRequestBatchArchiveAndReturnOrchestrator extends BaseReturnFiles
*/
public PenRequestBatchArchiveAndReturnOrchestrator(SagaService sagaService, MessagePublisher messagePublisher,
PenRequestBatchService penRequestBatchService,
PenCoordinatorService penCoordinatorService,
StudentRegistrationContactService penCoordinatorService,
PenCoordinatorProperties penCoordinatorProperties,
ResponseFileGeneratorService responseFileGeneratorService,
PenRequestBatchStudentValidationIssueService penRequestBatchStudentValidationIssueService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import ca.bc.gov.educ.penreg.api.model.v1.SagaEvent;
import ca.bc.gov.educ.penreg.api.properties.PenCoordinatorProperties;
import ca.bc.gov.educ.penreg.api.rest.RestUtils;
import ca.bc.gov.educ.penreg.api.service.PenCoordinatorService;
import ca.bc.gov.educ.penreg.api.service.StudentRegistrationContactService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchService;
import ca.bc.gov.educ.penreg.api.service.PenRequestBatchStudentValidationIssueService;
import ca.bc.gov.educ.penreg.api.service.ResponseFileGeneratorService;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class PenRequestBatchRepostReportsOrchestrator extends BaseReturnFilesOrc
*/
public PenRequestBatchRepostReportsOrchestrator(SagaService sagaService, MessagePublisher messagePublisher,
PenRequestBatchService penRequestBatchService,
PenCoordinatorService penCoordinatorService,
StudentRegistrationContactService penCoordinatorService,
PenCoordinatorProperties penCoordinatorProperties,
ResponseFileGeneratorService responseFileGeneratorService,
PenRequestBatchStudentValidationIssueService penRequestBatchStudentValidationIssueService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class ApplicationProperties {
@Value("${url.api.school}")
private String schoolApiURL;

@Value("${url.api.institute}")
private String instituteApiUrl;

@Value("${nats.server}")
private String server;

Expand Down
Loading

0 comments on commit e278c77

Please sign in to comment.