18
18
import ca .bc .gov .educ .penreg .api .properties .ApplicationProperties ;
19
19
import ca .bc .gov .educ .penreg .api .rest .RestUtils ;
20
20
import 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 ;
22
22
import ca .bc .gov .educ .penreg .api .struct .School ;
23
23
import com .google .common .base .Stopwatch ;
24
24
import lombok .Getter ;
36
36
37
37
import java .io .*;
38
38
import java .nio .charset .Charset ;
39
- import java .nio .charset .CharsetDecoder ;
40
39
import java .util .*;
41
40
import java .util .concurrent .CompletableFuture ;
42
41
import java .util .concurrent .ExecutionException ;
@@ -95,9 +94,9 @@ public class PenRegBatchProcessor {
95
94
*/
96
95
private final NotificationService notificationService ;
97
96
/**
98
- * The Pen coordinator service.
97
+ * The Student Registration Contact service.
99
98
*/
100
- private final PenCoordinatorService penCoordinatorService ;
99
+ private final StudentRegistrationContactService studentRegistrationContactService ;
101
100
102
101
/**
103
102
* The Duplicate file check service map.
@@ -115,17 +114,17 @@ public class PenRegBatchProcessor {
115
114
* @param penRequestBatchFileService the pen request batch file service
116
115
* @param applicationProperties the application properties
117
116
* @param notificationService the notification service
118
- * @param penCoordinatorService the pen coordinator service
117
+ * @param studentRegistrationContactService the student registration contact service
119
118
* @param duplicateFileCheckServiceList the duplicate file check service list
120
119
* @param penRequestBatchFileValidator the pen request batch file validator
121
120
*/
122
121
@ 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 ) {
124
123
this .penRegBatchStudentRecordsProcessor = penRegBatchStudentRecordsProcessor ;
125
124
this .penRequestBatchFileService = penRequestBatchFileService ;
126
125
this .applicationProperties = applicationProperties ;
127
126
this .notificationService = notificationService ;
128
- this .penCoordinatorService = penCoordinatorService ;
127
+ this .studentRegistrationContactService = studentRegistrationContactService ;
129
128
this .duplicateFileCheckServiceMap = duplicateFileCheckServiceList .stream ().collect (Collectors .toMap (DuplicateFileCheckService ::getSchoolGroupCode , Function .identity ()));
130
129
this .penRequestBatchFileValidator = penRequestBatchFileValidator ;
131
130
this .restUtils = restUtils ;
@@ -220,7 +219,7 @@ private void processFileUnProcessableException(@NonNull final String guid, @NonN
220
219
val notifySchoolForFileFormatErrorsOptional = this .notifySchoolForFileFormatErrors (guid , penWebBlobEntity , fileUnProcessableException );
221
220
final PenRequestBatchEntity entity = mapper .toPenReqBatchEntityForBusinessException (penWebBlobEntity , fileUnProcessableException .getReason (), fileUnProcessableException .getPenRequestBatchStatusCode (), batchFile , persistStudentRecords (fileUnProcessableException .getFileError ())); // batch file can be processed further and persisted.
222
221
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 ()));
224
223
//wait here if notification was sent, if there was any error this file will be picked up again as it wont be persisted.
225
224
if (notifySchoolForFileFormatErrorsOptional .isPresent ()) {
226
225
final boolean isNotified = this .waitForNotificationToCompleteIfPresent (guid , notifySchoolForFileFormatErrorsOptional .get ());
@@ -272,10 +271,10 @@ private Optional<CompletableFuture<Boolean>> notifySchoolForFileFormatErrors(fin
272
271
Optional <CompletableFuture <Boolean >> isSchoolNotifiedFutureOptional = Optional .empty ();
273
272
if (this .isNotificationToSchoolRequired (fileUnProcessableException )) {
274
273
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 ));
279
278
}
280
279
}
281
280
return isSchoolNotifiedFutureOptional ;
@@ -311,7 +310,7 @@ private void processLoadedRecordsInBatchFile(@NonNull final String guid, @NonNul
311
310
log .info ("going to persist data for batch :: {}" , guid );
312
311
final PenRequestBatchEntity entity = mapper .toPenReqBatchEntityLoaded (penWebBlobEntity , batchFile ); // batch file can be processed further and persisted.
313
312
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 ()));
315
314
for (final var student : batchFile .getStudentDetails ()) { // set the object so that PK/FK relationship will be auto established by hibernate.
316
315
final var penRequestBatchStudentEntity = mapper .toPenRequestBatchStudentEntity (student , entity );
317
316
penRequestBatchStudentEntity .setRecordNumber (counter ++);
0 commit comments