Skip to content

Commit

Permalink
Committed the missing files and cleaned up unused import.
Browse files Browse the repository at this point in the history
Committed the missing files and cleaned up unused import.
  • Loading branch information
infstar committed May 16, 2024
1 parent 4cb5e37 commit e502f8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecordDistribution;
import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution;
import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils;
import jakarta.validation.ValidationException;
import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand All @@ -15,7 +14,6 @@
import org.springframework.lang.Nullable;

import java.io.IOException;
import java.net.UnknownServiceException;
import java.util.UUID;

public class RunCertificateRegenerationProcessor implements ItemProcessor<StudentCredentialDistribution, Integer> {
Expand Down Expand Up @@ -55,7 +53,7 @@ public Integer process(@NotNull StudentCredentialDistribution item) throws Excep
return null;
}
}
LOGGER.warn("Skipped STU-ID:{} Errors:{}", item != null? item.getStudentID() : "UNKNOWN PEN#",summaryDTO.getErrors().size());
LOGGER.warn("Skipped STU-ID:{} Errors:{}", item != null? item.getStudentID() : "UNKNOWN STUDENT",summaryDTO.getErrors().size());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
package ca.bc.gov.educ.api.batchgraduation.reader;

import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO;
import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factory.annotation.Value;

import java.util.UUID;
import java.util.List;

public class RegenerateCertificateReader extends BaseReader {
public class RegenerateCertificateReader extends BaseReader implements ItemReader<StudentCredentialDistribution> {

private static final Logger LOGGER = LoggerFactory.getLogger(RegenerateCertificateReader.class);

@Value("#{stepExecutionContext['index']}")
private Integer nxtCredentialForProcessing;

@Value("#{stepExecutionContext['data']}")
List<StudentCredentialDistribution> credentialList;

@Override
public UUID read() throws Exception {
public StudentCredentialDistribution read() throws Exception {
fetchAccessToken();
summaryDTO.setReadCount(studentList.size());
summaryDTO.setReadCount(credentialList.size());

UUID nextStudent = null;
StudentCredentialDistribution nextCredential = null;

if (nxtStudentForProcessing < studentList.size()) {
nextStudent = studentList.get(nxtStudentForProcessing);
LOGGER.info("StudID:{} - {} of {}", nextStudent, nxtStudentForProcessing + 1, summaryDTO.getReadCount());
nxtStudentForProcessing++;
if (nxtCredentialForProcessing < credentialList.size()) {
nextCredential = credentialList.get(nxtCredentialForProcessing);
LOGGER.info("StudID:{} - {} of {}", nextCredential, nxtCredentialForProcessing + 1, summaryDTO.getReadCount());
nxtCredentialForProcessing++;
} else {
aggregate("regenCertSummaryDTO");
}
return nextStudent;
}

public void aggregate(String summaryContextName) {
AlgorithmSummaryDTO totalSummaryDTO = (AlgorithmSummaryDTO)jobExecution.getExecutionContext().get(summaryContextName);
if (totalSummaryDTO == null) {
totalSummaryDTO = new AlgorithmSummaryDTO();
jobExecution.getExecutionContext().put(summaryContextName, totalSummaryDTO);
}
totalSummaryDTO.setBatchId(summaryDTO.getBatchId());
totalSummaryDTO.setReadCount(totalSummaryDTO.getReadCount() + summaryDTO.getReadCount());
totalSummaryDTO.setProcessedCount(totalSummaryDTO.getProcessedCount() + summaryDTO.getProcessedCount());
totalSummaryDTO.getErrors().putAll(summaryDTO.getErrors());
return nextCredential;
}
}

0 comments on commit e502f8b

Please sign in to comment.