Skip to content

Commit

Permalink
Merge pull request #479 from bcgov/develop/alex-GRAD2-2377
Browse files Browse the repository at this point in the history
GRAD2-2377
  • Loading branch information
arybakov-cgi authored Apr 20, 2024
2 parents 954280c + 773bc96 commit 9c6b7a3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ public DistributionRunProcessor itemProcessorDisRun() {
return new DistributionRunProcessor();
}

@Bean
@StepScope
public DistributionRunYearlyProcessor itemProcessorYearlyDisRun() {
return new DistributionRunYearlyProcessor();
}

@Bean
@StepScope
public DistributionRunYearlyNonGradProcessor itemProcessorDisRunYearlyNonGradByMincode() {
Expand Down Expand Up @@ -571,7 +577,7 @@ public Step slaveStepDisRunYearly(JobRepository jobRepository, PlatformTransacti
return new StepBuilder("slaveStepDisRun", jobRepository)
.<StudentCredentialDistribution, StudentCredentialDistribution>chunk(1, transactionManager)
.reader(itemReaderDisRun())
.processor(itemProcessorDisRun())
.processor(itemProcessorYearlyDisRun())
.writer(itemWriterDisRun())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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);
return restUtils.processDistribution(item, summaryDTO, false);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DistributionRunYearlyProcessor implements ItemProcessor<StudentCred
public StudentCredentialDistribution process(StudentCredentialDistribution item) throws Exception {
LOGGER.info("Processing partitionData = {}", item.getCredentialTypeCode());
summaryDTO.setBatchId(batchId);
return restUtils.processDistribution(item, summaryDTO);
return restUtils.processDistribution(item, summaryDTO, true);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiUtils;
import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil;
import io.github.resilience4j.retry.annotation.Retry;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -402,24 +403,32 @@ public List<GraduationStudentRecord> getStudentData(List<UUID> studentIds) {
.retrieve().bodyToMono(responseType).block();
}

public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary) {
public StudentCredentialDistribution processDistribution(StudentCredentialDistribution item, DistributionSummaryDTO summary, boolean useSchoolAtGrad) {
LOGGER.info(STUDENT_PROCESS,item.getStudentID());
summary.setProcessedCount(summary.getProcessedCount() + 1L);
StudentCredentialDistribution scObj = summary.getGlobalList().stream().filter(pr -> pr.getStudentID().compareTo(item.getStudentID()) == 0)
.findAny()
.orElse(null);
if(scObj != null) {
item.setSchoolOfRecord(scObj.getSchoolOfRecord());
if(useSchoolAtGrad) {
item.setSchoolOfRecord(StringUtils.isBlank(scObj.getSchoolAtGrad()) ? scObj.getSchoolOfRecord() : scObj.getSchoolAtGrad());
} else {
item.setSchoolOfRecord(scObj.getSchoolOfRecord());
}
item.setPen(scObj.getPen());
item.setLegalLastName(scObj.getLegalLastName());
item.setLegalFirstName(scObj.getLegalFirstName());
item.setLegalMiddleNames(scObj.getLegalMiddleNames());
} else {
GraduationStudentRecordDistribution stuRec =this.getStudentData(item.getStudentID().toString());
GraduationStudentRecordDistribution stuRec = getStudentData(item.getStudentID().toString());
if (stuRec != null) {
item.setProgram(stuRec.getProgram());
item.setHonoursStanding(stuRec.getHonoursStanding());
item.setSchoolOfRecord(stuRec.getSchoolOfRecord());
if(useSchoolAtGrad) {
item.setSchoolOfRecord(StringUtils.isBlank(stuRec.getSchoolAtGrad()) ? stuRec.getSchoolOfRecord() : stuRec.getSchoolAtGrad());
} else {
item.setSchoolOfRecord(stuRec.getSchoolOfRecord());
}
item.setProgramCompletionDate(stuRec.getProgramCompletionDate());
item.setStudentID(stuRec.getStudentID());
item.setPen(stuRec.getPen());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public void testProcessDistribution() {
summary.setBatchId(batchId);
summary.setGlobalList(globalList);

StudentCredentialDistribution res = this.restUtils.processDistribution(scd,summary);
StudentCredentialDistribution res = this.restUtils.processDistribution(scd,summary, false);
assertNotNull(res);
}

Expand Down Expand Up @@ -491,7 +491,7 @@ public void testProcessDistribution_elsecase() {
summary.setBatchId(batchId);
summary.setGlobalList(globalList);

StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary);
StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary, false);
assertNotNull(res);
}

Expand Down Expand Up @@ -538,7 +538,7 @@ public void testProcessDistribution_elsecase_null() {
summary.setBatchId(batchId);
summary.setGlobalList(globalList);

StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary);
StudentCredentialDistribution res = this.restUtils.processDistribution(scd2,summary, false);
assertNotNull(res);
}

Expand Down

0 comments on commit 9c6b7a3

Please sign in to comment.