Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grad release 1.19.0 #491

Merged
merged 13 commits into from
May 23, 2024
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-batch-graduation-api</artifactId>
<version>1.8.61</version>
<version>1.8.62</version>
<name>educ-grad-batch-graduation-api</name>
<description>Ministry of Education GRAD BATCH GRADUATION API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public ResponseEntity<BatchJobResponse> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId,
Map<String, DistributionPrintRequest> mapDist = summaryDTO.getMapDist();
List<String> uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList());
sortSchoolBySchoolOfRecord(uniqueSchoolList);
List<StudentCredentialDistribution> studentCredentialDistributionControlList = new ArrayList<>();
uniqueSchoolList.forEach(usl->{
List<StudentCredentialDistribution> yed4List = new ArrayList<>();
List<StudentCredentialDistribution> yed2List = new ArrayList<>();
Expand All @@ -113,46 +114,52 @@ 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";
/** GRADT-553
* 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);
} else {
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<StudentCredentialDistribution> cList, DistributionSummaryDTO summaryDTO, Long batchId, String properName) {
private void addTranscriptsToDistributionRequest(List<StudentCredentialDistribution> controlList, List<StudentCredentialDistribution> cList, DistributionSummaryDTO summaryDTO, Long batchId, String properName) {
Map<String, DistributionPrintRequest> mapDist = summaryDTO.getMapDist();
mapDist.forEach((schoolCode, distributionPrintRequest) -> {
List<StudentCredentialDistribution> mergedCertificateList = distributionPrintRequest.getMergedListOfCertificates();
Expand All @@ -161,8 +168,8 @@ private void addTranscriptsToDistributionRequest(List<StudentCredentialDistribut
List<UUID> 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<StudentCredentialDistribution> transcriptDistributionList = restUtils.getStudentsForUserReqDisRun("OT",searchRequest);
for(StudentCredentialDistribution certScd: uniqueCertificateList) {
Expand All @@ -184,17 +191,18 @@ private void addTranscriptsToDistributionRequest(List<StudentCredentialDistribut
}
}
cList.addAll(transcriptDistributionList);
controlList.addAll(transcriptDistributionList);
supportListener.transcriptPrintFile(transcriptDistributionList, batchId, schoolCode, mapDist, properName);
});
}

private void updateBackStudentRecords(List<StudentCredentialDistribution> cList, Long batchId,String activityCode) {
private void updateBackStudentRecords(Collection<StudentCredentialDistribution> 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<UUID> studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().collect(Collectors.toList());
List<UUID> studentIDs = cList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList();
studentIDs.forEach(sid-> {
restUtils.updateStudentGradRecord(sid,batchId,activityCode);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public class StudentSearchRequest implements Serializable {
LocalDate gradDateTo;

Boolean validateInput;
String activityCode;
String localDownload;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +28,12 @@ public class DistributionRunProcessor implements ItemProcessor<StudentCredential
public StudentCredentialDistribution process(StudentCredentialDistribution item) throws Exception {
LOGGER.info("Processing partitionData = {}", item.getCredentialTypeCode());
summaryDTO.setBatchId(batchId);
return restUtils.processDistribution(item, summaryDTO, false);
boolean useSchoolAtGrad = false;
String credentialType = summaryDTO.getCredentialType();
if (StringUtils.equalsAnyIgnoreCase(credentialType, "OC", "RC")) {
useSchoolAtGrad = true;
}
return restUtils.processDistribution(item, summaryDTO, useSchoolAtGrad);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public DistributionResponse mergeAndUpload(Long batchId, DistributionRequest dis
} else {
distributionUrl = String.format(constants.getMergeAndUpload(),batchId,activityCode,localDownload);
}
LOGGER.debug("****** Call distribution API to process the merge request for {} *******", batchId);
LOGGER.debug("****** Call distribution API {} to process the merge request for {} *******", distributionUrl, batchId);
return this.post(distributionUrl, distributionRequest, DistributionResponse.class, accessToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class EducGradBatchGraduationApiConstants {
@Value("${endpoint.grad-graduation-api.student-certificate-regeneration.url}")
private String studentCertificateRegeneration;

@Value("${endpoint.educ-school-api.school-by-min-code.url}")
@Value("${endpoint.grad-trax-api.commonschool-by-mincode.url}")
private String commonSchoolByMincode;

@Value("${endpoint.grad-trax-api.school-by-min-code.url}")
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ endpoint:
url: ${GRAD_TRAX_API}api/v1/trax/edw/get-schools/snapshot/%s
get-edw-snapshot-students-by-min-code:
url: ${GRAD_TRAX_API}api/v1/trax/edw/get-students/snapshot/%s/%s
educ-school-api:
school-by-min-code:
url: ${EDUC_SCHOOL_API}api/v1/schools/%s
commonschool-by-mincode:
url: ${GRAD_TRAX_API}api/v1/trax/school/common/%s


#Splunk LogHelper
splunk:
Expand Down
5 changes: 2 additions & 3 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ endpoint:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/edw/get-schools/snapshot/%s
get-edw-snapshot-students-by-min-code:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/edw/get-students/snapshot/%s/%s
educ-school-api:
school-by-min-code:
url: https://educ-school-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/schools/%s
commonschool-by-mincode:
url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common/%s

#Splunk LogHelper
splunk:
Expand Down
Loading