1818import ca .bc .gov .educ .penreg .api .properties .ApplicationProperties ;
1919import ca .bc .gov .educ .penreg .api .rest .RestUtils ;
2020import ca .bc .gov .educ .penreg .api .service .NotificationService ;
21- import ca .bc .gov .educ .penreg .api .service .PenCoordinatorService ;
21+ import ca .bc .gov .educ .penreg .api .service .StudentRegistrationContactService ;
2222import ca .bc .gov .educ .penreg .api .struct .School ;
2323import com .google .common .base .Stopwatch ;
2424import lombok .Getter ;
3636
3737import java .io .*;
3838import java .nio .charset .Charset ;
39- import java .nio .charset .CharsetDecoder ;
4039import java .util .*;
4140import java .util .concurrent .CompletableFuture ;
4241import java .util .concurrent .ExecutionException ;
@@ -95,9 +94,9 @@ public class PenRegBatchProcessor {
9594 */
9695 private final NotificationService notificationService ;
9796 /**
98- * The Pen coordinator service.
97+ * The Student Registration Contact service.
9998 */
100- private final PenCoordinatorService penCoordinatorService ;
99+ private final StudentRegistrationContactService studentRegistrationContactService ;
101100
102101 /**
103102 * The Duplicate file check service map.
@@ -115,17 +114,17 @@ public class PenRegBatchProcessor {
115114 * @param penRequestBatchFileService the pen request batch file service
116115 * @param applicationProperties the application properties
117116 * @param notificationService the notification service
118- * @param penCoordinatorService the pen coordinator service
117+ * @param studentRegistrationContactService the student registration contact service
119118 * @param duplicateFileCheckServiceList the duplicate file check service list
120119 * @param penRequestBatchFileValidator the pen request batch file validator
121120 */
122121 @ Autowired
123- 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 ) {
122+ public PenRegBatchProcessor (final PenRegBatchStudentRecordsProcessor penRegBatchStudentRecordsProcessor , final PenRequestBatchFileService penRequestBatchFileService , final ApplicationProperties applicationProperties , final NotificationService notificationService , final StudentRegistrationContactService studentRegistrationContactService , final List <DuplicateFileCheckService > duplicateFileCheckServiceList , final PenRequestBatchFileValidator penRequestBatchFileValidator , final RestUtils restUtils ) {
124123 this .penRegBatchStudentRecordsProcessor = penRegBatchStudentRecordsProcessor ;
125124 this .penRequestBatchFileService = penRequestBatchFileService ;
126125 this .applicationProperties = applicationProperties ;
127126 this .notificationService = notificationService ;
128- this .penCoordinatorService = penCoordinatorService ;
127+ this .studentRegistrationContactService = studentRegistrationContactService ;
129128 this .duplicateFileCheckServiceMap = duplicateFileCheckServiceList .stream ().collect (Collectors .toMap (DuplicateFileCheckService ::getSchoolGroupCode , Function .identity ()));
130129 this .penRequestBatchFileValidator = penRequestBatchFileValidator ;
131130 this .restUtils = restUtils ;
@@ -220,7 +219,7 @@ private void processFileUnProcessableException(@NonNull final String guid, @NonN
220219 val notifySchoolForFileFormatErrorsOptional = this .notifySchoolForFileFormatErrors (guid , penWebBlobEntity , fileUnProcessableException );
221220 final PenRequestBatchEntity entity = mapper .toPenReqBatchEntityForBusinessException (penWebBlobEntity , fileUnProcessableException .getReason (), fileUnProcessableException .getPenRequestBatchStatusCode (), batchFile , persistStudentRecords (fileUnProcessableException .getFileError ())); // batch file can be processed further and persisted.
222221 final Optional <School > school = this .restUtils .getSchoolByMincode (penWebBlobEntity .getMincode ());
223- school .ifPresent (value -> entity .setSchoolName (value .getSchoolName ()));
222+ school .ifPresent (value -> entity .setSchoolName (value .getDisplayName ()));
224223 //wait here if notification was sent, if there was any error this file will be picked up again as it wont be persisted.
225224 if (notifySchoolForFileFormatErrorsOptional .isPresent ()) {
226225 final boolean isNotified = this .waitForNotificationToCompleteIfPresent (guid , notifySchoolForFileFormatErrorsOptional .get ());
@@ -272,10 +271,10 @@ private Optional<CompletableFuture<Boolean>> notifySchoolForFileFormatErrors(fin
272271 Optional <CompletableFuture <Boolean >> isSchoolNotifiedFutureOptional = Optional .empty ();
273272 if (this .isNotificationToSchoolRequired (fileUnProcessableException )) {
274273 log .info ("notification to school is required :: {}" , guid );
275- val coordinatorEmailOptional = this .penCoordinatorService . getPenCoordinatorEmailByMinCode (penWebBlobEntity .getMincode ());
276- if (coordinatorEmailOptional . isPresent ()) {
277- log .info ("pen coordinator email found :: {}, for guid :: {}" , coordinatorEmailOptional . get () , guid );
278- isSchoolNotifiedFutureOptional = Optional .ofNullable (this .notificationService .notifySchoolForLoadFailed (guid , penWebBlobEntity .getFileName (), penWebBlobEntity .getSubmissionNumber (), fileUnProcessableException .getReason (), coordinatorEmailOptional . get () ));
274+ val studentRegistrationContactList = this .studentRegistrationContactService . getStudentRegistrationContactEmailsByMincode (penWebBlobEntity .getMincode ());
275+ if (! studentRegistrationContactList . isEmpty ()) {
276+ log .info ("student registration school contact email(s) found :: {}, for guid :: {}" , studentRegistrationContactList , guid );
277+ isSchoolNotifiedFutureOptional = Optional .ofNullable (this .notificationService .notifySchoolForLoadFailed (guid , penWebBlobEntity .getFileName (), penWebBlobEntity .getSubmissionNumber (), fileUnProcessableException .getReason (), studentRegistrationContactList ));
279278 }
280279 }
281280 return isSchoolNotifiedFutureOptional ;
@@ -311,7 +310,7 @@ private void processLoadedRecordsInBatchFile(@NonNull final String guid, @NonNul
311310 log .info ("going to persist data for batch :: {}" , guid );
312311 final PenRequestBatchEntity entity = mapper .toPenReqBatchEntityLoaded (penWebBlobEntity , batchFile ); // batch file can be processed further and persisted.
313312 final Optional <School > school = this .restUtils .getSchoolByMincode (penWebBlobEntity .getMincode ());
314- school .ifPresent (value -> entity .setSchoolName (value .getSchoolName ()));
313+ school .ifPresent (value -> entity .setSchoolName (value .getDisplayName ()));
315314 for (final var student : batchFile .getStudentDetails ()) { // set the object so that PK/FK relationship will be auto established by hibernate.
316315 final var penRequestBatchStudentEntity = mapper .toPenRequestBatchStudentEntity (student , entity );
317316 penRequestBatchStudentEntity .setRecordNumber (counter ++);
0 commit comments