diff --git a/api/pom.xml b/api/pom.xml
index a8c712c6..a6bf5127 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-batch-graduation-api
- 1.8.61
+ 1.8.62
educ-grad-batch-graduation-api
Ministry of Education GRAD BATCH GRADUATION API
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
index 45464f60..201e4ade 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
@@ -232,6 +232,9 @@ public ResponseEntity launchRegGradSpecialJob(@RequestBody Stu
response.setTriggerBy(MANUAL);
response.setStartTime(LocalDateTime.now());
response.setStatus(BatchStatusEnum.STARTED.name());
+ if(StringUtils.isBlank(studentSearchRequest.getActivityCode())) {
+ studentSearchRequest.setActivityCode("USERDIST");
+ }
validateInput(response, studentSearchRequest);
if(response.getException() != null) {
return ResponseEntity.status(400).body(response);
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java
index f00e5040..f3c68b93 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListener.java
@@ -104,6 +104,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId,
Map mapDist = summaryDTO.getMapDist();
List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList());
sortSchoolBySchoolOfRecord(uniqueSchoolList);
+ List studentCredentialDistributionControlList = new ArrayList<>();
uniqueSchoolList.forEach(usl->{
List yed4List = new ArrayList<>();
List yed2List = new ArrayList<>();
@@ -113,20 +114,26 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId,
if (credentialType.equalsIgnoreCase("OT") || credentialType.equalsIgnoreCase("RT")) {
yed4List = cList.stream().filter(scd -> scd.getSchoolOfRecord().compareTo(usl) == 0 && "YED4".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList());
}
-
if (credentialType.equalsIgnoreCase("OC") || credentialType.equalsIgnoreCase("RC")) {
yed2List = cList.stream().filter(scd -> scd.getSchoolOfRecord().compareTo(usl) == 0 && "YED2".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList());
yedrList = cList.stream().filter(scd -> scd.getSchoolOfRecord().compareTo(usl) == 0 && "YEDR".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList());
yedbList = cList.stream().filter(scd -> scd.getSchoolOfRecord().compareTo(usl) == 0 && "YEDB".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList());
}
}
+
supportListener.transcriptPrintFile(yed4List,batchId,usl,mapDist,properName);
supportListener.certificatePrintFile(yed2List,batchId,usl,mapDist,"YED2",properName);
supportListener.certificatePrintFile(yedrList,batchId,usl,mapDist,"YEDR",properName);
supportListener.certificatePrintFile(yedbList,batchId,usl,mapDist,"YEDB",properName);
+
+ studentCredentialDistributionControlList.addAll(yed4List);
+ studentCredentialDistributionControlList.addAll(yed2List);
+ studentCredentialDistributionControlList.addAll(yedrList);
+ studentCredentialDistributionControlList.addAll(yedbList);
+
});
- DistributionResponse disres = null;
- String activityCode = null;
+ DistributionResponse disres;
+ String activityCode;
if(credentialType != null) {
if("OC".equalsIgnoreCase(credentialType)) {
activityCode = "USERDISTOC";
@@ -134,11 +141,11 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId,
* User Request Distribution Run - Original Certificate OC
**** Also select the students’ transcript for print
*/
- addTranscriptsToDistributionRequest(cList,summaryDTO,batchId,properName);
+ addTranscriptsToDistributionRequest(studentCredentialDistributionControlList, cList,summaryDTO,batchId,properName);
} else {
activityCode = "OT".equalsIgnoreCase(credentialType) ? "USERDISTOT" : "USERDISTRC";
}
- if(!cList.isEmpty()) {
+ if(!studentCredentialDistributionControlList.isEmpty()) {
DistributionRequest distributionRequest = DistributionRequest.builder().mapDist(mapDist).activityCode(activityCode).studentSearchRequest(summaryDTO.getStudentSearchRequest()).build();
if (credentialType.equalsIgnoreCase("RC")) {
disres = restUtils.createReprintAndUpload(batchId, accessToken, distributionRequest, activityCode, localDownload);
@@ -146,13 +153,13 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId,
disres = restUtils.mergeAndUpload(batchId, distributionRequest, activityCode, localDownload);
}
if(disres != null) {
- updateBackStudentRecords(cList,batchId,activityCode);
+ updateBackStudentRecords(studentCredentialDistributionControlList.stream().distinct().toList(),batchId,activityCode);
}
}
}
}
- private void addTranscriptsToDistributionRequest(List cList, DistributionSummaryDTO summaryDTO, Long batchId, String properName) {
+ private void addTranscriptsToDistributionRequest(List controlList, List cList, DistributionSummaryDTO summaryDTO, Long batchId, String properName) {
Map mapDist = summaryDTO.getMapDist();
mapDist.forEach((schoolCode, distributionPrintRequest) -> {
List mergedCertificateList = distributionPrintRequest.getMergedListOfCertificates();
@@ -161,8 +168,8 @@ private void addTranscriptsToDistributionRequest(List studentIDs = uniqueCertificateList.stream().map(StudentCredentialDistribution::getStudentID).collect(Collectors.toList());
StudentSearchRequest searchRequest = StudentSearchRequest.builder().pens(studentPens).studentIDs(studentIDs).build();
if(LOGGER.isDebugEnabled()) {
- String studentPensSearchRequest = jsonTransformer.marshall(searchRequest);
- LOGGER.debug("Get {} students credentials for the pens: {}", "OT", studentPensSearchRequest);
+ String studentSearchRequest = jsonTransformer.marshall(searchRequest);
+ LOGGER.debug("Get {} students credentials for the pens: {}", "OT", studentSearchRequest);
}
List transcriptDistributionList = restUtils.getStudentsForUserReqDisRun("OT",searchRequest);
for(StudentCredentialDistribution certScd: uniqueCertificateList) {
@@ -184,17 +191,18 @@ private void addTranscriptsToDistributionRequest(List cList, Long batchId,String activityCode) {
+ private void updateBackStudentRecords(Collection cList, Long batchId,String activityCode) {
cList.forEach(scd-> {
LOGGER.debug("Update back Student Record {}", scd.getStudentID());
String accessToken = restUtils.fetchAccessToken();
restUtils.updateStudentCredentialRecord(scd.getStudentID(),scd.getCredentialTypeCode(),scd.getPaperType(),scd.getDocumentStatusCode(),activityCode,accessToken);
});
- List studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().collect(Collectors.toList());
+ List studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList();
studentIDs.forEach(sid-> {
restUtils.updateStudentGradRecord(sid,batchId,activityCode);
});
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java
index ee3cc93f..91b15633 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentCredentialDistribution.java
@@ -2,12 +2,14 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@Data
+@EqualsAndHashCode(of = {"studentID", "credentialTypeCode", "paperType", "documentStatusCode"})
public class StudentCredentialDistribution implements Serializable {
private UUID id;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java
index ae37c4fb..2215ae5e 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java
@@ -34,5 +34,6 @@ public class StudentSearchRequest implements Serializable {
LocalDate gradDateTo;
Boolean validateInput;
+ String activityCode;
String localDownload;
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java
index 33b84cf1..150ce728 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunProcessor.java
@@ -3,6 +3,7 @@
import ca.bc.gov.educ.api.batchgraduation.model.DistributionSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution;
import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
@@ -27,7 +28,12 @@ public class DistributionRunProcessor implements ItemProcessor