From 4c06b42535a8ed7af36815cab8e4c0467655b7c7 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 22 Aug 2023 14:28:49 -0600 Subject: [PATCH 01/26] GRAD2-2004 - If a User selects USER in the Where dropdown opion off of UI page for User Request Batch runs the job(s) fail. --- ...erReqDistributionRunCompletionNotificationListener.java | 7 ++++++- .../api/batchgraduation/model/StudentSearchRequest.java | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 0bcc452a..499819f2 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 @@ -5,6 +5,7 @@ import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; import ca.bc.gov.educ.api.batchgraduation.service.TaskSchedulingService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; @@ -76,6 +77,10 @@ public void afterJob(JobExecution jobExecution) { ResponseObj obj = restUtils.getTokenResponseObject(); LOGGER.info("Starting Report Process " + LOG_SEPARATION_SINGLE); + if(StringUtils.isNotBlank(studentSearchRequest)) { + StudentSearchRequest payload = (StudentSearchRequest)jsonTransformer.unmarshall(studentSearchRequest, StudentSearchRequest.class); + summaryDTO.setStudentSearchRequest(payload); + } processGlobalList(summaryDTO,jobExecutionId,credentialType,obj.getAccess_token(),localDownLoad,properName); DistributionSummaryDTO finalSummaryDTO = summaryDTO; @@ -133,7 +138,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, Long batchId, activityCode = credentialType.equalsIgnoreCase("OT")?"USERDISTOT":"USERDISTRC"; } if(!cList.isEmpty()) { - DistributionRequest distributionRequest = DistributionRequest.builder().mapDist(mapDist).activityCode(activityCode).build(); + 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 { 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 1f8d0365..ec7bc8af 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 @@ -23,6 +23,8 @@ public class StudentSearchRequest implements Serializable { private List pens; private List programs; + private String user; + @JsonFormat(pattern = "yyyy-MM-dd") Date gradDateFrom; @JsonFormat(pattern = "yyyy-MM-dd") From 1f874fde466e31aa1bc8915e86c6983963291bb3 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 22 Aug 2023 15:10:21 -0600 Subject: [PATCH 02/26] GRAD2-2004 - If a User selects USER in the Where dropdown opion off of UI page for User Request Batch runs the job(s) fail. --- .../DistributionRunYearlyNonGradPartitioner.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java index f065fd6e..28befdbb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java @@ -53,10 +53,18 @@ public Map partition(int gridSize) { } } if(searchRequest != null && searchRequest.getDistricts() != null && !searchRequest.getDistricts().isEmpty()) { - eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3))); + if(!eligibleStudentSchoolDistricts.isEmpty()) { + eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3))); + } else { + eligibleStudentSchoolDistricts = searchRequest.getDistricts(); + } } if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) { - eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getSchoolOfRecords().contains(scr)); + if(!eligibleStudentSchoolDistricts.isEmpty()) { + eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getSchoolOfRecords().contains(scr)); + } else { + eligibleStudentSchoolDistricts = searchRequest.getSchoolOfRecords(); + } } endTime = System.currentTimeMillis(); diff = (endTime - startTime)/1000; From a329ab292bee0c209c4db1c0677c0586527d78ad Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Thu, 24 Aug 2023 16:38:54 -0700 Subject: [PATCH 03/26] GRAD2-2295: task is completed. GRAD2-2295: task is completed. --- .../api/batchgraduation/reader/BasePartitioner.java | 10 ++++++++++ .../reader/DistributionRunPartitioner.java | 9 +-------- .../reader/DistributionRunSupplementalPartitioner.java | 6 ++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 5d79fe12..2e67c2ee 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -237,4 +237,14 @@ void filterByStudentSearchRequest(List eligibleSt eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getPens().contains(scr.getPen())); } } + + void filterOutDeceasedStudents(List credentialList) { + LOGGER.debug("Total size of credential list: {}", credentialList.size()); + List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); + if (!deceasedIDs.isEmpty()) { + LOGGER.debug("Deceased students: {}", deceasedIDs.size()); + credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); + LOGGER.debug("Revised size of credential list: {}", credentialList.size()); + } + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java index cd250813..66a31d6b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java @@ -46,14 +46,7 @@ public Map partition(int gridSize) { credentialList.addAll(parallelDTO.certificateList()); } if(!credentialList.isEmpty()) { - LOGGER.debug("Total size of credential list: {}", credentialList.size()); - // Filter deceased students out - List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); - if (!deceasedIDs.isEmpty()) { - LOGGER.debug("Deceased students: {}", deceasedIDs.size()); - credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); - LOGGER.debug("Revised size of credential list: {}", credentialList.size()); - } + filterOutDeceasedStudents(credentialList); updateBatchJobHistory(createBatchJobHistory(), (long) credentialList.size()); return getStringExecutionContextMap(gridSize, credentialList, null, LOGGER); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java index 3ad37ee6..23f1c494 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java @@ -11,10 +11,7 @@ import org.springframework.beans.factory.annotation.Value; import reactor.core.publisher.Mono; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class DistributionRunSupplementalPartitioner extends BasePartitioner { @@ -53,6 +50,7 @@ public Map partition(int gridSize) { logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", eligibleStudentSchoolDistricts.size(), diff); filterByStudentSearchRequest(eligibleStudentSchoolDistricts); if(!eligibleStudentSchoolDistricts.isEmpty()) { + filterOutDeceasedStudents(eligibleStudentSchoolDistricts); updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size()); return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null, logger); } From 52a7d2683d00644a184df4b4f54690cfcf494f67 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 29 Aug 2023 16:21:50 -0600 Subject: [PATCH 04/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- api/pom.xml | 20 +- .../batchgraduation/config/BatchConfig.java | 16 +- .../config/BatchJobConfig.java | 354 +++++++++--------- .../CustomRequestBodyAdviceAdapter.java | 2 +- .../config/RequestInterceptor.java | 4 +- .../config/WebSecurityConfiguration.java | 31 +- .../controller/CodeController.java | 2 +- .../batchgraduation/entity/BaseEntity.java | 2 +- .../BatchGradAlgorithmJobHistoryEntity.java | 18 +- .../BatchGradAlgorithmStudentEntity.java | 2 +- .../BatchJobExecutionContextEntity.java | 3 +- .../entity/BatchJobExecutionEntity.java | 2 +- .../entity/BatchJobExecutionParamEntity.java | 8 +- .../entity/BatchJobInstanceEntity.java | 9 +- .../entity/BatchJobTypeEntity.java | 8 +- .../entity/BatchProcessingEntity.java | 2 +- .../entity/BatchShedlockEntity.java | 8 +- .../BatchStepExecutionContextEntity.java | 3 +- .../entity/BatchStepExecutionEntity.java | 8 +- .../StudentCredentialDistributionEntity.java | 2 +- .../entity/UserScheduledJobsEntity.java | 2 +- ...tionRunCompletionNotificationListener.java | 6 + ...BaseRunCompletionNotificationListener.java | 5 +- ...tionRunCompletionNotificationListener.java | 3 +- ...nYearlyCompletionNotificationListener.java | 7 +- ...NonGradCompletionNotificationListener.java | 7 +- ...GradRunCompletionNotificationListener.java | 5 +- ...CertRunCompletionNotificationListener.java | 6 +- ...cialRunCompletionNotificationListener.java | 5 +- ...rRunJobCompletionNotificationListener.java | 5 +- ...tionRunCompletionNotificationListener.java | 7 +- ...tionRunCompletionNotificationListener.java | 7 +- ...tionRunCompletionNotificationListener.java | 7 +- ...heduledCompletionNotificationListener.java | 3 +- .../reader/BasePartitioner.java | 3 +- .../api/batchgraduation/rest/RestUtils.java | 5 +- .../batchgraduation/service/CodeService.java | 4 +- .../service/TaskDefinition.java | 2 +- .../util/ApiResponseMessage.java | 2 +- .../util/ApiResponseModel.java | 2 +- .../api/batchgraduation/util/DateUtils.java | 40 ++ .../batchgraduation/util/JsonTransformer.java | 2 +- .../api/batchgraduation/util/LogHelper.java | 4 +- .../writer/BlankDistributionRunWriter.java | 7 +- .../writer/DistributionRunWriter.java | 7 +- .../DistributionRunYearlyNonGradWriter.java | 5 +- .../writer/PsiDistributionRunWriter.java | 6 +- .../RegGradAlgBatchPerformanceWriter.java | 9 +- .../RegenerateCertificateRunWriter.java | 6 +- .../writer/TvrRunBatchPerformanceWriter.java | 7 +- .../writer/UserScheduledWriter.java | 5 +- .../batchgraduation/config/BatchConfig.java | 17 +- .../controller/JobLauncherControllerTest.java | 8 +- ...RunCompletionNotificationListenerTest.java | 24 +- ...RunCompletionNotificationListenerTest.java | 51 +-- ...RunCompletionNotificationListenerTest.java | 51 +-- ...JobCompletionNotificationListenerTest.java | 51 +-- ...RunCompletionNotificationListenerTest.java | 56 +-- ...RunCompletionNotificationListenerTest.java | 50 +-- ...RunCompletionNotificationListenerTest.java | 30 +- .../service/TaskDefinitionTest.java | 24 +- .../service/TaskSchedulingServiceTest.java | 8 +- 62 files changed, 577 insertions(+), 488 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/DateUtils.java diff --git a/api/pom.xml b/api/pom.xml index 4c883473..2d2db461 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -48,7 +48,7 @@ ${java.version} ${java.version} 1.3.1.Final - 1.6.9 + 2.0.2 2.18.0 2.0.2 4.38.0 @@ -57,7 +57,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.1 + 3.0.2 @@ -97,19 +97,10 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.springframework.security - spring-security-core - 5.7.5 - org.apache.commons commons-lang3 - - javax.persistence - javax.persistence-api - com.fasterxml.jackson.datatype jackson-datatype-jsr310 @@ -157,12 +148,7 @@ org.springdoc - springdoc-openapi-webmvc-core - ${springdoc.version} - - - org.springdoc - springdoc-openapi-ui + springdoc-openapi-starter-webmvc-ui ${springdoc.version} diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java index bef8f603..9b1084fb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java @@ -1,32 +1,22 @@ package ca.bc.gov.educ.api.batchgraduation.config; -import org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.stereotype.Component; -import javax.sql.DataSource; - @Configuration @Profile("!test") @Component -public class BatchConfig extends DefaultBatchConfigurer { - - @Autowired - public BatchConfig(@Qualifier("batchDataSource") DataSource batchDataSource) { - super(batchDataSource); - } +public class BatchConfig { @Bean(name = "asyncJobLauncher") public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exception { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java index 00a15246..a934b820 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchJobConfig.java @@ -10,11 +10,12 @@ import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; -import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.support.RunIdIncrementer; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -80,30 +81,30 @@ public ItemWriter itemWriterRegGrad() { } @Bean - public Step masterStepRegGrad(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepRegGrad") - .partitioner(graduationJobStep(stepBuilderFactory, skipListener).getName(), partitionerRegGrad()) - .step(graduationJobStep(stepBuilderFactory, skipListener)) + public Step masterStepRegGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepRegGrad", jobRepository) + .partitioner(graduationJobStep(jobRepository, skipListener).getName(), partitionerRegGrad()) + .step(graduationJobStep(jobRepository, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepRegGradError(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepRegGradError") - .partitioner(graduationJobErrorStep(stepBuilderFactory, skipListener).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorStep(stepBuilderFactory, skipListener)) + public Step masterStepRegGradError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepRegGradError", jobRepository) + .partitioner(graduationJobErrorStep(jobRepository, skipListener).getName(), partitionerRegGradRetry()) + .step(graduationJobErrorStep(jobRepository, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepRegGradErrorRetry(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepRegGradErrorRetry") - .partitioner(graduationJobErrorRetryStep(stepBuilderFactory, skipListener).getName(), partitionerRegGradRetry()) - .step(graduationJobErrorRetryStep(stepBuilderFactory, skipListener)) + public Step masterStepRegGradErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepRegGradErrorRetry", jobRepository) + .partitioner(graduationJobErrorRetryStep(jobRepository, skipListener).getName(), partitionerRegGradRetry()) + .step(graduationJobErrorRetryStep(jobRepository, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); @@ -123,9 +124,10 @@ public RegGradAlgPartitionerRetry partitionerRegGradRetry() { } @Bean - public Step graduationJobErrorStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("graduationJobErrorStep") + public Step graduationJobErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("graduationJobErrorStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -138,9 +140,10 @@ public Step graduationJobErrorStep(StepBuilderFactory stepBuilderFactory, SkipSQ } @Bean - public Step graduationJobErrorRetryStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("graduationJobErrorRetryStep") + public Step graduationJobErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("graduationJobErrorRetryStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -153,9 +156,10 @@ public Step graduationJobErrorRetryStep(StepBuilderFactory stepBuilderFactory, S } @Bean - public Step graduationJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("graduationJobStep") + public Step graduationJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("graduationJobStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -168,15 +172,15 @@ public Step graduationJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTran } @Bean(name="GraduationBatchJob") - public Job graduationBatchJob(GradRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("GraduationBatchJob") + public Job graduationBatchJob(JobRepository jobRepository, GradRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("GraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepRegGrad(stepBuilderFactory,constants, skipListener)) + .start(masterStepRegGrad(jobRepository, constants, skipListener)) .on("*") - .to(masterStepRegGradError(stepBuilderFactory,constants, skipListener)) + .to(masterStepRegGradError(jobRepository,constants, skipListener)) .on("*") - .to(masterStepRegGradErrorRetry(stepBuilderFactory,constants, skipListener)) + .to(masterStepRegGradErrorRetry(jobRepository,constants, skipListener)) .on("*") .end().build() .build(); @@ -220,30 +224,30 @@ public ItemWriter itemWriterTvrRun() { } @Bean - public Step masterStepTvrRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepTvrRun") - .partitioner(tvrJobStep(stepBuilderFactory,skipListener).getName(), partitionerTvrRun()) - .step(tvrJobStep(stepBuilderFactory,skipListener)) + public Step masterStepTvrRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepTvrRun", jobRepository) + .partitioner(tvrJobStep(jobRepository,skipListener).getName(), partitionerTvrRun()) + .step(tvrJobStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepTvrRunError(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepTvrRunError") - .partitioner(tvrJobErrorStep(stepBuilderFactory,skipListener).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorStep(stepBuilderFactory,skipListener)) + public Step masterStepTvrRunError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepTvrRunError", jobRepository) + .partitioner(tvrJobErrorStep(jobRepository,skipListener).getName(), partitionerTvrRunRetry()) + .step(tvrJobErrorStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepTvrRunErrorRetry(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepTvrRunErrorRetry") - .partitioner(tvrJobErrorRetryStep(stepBuilderFactory,skipListener).getName(), partitionerTvrRunRetry()) - .step(tvrJobErrorRetryStep(stepBuilderFactory,skipListener)) + public Step masterStepTvrRunErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepTvrRunErrorRetry", jobRepository) + .partitioner(tvrJobErrorRetryStep(jobRepository,skipListener).getName(), partitionerTvrRunRetry()) + .step(tvrJobErrorRetryStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); @@ -263,9 +267,10 @@ public TvrRunPartitionerRetry partitionerTvrRunRetry() { @Bean - public Step tvrJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("tvrJobStep") + public Step tvrJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("tvrJobStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -278,9 +283,10 @@ public Step tvrJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransaction } @Bean - public Step tvrJobErrorStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("tvrJobErrorStep") + public Step tvrJobErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("tvrJobErrorStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -293,9 +299,10 @@ public Step tvrJobErrorStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransa } @Bean - public Step tvrJobErrorRetryStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("tvrJobErrorRetryStep") + public Step tvrJobErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("tvrJobErrorRetryStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -308,15 +315,15 @@ public Step tvrJobErrorRetryStep(StepBuilderFactory stepBuilderFactory, SkipSQLT } @Bean(name="tvrBatchJob") - public Job tvrBatchJob(TvrRunJobCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("tvrBatchJob") + public Job tvrBatchJob(JobRepository jobRepository, TvrRunJobCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("tvrBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepTvrRun(stepBuilderFactory,constants,skipListener)) + .start(masterStepTvrRun(jobRepository,constants,skipListener)) .on("*") - .to(masterStepTvrRunError(stepBuilderFactory,constants,skipListener)) + .to(masterStepTvrRunError(jobRepository,constants,skipListener)) .on("*") - .to(masterStepTvrRunErrorRetry(stepBuilderFactory,constants,skipListener)) + .to(masterStepTvrRunErrorRetry(jobRepository,constants,skipListener)) .on("*") .end().build() .build(); @@ -349,30 +356,30 @@ public ItemWriter itemWriterSpcRegGrad() { @Bean - public Step masterStepSpcRegGrad(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcRegGrad") - .partitioner(slaveSpcRegGradStep(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGrad()) - .step(slaveSpcRegGradStep(stepBuilderFactory,skipListener)) + public Step masterStepSpcRegGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcRegGrad", jobRepository) + .partitioner(slaveSpcRegGradStep(jobRepository,skipListener).getName(), partitionerSpcRegGrad()) + .step(slaveSpcRegGradStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepSpcRegGradError(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcRegGradError") - .partitioner(slaveSpcRegGradErrorStep(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorStep(stepBuilderFactory,skipListener)) + public Step masterStepSpcRegGradError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcRegGradError", jobRepository) + .partitioner(slaveSpcRegGradErrorStep(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) + .step(slaveSpcRegGradErrorStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepSpcRegGradErrorRetry(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcRegGradErrorRetry") - .partitioner(slaveSpcRegGradErrorRetryStep(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveSpcRegGradErrorRetryStep(stepBuilderFactory,skipListener)) + public Step masterStepSpcRegGradErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcRegGradErrorRetry", jobRepository) + .partitioner(slaveSpcRegGradErrorRetryStep(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) + .step(slaveSpcRegGradErrorRetryStep(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); @@ -391,9 +398,10 @@ public SpcRegGradAlgPartitionerRetry partitionerSpcRegGradRetry() { } @Bean - public Step slaveSpcRegGradStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveStepSpcRegGrad") + public Step slaveSpcRegGradStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveStepSpcRegGrad", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -406,9 +414,10 @@ public Step slaveSpcRegGradStep(StepBuilderFactory stepBuilderFactory, SkipSQLTr } @Bean - public Step slaveSpcRegGradErrorStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveSpcRegGradErrorStep") + public Step slaveSpcRegGradErrorStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveSpcRegGradErrorStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -421,9 +430,10 @@ public Step slaveSpcRegGradErrorStep(StepBuilderFactory stepBuilderFactory, Skip } @Bean - public Step slaveSpcRegGradErrorRetryStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveSpcRegGradErrorRetryStep") + public Step slaveSpcRegGradErrorRetryStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveSpcRegGradErrorRetryStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -436,15 +446,15 @@ public Step slaveSpcRegGradErrorRetryStep(StepBuilderFactory stepBuilderFactory, } @Bean(name="SpecialGraduationBatchJob") - public Job specialGraduationBatchJob(SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("SpecialGraduationBatchJob") + public Job specialGraduationBatchJob(JobRepository jobRepository, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("SpecialGraduationBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcRegGrad(stepBuilderFactory,constants,skipListener)) + .start(masterStepSpcRegGrad(jobRepository,constants,skipListener)) .on("*") - .to(masterStepSpcRegGradError(stepBuilderFactory,constants,skipListener)) + .to(masterStepSpcRegGradError(jobRepository,constants,skipListener)) .on("*") - .to(masterStepSpcRegGradErrorRetry(stepBuilderFactory,constants,skipListener)) + .to(masterStepSpcRegGradErrorRetry(jobRepository,constants,skipListener)) .on("*") .end().build() .build(); @@ -475,39 +485,40 @@ public ItemWriter itemWriterSpcTvrRun() { } @Bean - public Step masterStepSpcTvrRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcTvrRun") - .partitioner(slaveStepSpcTvrRun(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGrad()) - .step(slaveStepSpcTvrRun(stepBuilderFactory,skipListener)) + public Step masterStepSpcTvrRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcTvrRun", jobRepository) + .partitioner(slaveStepSpcTvrRun(jobRepository,skipListener).getName(), partitionerSpcRegGrad()) + .step(slaveStepSpcTvrRun(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepSpcTvrRunError(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcTvrRunError") - .partitioner(slaveStepSpcTvrRunError(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunError(stepBuilderFactory,skipListener)) + public Step masterStepSpcTvrRunError(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcTvrRunError", jobRepository) + .partitioner(slaveStepSpcTvrRunError(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) + .step(slaveStepSpcTvrRunError(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step masterStepSpcTvrRunErrorRetry(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepSpcTvrRunErrorRetry") - .partitioner(slaveStepSpcTvrRunErrorRetry(stepBuilderFactory,skipListener).getName(), partitionerSpcRegGradRetry()) - .step(slaveStepSpcTvrRunErrorRetry(stepBuilderFactory,skipListener)) + public Step masterStepSpcTvrRunErrorRetry(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepSpcTvrRunErrorRetry", jobRepository) + .partitioner(slaveStepSpcTvrRunErrorRetry(jobRepository,skipListener).getName(), partitionerSpcRegGradRetry()) + .step(slaveStepSpcTvrRunErrorRetry(jobRepository,skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step slaveStepSpcTvrRun(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveStepSpcTvrRun") + public Step slaveStepSpcTvrRun(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveStepSpcTvrRun", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -520,9 +531,10 @@ public Step slaveStepSpcTvrRun(StepBuilderFactory stepBuilderFactory, SkipSQLTra } @Bean - public Step slaveStepSpcTvrRunError(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveStepSpcTvrRunError") + public Step slaveStepSpcTvrRunError(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveStepSpcTvrRunError", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -535,9 +547,10 @@ public Step slaveStepSpcTvrRunError(StepBuilderFactory stepBuilderFactory, SkipS } @Bean - public Step slaveStepSpcTvrRunErrorRetry(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("slaveStepSpcTvrRunErrorRetry") + public Step slaveStepSpcTvrRunErrorRetry(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("slaveStepSpcTvrRunErrorRetry", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -550,15 +563,15 @@ public Step slaveStepSpcTvrRunErrorRetry(StepBuilderFactory stepBuilderFactory, } @Bean(name="SpecialTvrRunBatchJob") - public Job specialTvrRunBatchJob(SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("SpecialTvrRunBatchJob") + public Job specialTvrRunBatchJob(JobRepository jobRepository, SpecialRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("SpecialTvrRunBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepSpcTvrRun(stepBuilderFactory,constants,skipListener)) + .start(masterStepSpcTvrRun(jobRepository,constants,skipListener)) .on("*") - .to(masterStepSpcTvrRunError(stepBuilderFactory,constants,skipListener)) + .to(masterStepSpcTvrRunError(jobRepository,constants,skipListener)) .on("*") - .to(masterStepSpcTvrRunErrorRetry(stepBuilderFactory,constants,skipListener)) + .to(masterStepSpcTvrRunErrorRetry(jobRepository,constants,skipListener)) .on("*") .end().build() .build(); @@ -614,9 +627,10 @@ public DistributionRunPartitioner partitionerDisRun() { @Bean - public Step slaveStepDisRun(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepDisRun") + public Step slaveStepDisRun(JobRepository jobRepository) { + return new StepBuilder("slaveStepDisRun", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderDisRun()) .processor(itemProcessorDisRun()) .writer(itemWriterDisRun()) @@ -625,9 +639,10 @@ public Step slaveStepDisRun(StepBuilderFactory stepBuilderFactory) { } @Bean - public Step slaveStepDisRunYearly(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepDisRun") + public Step slaveStepDisRunYearly(JobRepository jobRepository) { + return new StepBuilder("slaveStepDisRun", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderDisRun()) .processor(itemProcessorDisRun()) .writer(itemWriterDisRun()) @@ -636,9 +651,10 @@ public Step slaveStepDisRunYearly(StepBuilderFactory stepBuilderFactory) { } @Bean - public Step slaveStepDisRunYearlyNonGradByMincode(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepDisRunYearlyNonGrad") + public Step slaveStepDisRunYearlyNonGradByMincode(JobRepository jobRepository) { + return new StepBuilder("slaveStepDisRunYearlyNonGrad", jobRepository) .>chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderDisRunYearlyNonGrad()) .processor(itemProcessorDisRunYearlyNonGradByMincode()) .writer(itemWriterDisRunYearlyNonGrad()) @@ -647,21 +663,21 @@ public Step slaveStepDisRunYearlyNonGradByMincode(StepBuilderFactory stepBuilder } @Bean - public Step masterStepDisRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepDisRun") - .partitioner(slaveStepDisRun(stepBuilderFactory).getName(), partitionerDisRun()) - .step(slaveStepDisRun(stepBuilderFactory)) + public Step masterStepDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepDisRun", jobRepository) + .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRun()) + .step(slaveStepDisRun(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean(name="DistributionBatchJob") - public Job distributionBatchJob(DistributionRunCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("DistributionBatchJob") + public Job distributionBatchJob(JobRepository jobRepository, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("DistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRun(stepBuilderFactory,constants)) + .flow(masterStepDisRun(jobRepository,constants)) .end() .build(); } @@ -679,21 +695,21 @@ public DistributionRunYearlyPartitioner partitionerDisRunYearly() { } @Bean - public Step masterStepDisRunYearly(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepDisRunYearly") - .partitioner(slaveStepDisRun(stepBuilderFactory).getName(), partitionerDisRunYearly()) - .step(slaveStepDisRunYearly(stepBuilderFactory)) + public Step masterStepDisRunYearly(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepDisRunYearly", jobRepository) + .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunYearly()) + .step(slaveStepDisRunYearly(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean(name="YearlyDistributionBatchJob") - public Job distributionBatchJobYearly(DistributionRunYearlyCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("YearlyDistributionBatchJob") + public Job distributionBatchJobYearly(JobRepository jobRepository, DistributionRunYearlyCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("YearlyDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunYearly(stepBuilderFactory,constants)) + .flow(masterStepDisRunYearly(jobRepository,constants)) .end() .build(); } @@ -705,21 +721,21 @@ public DistributionRunYearlyNonGradPartitioner partitionerDisRunYearlyNonGrad() } @Bean - public Step masterStepDisRunYearlyNonGrad(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepDisRunYearlyNonGrad") - .partitioner(slaveStepDisRunYearlyNonGradByMincode(stepBuilderFactory).getName(), partitionerDisRunYearlyNonGrad()) - .step(slaveStepDisRunYearlyNonGradByMincode(stepBuilderFactory)) + public Step masterStepDisRunYearlyNonGrad(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepDisRunYearlyNonGrad", jobRepository) + .partitioner(slaveStepDisRunYearlyNonGradByMincode(jobRepository).getName(), partitionerDisRunYearlyNonGrad()) + .step(slaveStepDisRunYearlyNonGradByMincode(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean(name="YearlyNonGradDistributionBatchJob") - public Job distributionBatchJobYearlyNonGrad(DistributionRunYearlyNonGradCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("YearlyNonGradDistributionBatchJob") + public Job distributionBatchJobYearlyNonGrad(JobRepository jobRepository, DistributionRunYearlyNonGradCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("YearlyNonGradDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunYearlyNonGrad(stepBuilderFactory,constants)) + .flow(masterStepDisRunYearlyNonGrad(jobRepository,constants)) .end() .build(); } @@ -731,21 +747,21 @@ public DistributionRunSupplementalPartitioner partitionerDisRunSupplemental() { } @Bean - public Step masterStepDisRunSupplemental(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepDisRunSupplemental") - .partitioner(slaveStepDisRun(stepBuilderFactory).getName(), partitionerDisRunSupplemental()) - .step(slaveStepDisRun(stepBuilderFactory)) + public Step masterStepDisRunSupplemental(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepDisRunSupplemental", jobRepository) + .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunSupplemental()) + .step(slaveStepDisRun(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean(name="SupplementalDistributionBatchJob") - public Job distributionBatchJobSupplemental(DistributionRunCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("SupplementalDistributionBatchJob") + public Job distributionBatchJobSupplemental(JobRepository jobRepository, DistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("SupplementalDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepDisRunSupplemental(stepBuilderFactory,constants)) + .flow(masterStepDisRunSupplemental(jobRepository,constants)) .end() .build(); } @@ -763,21 +779,21 @@ public DistributionRunPartitionerUserReq partitionerDisRunUserReq() { } @Bean - public Step masterStepUserReqDisRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepUserReqDisRun") - .partitioner(slaveStepDisRun(stepBuilderFactory).getName(), partitionerDisRunUserReq()) - .step(slaveStepDisRun(stepBuilderFactory)) + public Step masterStepUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepUserReqDisRun", jobRepository) + .partitioner(slaveStepDisRun(jobRepository).getName(), partitionerDisRunUserReq()) + .step(slaveStepDisRun(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean(name="UserReqDistributionBatchJob") - public Job distributionBatchJobUserReq(UserReqDistributionRunCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("UserReqDistributionBatchJob") + public Job distributionBatchJobUserReq(JobRepository jobRepository, UserReqDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("UserReqDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepUserReqDisRun(stepBuilderFactory,constants)) + .flow(masterStepUserReqDisRun(jobRepository,constants)) .end() .build(); } @@ -814,9 +830,10 @@ public DistributionRunPartitionerBlankUserReq partitionerDisRunBlankUserReq() { } @Bean - public Step slaveStepBlankDisRun(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepBlankDisRun") + public Step slaveStepBlankDisRun(JobRepository jobRepository) { + return new StepBuilder("slaveStepBlankDisRun", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderBlankDisRun()) .processor(itemProcessorBlankDisRun()) .writer(itemWriterBlankDisRun()) @@ -824,10 +841,10 @@ public Step slaveStepBlankDisRun(StepBuilderFactory stepBuilderFactory) { } @Bean - public Step masterStepBlankUserReqDisRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepBlankUserReqDisRun") - .partitioner(slaveStepBlankDisRun(stepBuilderFactory).getName(), partitionerDisRunBlankUserReq()) - .step(slaveStepBlankDisRun(stepBuilderFactory)) + public Step masterStepBlankUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepBlankUserReqDisRun", jobRepository) + .partitioner(slaveStepBlankDisRun(jobRepository).getName(), partitionerDisRunBlankUserReq()) + .step(slaveStepBlankDisRun(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); @@ -835,11 +852,11 @@ public Step masterStepBlankUserReqDisRun(StepBuilderFactory stepBuilderFactory, @Bean(name="blankDistributionBatchJob") - public Job blankDistributionBatchJobUserReq(UserReqBlankDistributionRunCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("blankDistributionBatchJob") + public Job blankDistributionBatchJobUserReq(JobRepository jobRepository, UserReqBlankDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("blankDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepBlankUserReqDisRun(stepBuilderFactory,constants)) + .flow(masterStepBlankUserReqDisRun(jobRepository,constants)) .end() .build(); } @@ -876,9 +893,10 @@ public DistributionRunPartitionerPsiUserReq partitionerDisRunPsiUserReq() { } @Bean - public Step slaveStepPsiDisRun(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepPsiDisRun") + public Step slaveStepPsiDisRun(JobRepository jobRepository) { + return new StepBuilder("slaveStepPsiDisRun", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderPsiDisRun()) .processor(itemProcessorPsiDisRun()) .writer(itemWriterPsiDisRun()) @@ -886,10 +904,10 @@ public Step slaveStepPsiDisRun(StepBuilderFactory stepBuilderFactory) { } @Bean - public Step masterStepPsiUserReqDisRun(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return stepBuilderFactory.get("masterStepPsiUserReqDisRun") - .partitioner(slaveStepPsiDisRun(stepBuilderFactory).getName(), partitionerDisRunPsiUserReq()) - .step(slaveStepPsiDisRun(stepBuilderFactory)) + public Step masterStepPsiUserReqDisRun(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants) { + return new StepBuilder("masterStepPsiUserReqDisRun", jobRepository) + .partitioner(slaveStepPsiDisRun(jobRepository).getName(), partitionerDisRunPsiUserReq()) + .step(slaveStepPsiDisRun(jobRepository)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); @@ -897,11 +915,11 @@ public Step masterStepPsiUserReqDisRun(StepBuilderFactory stepBuilderFactory, Ed @Bean(name="psiDistributionBatchJob") - public Job psiDistributionBatchJobUserReq(UserReqPsiDistributionRunCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("psiDistributionBatchJob") + public Job psiDistributionBatchJobUserReq(JobRepository jobRepository, UserReqPsiDistributionRunCompletionNotificationListener listener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("psiDistributionBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(masterStepPsiUserReqDisRun(stepBuilderFactory,constants)) + .flow(masterStepPsiUserReqDisRun(jobRepository,constants)) .end() .build(); } @@ -934,19 +952,20 @@ public ItemProcessor itemProcessorCertRegen() { } @Bean - public Step masterStepCertRegen(StepBuilderFactory stepBuilderFactory, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("masterStepCertRegen") - .partitioner(certRegenJobStep(stepBuilderFactory, skipListener).getName(), partitionerCertRegen()) - .step(certRegenJobStep(stepBuilderFactory, skipListener)) + public Step masterStepCertRegen(JobRepository jobRepository, EducGradBatchGraduationApiConstants constants, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("masterStepCertRegen", jobRepository) + .partitioner(certRegenJobStep(jobRepository, skipListener).getName(), partitionerCertRegen()) + .step(certRegenJobStep(jobRepository, skipListener)) .gridSize(constants.getNumberOfPartitions()) .taskExecutor(taskExecutor(constants)) .build(); } @Bean - public Step certRegenJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTransactionExceptionsListener skipListener) { - return stepBuilderFactory.get("certRegenJobStep") + public Step certRegenJobStep(JobRepository jobRepository, SkipSQLTransactionExceptionsListener skipListener) { + return new StepBuilder("certRegenJobStep", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .faultTolerant() .skip(SQLException.class) .skip(TransactionException.class) @@ -959,11 +978,11 @@ public Step certRegenJobStep(StepBuilderFactory stepBuilderFactory, SkipSQLTrans } @Bean(name="certRegenBatchJob") - public Job certRegenBatchJob(RegenCertRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory, EducGradBatchGraduationApiConstants constants) { - return jobBuilderFactory.get("certRegenBatchJob") + public Job certRegenBatchJob(JobRepository jobRepository, RegenCertRunCompletionNotificationListener listener, SkipSQLTransactionExceptionsListener skipListener, EducGradBatchGraduationApiConstants constants) { + return new JobBuilder("certRegenBatchJob", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .start(masterStepCertRegen(stepBuilderFactory,constants, skipListener)) + .start(masterStepCertRegen(jobRepository,constants, skipListener)) .on("*") .end().build() .build(); @@ -991,9 +1010,10 @@ public ItemWriter itemWriterUserScheduled() { } @Bean - public Step slaveStepUserScheduled(StepBuilderFactory stepBuilderFactory) { - return stepBuilderFactory.get("slaveStepUserScheduled") + public Step slaveStepUserScheduled(JobRepository jobRepository) { + return new StepBuilder("slaveStepUserScheduled", jobRepository) .chunk(1) + .transactionManager(batchTransactionManager) .reader(itemReaderUserScheduled()) .processor(itemProcessorUserScheduled()) .writer(itemWriterUserScheduled()) @@ -1001,11 +1021,11 @@ public Step slaveStepUserScheduled(StepBuilderFactory stepBuilderFactory) { } @Bean(name="userScheduledBatchJobRefresher") - public Job userScheduledBatchJobQueueRefresher(UserScheduledCompletionNotificationListener listener, StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory) { - return jobBuilderFactory.get("userScheduledBatchJobRefresher") + public Job userScheduledBatchJobQueueRefresher(JobRepository jobRepository, UserScheduledCompletionNotificationListener listener) { + return new JobBuilder("userScheduledBatchJobRefresher", jobRepository) .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(slaveStepUserScheduled(stepBuilderFactory)) + .flow(slaveStepUserScheduled(jobRepository)) .end() .build(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/CustomRequestBodyAdviceAdapter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/CustomRequestBodyAdviceAdapter.java index 5d85b81c..3f6142c5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/CustomRequestBodyAdviceAdapter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/CustomRequestBodyAdviceAdapter.java @@ -1,5 +1,6 @@ package ca.bc.gov.educ.api.batchgraduation.config; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.MethodParameter; import org.springframework.http.HttpInputMessage; @@ -7,7 +8,6 @@ import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter; -import javax.servlet.http.HttpServletRequest; import java.lang.reflect.Type; @ControllerAdvice diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java index 3a32ffc9..57804272 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/RequestInterceptor.java @@ -4,6 +4,8 @@ import ca.bc.gov.educ.api.batchgraduation.util.JwtUtil; import ca.bc.gov.educ.api.batchgraduation.util.LogHelper; import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.beans.factory.annotation.Autowired; @@ -15,8 +17,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.servlet.AsyncHandlerInterceptor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.time.Instant; @Component diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java index f60cb911..960061cf 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java @@ -4,6 +4,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; +import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.SecurityFilterChain; @@ -18,20 +21,20 @@ public WebSecurityConfiguration() { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http - .authorizeRequests() - .antMatchers( - "/api/v1/api-docs-ui.html", - "/api/v1/swagger-ui/**", - "/api/v1/api-docs/**", - "/actuator/health", - "/actuator/prometheus", - "/health") - .permitAll() - .anyRequest() - .authenticated() - .and() - .oauth2ResourceServer() - .jwt(); + .csrf(AbstractHttpConfigurer::disable) + .authorizeHttpRequests(auth -> auth + .requestMatchers( + "/api/v1/api-docs-ui.html", + "/api/v1/swagger-ui/**", + "/api/v1/api-docs/**", + "/actuator/health", + "/actuator/prometheus", + "/health") + .permitAll() + .anyRequest().authenticated() + ) + .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt); return http.build(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/CodeController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/CodeController.java index 1aa4b687..418a5584 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/CodeController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/CodeController.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import jakarta.validation.Valid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,7 +18,6 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; import java.util.List; @RestController diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java index 1ab8c459..b7276a76 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java @@ -2,11 +2,11 @@ import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil; +import jakarta.persistence.*; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.format.annotation.DateTimeFormat; -import javax.persistence.*; import java.util.Date; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java index d5f07523..f3c2de72 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java @@ -1,20 +1,12 @@ package ca.bc.gov.educ.api.batchgraduation.entity; -import java.util.Date; -import java.util.UUID; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -import org.hibernate.annotations.GenericGenerator; - +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; +import org.hibernate.annotations.GenericGenerator; + +import java.util.Date; +import java.util.UUID; @Data @Entity diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmStudentEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmStudentEntity.java index 6cd4f6d0..4471b19d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmStudentEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmStudentEntity.java @@ -1,10 +1,10 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.annotations.GenericGenerator; -import javax.persistence.*; import java.util.UUID; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionContextEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionContextEntity.java index 0318a6c8..36da6f86 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionContextEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionContextEntity.java @@ -1,10 +1,9 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.persistence.*; - @Data @Entity @Table(name = "BATCH_JOB_EXECUTION_CONTEXT") diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java index b2add57f..04bd6c4c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java @@ -1,9 +1,9 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.persistence.*; import java.time.Instant; import java.util.Date; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java index a831f10c..6866b218 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java @@ -1,12 +1,12 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; import java.io.Serializable; import java.time.Instant; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobInstanceEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobInstanceEntity.java index ad1ebbfc..7407759d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobInstanceEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobInstanceEntity.java @@ -1,13 +1,12 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - @Data @EqualsAndHashCode(callSuper = false) @Entity diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobTypeEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobTypeEntity.java index da45e977..b6863a01 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobTypeEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobTypeEntity.java @@ -1,12 +1,12 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; import java.util.Date; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchProcessingEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchProcessingEntity.java index 29e22916..8d1a2ce1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchProcessingEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchProcessingEntity.java @@ -1,10 +1,10 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.annotations.GenericGenerator; -import javax.persistence.*; import java.util.UUID; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchShedlockEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchShedlockEntity.java index 874672f7..62b912c9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchShedlockEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchShedlockEntity.java @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; import java.io.Serializable; import java.util.Date; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java index 3e9478b6..50ebb294 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java @@ -1,9 +1,8 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; -import javax.persistence.*; - @Data @Entity @Table(name = "BATCH_STEP_EXECUTION_CONTEXT") diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java index f8e4dda5..d17a1e1f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; import java.time.Instant; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/StudentCredentialDistributionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/StudentCredentialDistributionEntity.java index f59cbd3d..aa0f09ae 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/StudentCredentialDistributionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/StudentCredentialDistributionEntity.java @@ -1,10 +1,10 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.annotations.GenericGenerator; -import javax.persistence.*; import java.util.UUID; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/UserScheduledJobsEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/UserScheduledJobsEntity.java index c1abe25d..95c0e356 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/UserScheduledJobsEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/UserScheduledJobsEntity.java @@ -1,10 +1,10 @@ package ca.bc.gov.educ.api.batchgraduation.entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.annotations.GenericGenerator; -import javax.persistence.*; import java.util.UUID; @Data diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java index 65fa22a3..28b3f2ac 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java @@ -10,9 +10,11 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.listener.JobExecutionListenerSupport; import org.springframework.beans.factory.annotation.Autowired; +import java.time.ZoneId; import java.util.Date; import java.util.List; @@ -133,4 +135,8 @@ void filterStudentCredentialDistribution(List cre } LOGGER.debug("Total {} selected after filter", credentialList.size()); } + + long getElapsedTimeMillis(JobExecution jobExecution) { + return new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java index 5d318065..e1189635 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java @@ -7,6 +7,7 @@ import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; import ca.bc.gov.educ.api.batchgraduation.service.TaskSchedulingService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; @@ -35,8 +36,8 @@ protected void handleSummary(JobExecution jobExecution, String summaryDtoName, b ExecutionContext jobContext = jobExecution.getExecutionContext(); Long jobExecutionId = jobExecution.getId(); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java index 9c5fe779..c7a1cdfb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java @@ -11,7 +11,6 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -29,7 +28,7 @@ public class DistributionRunCompletionNotificationListener extends BaseDistribut @Override public void afterJob(JobExecution jobExecution) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info("======================================================================================="); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java index 6fe6392e..2edf62a7 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.api.batchgraduation.listener; import ca.bc.gov.educ.api.batchgraduation.model.*; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +36,7 @@ public class DistributionRunYearlyCompletionNotificationListener extends BaseDis @Generated("default") public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info("======================================================================================="); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); @@ -44,8 +45,8 @@ public void afterJob(JobExecution jobExecution) { LOGGER.info("{} Distribution Job {} completed in {} s with jobExecution status {}", jobType, jobExecutionId, elapsedTimeMillis/1000, jobExecution.getStatus()); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String searchRequest = jobParameters.getString(SEARCH_REQUEST); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java index 40b98156..846b4da8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.api.batchgraduation.listener; import ca.bc.gov.educ.api.batchgraduation.model.*; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +36,7 @@ public class DistributionRunYearlyNonGradCompletionNotificationListener extends @Generated("default") public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info("======================================================================================="); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); @@ -44,8 +45,8 @@ public void afterJob(JobExecution jobExecution) { LOGGER.info("{} Distribution Job {} completed in {} s with jobExecution status {}", jobType, jobExecutionId, elapsedTimeMillis/1000, jobExecution.getStatus()); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String searchRequest = jobParameters.getString(SEARCH_REQUEST); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListener.java index c24cc59b..794c5d71 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListener.java @@ -6,7 +6,8 @@ import org.springframework.batch.core.JobExecution; import org.springframework.stereotype.Component; -import java.util.*; +import java.time.ZoneId; +import java.util.Date; @Component public class GradRunCompletionNotificationListener extends BaseRunCompletionNotificationListener { @@ -16,7 +17,7 @@ public class GradRunCompletionNotificationListener extends BaseRunCompletionNoti @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); LOGGER.info("======================================================================================="); LOGGER.info("Grad Algorithm Job completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus()); handleSummary(jobExecution, "regGradAlgSummaryDTO", false); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java index 54ebc24c..d2b017a3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java @@ -3,6 +3,7 @@ import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO; import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; @@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.ZoneId; import java.util.Date; @Component @@ -25,13 +27,13 @@ public class RegenCertRunCompletionNotificationListener extends JobExecutionList @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); LOGGER.info("======================================================================================="); LOGGER.info("Regenerate Certificate Job completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus()); ExecutionContext jobContext = jobExecution.getExecutionContext(); Long jobExecutionId = jobExecution.getId(); String status = jobExecution.getStatus().toString(); - Date endTime = jobExecution.getEndTime(); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); AlgorithmSummaryDTO summaryDTO = (AlgorithmSummaryDTO)jobContext.get("regenCertSummaryDTO"); if(summaryDTO == null) { summaryDTO = new AlgorithmSummaryDTO(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java index b2646bcc..d981dc62 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListener.java @@ -6,7 +6,8 @@ import org.springframework.batch.core.JobExecution; import org.springframework.stereotype.Component; -import java.util.*; +import java.time.ZoneId; +import java.util.Date; @Component public class SpecialRunCompletionNotificationListener extends BaseRunCompletionNotificationListener { @@ -16,7 +17,7 @@ public class SpecialRunCompletionNotificationListener extends BaseRunCompletionN @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); LOGGER.info("======================================================================================="); LOGGER.info("Special Job completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus()); handleSummary(jobExecution, "spcRunAlgSummaryDTO", true); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListener.java index 3a5bfea2..9a2c4304 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListener.java @@ -6,7 +6,8 @@ import org.springframework.batch.core.JobExecution; import org.springframework.stereotype.Component; -import java.util.*; +import java.time.ZoneId; +import java.util.Date; @Component public class TvrRunJobCompletionNotificationListener extends BaseRunCompletionNotificationListener { @@ -16,7 +17,7 @@ public class TvrRunJobCompletionNotificationListener extends BaseRunCompletionNo @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); LOGGER.info("======================================================================================="); LOGGER.info("TVR Job completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus()); handleSummary(jobExecution, "tvrRunSummaryDTO", false); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListener.java index c24dea74..8360a520 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListener.java @@ -2,6 +2,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.*; import ca.bc.gov.educ.api.batchgraduation.service.TaskSchedulingService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +37,7 @@ public class UserReqBlankDistributionRunCompletionNotificationListener extends B @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info(LOG_SEPARATION); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); @@ -45,8 +46,8 @@ public void afterJob(JobExecution jobExecution) { LOGGER.info("{} Distribution Job {} completed in {} s with jobExecution status {}", jobType, jobExecutionId, elapsedTimeMillis/1000, jobExecution.getStatus()); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String credentialType = jobParameters.getString("credentialType"); String localDownLoad = jobParameters.getString("LocalDownload"); 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 0bcc452a..5d80f147 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 @@ -5,6 +5,7 @@ import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; import ca.bc.gov.educ.api.batchgraduation.service.TaskSchedulingService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.BatchStatus; @@ -42,7 +43,7 @@ public class UserReqDistributionRunCompletionNotificationListener extends BaseDi @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info(LOG_SEPARATION); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); @@ -51,8 +52,8 @@ public void afterJob(JobExecution jobExecution) { LOGGER.info("{} Distribution Job {} completed in {} s with jobExecution status {}", jobType, jobExecutionId, elapsedTimeMillis/1000, jobExecution.getStatus()); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String localDownLoad = jobParameters.getString("LocalDownload"); String credentialType = jobParameters.getString("credentialType"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java index f2dba17a..d453ca64 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListener.java @@ -2,6 +2,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.*; import ca.bc.gov.educ.api.batchgraduation.service.TaskSchedulingService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -35,7 +36,7 @@ public UserReqPsiDistributionRunCompletionNotificationListener(TaskSchedulingSer @Override public void afterJob(JobExecution jobExecution) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = getElapsedTimeMillis(jobExecution); LOGGER.info(LOG_SEPARATION); JobParameters jobParameters = jobExecution.getJobParameters(); ExecutionContext jobContext = jobExecution.getExecutionContext(); @@ -44,8 +45,8 @@ public void afterJob(JobExecution jobExecution) { LOGGER.info("{} Distribution Job {} completed in {} s with jobExecution status {}", jobType, jobExecutionId, elapsedTimeMillis/1000, jobExecution.getStatus()); String status = jobExecution.getStatus().toString(); - Date startTime = jobExecution.getStartTime(); - Date endTime = jobExecution.getEndTime(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString(EducGradBatchGraduationApiConstants.JOB_TRIGGER); String transmissionType = jobParameters.getString(EducGradBatchGraduationApiConstants.TRANSMISSION_TYPE); String studentSearchRequest = jobParameters.getString(EducGradBatchGraduationApiConstants.SEARCH_REQUEST, "{}"); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java index 8cd60bba..fe9710d7 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/UserScheduledCompletionNotificationListener.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.ZoneId; import java.util.Date; @Component @@ -29,7 +30,7 @@ public class UserScheduledCompletionNotificationListener extends JobExecutionLis @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { - long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().getTime(); + long elapsedTimeMillis = new Date().getTime() - jobExecution.getStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); LOGGER.info(LOG_SEPARATION); LOGGER.info("User Scheduled Jobs Refresher completed in {} s with jobExecution status {}", elapsedTimeMillis/1000, jobExecution.getStatus()); LOGGER.info(LOG_SEPARATION); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 5d79fe12..e63f587c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.*; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.GradSorter; import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; import org.apache.commons.lang3.StringUtils; @@ -126,7 +127,7 @@ protected BatchGradAlgorithmJobHistoryEntity createBatchJobHistory() { String username = jobParameters.getString(RUN_BY); String studentSearchRequest = jobParameters.getString(SEARCH_REQUEST); String status = getJobExecution().getStatus().toString(); - Date startTime = getJobExecution().getStartTime(); + Date startTime = DateUtils.toDate(getJobExecution().getStartTime()); BatchGradAlgorithmJobHistoryEntity ent = new BatchGradAlgorithmJobHistoryEntity(); ent.setActualStudentsProcessed(0L); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 4afdbe9b..d218ab5b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -13,6 +13,7 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; @@ -75,7 +76,7 @@ public T post(String url, Object body, Class clazz, String accessToken) { .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); }) .body(BodyInserters.fromValue(body)) .retrieve() - .onStatus(HttpStatus::is5xxServerError, + .onStatus(HttpStatusCode::is5xxServerError, clientResponse -> Mono.error(new ServiceException(getErrorMessage(url, "5xx error."), clientResponse.statusCode().value()))) .bodyToMono(clazz) .retryWhen(reactor.util.retry.Retry.backoff(3, Duration.ofSeconds(2)) @@ -109,7 +110,7 @@ public T get(String url, Class clazz, String accessToken) { .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); }) .retrieve() // if 5xx errors, throw Service error - .onStatus(HttpStatus::is5xxServerError, + .onStatus(HttpStatusCode::is5xxServerError, clientResponse -> Mono.error(new ServiceException(getErrorMessage(url, "5xx error."), clientResponse.statusCode().value()))) .bodyToMono(clazz) // only does retry if initial error was 5xx as service may be temporarily down diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/CodeService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/CodeService.java index c3a31ae6..46530b5a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/CodeService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/CodeService.java @@ -5,6 +5,8 @@ import ca.bc.gov.educ.api.batchgraduation.model.transformer.BatchJobTypeTransformer; import ca.bc.gov.educ.api.batchgraduation.repository.BatchJobTypeRepository; import ca.bc.gov.educ.api.batchgraduation.util.GradValidation; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,8 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.transaction.Transactional; -import javax.validation.Valid; import java.util.List; import java.util.Optional; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinition.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinition.java index 94ad2f5a..2a7662e8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinition.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinition.java @@ -24,7 +24,7 @@ import static ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants.SEARCH_REQUEST; @Service -public class TaskDefinition implements Runnable{ +public class TaskDefinition implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(TaskDefinition.class); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseMessage.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseMessage.java index 659d8d13..8be90f24 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseMessage.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseMessage.java @@ -11,7 +11,7 @@ * ApiResponseMessage */ @Validated -@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-11T13:04:32.545-08:00") +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-11T13:04:32.545-08:00") public class ApiResponseMessage { @JsonProperty("message") diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseModel.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseModel.java index 490da07f..53b508f8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseModel.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/ApiResponseModel.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; +import jakarta.validation.Valid; -import javax.validation.Valid; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/DateUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/DateUtils.java new file mode 100644 index 00000000..e197f73a --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/DateUtils.java @@ -0,0 +1,40 @@ +package ca.bc.gov.educ.api.batchgraduation.util; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; + +public class DateUtils { + + private DateUtils(){} + + public static LocalDate toLocalDate(Date date) { + if(date == null) return null; + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + } + + public static LocalDateTime toLocalDateTime(Date date) { + if(date == null) return null; + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDateTime(); + } + + public static Date toDate(LocalDate localDate) { + if(localDate == null) return null; + return Date.from(localDate.atStartOfDay() + .atZone(ZoneId.systemDefault()) + .toInstant()); + } + + public static Date toDate(LocalDateTime localDateTime) { + if(localDateTime == null) return null; + return Date.from(localDateTime + .atZone(ZoneId.systemDefault()) + .toInstant()); + } + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java index 822311b8..60d0cf19 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java @@ -3,12 +3,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.module.SimpleModule; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import java.io.IOException; import java.io.InputStream; import java.time.LocalDate; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/LogHelper.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/LogHelper.java index 018f0cc1..f396c36c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/LogHelper.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/LogHelper.java @@ -1,5 +1,7 @@ package ca.bc.gov.educ.api.batchgraduation.util; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import lombok.val; import org.apache.commons.lang3.StringUtils; @@ -9,8 +11,6 @@ import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.time.Instant; import java.util.HashMap; import java.util.List; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BlankDistributionRunWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BlankDistributionRunWriter.java index 4823a237..cc04484b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BlankDistributionRunWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BlankDistributionRunWriter.java @@ -4,11 +4,10 @@ import ca.bc.gov.educ.api.batchgraduation.model.BlankDistributionSummaryDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Value; -import java.util.List; - public class BlankDistributionRunWriter implements ItemWriter { private static final Logger LOGGER = LoggerFactory.getLogger(BlankDistributionRunWriter.class); @@ -17,9 +16,9 @@ public class BlankDistributionRunWriter implements ItemWriter list) throws Exception { + public void write(Chunk list) { if(!list.isEmpty()) { - BlankCredentialDistribution cred = list.get(0); + BlankCredentialDistribution cred = list.getItems().get(0); summaryDTO.increment(cred.getCredentialTypeCode()); LOGGER.debug("Left : {}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunWriter.java index 09b2555b..542ceb6c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunWriter.java @@ -7,12 +7,11 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParameters; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import java.util.List; - public class DistributionRunWriter implements ItemWriter { private static final Logger LOGGER = LoggerFactory.getLogger(DistributionRunWriter.class); @@ -28,9 +27,9 @@ public class DistributionRunWriter implements ItemWriter list) throws Exception { + public void write(Chunk list) { if(!list.isEmpty()) { - StudentCredentialDistribution cred = list.get(0); + StudentCredentialDistribution cred = list.getItems().get(0); summaryDTO.increment(cred.getPaperType()); // save StudentCredentialDistribution diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunYearlyNonGradWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunYearlyNonGradWriter.java index c2124f48..cfdcb3c5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunYearlyNonGradWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/DistributionRunYearlyNonGradWriter.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.api.batchgraduation.writer; import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import java.util.List; @@ -8,13 +9,13 @@ public class DistributionRunYearlyNonGradWriter extends BaseYearEndWriter implements ItemWriter> { @Override - public void write(List> list) { + public void write(Chunk> list) { if (!list.isEmpty()) { summaryDTO.setCredentialCounter("YED4", summaryDTO.getGlobalList().size()); // save StudentCredentialDistributions String jobType = jobParameters.getString("jobType"); - List scdList = list.get(0); + List scdList = list.getItems().get(0); if (scdList != null && !scdList.isEmpty()) { scdList.forEach(scd -> distributionService.saveStudentCredentialDistribution(summaryDTO.getBatchId(), jobType, scd)); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/PsiDistributionRunWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/PsiDistributionRunWriter.java index faaa8d7b..7cd852c7 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/PsiDistributionRunWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/PsiDistributionRunWriter.java @@ -4,11 +4,10 @@ import ca.bc.gov.educ.api.batchgraduation.model.PsiDistributionSummaryDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Value; -import java.util.List; - public class PsiDistributionRunWriter implements ItemWriter { private static final Logger LOGGER = LoggerFactory.getLogger(PsiDistributionRunWriter.class); @@ -17,11 +16,10 @@ public class PsiDistributionRunWriter implements ItemWriter list) throws Exception { + public void write(Chunk list) throws Exception { if(!list.isEmpty()) { summaryDTO.increment("YED4"); LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } } - } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java index f20bf87a..e614d5d4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegGradAlgBatchPerformanceWriter.java @@ -1,19 +1,18 @@ package ca.bc.gov.educ.api.batchgraduation.writer; -import java.util.List; - +import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import ca.bc.gov.educ.api.batchgraduation.model.GraduationStudentRecord; +import org.springframework.batch.item.Chunk; public class RegGradAlgBatchPerformanceWriter extends BaseWriter { private static final Logger LOGGER = LoggerFactory.getLogger(RegGradAlgBatchPerformanceWriter.class); @Override - public void write(List list) throws Exception { + public void write(Chunk list) { if(!list.isEmpty()) { - GraduationStudentRecord gradStatus = list.get(0); + GraduationStudentRecord gradStatus = list.getItems().get(0); saveBatchStatus(gradStatus); LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegenerateCertificateRunWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegenerateCertificateRunWriter.java index 007aad9e..4d074491 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegenerateCertificateRunWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/RegenerateCertificateRunWriter.java @@ -1,14 +1,12 @@ package ca.bc.gov.educ.api.batchgraduation.writer; -import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmResponse; import ca.bc.gov.educ.api.batchgraduation.model.AlgorithmSummaryDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Value; -import java.util.List; - public class RegenerateCertificateRunWriter implements ItemWriter { private static final Logger LOGGER = LoggerFactory.getLogger(RegenerateCertificateRunWriter.class); @@ -17,7 +15,7 @@ public class RegenerateCertificateRunWriter implements ItemWriter { AlgorithmSummaryDTO summaryDTO; @Override - public void write(List list) throws Exception { + public void write(Chunk list) { if(!list.isEmpty()) { LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java index f8ae07f4..fe4a717b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/TvrRunBatchPerformanceWriter.java @@ -4,10 +4,9 @@ import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; - public class TvrRunBatchPerformanceWriter extends BaseWriter { private static final Logger LOGGER = LoggerFactory.getLogger(TvrRunBatchPerformanceWriter.class); @@ -17,9 +16,9 @@ public class TvrRunBatchPerformanceWriter extends BaseWriter { GradBatchHistoryService gradBatchHistoryService; @Override - public void write(List list) throws Exception { + public void write(Chunk list) throws Exception { if(!list.isEmpty()) { - GraduationStudentRecord gradStatus = list.get(0); + GraduationStudentRecord gradStatus = list.getItems().get(0); saveBatchStatus(gradStatus); LOGGER.debug("Left:{}\n",summaryDTO.getReadCount()-summaryDTO.getProcessedCount()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/UserScheduledWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/UserScheduledWriter.java index 6ba82a6a..7094ee71 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/UserScheduledWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/UserScheduledWriter.java @@ -3,16 +3,15 @@ import ca.bc.gov.educ.api.batchgraduation.model.UserScheduledJobs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; -import java.util.List; - public class UserScheduledWriter implements ItemWriter { private static final Logger LOGGER = LoggerFactory.getLogger(UserScheduledWriter.class); @Override - public void write(List list) throws Exception { + public void write(Chunk list) { LOGGER.debug("Recording Distribution Processed Data"); if(!list.isEmpty()) { LOGGER.debug("Rescheduling Done\n"); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java index 51f6608f..5535e910 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java @@ -1,26 +1,35 @@ package ca.bc.gov.educ.api.batchgraduation.config; -import org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobLauncher; +import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; @Configuration @Profile("test") @Component -public class BatchConfig extends DefaultBatchConfigurer { +public class BatchConfig { @Bean(name = "asyncJobLauncher") public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exception { - SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); return jobLauncher; } + + @Bean + public ThreadPoolTaskScheduler threadPoolTaskScheduler(){ + ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); + threadPoolTaskScheduler.setPoolSize(5); + threadPoolTaskScheduler.setThreadNamePrefix( + "ThreadPoolTaskScheduler"); + return threadPoolTaskScheduler; + } } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherControllerTest.java index cad2a9d8..64c4465b 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherControllerTest.java @@ -234,7 +234,7 @@ public void testlaunchUserReqDisRunSpecialJob() { builder.addLong(TIME, System.currentTimeMillis()).toJobParameters(); builder.addString(JOB_TRIGGER, MANUAL); builder.addString(JOB_TYPE, DISTRUNUSER); - builder.addString("LocalDownload",null); + builder.addString("LocalDownload","Y"); StudentSearchRequest req = new StudentSearchRequest(); req.setPens(Arrays.asList("123213123")); try { @@ -296,7 +296,7 @@ public void testlaunchUserReqBlankDisRunSpecialJob_1() { builder.addString(JOB_TRIGGER, MANUAL); builder.addString(JOB_TYPE, DISTRUNUSER); builder.addString(CREDENTIALTYPE,"OT"); - builder.addString("LocalDownload",null); + builder.addString("LocalDownload","Y"); BlankCredentialRequest req = new BlankCredentialRequest(); req.setCredentialTypeCode(Arrays.asList("123213123")); @@ -318,7 +318,7 @@ public void testlaunchUserReqBlankDisRunSpecialJob_2() { builder.addString(JOB_TRIGGER, MANUAL); builder.addString(JOB_TYPE, DISTRUNUSER); builder.addString(CREDENTIALTYPE,"OT"); - builder.addString("LocalDownload",null); + builder.addString("LocalDownload","Y"); BlankCredentialRequest req = new BlankCredentialRequest(); req.setSchoolOfRecords(Arrays.asList("123213123")); @@ -340,7 +340,7 @@ public void testlaunchUserReqBlankDisRunSpecialJob_3() { builder.addString(JOB_TRIGGER, MANUAL); builder.addString(JOB_TYPE, DISTRUNUSER); builder.addString(CREDENTIALTYPE,"OT"); - builder.addString("LocalDownload",null); + builder.addString("LocalDownload","Y"); BlankCredentialRequest req = new BlankCredentialRequest(); req.setCredentialTypeCode(new ArrayList<>()); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java index c7b2f5b4..a3925b9a 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.junit.After; import org.junit.Before; @@ -27,6 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; +import java.time.LocalDateTime; import java.util.*; import java.util.function.Consumer; @@ -86,11 +88,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -114,13 +116,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setGlobalList(scdList); jobContext.put("distributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -135,7 +137,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -209,7 +211,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); Mockito.when(restUtils.mergeAndUpload(121L, distributionRequest,"YEARENDDIST",null)).thenReturn(new DistributionResponse()); - distributionRunCompletionNotificationListener.afterJob(ex); + distributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java index e4dd3b2b..1653e965 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,7 +24,11 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; -import java.util.*; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.MockitoAnnotations.openMocks; @@ -63,11 +68,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -78,13 +83,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setErrors(new HashMap<>()); jobContext.put("summaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -99,11 +104,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - gradRunCompletionNotificationListener.afterJob(ex); + gradRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } @@ -115,11 +120,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -136,13 +141,13 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, summaryDTO.setErrors(mapP); jobContext.put("regGradAlgSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -157,11 +162,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - gradRunCompletionNotificationListener.afterJob(ex); + gradRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java index ae673fd9..acd17ef5 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,7 +24,11 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; -import java.util.*; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.MockitoAnnotations.openMocks; @@ -63,11 +68,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -78,13 +83,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setErrors(new HashMap<>()); jobContext.put("summaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -99,11 +104,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - specialRunCompletionNotificationListener.afterJob(ex); + specialRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } @@ -116,11 +121,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, builder.addString(JOB_TYPE, "TVRRUN"); builder.addString("userScheduled", UUID.randomUUID().toString()); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -138,13 +143,13 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, summaryDTO.setErrors(mapP); jobContext.put("spcRunAlgSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -159,11 +164,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - specialRunCompletionNotificationListener.afterJob(ex); + specialRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java index d0f6f252..5c7c7de5 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,7 +24,11 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; -import java.util.*; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.MockitoAnnotations.openMocks; @@ -63,11 +68,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -78,13 +83,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setErrors(new HashMap<>()); jobContext.put("summaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -99,11 +104,11 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - tvrRunJobCompletionNotificationListener.afterJob(ex); + tvrRunJobCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } @@ -115,11 +120,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, builder.addString(JOB_TRIGGER, "MANUAL"); builder.addString(JOB_TYPE, "TVRRUN"); - JobExecution ex = new JobExecution(121L); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); + JobExecution jobExecution = new JobExecution(121L); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); ExecutionContext jobContext = new ExecutionContext(); @@ -136,13 +141,13 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, summaryDTO.setErrors(mapP); jobContext.put("tvrRunSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); @@ -157,11 +162,11 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - tvrRunJobCompletionNotificationListener.afterJob(ex); + tvrRunJobCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java index d200ff16..5cbadf42 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java @@ -1,11 +1,15 @@ package ca.bc.gov.educ.api.batchgraduation.listener; import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; -import ca.bc.gov.educ.api.batchgraduation.model.*; +import ca.bc.gov.educ.api.batchgraduation.model.BlankCredentialDistribution; +import ca.bc.gov.educ.api.batchgraduation.model.BlankDistributionSummaryDTO; +import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; +import ca.bc.gov.educ.api.batchgraduation.model.StudentCredentialDistribution; import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.junit.After; import org.junit.Before; @@ -26,13 +30,13 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.MockitoAnnotations.openMocks; @RunWith(SpringRunner.class) @@ -88,12 +92,12 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString("credentialType","OT"); builder.addString("userScheduled", UUID.randomUUID().toString()); - JobExecution ex = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), builder.toJobParameters(), null); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); - ExecutionContext jobContext = ex.getExecutionContext(); + JobExecution jobExecution = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), 121L, builder.toJobParameters()); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); + ExecutionContext jobContext = jobExecution.getExecutionContext(); List scdList = new ArrayList<>(); BlankCredentialDistribution scd = new BlankCredentialDistribution(); @@ -129,13 +133,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setGlobalList(scdList); jobContext.put("blankDistributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); String credentialType = jobParameters.getString("credentialType"); @@ -151,7 +155,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -165,7 +169,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - userReqBlankDistributionRunCompletionNotificationListener.afterJob(ex); + userReqBlankDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } @@ -178,12 +182,12 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe builder.addString(JOB_TYPE, "TVRRUN"); builder.addString("credentialType","OC"); - JobExecution ex = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), builder.toJobParameters(), null); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); - ExecutionContext jobContext = ex.getExecutionContext(); + JobExecution jobExecution = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), 121L, builder.toJobParameters()); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); + ExecutionContext jobContext = jobExecution.getExecutionContext(); List scdList = new ArrayList<>(); BlankCredentialDistribution scd = new BlankCredentialDistribution(); @@ -219,13 +223,13 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe summaryDTO.setGlobalList(scdList); jobContext.put("blankDistributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); String credentialType = jobParameters.getString("credentialType"); @@ -241,7 +245,7 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -255,7 +259,7 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - userReqBlankDistributionRunCompletionNotificationListener.afterJob(ex); + userReqBlankDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java index 9fa814e5..c526caf9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.junit.After; import org.junit.Before; @@ -27,6 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -91,12 +93,12 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString("credentialType","OT"); builder.addString("userScheduled", UUID.randomUUID().toString()); - JobExecution ex = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), builder.toJobParameters(), null); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); - ExecutionContext jobContext = ex.getExecutionContext(); + JobExecution jobExecution = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), 121L, builder.toJobParameters()); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); + ExecutionContext jobContext = jobExecution.getExecutionContext(); List scdList = new ArrayList<>(); StudentCredentialDistribution scd = new StudentCredentialDistribution(); @@ -137,13 +139,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setGlobalList(scdList); jobContext.put("distributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); String credentialType = jobParameters.getString("credentialType"); @@ -159,7 +161,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -193,7 +195,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut Mockito.when(graduationReportService.getTranscriptList(null)).thenReturn(Mono.just(tList)); Mockito.when(graduationReportService.getCertificateList(null)).thenReturn(Mono.just(cList)); Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); - userReqDistributionRunCompletionNotificationListener.afterJob(ex); + userReqDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } @@ -206,12 +208,12 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe builder.addString(JOB_TYPE, "TVRRUN"); builder.addString("credentialType","OC"); - JobExecution ex = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), builder.toJobParameters(), null); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); - ExecutionContext jobContext = ex.getExecutionContext(); + JobExecution jobExecution = new JobExecution(new JobInstance(121L,"UserReqDistributionBatchJob"), 121L, builder.toJobParameters()); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); + ExecutionContext jobContext = jobExecution.getExecutionContext(); List scdList = new ArrayList<>(); StudentCredentialDistribution scd = new StudentCredentialDistribution(); @@ -252,13 +254,13 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe summaryDTO.setGlobalList(scdList); jobContext.put("distributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); String credentialType = jobParameters.getString("credentialType"); @@ -274,7 +276,7 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -329,7 +331,7 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe Mockito.when(graduationReportService.getCertificateList(null)).thenReturn(Mono.just(cList)); Mockito.when(parallelDataFetch.fetchDistributionRequiredData(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); Mockito.when(parallelDataFetch.fetchDistributionRequiredDataYearly(summaryDTO.getAccessToken())).thenReturn(Mono.just(dp)); - userReqDistributionRunCompletionNotificationListener.afterJob(ex); + userReqDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java index 321e025a..05647ebe 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java @@ -1,11 +1,14 @@ package ca.bc.gov.educ.api.batchgraduation.listener; import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; -import ca.bc.gov.educ.api.batchgraduation.model.*; +import ca.bc.gov.educ.api.batchgraduation.model.PsiCredentialDistribution; +import ca.bc.gov.educ.api.batchgraduation.model.PsiDistributionSummaryDTO; +import ca.bc.gov.educ.api.batchgraduation.model.ResponseObj; import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GraduationReportService; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; import org.junit.After; import org.junit.Before; @@ -26,6 +29,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -87,12 +91,12 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut builder.addString("transmissionType","FTP"); builder.addString("userScheduled", UUID.randomUUID().toString()); - JobExecution ex = new JobExecution(new JobInstance(121L,"psiDistributionBatchJob"), builder.toJobParameters(), null); - ex.setStatus(BatchStatus.COMPLETED); - ex.setStartTime(new Date()); - ex.setEndTime(new Date()); - ex.setId(121L); - ExecutionContext jobContext = ex.getExecutionContext(); + JobExecution jobExecution = new JobExecution(new JobInstance(121L,"psiDistributionBatchJob"), 121L, builder.toJobParameters()); + jobExecution.setStatus(BatchStatus.COMPLETED); + jobExecution.setStartTime(LocalDateTime.now()); + jobExecution.setEndTime(LocalDateTime.now()); + jobExecution.setId(121L); + ExecutionContext jobContext = jobExecution.getExecutionContext(); final UUID studentID = UUID.randomUUID(); List scdList = new ArrayList<>(); @@ -116,13 +120,13 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut summaryDTO.setGlobalList(scdList); jobContext.put("psiDistributionSummaryDTO", summaryDTO); - JobParameters jobParameters = ex. getJobParameters(); + JobParameters jobParameters = jobExecution. getJobParameters(); int failedRecords = summaryDTO.getErrors().size(); Long processedStudents = summaryDTO.getProcessedCount(); Long expectedStudents = summaryDTO.getReadCount(); - String status = ex.getStatus().toString(); - Date startTime = ex.getStartTime(); - Date endTime = ex.getEndTime(); + String status = jobExecution.getStatus().toString(); + Date startTime = DateUtils.toDate(jobExecution.getStartTime()); + Date endTime = DateUtils.toDate(jobExecution.getEndTime()); String jobTrigger = jobParameters.getString("jobTrigger"); String jobType = jobParameters.getString("jobType"); String transmissionType = jobParameters.getString("transmissionType"); @@ -138,7 +142,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); - ex.setExecutionContext(jobContext); + jobExecution.setExecutionContext(jobContext); List cList = new ArrayList<>(); cList.add(scd); @@ -149,7 +153,7 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ResponseObj obj = new ResponseObj(); obj.setAccess_token("asdasd"); Mockito.when(restUtils.getTokenResponseObject()).thenReturn(obj); - userReqPsiDistributionRunCompletionNotificationListener.afterJob(ex); + userReqPsiDistributionRunCompletionNotificationListener.afterJob(jobExecution); assertThat(ent.getActualStudentsProcessed()).isEqualTo(10); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinitionTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinitionTest.java index 505c7514..cbca65e9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinitionTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskDefinitionTest.java @@ -1,11 +1,16 @@ package ca.bc.gov.educ.api.batchgraduation.service; import ca.bc.gov.educ.api.batchgraduation.entity.UserScheduledJobsEntity; -import ca.bc.gov.educ.api.batchgraduation.model.*; +import ca.bc.gov.educ.api.batchgraduation.model.BlankCredentialRequest; +import ca.bc.gov.educ.api.batchgraduation.model.PsiCredentialRequest; +import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; +import ca.bc.gov.educ.api.batchgraduation.model.Task; import ca.bc.gov.educ.api.batchgraduation.repository.UserScheduledJobsRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import net.javacrumbs.shedlock.spring.LockableTaskScheduler; import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.springframework.batch.core.Job; @@ -16,15 +21,12 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.scheduling.support.CronTrigger; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import static org.junit.Assert.assertNotNull; @@ -62,6 +64,16 @@ public class TaskDefinitionTest { @MockBean UserScheduledJobsRepository userScheduledJobsRepository; + @BeforeEach + public void setup() { + taskScheduler.schedule(taskDefinition, new CronTrigger("0 12 23 5 7 *", TimeZone.getTimeZone(TimeZone.getDefault().getID()))); + } + + @AfterEach + public void close() { + + } + @Test public void testRun() { Task task = new Task(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskSchedulingServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskSchedulingServiceTest.java index 4ce3edac..157855f6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskSchedulingServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/TaskSchedulingServiceTest.java @@ -7,14 +7,15 @@ import ca.bc.gov.educ.api.batchgraduation.repository.UserScheduledJobsRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; +import net.javacrumbs.shedlock.spring.LockableTaskScheduler; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.support.CronTrigger; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -38,8 +39,9 @@ public class TaskSchedulingServiceTest { @Autowired TaskDefinition taskDefinition; - @Autowired - TaskScheduler taskScheduler; + @MockBean + @Qualifier("lockableTaskScheduler") + LockableTaskScheduler taskScheduler; @Autowired JsonTransformer jsonTransformer; From 3da2d9e5a4ed5523743b94b59005761f71da231d Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 30 Aug 2023 12:41:04 -0600 Subject: [PATCH 05/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- api/pom.xml | 6 +++++- .../batchgraduation/config/BatchConfig.java | 20 +++++++++++++++++++ .../batchgraduation/config/BatchDbConfig.java | 11 ++++++---- api/src/main/resources/application.yaml | 2 +- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 2d2db461..4d8cf20c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -136,7 +136,11 @@ org.springframework.boot spring-boot-starter-aop - + + org.hibernate.validator + hibernate-validator + 8.0.0.Final + org.springframework.boot spring-boot-starter-actuator diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java index 9b1084fb..c3c53202 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchConfig.java @@ -3,17 +3,28 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.core.task.SyncTaskExecutor; import org.springframework.stereotype.Component; +import org.springframework.transaction.TransactionManager; + +import javax.sql.DataSource; @Configuration @Profile("!test") @Component public class BatchConfig { + @Autowired + DataSource dataSource; + + @Autowired + TransactionManager transactionManager; + @Bean(name = "asyncJobLauncher") public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exception { TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); @@ -22,4 +33,13 @@ public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exceptio jobLauncher.afterPropertiesSet(); return jobLauncher; } + + @Bean(name = "jobLauncher") + public JobLauncher jobLauncher(JobRepository jobRepository) throws Exception { + TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); + jobLauncher.setJobRepository(jobRepository); + jobLauncher.setTaskExecutor(new SyncTaskExecutor()); + jobLauncher.afterPropertiesSet(); + return jobLauncher; + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java index db31b159..d7484ae7 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java @@ -2,6 +2,7 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -62,7 +63,8 @@ public class BatchDbConfig { @Primary @Bean - public DataSource batchDataSource() { + @Qualifier("datasource") + public DataSource dataSource() { HikariConfig config = new HikariConfig(); config.setDriverClassName(driverClassName); @@ -88,14 +90,14 @@ public DataSource batchDataSource() { public LocalContainerEntityManagerFactoryBean batchEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(batchDataSource()); + em.setDataSource(dataSource()); em.setPackagesToScan("ca.bc.gov.educ.api.batchgraduation.entity"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); HashMap properties = new HashMap<>(); properties.put("hibernate.hbm2ddl.auto", "none"); - properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle12cDialect"); + properties.put("hibernate.dialect", "org.hibernate.dialect.OracleDialect"); properties.put("hibernate.format_sql", "true"); properties.put("hibernate.show_sql", "false"); em.setJpaPropertyMap(properties); @@ -107,7 +109,8 @@ public LocalContainerEntityManagerFactoryBean batchEntityManager() { @Primary @Bean - public PlatformTransactionManager batchTransactionManager() { + @Qualifier("transactionManager") + public PlatformTransactionManager transactionManager() { JpaTransactionManager transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory(batchEntityManager().getObject()); return transactionManager; diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index dbef4df1..c691f348 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -17,7 +17,7 @@ spring: driver-class: oracle.jdbc.driver.OracleDriver jpa: show-sql: true - database-platform: org.hibernate.dialect.Oracle12cDialect + database-platform: org.hibernate.dialect.OracleDialect hibernate: ddl-auto: none mvc: From 6b6574ef7836ac671c72c49f9b35e9d9ceaece5c Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 30 Aug 2023 12:43:34 -0600 Subject: [PATCH 06/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .github/workflows/on.pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml index 643f2683..6608dab2 100644 --- a/.github/workflows/on.pr.yml +++ b/.github/workflows/on.pr.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 + - name: Set up JDK 18 uses: actions/setup-java@v1 with: java-version: 18 From 9db11a3c87b1066d138fb0922b1b72603ca7d3d0 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 30 Aug 2023 15:59:52 -0600 Subject: [PATCH 07/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .../entity/BatchJobExecutionParamEntity.java | 22 +++++-------------- .../entity/BatchStepExecutionEntity.java | 9 +++++--- api/src/main/resources/application.yaml | 2 +- .../V1.0.1__DDL-CREATE_TABLE-spring_batch.sql | 10 ++++----- ...PDATE_TABLE-batch_job_execution_params.sql | 2 +- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java index 6866b218..e118ed4e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java @@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode; import java.io.Serializable; -import java.time.Instant; @Data @Entity @@ -20,24 +19,15 @@ public class BatchJobExecutionParamEntity implements Serializable { @Column(name = "JOB_EXECUTION_ID", nullable = false) private Long jobExecutionId; - @Column(name = "TYPE_CD", nullable = false, length = 6) - private String typeCd; + @Column(name = "PARAMETER_TYPE", nullable = false, length = 32) + private String parameterType; @Id - @Column(name = "KEY_NAME", nullable = false, length = 100) - private String keyName; + @Column(name = "PARAMETER_NAME", nullable = false, length = 100) + private String parameterName; - @Column(name = "STRING_VAL", length = 1000) - private String stringVal; - - @Column(name = "DATE_VAL") - private Instant dateVal; - - @Column(name = "LONG_VAL") - private Long longVal; - - @Column(name = "DOUBLE_VAL") - private Long doubleVal; + @Column(name = "PARAMETER_VALUE", length = 1000) + private String parameterValue; @Column(name = "IDENTIFYING", nullable = false) private Boolean identifying = false; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java index d17a1e1f..eefb4f1e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java @@ -26,8 +26,8 @@ public class BatchStepExecutionEntity { @Column(name = "STEP_NAME", nullable = false, length = 100) private String stepName; - @Column(name = "START_TIME", nullable = false) - private Instant startTime; + @Column(name = "START_TIME") + private Instant startTime = Instant.now(); @Column(name = "END_TIME") private Instant endTime; @@ -66,6 +66,9 @@ public class BatchStepExecutionEntity { private String exitMessage; @Column(name = "LAST_UPDATED") - private Instant lastUpdated; + private Instant lastUpdated = Instant.now(); + + @Column(name = "CREATE_TIME") + private Instant createTime = Instant.now(); } \ No newline at end of file diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index c691f348..d44ed4c7 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -43,7 +43,7 @@ spring: isolation-level-for-create: READ_COMMITTED flyway: enabled: ${ENABLE_FLYWAY} - baseline-on-migrate: false + baseline-on-migrate: true table: FLYWAY_SCHEMA_HISTORY url: ${CONNECTION_STRING} schema: ${USERNAME} diff --git a/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql b/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql index 1df8b494..f7e2ab1f 100644 --- a/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql +++ b/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql @@ -26,12 +26,9 @@ CREATE TABLE BATCH_JOB_EXECUTION ( CREATE TABLE BATCH_JOB_EXECUTION_PARAMS ( JOB_EXECUTION_ID NUMBER(19,0) NOT NULL , - TYPE_CD VARCHAR2(6 char) NOT NULL , - KEY_NAME VARCHAR2(100 char) NOT NULL , - STRING_VAL VARCHAR2(250 char) , - DATE_VAL TIMESTAMP DEFAULT NULL , - LONG_VAL NUMBER(19,0) , - DOUBLE_VAL NUMBER , + PARAMETER_TYPE VARCHAR2(32 char) NOT NULL , + PARAMETER_NAME VARCHAR2(100 char) NOT NULL , + PARAMETER_VALUE VARCHAR2(1000 char) , IDENTIFYING CHAR(1) NOT NULL , constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) @@ -56,6 +53,7 @@ CREATE TABLE BATCH_STEP_EXECUTION ( EXIT_CODE VARCHAR2(2500 char) , EXIT_MESSAGE VARCHAR2(2500 char) , LAST_UPDATED TIMESTAMP, + CREATE_TIME TIMESTAMP, constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID) references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) ) ; diff --git a/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql b/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql index 0caac72c..2afa98d1 100644 --- a/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql +++ b/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql @@ -1 +1 @@ -ALTER TABLE API_GRAD_BATCH.BATCH_JOB_EXECUTION_PARAMS MODIFY STRING_VAL VARCHAR2(1000); +ALTER TABLE API_GRAD_BATCH.BATCH_JOB_EXECUTION_PARAMS MODIFY PARAMETER_VALUE VARCHAR2(1000); From e6fe45df74f5eefe18e9426156928831c0719b09 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 31 Aug 2023 12:20:23 -0600 Subject: [PATCH 08/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .../batchgraduation/config/BatchDbConfig.java | 2 +- .../config/WebSecurityConfiguration.java | 5 --- .../controller/JobLauncherController.java | 35 +++++++++++++++ .../BatchStepExecutionContextEntity.java | 2 +- .../batchgraduation/model/BaseSummaryDTO.java | 4 +- .../model/StudentCredentialDistribution.java | 4 +- .../reader/BasePartitioner.java | 4 +- .../reader/DistributionRunPartitioner.java | 21 ++++++--- .../DistributionRunPartitionerUserReq.java | 2 +- ...istributionRunSupplementalPartitioner.java | 2 +- .../DistributionRunYearlyPartitioner.java | 2 +- .../batchgraduation/util/JsonTransformer.java | 3 +- .../DefaultExecutionContextSerializer.java | 36 ++++++++++++++++ api/src/main/resources/application.yaml | 2 +- .../V1.0.1__DDL-CREATE_TABLE-spring_batch.sql | 10 +++-- ...PDATE_TABLE-batch_job_execution_params.sql | 2 +- ....40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql | 43 +++++++++++++++++++ 17 files changed, 152 insertions(+), 27 deletions(-) create mode 100644 api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java create mode 100644 api/src/main/resources/db/migration/1.0/V1.0.40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java index d7484ae7..b28c7c11 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/BatchDbConfig.java @@ -109,7 +109,7 @@ public LocalContainerEntityManagerFactoryBean batchEntityManager() { @Primary @Bean - @Qualifier("transactionManager") + @Qualifier("batchTransactionManager") public PlatformTransactionManager transactionManager() { JpaTransactionManager transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory(batchEntityManager().getObject()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java index 960061cf..1e070e5e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/config/WebSecurityConfiguration.java @@ -7,17 +7,12 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.SecurityFilterChain; @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) public class WebSecurityConfiguration { - public WebSecurityConfiguration() { - SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); - } - @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http 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 1e646cf8..799a82b8 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 @@ -453,6 +453,11 @@ public ResponseEntity launchDistributionRunJob() { JobExecution jobExecution = asyncJobLauncher.run(jobRegistry.getJob("DistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); DistributionSummaryDTO summaryDTO = (DistributionSummaryDTO)jobContext.get(DISDTO); + if(summaryDTO == null) { + summaryDTO = new DistributionSummaryDTO(); + jobContext.put(DISDTO, summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { @@ -478,6 +483,11 @@ public ResponseEntity launchYearlyDistributionRunJob(@Re JobExecution jobExecution = asyncJobLauncher.run(jobRegistry.getJob("YearlyDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); DistributionSummaryDTO summaryDTO = (DistributionSummaryDTO)jobContext.get(DISDTO); + if(summaryDTO == null) { + summaryDTO = new DistributionSummaryDTO(); + jobContext.put(DISDTO, summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { @@ -503,6 +513,11 @@ public ResponseEntity launchSupplementalDistributionRunJ JobExecution jobExecution = asyncJobLauncher.run(jobRegistry.getJob("SupplementalDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); DistributionSummaryDTO summaryDTO = (DistributionSummaryDTO)jobContext.get(DISDTO); + if(summaryDTO == null) { + summaryDTO = new DistributionSummaryDTO(); + jobContext.put(DISDTO, summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { @@ -528,6 +543,11 @@ public ResponseEntity launchYearlyNonGradDistributionRun JobExecution jobExecution = asyncJobLauncher.run(jobRegistry.getJob("YearlyNonGradDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); DistributionSummaryDTO summaryDTO = (DistributionSummaryDTO)jobContext.get(DISDTO); + if(summaryDTO == null) { + summaryDTO = new DistributionSummaryDTO(); + jobContext.put(DISDTO, summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { @@ -573,6 +593,11 @@ public ResponseEntity launchUserReqDisRunSpecialJob(@Pat JobExecution jobExecution = jobLauncher.run(jobRegistry.getJob("UserReqDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); DistributionSummaryDTO summaryDTO = (DistributionSummaryDTO)jobContext.get(DISDTO); + if(summaryDTO == null) { + summaryDTO = new DistributionSummaryDTO(); + jobContext.put(DISDTO, summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { DistributionSummaryDTO summaryDTO = new DistributionSummaryDTO(); @@ -605,6 +630,11 @@ public ResponseEntity launchUserReqBlankDisRunSpeci JobExecution jobExecution = jobLauncher.run(jobRegistry.getJob("blankDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); BlankDistributionSummaryDTO summaryDTO = (BlankDistributionSummaryDTO) jobContext.get("blankDistributionSummaryDTO"); + if(summaryDTO == null) { + summaryDTO = new BlankDistributionSummaryDTO(); + jobContext.put("blankDistributionSummaryDTO", summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { BlankDistributionSummaryDTO summaryDTO = new BlankDistributionSummaryDTO(); @@ -639,6 +669,11 @@ public ResponseEntity launchUserReqPsiDisRunSpecialJo JobExecution jobExecution = asyncJobLauncher.run(jobRegistry.getJob("psiDistributionBatchJob"), builder.toJobParameters()); ExecutionContext jobContext = jobExecution.getExecutionContext(); PsiDistributionSummaryDTO summaryDTO = (PsiDistributionSummaryDTO)jobContext.get("psiDistributionSummaryDTO"); + if(summaryDTO == null) { + summaryDTO = new PsiDistributionSummaryDTO(); + jobContext.put("psiDistributionSummaryDTO", summaryDTO); + } + summaryDTO.setBatchId(jobExecution.getId()); return ResponseEntity.ok(summaryDTO); } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException e) { PsiDistributionSummaryDTO summaryDTO = new PsiDistributionSummaryDTO(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java index 50ebb294..0d0e684f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionContextEntity.java @@ -12,7 +12,7 @@ public class BatchStepExecutionContextEntity { @Column(name = "STEP_EXECUTION_ID", nullable = false) private Long id; - @Column(name = "SHORT_CONTEXT", nullable = false, length = 2500) + @Column(name = "SHORT_CONTEXT", length = 2500) private String shortContext; @Lob diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BaseSummaryDTO.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BaseSummaryDTO.java index 6c4b8a3f..98175f4b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BaseSummaryDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BaseSummaryDTO.java @@ -3,8 +3,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; +import java.io.Serializable; + @Data -public class BaseSummaryDTO { +public class BaseSummaryDTO implements Serializable { private Long batchId; // partition 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 59b73d5a..ffd4aaba 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,11 +2,12 @@ import lombok.Data; +import java.io.Serializable; import java.util.List; import java.util.UUID; @Data -public class StudentCredentialDistribution { +public class StudentCredentialDistribution implements Serializable { private UUID id; private String credentialTypeCode; @@ -25,4 +26,5 @@ public class StudentCredentialDistribution { private String program; private String studentGrade; private List nonGradReasons; + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index e63f587c..a6188c77 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -177,7 +177,7 @@ void filterStudentCredentialDistribution(List cre LOGGER.debug("Total {} selected after filter", credentialList.size()); } - Map getStringExecutionContextMap(int gridSize, List credentialList, String credentialType, Logger logger) { + Map getStringExecutionContextMap(int gridSize, List credentialList, String credentialType) { filterStudentCredentialDistribution(credentialList); sortStudentCredentialDistributionByNames(credentialList); int partitionSize = credentialList.size()/gridSize + 1; @@ -201,7 +201,7 @@ Map getStringExecutionContextMap(int gridSize, List partition(int gridSize) { } // Clean up existing reports before running new one + logger.debug("Delete School Reports for Monthly Distribution"); + long startTime = System.currentTimeMillis(); restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); + long endTime = System.currentTimeMillis(); + long diff = (endTime - startTime)/1000; + logger.debug("Old School Reports deleted in {} sec", diff); + startTime = System.currentTimeMillis(); + logger.debug("Retrieve students for Monthly Distribution"); Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); List credentialList = new ArrayList<>(); @@ -45,19 +52,21 @@ public Map partition(int gridSize) { credentialList.addAll(parallelDTO.transcriptList()); credentialList.addAll(parallelDTO.certificateList()); } + endTime = System.currentTimeMillis(); + diff = (endTime - startTime)/1000; + logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff); if(!credentialList.isEmpty()) { - LOGGER.debug("Total size of credential list: {}", credentialList.size()); // Filter deceased students out List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); if (!deceasedIDs.isEmpty()) { - LOGGER.debug("Deceased students: {}", deceasedIDs.size()); + logger.debug("Deceased students: {}", deceasedIDs.size()); credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); - LOGGER.debug("Revised size of credential list: {}", credentialList.size()); + logger.debug("Revised size of credential list: {}", credentialList.size()); } updateBatchJobHistory(createBatchJobHistory(), (long) credentialList.size()); - return getStringExecutionContextMap(gridSize, credentialList, null, LOGGER); + return getStringExecutionContextMap(gridSize, credentialList, null); } - LOGGER.info("No Credentials Found for Processing"); + logger.info("No Credentials Found for Processing"); return new HashMap<>(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java index 872be4c4..d989d458 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitionerUserReq.java @@ -33,7 +33,7 @@ public Map partition(int gridSize) { StudentSearchRequest req = getStudentSearchRequest(); List credentialList = restUtils.getStudentsForUserReqDisRun(credentialType,req,accessToken); if(!credentialList.isEmpty()) { - Map map = getStringExecutionContextMap(gridSize, credentialList, credentialType, LOGGER); + Map map = getStringExecutionContextMap(gridSize, credentialList, credentialType); LOGGER.info("Found {} in total running on {} partitions",credentialList.size(),map.size()); return map; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java index 3ad37ee6..1c54319b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java @@ -54,7 +54,7 @@ public Map partition(int gridSize) { filterByStudentSearchRequest(eligibleStudentSchoolDistricts); if(!eligibleStudentSchoolDistricts.isEmpty()) { updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size()); - return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null, logger); + return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null); } logger.info("No Credentials Found for Processing"); return new HashMap<>(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java index 9f979d64..4acd136c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyPartitioner.java @@ -46,7 +46,7 @@ public Map partition(int gridSize) { filterByStudentSearchRequest(eligibleStudentSchoolDistricts); if(!eligibleStudentSchoolDistricts.isEmpty()) { updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size()); - return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null, logger); + return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null); } logger.info("No Credentials Found for Processing"); return new HashMap<>(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java index 60d0cf19..316ccb98 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/JsonTransformer.java @@ -24,7 +24,8 @@ public class JsonTransformer implements Transformer { ObjectMapper objectMapper; @PostConstruct - void initMapper() { + public void initMapper() { + if(objectMapper == null) objectMapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule(); simpleModule.addSerializer(LocalDate.class, new GradLocalDateSerializer()); simpleModule.addSerializer(LocalDateTime.class, new GradLocalDateTimeSerializer()); diff --git a/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java b/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java new file mode 100644 index 00000000..c2c8dcde --- /dev/null +++ b/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java @@ -0,0 +1,36 @@ +package org.springframework.batch.core.repository.dao; + +import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; +import org.springframework.batch.core.repository.ExecutionContextSerializer; +import org.springframework.util.Assert; +import org.springframework.util.Base64Utils; +import org.springframework.util.SerializationUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Map; + +public class DefaultExecutionContextSerializer implements ExecutionContextSerializer { + + JsonTransformer jsonTransformer; + + public DefaultExecutionContextSerializer() { + jsonTransformer = new JsonTransformer(); + jsonTransformer.initMapper(); + } + + public void serialize(Map context, OutputStream out) throws IOException { + Assert.notNull(context, "context is required"); + Assert.notNull(out, "OutputStream is required"); + byte[] serializedContext = jsonTransformer.marshall(context).getBytes(); + String base64EncodedContext = Base64Utils.encodeToString(serializedContext); + out.write(base64EncodedContext.getBytes()); + } + + public Map deserialize(InputStream inputStream) throws IOException { + String base64EncodedContext = new String(inputStream.readAllBytes()); + byte[] decodedContext = Base64Utils.decodeFromString(base64EncodedContext); + return (Map)SerializationUtils.deserialize(decodedContext); + } +} diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index d44ed4c7..c691f348 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -43,7 +43,7 @@ spring: isolation-level-for-create: READ_COMMITTED flyway: enabled: ${ENABLE_FLYWAY} - baseline-on-migrate: true + baseline-on-migrate: false table: FLYWAY_SCHEMA_HISTORY url: ${CONNECTION_STRING} schema: ${USERNAME} diff --git a/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql b/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql index f7e2ab1f..1df8b494 100644 --- a/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql +++ b/api/src/main/resources/db/migration/1.0/V1.0.1__DDL-CREATE_TABLE-spring_batch.sql @@ -26,9 +26,12 @@ CREATE TABLE BATCH_JOB_EXECUTION ( CREATE TABLE BATCH_JOB_EXECUTION_PARAMS ( JOB_EXECUTION_ID NUMBER(19,0) NOT NULL , - PARAMETER_TYPE VARCHAR2(32 char) NOT NULL , - PARAMETER_NAME VARCHAR2(100 char) NOT NULL , - PARAMETER_VALUE VARCHAR2(1000 char) , + TYPE_CD VARCHAR2(6 char) NOT NULL , + KEY_NAME VARCHAR2(100 char) NOT NULL , + STRING_VAL VARCHAR2(250 char) , + DATE_VAL TIMESTAMP DEFAULT NULL , + LONG_VAL NUMBER(19,0) , + DOUBLE_VAL NUMBER , IDENTIFYING CHAR(1) NOT NULL , constraint JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) @@ -53,7 +56,6 @@ CREATE TABLE BATCH_STEP_EXECUTION ( EXIT_CODE VARCHAR2(2500 char) , EXIT_MESSAGE VARCHAR2(2500 char) , LAST_UPDATED TIMESTAMP, - CREATE_TIME TIMESTAMP, constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID) references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) ) ; diff --git a/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql b/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql index 2afa98d1..0caac72c 100644 --- a/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql +++ b/api/src/main/resources/db/migration/1.0/V1.0.20__DDL-UPDATE_TABLE-batch_job_execution_params.sql @@ -1 +1 @@ -ALTER TABLE API_GRAD_BATCH.BATCH_JOB_EXECUTION_PARAMS MODIFY PARAMETER_VALUE VARCHAR2(1000); +ALTER TABLE API_GRAD_BATCH.BATCH_JOB_EXECUTION_PARAMS MODIFY STRING_VAL VARCHAR2(1000); diff --git a/api/src/main/resources/db/migration/1.0/V1.0.40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql b/api/src/main/resources/db/migration/1.0/V1.0.40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql new file mode 100644 index 00000000..556ebbbd --- /dev/null +++ b/api/src/main/resources/db/migration/1.0/V1.0.40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql @@ -0,0 +1,43 @@ +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME TO BATCH_JOB_EXECUTION_PARAMS_OLD; + +CREATE TABLE BATCH_JOB_EXECUTION_PARAMS ( + JOB_EXECUTION_ID NUMBER(19,0) NOT NULL , + PARAMETER_TYPE VARCHAR2(32 char) NOT NULL , + PARAMETER_NAME VARCHAR2(100 char) NOT NULL , + PARAMETER_VALUE VARCHAR2(1000 char) , + IDENTIFYING CHAR(1) NOT NULL , + constraint BATCH_JOB_EXEC_PARAMS_FK foreign key (JOB_EXECUTION_ID) + references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID) +); + +INSERT INTO BATCH_JOB_EXECUTION_PARAMS ( + JOB_EXECUTION_ID, + PARAMETER_TYPE, + PARAMETER_NAME, + PARAMETER_VALUE, + IDENTIFYING +) SELECT + JOB_EXECUTION_ID, + CASE + WHEN TYPE_CD = 'STRING' THEN 'java.lang.String' + WHEN TYPE_CD = 'LONG' THEN 'java.lang.Long' + WHEN TYPE_CD = 'DOUBLE' THEN 'java.lang.Double' + ELSE 'java.lang.String' + END TYPE_CD, + KEY_NAME, + CASE + WHEN TYPE_CD = 'STRING' THEN STRING_VAL + WHEN TYPE_CD = 'LONG' THEN TO_CHAR(LONG_VAL) + WHEN TYPE_CD = 'DOUBLE' THEN TO_CHAR(DOUBLE_VAL) + ELSE STRING_VAL + END STRING_VAL, + IDENTIFYING +FROM BATCH_JOB_EXECUTION_PARAMS_OLD; + +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP; +ALTER TABLE BATCH_STEP_EXECUTION MODIFY (START_TIME NULL); +ALTER TABLE BATCH_JOB_EXECUTION_CONTEXT MODIFY (SHORT_CONTEXT NULL); +ALTER TABLE BATCH_STEP_EXECUTION_CONTEXT MODIFY (SHORT_CONTEXT NULL); + + + From 860071f534f5f5c4d7005a3d4b27391357b26734 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 1 Sep 2023 10:25:09 -0600 Subject: [PATCH 09/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .../DistributionRunStatusUpdateProcessor.java | 4 +- ....40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql | 42 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java index f783ed81..3a406930 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/DistributionRunStatusUpdateProcessor.java @@ -74,10 +74,10 @@ private Map updateBackStudentRecords(List Date: Fri, 1 Sep 2023 10:28:37 -0600 Subject: [PATCH 10/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .../BaseDistributionRunCompletionNotificationListener.java | 2 +- .../listener/DistributionRunCompletionNotificationListener.java | 2 +- .../DistributionRunYearlyCompletionNotificationListener.java | 2 +- ...tributionRunYearlyNonGradCompletionNotificationListener.java | 2 +- .../bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java index 28b3f2ac..4d3af29e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java @@ -133,7 +133,7 @@ void filterStudentCredentialDistribution(List cre credentialList.removeIf(s->"1950".equalsIgnoreCase(s.getProgram()) && !"AD".equalsIgnoreCase(s.getStudentGrade())); credentialList.removeIf(s->!"1950".equalsIgnoreCase(s.getProgram()) && !"12".equalsIgnoreCase(s.getStudentGrade())); } - LOGGER.debug("Total {} selected after filter", credentialList.size()); + LOGGER.debug("Total {} Student Credentials selected after filter", credentialList.size()); } long getElapsedTimeMillis(JobExecution jobExecution) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java index c7a1cdfb..a9f80d1c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java @@ -71,7 +71,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, String activit Long batchId = summaryDTO.getBatchId(); List cList = distributionService.getStudentCredentialDistributions(batchId); sortStudentCredentialDistributionBySchoolAndNames(cList); - LOGGER.info("list size = {}", cList.size()); + LOGGER.info("Student Credentials list size = {}", cList.size()); Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = distributionService.getSchoolListForDistribution(batchId); sortSchoolBySchoolOfRecord(uniqueSchoolList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java index 2edf62a7..52fb5024 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java @@ -82,7 +82,7 @@ protected boolean processGlobalList(DistributionSummaryDTO summaryDTO, String se filterStudentCredentialDistribution(cList, activityCode); sortStudentCredentialDistributionBySchoolAndNames(cList); summaryDTO.recalculateCredentialCounts(); - LOGGER.info("list size = {}", cList.size()); + LOGGER.info("Student Credentials list size = {}", cList.size()); Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList()); sortSchoolBySchoolOfRecord(uniqueSchoolList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java index 846b4da8..f4717d64 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java @@ -86,7 +86,7 @@ protected boolean processGlobalList(DistributionSummaryDTO summaryDTO, String se filterStudentCredentialDistribution(cList, activityCode); sortStudentCredentialDistributionBySchoolAndNames(cList); summaryDTO.recalculateCredentialCounts(); - LOGGER.info("list size = {}", cList.size()); + LOGGER.info("Student Credentials list size = {}", cList.size()); Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList()); sortSchoolBySchoolOfRecord(uniqueSchoolList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index a6188c77..9f567030 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -174,7 +174,7 @@ void filterStudentCredentialDistribution(List cre LOGGER.debug("Student Credential {}/{} removed by the filter \"{}\"", scd.getPen(), scd.getSchoolOfRecord(), String.join(",", request.getDistricts())); } } - LOGGER.debug("Total {} selected after filter", credentialList.size()); + LOGGER.debug("Total {} Student Credentials selected after filter", credentialList.size()); } Map getStringExecutionContextMap(int gridSize, List credentialList, String credentialType) { From ef4c9cd8c3282318de23134f434ca9536efaea3d Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 1 Sep 2023 10:29:40 -0600 Subject: [PATCH 11/26] GRAD2-1951 Upgrade GRAD-BATCH-GRADUATION-API to Java 18 - Spring Boot 3.0.2 --- .../listener/DistributionRunCompletionNotificationListener.java | 2 +- .../DistributionRunYearlyCompletionNotificationListener.java | 2 +- ...tributionRunYearlyNonGradCompletionNotificationListener.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java index a9f80d1c..1c913952 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java @@ -75,7 +75,7 @@ private void processGlobalList(DistributionSummaryDTO summaryDTO, String activit Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = distributionService.getSchoolListForDistribution(batchId); sortSchoolBySchoolOfRecord(uniqueSchoolList); - LOGGER.info("unique schools = {}", uniqueSchoolList.size()); + LOGGER.info("Unique Schools = {}", uniqueSchoolList.size()); uniqueSchoolList.forEach(usl->{ List yed4List = cList.stream().filter(scd->scd.getSchoolOfRecord().compareTo(usl)==0 && StringUtils.isNotBlank(scd.getPen()) && "YED4".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList()); supportListener.transcriptPrintFile(yed4List,batchId,usl,mapDist,null); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java index 52fb5024..3afd88ef 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyCompletionNotificationListener.java @@ -86,7 +86,7 @@ protected boolean processGlobalList(DistributionSummaryDTO summaryDTO, String se Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList()); sortSchoolBySchoolOfRecord(uniqueSchoolList); - LOGGER.info("unique schools = {}", uniqueSchoolList.size()); + LOGGER.info("Unique Schools = {}", uniqueSchoolList.size()); uniqueSchoolList.forEach(usl->{ List yed4List = cList.stream().filter(scd->scd.getSchoolOfRecord().compareTo(usl)==0 && StringUtils.isNotBlank(scd.getPen()) && "YED4".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList()); supportListener.transcriptPrintFile(yed4List,batchId,usl,mapDist,null); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java index f4717d64..1517c46c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunYearlyNonGradCompletionNotificationListener.java @@ -90,7 +90,7 @@ protected boolean processGlobalList(DistributionSummaryDTO summaryDTO, String se Map mapDist = summaryDTO.getMapDist(); List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList()); sortSchoolBySchoolOfRecord(uniqueSchoolList); - LOGGER.info("unique schools = {}", uniqueSchoolList.size()); + LOGGER.info("Unique Schools = {}", uniqueSchoolList.size()); uniqueSchoolList.forEach(usl->{ List yed4List = cList.stream().filter(scd->scd.getSchoolOfRecord().compareTo(usl)==0 && StringUtils.isNotBlank(scd.getPen()) && "YED4".compareTo(scd.getPaperType()) == 0).collect(Collectors.toList()); List studentList = cList.stream().filter(scd->scd.getSchoolOfRecord().compareTo(usl)==0 && StringUtils.isNotBlank(scd.getPen())).collect(Collectors.toList()); From 38f64d4b453ed27e958f784b5d225e297fe8e5a2 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 1 Sep 2023 11:15:51 -0600 Subject: [PATCH 12/26] Fix code smells --- api/pom.xml | 2 ++ .../repository/dao/DefaultExecutionContextSerializer.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index 60c46a3b..04c81201 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -27,6 +27,7 @@ src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/**, src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/**, src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/**, + src/main/java/org/springframework/**, src/test/java/ca/bc/gov/educ/api/batchgraduation/** @@ -41,6 +42,7 @@ src/main/java/ca/bc/gov/educ/api/batchgraduation/processor/**, src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/**, src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/**, + src/main/java/org/springframework/**, src/test/java/ca/bc/gov/educ/api/batchgraduation/** 18 diff --git a/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java b/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java index c2c8dcde..f56412db 100644 --- a/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java +++ b/api/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java @@ -4,11 +4,11 @@ import org.springframework.batch.core.repository.ExecutionContextSerializer; import org.springframework.util.Assert; import org.springframework.util.Base64Utils; -import org.springframework.util.SerializationUtils; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.HashMap; import java.util.Map; public class DefaultExecutionContextSerializer implements ExecutionContextSerializer { @@ -31,6 +31,6 @@ public void serialize(Map context, OutputStream out) throws IOEx public Map deserialize(InputStream inputStream) throws IOException { String base64EncodedContext = new String(inputStream.readAllBytes()); byte[] decodedContext = Base64Utils.decodeFromString(base64EncodedContext); - return (Map)SerializationUtils.deserialize(decodedContext); + return (Map)jsonTransformer.unmarshall(decodedContext, HashMap.class); } } From 90e5fd97b1c92e1652624f614d7d9154439577d2 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 6 Sep 2023 15:22:05 -0600 Subject: [PATCH 13/26] Fix LocalDate issues --- .../controller/JobLauncherController.java | 18 ++++++------ .../batchgraduation/entity/BaseEntity.java | 14 ++++----- .../BatchGradAlgorithmJobHistoryEntity.java | 6 ++-- .../entity/BatchJobExecutionEntity.java | 8 ++--- ...tionRunCompletionNotificationListener.java | 5 ++-- ...BaseRunCompletionNotificationListener.java | 4 +-- ...CertRunCompletionNotificationListener.java | 2 +- .../model/BatchGradAlgorithmJobHistory.java | 6 ++-- .../model/BatchJobExecution.java | 8 ++--- .../model/BatchJobResponse.java | 4 +-- .../reader/BasePartitioner.java | 2 +- .../service/DistributionService.java | 4 +-- .../service/GradDashboardService.java | 23 ++++++++------- .../writer/BaseYearEndWriter.java | 6 ++-- api/src/main/resources/application.yaml | 1 + ...RunCompletionNotificationListenerTest.java | 4 +-- ...RunCompletionNotificationListenerTest.java | 8 ++--- ...RunCompletionNotificationListenerTest.java | 8 ++--- ...JobCompletionNotificationListenerTest.java | 8 ++--- ...RunCompletionNotificationListenerTest.java | 8 ++--- ...RunCompletionNotificationListenerTest.java | 8 ++--- ...RunCompletionNotificationListenerTest.java | 4 +-- .../service/CodeServiceTest.java | 29 +++++++++---------- .../service/DistributionServiceTest.java | 4 +-- .../service/GradDashboardServiceTest.java | 21 +++++++++----- 25 files changed, 112 insertions(+), 101 deletions(-) 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 799a82b8..22784081 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 @@ -37,7 +37,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; -import java.util.Date; +import java.time.LocalDateTime; import java.util.List; import static ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants.SEARCH_REQUEST; @@ -124,7 +124,7 @@ public ResponseEntity launchRegGradJob() { builder.addString(JOB_TYPE, REGALG); response.setJobType(REGALG); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { @@ -153,7 +153,7 @@ public ResponseEntity launchTvrRunJob() { builder.addString(JOB_TYPE, TVRRUN); response.setJobType(TVRRUN); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { @@ -222,7 +222,7 @@ public ResponseEntity launchRegGradSpecialJob(@RequestBody Stu builder.addString(JOB_TYPE, REGALG); response.setJobType(REGALG); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); validateInput(response, studentSearchRequest); if(response.getException() != null) { @@ -280,7 +280,7 @@ public ResponseEntity launchTvrRunSpecialJob(@RequestBody Stud builder.addString(JOB_TYPE, TVRRUN); response.setJobType(TVRRUN); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); validateInput(response, studentSearchRequest); if(response.getException() != null) { @@ -313,7 +313,7 @@ public ResponseEntity launchRerunAll(@PathVariable Long batchI builder.addString(JOB_TYPE, entity.getJobType()); response.setJobType(entity.getJobType()); response.setTriggerBy(entity.getTriggerBy()); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { @@ -369,7 +369,7 @@ public ResponseEntity launchRerunFailed(@PathVariable Long bat builder.addString(JOB_TYPE, entity.getJobType()); response.setJobType(entity.getJobType()); response.setTriggerBy(entity.getTriggerBy()); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { @@ -706,7 +706,7 @@ public ResponseEntity launchCertRegenJob() { builder.addString(SEARCH_REQUEST, ""); response.setJobType(CERT_REGEN); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { @@ -734,7 +734,7 @@ public ResponseEntity launchUserReqCertRegenJob(@RequestBody C builder.addString(JOB_TYPE, CERT_REGEN); response.setJobType(CERT_REGEN); response.setTriggerBy(MANUAL); - response.setStartTime(new Date(System.currentTimeMillis())); + response.setStartTime(LocalDateTime.now()); response.setStatus(BatchStatusEnum.STARTED.name()); try { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java index b7276a76..69e82c56 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BaseEntity.java @@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.format.annotation.DateTimeFormat; -import java.util.Date; +import java.time.LocalDateTime; @Data @MappedSuperclass @@ -18,7 +18,7 @@ public class BaseEntity { @Column(name = "CREATE_DATE", columnDefinition="datetime",nullable = false) @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-mm-dd hh:mm:ss") - private Date createDate; + private LocalDateTime createDate; @Column(name = "UPDATE_USER", nullable = false) @@ -27,7 +27,7 @@ public class BaseEntity { @Column(name = "UPDATE_DATE", columnDefinition="datetime") @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-mm-dd hh:mm:ss") - private Date updateDate; + private LocalDateTime updateDate; @PrePersist protected void onCreate() { @@ -43,14 +43,14 @@ protected void onCreate() { this.updateUser = EducGradBatchGraduationApiConstants.DEFAULT_UPDATED_BY; } } - this.createDate = new Date(System.currentTimeMillis()); - this.updateDate = new Date(System.currentTimeMillis()); + this.createDate = LocalDateTime.now(); + this.updateDate = LocalDateTime.now(); } @PreUpdate protected void onPersist() { - this.updateDate = new Date(); + this.updateDate = LocalDateTime.now(); if (StringUtils.isBlank(updateUser)) { this.updateUser = ThreadLocalStateUtil.getCurrentUser(); if (StringUtils.isBlank(updateUser)) { @@ -64,7 +64,7 @@ protected void onPersist() { } } if (this.createDate == null) { - this.createDate = new Date(); + this.createDate = LocalDateTime.now(); } } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java index f3c2de72..d895c87c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchGradAlgorithmJobHistoryEntity.java @@ -5,7 +5,7 @@ import lombok.EqualsAndHashCode; import org.hibernate.annotations.GenericGenerator; -import java.util.Date; +import java.time.LocalDateTime; import java.util.UUID; @Data @@ -28,11 +28,11 @@ public class BatchGradAlgorithmJobHistoryEntity extends BaseEntity { @Column(name = "START_TIME", nullable = true) @Temporal(TemporalType.TIMESTAMP) - private Date startTime; + private LocalDateTime startTime; @Column(name = "END_TIME", nullable = true) @Temporal(TemporalType.TIMESTAMP) - private Date endTime; + private LocalDateTime endTime; @Column(name = "EXPECTED_STUDENTS_PROCESSED", nullable = true) private Long expectedStudentsProcessed; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java index 04bd6c4c..c8d02118 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionEntity.java @@ -5,7 +5,7 @@ import lombok.EqualsAndHashCode; import java.time.Instant; -import java.util.Date; +import java.time.LocalDateTime; @Data @Entity @@ -22,15 +22,15 @@ public class BatchJobExecutionEntity { @Column(name = "CREATE_TIME", nullable = true) @Temporal(TemporalType.TIMESTAMP) - private Date createTime; + private LocalDateTime createTime; @Column(name = "START_TIME", nullable = true) @Temporal(TemporalType.TIMESTAMP) - private Date startTime; + private LocalDateTime startTime; @Column(name = "END_TIME", nullable = true) @Temporal(TemporalType.TIMESTAMP) - private Date endTime; + private LocalDateTime endTime; @Column(name = "STATUS", nullable = true) private String status; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java index 4d3af29e..1cc31181 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseDistributionRunCompletionNotificationListener.java @@ -5,6 +5,7 @@ import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.DistributionService; import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; +import ca.bc.gov.educ.api.batchgraduation.util.DateUtils; import ca.bc.gov.educ.api.batchgraduation.util.GradSorter; import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; import org.apache.commons.lang3.StringUtils; @@ -44,8 +45,8 @@ protected void processBatchJobHistory(BaseDistributionSummaryDTO summaryDTO, Lon ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(jobExecutionId); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java index e1189635..8f7228a0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java @@ -90,8 +90,8 @@ private void processBatchJobHistory(AlgorithmSummaryDTO summaryDTO, Long jobExec ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords != null? failedRecords.intValue() : 0); ent.setJobExecutionId(jobExecutionId); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java index d2b017a3..2763b488 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/RegenCertRunCompletionNotificationListener.java @@ -59,7 +59,7 @@ private void saveBatchJobHistory(AlgorithmSummaryDTO summaryDTO, Long jobExecuti if (ent != null) { ent.setActualStudentsProcessed(summaryDTO.getProcessedCount()); ent.setFailedStudentsProcessed((int) summaryDTO.getErroredCount()); - ent.setEndTime(endTime); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); gradBatchHistoryService.saveGradAlgorithmJobHistory(ent); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchGradAlgorithmJobHistory.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchGradAlgorithmJobHistory.java index 075ae8b7..1c80f749 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchGradAlgorithmJobHistory.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchGradAlgorithmJobHistory.java @@ -4,7 +4,7 @@ import lombok.EqualsAndHashCode; import org.springframework.stereotype.Component; -import java.util.Date; +import java.time.LocalDateTime; import java.util.UUID; @Data @@ -14,8 +14,8 @@ public class BatchGradAlgorithmJobHistory extends BaseModel{ private UUID id; private Integer jobExecutionId; - private Date startTime; - private Date endTime; + private LocalDateTime startTime; + private LocalDateTime endTime; private String expectedStudentsProcessed; private String actualStudentsProcessed; private String failedStudentsProcessed; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobExecution.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobExecution.java index e68f20b1..3878ed1d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobExecution.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobExecution.java @@ -4,7 +4,7 @@ import lombok.EqualsAndHashCode; import org.springframework.stereotype.Component; -import java.util.Date; +import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = false) @@ -12,8 +12,8 @@ public class BatchJobExecution { private Long jobExecutionId; - private Date createTime; - private Date startTime; - private Date endTime; + private LocalDateTime createTime; + private LocalDateTime startTime; + private LocalDateTime endTime; private String status; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobResponse.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobResponse.java index 771ec28a..6b06f327 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobResponse.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/BatchJobResponse.java @@ -2,12 +2,12 @@ import lombok.Data; -import java.util.Date; +import java.time.LocalDateTime; @Data public class BatchJobResponse { private Long batchId; - private Date startTime; + private LocalDateTime startTime; private String status; private String jobType; private String triggerBy; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 9f567030..e75ce37f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -134,7 +134,7 @@ protected BatchGradAlgorithmJobHistoryEntity createBatchJobHistory() { ent.setExpectedStudentsProcessed(0L); ent.setFailedStudentsProcessed(0); ent.setJobExecutionId(jobExecutionId); - ent.setStartTime(startTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java index b7e23c44..16634af9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionService.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Date; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -75,7 +75,7 @@ public void saveStudentCredentialDistribution(Long batchId, String jobType, Stud public void updateDistributionBatchJobStatus(Long batchId, int failedCount, String status) { log.debug("updateDistributionBatchJobStatus - retrieve the batch job history: batchId = {}", batchId); BatchGradAlgorithmJobHistoryEntity jobHistory = gradBatchHistoryService.getGradAlgorithmJobHistory(batchId); - jobHistory.setEndTime(new Date(System.currentTimeMillis())); + jobHistory.setEndTime(LocalDateTime.now()); jobHistory.setStatus(status); jobHistory.setActualStudentsProcessed(jobHistory.getExpectedStudentsProcessed() - failedCount); log.debug("updateDistributionBatchJobStatus - save the batch job history: batchId = {}, status = {}. actual processed count = {}", batchId, status, jobHistory.getActualStudentsProcessed()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java index b8e73dc3..126f1fea 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardService.java @@ -1,22 +1,25 @@ package ca.bc.gov.educ.api.batchgraduation.service; -import java.util.*; -import java.util.stream.Collectors; - import ca.bc.gov.educ.api.batchgraduation.entity.*; import ca.bc.gov.educ.api.batchgraduation.model.*; -import ca.bc.gov.educ.api.batchgraduation.repository.*; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmStudentRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchJobExecutionRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchProcessingRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; +import ca.bc.gov.educ.api.batchgraduation.transformer.BatchGradAlgorithmJobHistoryTransformer; import ca.bc.gov.educ.api.batchgraduation.transformer.BatchProcessingTransformer; import org.apache.commons.lang3.time.DateUtils; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; - -import ca.bc.gov.educ.api.batchgraduation.transformer.BatchGradAlgorithmJobHistoryTransformer; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + @Service public class GradDashboardService extends GradService { @@ -54,9 +57,9 @@ public GradDashboard getDashboardInfo() { gradDash.setLastActualStudentsProcessed(info.getActualStudentsProcessed()); gradDash.setLastExpectedStudentsProcessed(info.getExpectedStudentsProcessed()); gradDash.setLastFailedStudentsProcessed(info.getFailedStudentsProcessed()); - gradDash.setLastJobendTime(info.getEndTime()); + gradDash.setLastJobendTime(ca.bc.gov.educ.api.batchgraduation.util.DateUtils.toDate(info.getEndTime())); gradDash.setLastJobExecutionId(info.getJobExecutionId()); - gradDash.setLastJobstartTime(info.getStartTime()); + gradDash.setLastJobstartTime(ca.bc.gov.educ.api.batchgraduation.util.DateUtils.toDate(info.getStartTime())); gradDash.setLastStatus(info.getStatus()); gradDash.setTotalBatchRuns(infoDetailsList.size()); gradDash.setBatchInfoList(infoDetailsList); @@ -148,9 +151,9 @@ public BatchGradAlgorithmJobHistory handleDeadJob(BatchGradAlgorithmJobHistory b Integer jobExecutionId = batchJobHistory.getJobExecutionId(); Date now = new Date(System.currentTimeMillis()); - Date deadline = DateUtils.addDays(now, -3); + LocalDateTime deadline = ca.bc.gov.educ.api.batchgraduation.util.DateUtils.toLocalDateTime(DateUtils.addDays(now, -3)); - if (batchJobHistory.getStartTime().before(deadline)) { + if (batchJobHistory.getStartTime().isBefore(deadline)) { Optional optional = batchJobExecutionRepository.findById(jobExecutionId.longValue()); if (optional.isPresent()) { BatchJobExecutionEntity batchJobExecution = optional.get(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseYearEndWriter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseYearEndWriter.java index 6ebeb6f9..1e76d203 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseYearEndWriter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/writer/BaseYearEndWriter.java @@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import java.util.Date; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -44,10 +44,10 @@ public abstract class BaseYearEndWriter { JobParameters jobParameters; @Value("#{stepExecution.jobExecution.startTime}") - Date startTime; + LocalDateTime startTime; @Value("#{stepExecution.jobExecution.endTime}") - Date endTime; + LocalDateTime endTime; protected void processGlobalList(List cList, Long batchId, Map mapDist, String activityCode, String accessToken) { List uniqueSchoolList = cList.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().collect(Collectors.toList()); diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index c691f348..9fb89f56 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -25,6 +25,7 @@ spring: jackson: deserialization: fail-on-unknown-properties: false + date-format: com.fasterxml.jackson.databind.util.ISO8601DateFormat #Keycloak/OAuth properties security: user: diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java index a3925b9a..debc564f 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListenerTest.java @@ -131,8 +131,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java index 1653e965..412007ac 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/GradRunCompletionNotificationListenerTest.java @@ -98,8 +98,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); @@ -156,8 +156,8 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java index acd17ef5..1a659558 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/SpecialRunCompletionNotificationListenerTest.java @@ -98,8 +98,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); @@ -158,8 +158,8 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java index 5c7c7de5..5e7f1b30 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/TvrRunJobCompletionNotificationListenerTest.java @@ -98,8 +98,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); @@ -156,8 +156,8 @@ public void testAfterJob_witherror() throws JobInstanceAlreadyCompleteException, ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java index 5cbadf42..e75d1a0d 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqBlankDistributionRunCompletionNotificationListenerTest.java @@ -149,8 +149,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); @@ -239,8 +239,8 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java index c526caf9..22c88d1d 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqDistributionRunCompletionNotificationListenerTest.java @@ -155,8 +155,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); @@ -270,8 +270,8 @@ public void testAfterJob_OC() throws JobInstanceAlreadyCompleteException, JobExe ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java index 05647ebe..b6996ede 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/listener/UserReqPsiDistributionRunCompletionNotificationListenerTest.java @@ -136,8 +136,8 @@ public void testAfterJob() throws JobInstanceAlreadyCompleteException, JobExecut ent.setExpectedStudentsProcessed(expectedStudents); ent.setFailedStudentsProcessed(failedRecords); ent.setJobExecutionId(121L); - ent.setStartTime(startTime); - ent.setEndTime(endTime); + ent.setStartTime(DateUtils.toLocalDateTime(startTime)); + ent.setEndTime(DateUtils.toLocalDateTime(endTime)); ent.setStatus(status); ent.setTriggerBy(jobTrigger); ent.setJobType(jobType); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/CodeServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/CodeServiceTest.java index 7ba5edec..aed58b15 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/CodeServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/CodeServiceTest.java @@ -15,7 +15,6 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; -import java.sql.Date; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -50,16 +49,16 @@ void testGetAllBatchJobTypesCodeList() { obj.setDescription("Graduation Algorithm"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date(System.currentTimeMillis())); - obj.setUpdateDate(new Date(System.currentTimeMillis())); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradBatchJobTypeList.add(obj); obj = new BatchJobTypeEntity(); obj.setCode("TVRRUN"); obj.setDescription("Student Achievement Report (TVR)"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date(System.currentTimeMillis())); - obj.setUpdateDate(new Date(System.currentTimeMillis())); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradBatchJobTypeList.add(obj); Mockito.when(batchJobTypeRepository.findAll()).thenReturn(gradBatchJobTypeList); var result = codeService.getAllBatchJobTypeCodeList(); @@ -82,8 +81,8 @@ void testGetSpecificBatchJobTypeCode() { objEntity.setDescription("Student Achievement Report (TVR)"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date(System.currentTimeMillis())); - objEntity.setUpdateDate(new Date(System.currentTimeMillis())); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(batchJobTypeRepository.findById(code)).thenReturn(ent); var result = codeService.getSpecificBatchJobTypeCode(code); @@ -113,8 +112,8 @@ void testCreateBatchJobType() { objEntity.setDescription("PSI Run FTP / Paper"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date(System.currentTimeMillis())); - objEntity.setUpdateDate(new Date(System.currentTimeMillis())); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Mockito.when(batchJobTypeRepository.findById(obj.getCode())).thenReturn(Optional.empty()); Mockito.when(batchJobTypeRepository.save(objEntity)).thenReturn(objEntity); var result = codeService.createBatchJobType(obj); @@ -136,8 +135,8 @@ void testCreateBatchJobType_codeAlreadyExists() { objEntity.setDescription("PSI Run FTP / Paper"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date(System.currentTimeMillis())); - objEntity.setUpdateDate(new Date(System.currentTimeMillis())); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(batchJobTypeRepository.findById(obj.getCode())).thenReturn(ent); var result = codeService.createBatchJobType(obj); @@ -159,8 +158,8 @@ void testUpdateBatchJobType() { objEntity.setDescription("Graduation Algorithm"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date(System.currentTimeMillis())); - objEntity.setUpdateDate(new Date(System.currentTimeMillis())); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(batchJobTypeRepository.findById(obj.getCode())).thenReturn(ent); Mockito.when(batchJobTypeRepository.save(objEntity)).thenReturn(objEntity); @@ -182,8 +181,8 @@ void testUpdateBatchJobType_codeAlreadyExists() { objEntity.setDescription("Graduation Algorithm"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date(System.currentTimeMillis())); - objEntity.setUpdateDate(new Date(System.currentTimeMillis())); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Mockito.when(batchJobTypeRepository.findById(obj.getCode())).thenReturn(Optional.empty()); var result = codeService.updateBatchJobType(obj); assertThat(result).isNull(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionServiceTest.java index 7d54e7b6..5644814e 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/DistributionServiceTest.java @@ -16,8 +16,8 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; +import java.time.LocalDateTime; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.UUID; @@ -140,7 +140,7 @@ public void testUpdateDistributionBatchJobStatus() throws Exception { BatchGradAlgorithmJobHistoryEntity batchGradAlgorithmJobHistoryEntity = new BatchGradAlgorithmJobHistoryEntity(); batchGradAlgorithmJobHistoryEntity.setId(UUID.randomUUID()); batchGradAlgorithmJobHistoryEntity.setJobExecutionId(batchId); - batchGradAlgorithmJobHistoryEntity.setStartTime(new Date(System.currentTimeMillis())); + batchGradAlgorithmJobHistoryEntity.setStartTime(LocalDateTime.now()); batchGradAlgorithmJobHistoryEntity.setExpectedStudentsProcessed(1L); batchGradAlgorithmJobHistoryEntity.setActualStudentsProcessed(0L); batchGradAlgorithmJobHistoryEntity.setFailedStudentsProcessed(0); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java index 84a9ee55..980b0ea4 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/service/GradDashboardServiceTest.java @@ -1,8 +1,14 @@ package ca.bc.gov.educ.api.batchgraduation.service; -import ca.bc.gov.educ.api.batchgraduation.entity.*; +import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmJobHistoryEntity; +import ca.bc.gov.educ.api.batchgraduation.entity.BatchGradAlgorithmStudentEntity; +import ca.bc.gov.educ.api.batchgraduation.entity.BatchJobExecutionEntity; +import ca.bc.gov.educ.api.batchgraduation.entity.BatchProcessingEntity; import ca.bc.gov.educ.api.batchgraduation.model.*; -import ca.bc.gov.educ.api.batchgraduation.repository.*; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmJobHistoryRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchGradAlgorithmStudentRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchJobExecutionRepository; +import ca.bc.gov.educ.api.batchgraduation.repository.BatchProcessingRepository; import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import org.apache.commons.lang3.time.DateUtils; import org.junit.Test; @@ -19,6 +25,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.reactive.function.client.WebClient; +import java.time.LocalDateTime; import java.util.*; import static org.assertj.core.api.Assertions.assertThat; @@ -55,13 +62,13 @@ public void testGetDashboardInfo() { List list = new ArrayList<>(); BatchGradAlgorithmJobHistoryEntity hist = new BatchGradAlgorithmJobHistoryEntity(); - hist.setEndTime(new Date()); + hist.setEndTime(LocalDateTime.now()); hist.setActualStudentsProcessed(11L); hist.setId(new UUID(1,1)); hist.setExpectedStudentsProcessed(20L); hist.setJobExecutionId(121L); hist.setFailedStudentsProcessed(4); - hist.setStartTime(new Date()); + hist.setStartTime(LocalDateTime.now()); list.add(hist); when(batchGradAlgorithmJobHistoryRepository.findAll()).thenReturn(list); GradDashboard dash = gradDashboardService.getDashboardInfo(); @@ -80,7 +87,7 @@ public void testGetDashboardInfo_whenStartedDate_isOlderThan3Days_thenUpdateStat hist.setJobExecutionId(121L); Date today = new Date(System.currentTimeMillis()); Date startedDateTime = DateUtils.addDays(today, -3); - hist.setStartTime(startedDateTime); + hist.setStartTime(ca.bc.gov.educ.api.batchgraduation.util.DateUtils.toLocalDateTime(startedDateTime)); hist.setStatus("STARTED"); list.add(hist); @@ -170,9 +177,9 @@ public void testGetBatchSummary() { Long batchId= 123123L; UUID studentId = UUID.randomUUID(); BatchJobExecutionEntity ent = new BatchJobExecutionEntity(); - ent.setEndTime(new Date()); + ent.setEndTime(LocalDateTime.now()); ent.setJobExecutionId(batchId); - ent.setStartTime(new Date()); + ent.setStartTime(LocalDateTime.now()); ent.setStatus("COMPLETED"); Page pagedDate = new PageImpl(List.of(ent)); Mockito.when(batchJobExecutionRepository.findAllByOrderByCreateTimeDesc(paging)).thenReturn(pagedDate); From f618bfe7240c006b282fc1abbd6ac3d6436b2fe5 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 7 Sep 2023 10:27:45 -0600 Subject: [PATCH 14/26] Remove unused date/time settings --- api/src/main/resources/application.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 9fb89f56..c691f348 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -25,7 +25,6 @@ spring: jackson: deserialization: fail-on-unknown-properties: false - date-format: com.fasterxml.jackson.databind.util.ISO8601DateFormat #Keycloak/OAuth properties security: user: From c3136f0d2ca4de2c82f44f0939f3795cd3e320ea Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 13 Sep 2023 12:43:25 -0600 Subject: [PATCH 15/26] GRAD2-2308 - HD-21581-GRAD - P3 - GRAD Batch Processing - Select Student Options moved to wrong place --- .../gov/educ/api/batchgraduation/reader/BasePartitioner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 659fbf88..248ed903 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -166,9 +166,9 @@ void filterStudentCredentialDistribution(List cre StudentCredentialDistribution scd = (StudentCredentialDistribution)scdIt.next(); String districtCode = StringUtils.substring(scd.getSchoolOfRecord(), 0, 3); if ( - (request.getDistricts() != null && !request.getDistricts().isEmpty() && !request.getDistricts().contains(districtCode)) + (StringUtils.isNotBlank(scd.getSchoolOfRecord()) && request.getDistricts() != null && !request.getDistricts().isEmpty() && !request.getDistricts().contains(districtCode)) || - (request.getSchoolOfRecords() != null && !request.getSchoolOfRecords().isEmpty() && !request.getSchoolOfRecords().contains(scd.getSchoolOfRecord())) + (StringUtils.isNotBlank(scd.getSchoolOfRecord()) && request.getSchoolOfRecords() != null && !request.getSchoolOfRecords().isEmpty() && !request.getSchoolOfRecords().contains(scd.getSchoolOfRecord())) ) { scdIt.remove(); LOGGER.debug("Student Credential {}/{} removed by the filter \"{}\"", scd.getPen(), scd.getSchoolOfRecord(), String.join(",", request.getDistricts())); From f3b4454155f0c7ae49e651754593eb4c5169d15a Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 15 Sep 2023 14:48:26 -0600 Subject: [PATCH 16/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student Report --- .../controller/JobLauncherController.java | 24 ++++++-- ...stributionRunYearlyNonGradPartitioner.java | 36 +++--------- .../api/batchgraduation/rest/RestUtils.java | 2 +- .../EducGradBatchGraduationApiConstants.java | 3 +- .../util/GradSchoolOfRecordFilter.java | 57 +++++++++++++++++++ .../batchgraduation/util/RestUtilsTest.java | 6 +- 6 files changed, 91 insertions(+), 37 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java 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 22784081..a0ba173d 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 @@ -7,10 +7,7 @@ import ca.bc.gov.educ.api.batchgraduation.rest.RestUtils; import ca.bc.gov.educ.api.batchgraduation.service.GradBatchHistoryService; import ca.bc.gov.educ.api.batchgraduation.service.GradDashboardService; -import ca.bc.gov.educ.api.batchgraduation.util.EducGradBatchGraduationApiConstants; -import ca.bc.gov.educ.api.batchgraduation.util.JsonTransformer; -import ca.bc.gov.educ.api.batchgraduation.util.PermissionsConstants; -import ca.bc.gov.educ.api.batchgraduation.util.ThreadLocalStateUtil; +import ca.bc.gov.educ.api.batchgraduation.util.*; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.info.Info; @@ -91,6 +88,9 @@ public class JobLauncherController { @Autowired JsonTransformer jsonTransformer; + @Autowired + GradSchoolOfRecordFilter gradSchoolOfRecordFilter; + @Autowired public JobLauncherController( JobLauncher jobLauncher, @@ -430,6 +430,22 @@ public ResponseEntity launchRegenerateSchoolReports(@PathVariable Long return ResponseEntity.status(500).body(Boolean.FALSE); } + @PostMapping(EducGradBatchGraduationApiConstants.EXECUTE_REGEN_SCHOOL_REPORTS_BY_REQUEST) + @PreAuthorize(PermissionsConstants.RUN_GRAD_ALGORITHM) + @Operation(summary = "Re-Generate School Reports for the given batchJobId", description = "RRe-Generate School Reports for the given batchJobId", tags = { "RE-RUN" }) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),@ApiResponse(responseCode = "500", description = "Internal Server Error")}) + public ResponseEntity launchRegenerateSchoolReports(@RequestBody StudentSearchRequest searchRequest, @RequestHeader(name="Authorization") String accessToken) { + logger.info(" Re-Generating School Reports by request for {} --------------------------------------------------------", REGALG); + try { + List finalSchoolDistricts = gradSchoolOfRecordFilter.filterSchoolOfRecords(searchRequest).stream().sorted().toList(); + logger.info(" Number of Schools [{}] ---------------------------------------------------------", finalSchoolDistricts.size()); + restUtils.createAndStoreSchoolReports(accessToken.replace(BEARER, ""), finalSchoolDistricts, REGALG); + return ResponseEntity.ok(Boolean.TRUE); + } catch (Exception e) { + return ResponseEntity.status(500).body(Boolean.FALSE); + } + } + @GetMapping(EducGradBatchGraduationApiConstants.EXECUTE_MONTHLY_DIS_RUN_BATCH_JOB) @PreAuthorize(PermissionsConstants.RUN_GRAD_ALGORITHM) @Operation(summary = "Run Monthly Distribution Runs", description = "Run Monthly Distribution Runs", tags = { "Distribution" }) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java index 28befdbb..b0afd1ec 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java @@ -1,10 +1,9 @@ package ca.bc.gov.educ.api.batchgraduation.reader; import ca.bc.gov.educ.api.batchgraduation.model.DistributionSummaryDTO; -import ca.bc.gov.educ.api.batchgraduation.model.School; import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; import ca.bc.gov.educ.api.batchgraduation.service.ParallelDataFetch; -import org.apache.commons.lang3.StringUtils; +import ca.bc.gov.educ.api.batchgraduation.util.GradSchoolOfRecordFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.JobExecution; @@ -12,7 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; public class DistributionRunYearlyNonGradPartitioner extends BasePartitioner { @@ -23,6 +25,8 @@ public class DistributionRunYearlyNonGradPartitioner extends BasePartitioner { @Autowired ParallelDataFetch parallelDataFetch; + @Autowired + GradSchoolOfRecordFilter gradSchoolOfRecordFilter; @Override public Map partition(int gridSize) { @@ -40,32 +44,8 @@ public Map partition(int gridSize) { startTime = System.currentTimeMillis(); logger.debug("Retrieve schools for Non Grad Yearly Distribution"); - List eligibleStudentSchoolDistricts = new ArrayList<>(); StudentSearchRequest searchRequest = getStudentSearchRequest(); - if(searchRequest != null && searchRequest.getSchoolCategoryCodes() != null && !searchRequest.getSchoolCategoryCodes().isEmpty()) { - for(String schoolCategoryCode: searchRequest.getSchoolCategoryCodes()) { - logger.debug("Use schoolCategory code {} to find list of schools", schoolCategoryCode); - List schools = restUtils.getSchoolBySchoolCategoryCode(schoolCategoryCode); - for(School school: schools) { - logger.debug("School {} found by schoolCategory code {}", school.getMincode(), schoolCategoryCode); - eligibleStudentSchoolDistricts.add(school.getMincode()); - } - } - } - if(searchRequest != null && searchRequest.getDistricts() != null && !searchRequest.getDistricts().isEmpty()) { - if(!eligibleStudentSchoolDistricts.isEmpty()) { - eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3))); - } else { - eligibleStudentSchoolDistricts = searchRequest.getDistricts(); - } - } - if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) { - if(!eligibleStudentSchoolDistricts.isEmpty()) { - eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getSchoolOfRecords().contains(scr)); - } else { - eligibleStudentSchoolDistricts = searchRequest.getSchoolOfRecords(); - } - } + List eligibleStudentSchoolDistricts = gradSchoolOfRecordFilter.filterSchoolOfRecords(searchRequest); endTime = System.currentTimeMillis(); diff = (endTime - startTime)/1000; logger.debug("Total {} schools after filters in {} sec", eligibleStudentSchoolDistricts.size(), diff); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index d218ab5b..18693e3c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -482,7 +482,7 @@ public GraduationStudentRecordDistribution getStudentData(String studentID, Stri public void createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) { UUID correlationID = UUID.randomUUID(); Integer result = webClient.post() - .uri(String.format(constants.getCreateAndStore(),type)) + .uri(String.format(constants.getCreateAndStoreSchoolReports(),type)) .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .body(BodyInserters.fromValue(uniqueSchools)) .retrieve() diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java index efcb1f19..c4cfc969 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java @@ -39,6 +39,7 @@ public class EducGradBatchGraduationApiConstants { public static final String EXECUTE_RE_RUNS_ALL = "/rerun/all/{batchId}"; public static final String EXECUTE_RE_RUNS_FAILED = "/rerun/failed/{batchId}"; public static final String EXECUTE_REGEN_SCHOOL_REPORTS = "/regenerate/school-report/{batchId}"; + public static final String EXECUTE_REGEN_SCHOOL_REPORTS_BY_REQUEST = "/regenerate/school-report"; public static final String BATCH_JOB_TYPES_MAPPING = "/batchjobtype"; public static final String BATCH_JOB_TYPE_MAPPING = "/batchjobtype/{batchJobTypeCode}"; @@ -196,7 +197,7 @@ public class EducGradBatchGraduationApiConstants { private String studentDataForUserReqDisRun; @Value("${endpoint.grad-graduation-api.schoolreport.url}") - private String createAndStore; + private String createAndStoreSchoolReports; @Value("${endpoint.grad-graduation-api.school_year_end_report.url}") private String schoolYearEndReport; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java new file mode 100644 index 00000000..d627e8bb --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java @@ -0,0 +1,57 @@ +package ca.bc.gov.educ.api.batchgraduation.util; + +import ca.bc.gov.educ.api.batchgraduation.model.School; +import ca.bc.gov.educ.api.batchgraduation.model.StudentSearchRequest; +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.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@Component +public class GradSchoolOfRecordFilter implements Serializable { + + private static final Logger logger = LoggerFactory.getLogger(GradSchoolOfRecordFilter.class); + + private final RestUtils restUtils; + + @Autowired + public GradSchoolOfRecordFilter(RestUtils restUtils) { + this.restUtils = restUtils; + } + + public List filterSchoolOfRecords(StudentSearchRequest searchRequest) { + List eligibleStudentSchoolDistricts = new ArrayList<>(); + if(searchRequest != null && searchRequest.getSchoolCategoryCodes() != null && !searchRequest.getSchoolCategoryCodes().isEmpty()) { + for(String schoolCategoryCode: searchRequest.getSchoolCategoryCodes()) { + logger.debug("Use schoolCategory code {} to find list of schools", schoolCategoryCode); + List schools = restUtils.getSchoolBySchoolCategoryCode(schoolCategoryCode); + for(School school: schools) { + logger.debug("School {} found by schoolCategory code {}", school.getMincode(), schoolCategoryCode); + eligibleStudentSchoolDistricts.add(school.getMincode()); + } + } + } + if(searchRequest != null && searchRequest.getDistricts() != null && !searchRequest.getDistricts().isEmpty()) { + if(!eligibleStudentSchoolDistricts.isEmpty()) { + eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3))); + } else { + eligibleStudentSchoolDistricts = searchRequest.getDistricts(); + } + } + if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) { + if(!eligibleStudentSchoolDistricts.isEmpty()) { + eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getSchoolOfRecords().contains(scr)); + } else { + eligibleStudentSchoolDistricts = searchRequest.getSchoolOfRecords(); + } + } + return eligibleStudentSchoolDistricts; + } + +} diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index b8423da3..a146e7f5 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -814,7 +814,7 @@ public void testcreateAndStoreSchoolReports_null() { final String type = "NONGRADPRJ"; when(this.webClient.post()).thenReturn(this.requestBodyUriMock); - when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStore(),type))).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStoreSchoolReports(),type))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); @@ -831,7 +831,7 @@ public void testcreateAndStoreSchoolReports() { final String type = "NONGRADPRJ"; when(this.webClient.post()).thenReturn(this.requestBodyUriMock); - when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStore(),type))).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStoreSchoolReports(),type))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); @@ -847,7 +847,7 @@ public void testcreateAndStoreSchoolReports_0() { final String type = "NONGRADPRJ"; when(this.webClient.post()).thenReturn(this.requestBodyUriMock); - when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStore(),type))).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStoreSchoolReports(),type))).thenReturn(this.requestBodyUriMock); when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); From 8284911c19ac6030a67ccf86bfc27a0471386c95 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Sat, 16 Sep 2023 03:03:29 +0530 Subject: [PATCH 17/26] Revert "GRAD2-2295: task is completed." --- .../api/batchgraduation/reader/BasePartitioner.java | 10 ---------- .../reader/DistributionRunPartitioner.java | 9 ++++++++- .../reader/DistributionRunSupplementalPartitioner.java | 6 ++++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index 248ed903..a36fb445 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -238,14 +238,4 @@ void filterByStudentSearchRequest(List eligibleSt eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getPens().contains(scr.getPen())); } } - - void filterOutDeceasedStudents(List credentialList) { - LOGGER.debug("Total size of credential list: {}", credentialList.size()); - List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); - if (!deceasedIDs.isEmpty()) { - LOGGER.debug("Deceased students: {}", deceasedIDs.size()); - credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); - LOGGER.debug("Revised size of credential list: {}", credentialList.size()); - } - } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java index 7bfdafa7..4e37f66c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java @@ -56,7 +56,14 @@ public Map partition(int gridSize) { diff = (endTime - startTime)/1000; logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff); if(!credentialList.isEmpty()) { - filterOutDeceasedStudents(credentialList); + LOGGER.debug("Total size of credential list: {}", credentialList.size()); + // Filter deceased students out + List deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken()); + if (!deceasedIDs.isEmpty()) { + LOGGER.debug("Deceased students: {}", deceasedIDs.size()); + credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID())); + LOGGER.debug("Revised size of credential list: {}", credentialList.size()); + } updateBatchJobHistory(createBatchJobHistory(), (long) credentialList.size()); return getStringExecutionContextMap(gridSize, credentialList, null); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java index 47d5a691..1c54319b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunSupplementalPartitioner.java @@ -11,7 +11,10 @@ import org.springframework.beans.factory.annotation.Value; import reactor.core.publisher.Mono; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class DistributionRunSupplementalPartitioner extends BasePartitioner { @@ -50,7 +53,6 @@ public Map partition(int gridSize) { logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", eligibleStudentSchoolDistricts.size(), diff); filterByStudentSearchRequest(eligibleStudentSchoolDistricts); if(!eligibleStudentSchoolDistricts.isEmpty()) { - filterOutDeceasedStudents(eligibleStudentSchoolDistricts); updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size()); return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null); } From 8aa3804769f1d2b78348363fed950986d245493f Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Sat, 16 Sep 2023 03:30:16 +0530 Subject: [PATCH 18/26] GRAD2-2295 revert related changes --- .../reader/DistributionRunPartitioner.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java index 4e37f66c..95b565c3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunPartitioner.java @@ -19,7 +19,7 @@ */ public class DistributionRunPartitioner extends BasePartitioner { - private static final Logger logger = LoggerFactory.getLogger(DistributionRunPartitioner.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DistributionRunPartitioner.class); @Value("#{stepExecution.jobExecution}") JobExecution context; @@ -36,15 +36,15 @@ public Map partition(int gridSize) { } // Clean up existing reports before running new one - logger.debug("Delete School Reports for Monthly Distribution"); + LOGGER.debug("Delete School Reports for Monthly Distribution"); long startTime = System.currentTimeMillis(); restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken()); long endTime = System.currentTimeMillis(); long diff = (endTime - startTime)/1000; - logger.debug("Old School Reports deleted in {} sec", diff); + LOGGER.debug("Old School Reports deleted in {} sec", diff); startTime = System.currentTimeMillis(); - logger.debug("Retrieve students for Monthly Distribution"); + LOGGER.debug("Retrieve students for Monthly Distribution"); Mono parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken); DistributionDataParallelDTO parallelDTO = parallelDTOMono.block(); List credentialList = new ArrayList<>(); @@ -54,7 +54,7 @@ public Map partition(int gridSize) { } endTime = System.currentTimeMillis(); diff = (endTime - startTime)/1000; - logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff); + LOGGER.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff); if(!credentialList.isEmpty()) { LOGGER.debug("Total size of credential list: {}", credentialList.size()); // Filter deceased students out @@ -67,7 +67,7 @@ public Map partition(int gridSize) { updateBatchJobHistory(createBatchJobHistory(), (long) credentialList.size()); return getStringExecutionContextMap(gridSize, credentialList, null); } - logger.info("No Credentials Found for Processing"); + LOGGER.info("No Credentials Found for Processing"); return new HashMap<>(); } From ea6df35a40aacc0ee1c0b29a19922bdc0b65f29d Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Mon, 18 Sep 2023 23:07:35 +0530 Subject: [PATCH 19/26] =?UTF-8?q?Revert=20"GRAD2-2308=20-=20HD-21581-GRAD?= =?UTF-8?q?=20-=20P3=20-=20GRAD=20Batch=20Processing=20-=20Select=20Stud?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov/educ/api/batchgraduation/reader/BasePartitioner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java index a36fb445..e75ce37f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/BasePartitioner.java @@ -166,9 +166,9 @@ void filterStudentCredentialDistribution(List cre StudentCredentialDistribution scd = (StudentCredentialDistribution)scdIt.next(); String districtCode = StringUtils.substring(scd.getSchoolOfRecord(), 0, 3); if ( - (StringUtils.isNotBlank(scd.getSchoolOfRecord()) && request.getDistricts() != null && !request.getDistricts().isEmpty() && !request.getDistricts().contains(districtCode)) + (request.getDistricts() != null && !request.getDistricts().isEmpty() && !request.getDistricts().contains(districtCode)) || - (StringUtils.isNotBlank(scd.getSchoolOfRecord()) && request.getSchoolOfRecords() != null && !request.getSchoolOfRecords().isEmpty() && !request.getSchoolOfRecords().contains(scd.getSchoolOfRecord())) + (request.getSchoolOfRecords() != null && !request.getSchoolOfRecords().isEmpty() && !request.getSchoolOfRecords().contains(scd.getSchoolOfRecord())) ) { scdIt.remove(); LOGGER.debug("Student Credential {}/{} removed by the filter \"{}\"", scd.getPen(), scd.getSchoolOfRecord(), String.join(",", request.getDistricts())); From 5183c036783265c8153788d0846d5f4eb2d75b91 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 18 Sep 2023 13:38:17 -0600 Subject: [PATCH 20/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../controller/JobLauncherController.java | 12 +++++---- .../api/batchgraduation/rest/RestUtils.java | 25 ++++++++++++++++--- .../EducGradBatchGraduationApiConstants.java | 3 +++ .../util/GradSchoolOfRecordFilter.java | 9 ++++++- api/src/main/resources/application.yaml | 2 ++ .../batchgraduation/util/RestUtilsTest.java | 18 +++++++++++++ api/src/test/resources/application.yaml | 2 ++ 7 files changed, 61 insertions(+), 10 deletions(-) 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 a0ba173d..8bd33c82 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 @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -434,15 +435,16 @@ public ResponseEntity launchRegenerateSchoolReports(@PathVariable Long @PreAuthorize(PermissionsConstants.RUN_GRAD_ALGORITHM) @Operation(summary = "Re-Generate School Reports for the given batchJobId", description = "RRe-Generate School Reports for the given batchJobId", tags = { "RE-RUN" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),@ApiResponse(responseCode = "500", description = "Internal Server Error")}) - public ResponseEntity launchRegenerateSchoolReports(@RequestBody StudentSearchRequest searchRequest, @RequestHeader(name="Authorization") String accessToken) { - logger.info(" Re-Generating School Reports by request for {} --------------------------------------------------------", REGALG); + public ResponseEntity launchRegenerateSchoolReports(@RequestBody StudentSearchRequest searchRequest, @RequestHeader(name="Authorization") String accessToken, @RequestParam(required = false) String type) { + String schoolReportType = ObjectUtils.defaultIfNull(type, REGALG); + logger.info(" Re-Generating School Reports by request for {} --------------------------------------------------------", schoolReportType); try { List finalSchoolDistricts = gradSchoolOfRecordFilter.filterSchoolOfRecords(searchRequest).stream().sorted().toList(); logger.info(" Number of Schools [{}] ---------------------------------------------------------", finalSchoolDistricts.size()); - restUtils.createAndStoreSchoolReports(accessToken.replace(BEARER, ""), finalSchoolDistricts, REGALG); - return ResponseEntity.ok(Boolean.TRUE); + int numberOfReports = restUtils.createAndStoreSchoolReports(accessToken.replace(BEARER, ""), finalSchoolDistricts, schoolReportType); + return ResponseEntity.ok(numberOfReports + " school reports " + schoolReportType + " created successfully"); } catch (Exception e) { - return ResponseEntity.status(500).body(Boolean.FALSE); + return ResponseEntity.status(500).body(e.getLocalizedMessage()); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 18693e3c..cba55a9c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -479,7 +479,7 @@ public GraduationStudentRecordDistribution getStudentData(String studentID, Stri return result; } - public void createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) { + public Integer createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) { UUID correlationID = UUID.randomUUID(); Integer result = webClient.post() .uri(String.format(constants.getCreateAndStoreSchoolReports(),type)) @@ -488,9 +488,8 @@ public void createAndStoreSchoolReports(String accessToken, List uniqueS .retrieve() .bodyToMono(Integer.class) .block(); - - if(result != null && result != 0) - LOGGER.info("Create and Store School Report Success {}",result); + LOGGER.info("Create and Store {} School Reports", result); + return result; } //Grad2-1931 sending transmissionType with the webclient. @@ -676,6 +675,24 @@ public List getSchoolBySchoolCategoryCode(String schoolCategoryCode) { } } + public List getSchoolByDistrictCode(String district) { + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { + }; + try { + String url = String.format(constants.getTraxSchoolByDistrict(), district); + return webClient.get().uri(url) + .headers(h -> { + h.setBearerAuth(getAccessToken()); + h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); + }) + .retrieve().bodyToMono(responseType) + .block(); + } catch (Exception e) { + LOGGER.error("Trax API is not available {}", e.getLocalizedMessage()); + return new ArrayList<>(); + } + } + public TraxSchool getTraxSchool(String mincode) { return get(String.format(constants.getTraxSchoolByMincode(), mincode), TraxSchool.class, getAccessToken()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java index c4cfc969..90954df3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java @@ -253,6 +253,9 @@ public class EducGradBatchGraduationApiConstants { @Value("${endpoint.grad-trax-api.school-by-school-category.url}") private String traxSchoolBySchoolCategory; + @Value("${endpoint.grad-trax-api.school-by-district-code.url}") + private String traxSchoolByDistrict; + @Value("${endpoint.grad-student-api.get-deceased-student-id-list}") private String deceasedStudentIDList; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java index d627e8bb..51ac7aa1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java @@ -41,7 +41,14 @@ public List filterSchoolOfRecords(StudentSearchRequest searchRequest) { if(!eligibleStudentSchoolDistricts.isEmpty()) { eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3))); } else { - eligibleStudentSchoolDistricts = searchRequest.getDistricts(); + for(String district: searchRequest.getDistricts()) { + logger.debug("Use district code {} to find list of schools", district); + List schools = restUtils.getSchoolByDistrictCode(district); + for(School school: schools) { + logger.debug("School {} found by district code {}", school.getMincode(), district); + eligibleStudentSchoolDistricts.add(school.getMincode()); + } + } } } if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) { diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index c691f348..1093a677 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -243,6 +243,8 @@ endpoint: url: ${GRAD_TRAX_API}api/v1/trax/psi/student?transmissionMode=%s&psiCode=%s&psiYear=%s school-by-min-code: url: ${GRAD_TRAX_API}api/v1/trax/school/%s + school-by-district-code: + url: ${GRAD_TRAX_API}api/v1/trax/school/search?district=%s district-by-school-category: url: ${GRAD_TRAX_API}api/v1/trax/district/schoolCategories?schoolCategory=%s school-by-school-category: diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index a146e7f5..20111e2a 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -1280,6 +1280,24 @@ public void testGetSchoolBySchoolCategoryCode() { assertThat(res).isNotNull(); } + @Test + public void testGetSchoolByDistrictCode() { + School school = new School(); + school.setMincode("1234567"); + + final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { + }; + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(constants.getTraxSchoolByDistrict(), "005"))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(List.of(school))); + + List res = this.restUtils.getSchoolByDistrictCode("005"); + assertThat(res).isNotNull(); + } + @Test public void testExecutePostDistribution() { DistributionResponse distributionResponse = new DistributionResponse(); diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 45112fe7..07e4b854 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -172,6 +172,8 @@ endpoint: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/psi/student?transmissionMode=%s&psiCode=%s&psiYear=%s school-by-min-code: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s + school-by-district-code: + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/search?district=%s district-by-school-category: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/district/schoolCategories?schoolCategory=%s school-by-school-category: From 21f0262bf1e2265a7cab77a31d0fc4937b35a86e Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 18 Sep 2023 13:40:31 -0600 Subject: [PATCH 21/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index cba55a9c..92058279 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -37,6 +37,7 @@ public class RestUtils { private static final String STUDENT_READ = "R:{}"; private static final String STUDENT_PROCESS = "P:{}"; private static final String STUDENT_PROCESSED = "D:{} {} of {} batch {}"; + private static final String TRAX_API_IS_DOWN = "Trax API is not available {}"; private static final String MERGE_MSG="Merge and Upload Success {}"; private static final String YEARENDDIST = "YEARENDDIST"; private static final String SUPPDIST = "SUPPDIST"; @@ -652,7 +653,7 @@ public List getDistrictBySchoolCategoryCode(String schoolCategoryCode) .retrieve().bodyToMono(responseType) .block(); } catch (Exception e) { - LOGGER.error("Trax API is not available {}", e.getLocalizedMessage()); + LOGGER.error(TRAX_API_IS_DOWN, e.getLocalizedMessage()); return new ArrayList<>(); } } @@ -670,7 +671,7 @@ public List getSchoolBySchoolCategoryCode(String schoolCategoryCode) { .retrieve().bodyToMono(responseType) .block(); } catch (Exception e) { - LOGGER.error("Trax API is not available {}", e.getLocalizedMessage()); + LOGGER.error(TRAX_API_IS_DOWN, e.getLocalizedMessage()); return new ArrayList<>(); } } @@ -688,7 +689,7 @@ public List getSchoolByDistrictCode(String district) { .retrieve().bodyToMono(responseType) .block(); } catch (Exception e) { - LOGGER.error("Trax API is not available {}", e.getLocalizedMessage()); + LOGGER.error(TRAX_API_IS_DOWN, e.getLocalizedMessage()); return new ArrayList<>(); } } From 63d3e25538703a3c39a924e67e9fd7be7af538d7 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 19 Sep 2023 08:47:14 -0600 Subject: [PATCH 22/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../api/batchgraduation/rest/RestUtils.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 92058279..4be37d85 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -482,13 +482,25 @@ public GraduationStudentRecordDistribution getStudentData(String studentID, Stri public Integer createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) { UUID correlationID = UUID.randomUUID(); - Integer result = webClient.post() - .uri(String.format(constants.getCreateAndStoreSchoolReports(),type)) - .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) - .body(BodyInserters.fromValue(uniqueSchools)) - .retrieve() - .bodyToMono(Integer.class) - .block(); + Integer result = 0; + if(uniqueSchools == null || uniqueSchools.isEmpty()) { + LOGGER.info("{} Schools selected for School Reports", result); + return result; + } + int pageSize = 1000; + int pageNum = uniqueSchools.size() / pageSize + 1; + for (int i = 0; i < pageNum; i++) { + int startIndex = i * pageSize; + int endIndex = Math.min(startIndex + pageSize, uniqueSchools.size()); + List mincodes = uniqueSchools.subList(startIndex, endIndex); + result += webClient.post() + .uri(String.format(constants.getCreateAndStoreSchoolReports(),type)) + .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) + .body(BodyInserters.fromValue(mincodes)) + .retrieve() + .bodyToMono(Integer.class) + .block(); + } LOGGER.info("Create and Store {} School Reports", result); return result; } From 495904fd27c11f567daeedd58b8d235a334e47ba Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 19 Sep 2023 09:04:47 -0600 Subject: [PATCH 23/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../controller/JobLauncherController.java | 8 ++++---- .../BaseRunCompletionNotificationListener.java | 6 +++--- .../gov/educ/api/batchgraduation/rest/RestUtils.java | 10 +++++++--- .../educ/api/batchgraduation/util/RestUtilsTest.java | 12 +++++++++--- 4 files changed, 23 insertions(+), 13 deletions(-) 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 8bd33c82..dd0ee3b5 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 @@ -415,14 +415,14 @@ public ResponseEntity launchRerunFailed(@PathVariable Long bat @PreAuthorize(PermissionsConstants.RUN_GRAD_ALGORITHM) @Operation(summary = "Re-Generate School Reports for the given batchJobId", description = "RRe-Generate School Reports for the given batchJobId", tags = { "RE-RUN" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),@ApiResponse(responseCode = "500", description = "Internal Server Error")}) - public ResponseEntity launchRegenerateSchoolReports(@PathVariable Long batchId, @RequestHeader(name="Authorization") String accessToken) { + public ResponseEntity launchRegenerateSchoolReports(@PathVariable Long batchId) { BatchGradAlgorithmJobHistoryEntity entity = gradBatchHistoryService.getGradAlgorithmJobHistory(batchId); if (entity != null) { try { logger.info(" Re-Generating School Reports for {} --------------------------------------------------------", entity.getJobType()); List uniqueSchoolList = gradBatchHistoryService.getSchoolListForReport(batchId); logger.info(" Number of Schools [{}] ---------------------------------------------------------", uniqueSchoolList.size()); - restUtils.createAndStoreSchoolReports(accessToken.replace(BEARER, ""), uniqueSchoolList, entity.getJobType()); + restUtils.createAndStoreSchoolReports(uniqueSchoolList, entity.getJobType()); return ResponseEntity.ok(Boolean.TRUE); } catch (Exception e) { return ResponseEntity.status(500).body(Boolean.FALSE); @@ -435,13 +435,13 @@ public ResponseEntity launchRegenerateSchoolReports(@PathVariable Long @PreAuthorize(PermissionsConstants.RUN_GRAD_ALGORITHM) @Operation(summary = "Re-Generate School Reports for the given batchJobId", description = "RRe-Generate School Reports for the given batchJobId", tags = { "RE-RUN" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),@ApiResponse(responseCode = "500", description = "Internal Server Error")}) - public ResponseEntity launchRegenerateSchoolReports(@RequestBody StudentSearchRequest searchRequest, @RequestHeader(name="Authorization") String accessToken, @RequestParam(required = false) String type) { + public ResponseEntity launchRegenerateSchoolReports(@RequestBody StudentSearchRequest searchRequest, @RequestParam(required = false) String type) { String schoolReportType = ObjectUtils.defaultIfNull(type, REGALG); logger.info(" Re-Generating School Reports by request for {} --------------------------------------------------------", schoolReportType); try { List finalSchoolDistricts = gradSchoolOfRecordFilter.filterSchoolOfRecords(searchRequest).stream().sorted().toList(); logger.info(" Number of Schools [{}] ---------------------------------------------------------", finalSchoolDistricts.size()); - int numberOfReports = restUtils.createAndStoreSchoolReports(accessToken.replace(BEARER, ""), finalSchoolDistricts, schoolReportType); + int numberOfReports = restUtils.createAndStoreSchoolReports(finalSchoolDistricts, schoolReportType); return ResponseEntity.ok(numberOfReports + " school reports " + schoolReportType + " created successfully"); } catch (Exception e) { return ResponseEntity.status(500).body(e.getLocalizedMessage()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java index 8f7228a0..d8466496 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/BaseRunCompletionNotificationListener.java @@ -77,7 +77,7 @@ protected void handleSummary(JobExecution jobExecution, String summaryDtoName, b if (!isSpecialRun) { updateBackStudentFlagForErroredStudents(summaryDTO.getErrors(), jobType, obj.getAccess_token()); } - processSchoolList(jobExecutionId, obj.getAccess_token(), jobType); + processSchoolList(jobExecutionId, jobType); } private void processBatchJobHistory(AlgorithmSummaryDTO summaryDTO, Long jobExecutionId, String status, String jobTrigger, String jobType, Date startTime, Date endTime) { @@ -107,11 +107,11 @@ private void updateBackStudentFlagForErroredStudents(Map err } } - private void processSchoolList(Long batchId, String accessToken, String jobType) { + private void processSchoolList(Long batchId, String jobType) { LOGGER.info(" Creating Reports for {}", jobType); List uniqueSchoolList = gradBatchHistoryService.getSchoolListForReport(batchId); LOGGER.info(" Number of Schools [{}]", uniqueSchoolList.size()); - restUtils.createAndStoreSchoolReports(accessToken,uniqueSchoolList,jobType); + restUtils.createAndStoreSchoolReports(uniqueSchoolList,jobType); } private long getTotalReadCount(Long batchId) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 4be37d85..54c05f6a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; @Component public class RestUtils { @@ -480,22 +481,25 @@ public GraduationStudentRecordDistribution getStudentData(String studentID, Stri return result; } - public Integer createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) { + public Integer createAndStoreSchoolReports(List uniqueSchools, String type) { UUID correlationID = UUID.randomUUID(); Integer result = 0; if(uniqueSchools == null || uniqueSchools.isEmpty()) { LOGGER.info("{} Schools selected for School Reports", result); return result; } - int pageSize = 1000; + int pageSize = 10; int pageNum = uniqueSchools.size() / pageSize + 1; for (int i = 0; i < pageNum; i++) { int startIndex = i * pageSize; int endIndex = Math.min(startIndex + pageSize, uniqueSchools.size()); List mincodes = uniqueSchools.subList(startIndex, endIndex); + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Creating School Reports for schools {}", mincodes.stream().collect(Collectors.joining(",", "{", "}"))); + } result += webClient.post() .uri(String.format(constants.getCreateAndStoreSchoolReports(),type)) - .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) + .headers(h -> { h.setBearerAuth(getAccessToken()); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); }) .body(BodyInserters.fromValue(mincodes)) .retrieve() .bodyToMono(Integer.class) diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index 20111e2a..4aa61340 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -822,7 +822,9 @@ public void testcreateAndStoreSchoolReports_null() { when(this.responseMock.bodyToMono(Integer.class)).thenReturn(inputResponseI); when(this.inputResponseI.block()).thenReturn(null); - this.restUtils.createAndStoreSchoolReports("Abc",new ArrayList<>(),type); + mockTokenResponseObject(); + + this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); } @@ -838,7 +840,9 @@ public void testcreateAndStoreSchoolReports() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(1)); - this.restUtils.createAndStoreSchoolReports("Abc",new ArrayList<>(),type); + mockTokenResponseObject(); + + this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); } @@ -854,7 +858,9 @@ public void testcreateAndStoreSchoolReports_0() { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(0)); - this.restUtils.createAndStoreSchoolReports("Abc",new ArrayList<>(),type); + mockTokenResponseObject(); + + this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); } From 933de57c18812a1329ab0fa78a035018797d8c3f Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 19 Sep 2023 09:14:22 -0600 Subject: [PATCH 24/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 54c05f6a..050b9aa5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -505,7 +505,7 @@ public Integer createAndStoreSchoolReports(List uniqueSchools, String ty .bodyToMono(Integer.class) .block(); } - LOGGER.info("Create and Store {} School Reports", result); + LOGGER.info("Created and Stored {} School Reports", result); return result; } From 0844fb126a4e8b009a25fd887b918c204bd708d0 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 19 Sep 2023 09:31:27 -0600 Subject: [PATCH 25/26] GRAD2-2312 HD-21648-GRAD - P3 - Regeneration of the Graduated Student SCHOOL Report --- .../gov/educ/api/batchgraduation/util/RestUtilsTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index 4aa61340..c85c3454 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -824,8 +824,9 @@ public void testcreateAndStoreSchoolReports_null() { mockTokenResponseObject(); - this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); + var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); + assertNotNull(result); } @Test @@ -842,8 +843,9 @@ public void testcreateAndStoreSchoolReports() { mockTokenResponseObject(); - this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); + var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); + assertNotNull(result); } @Test @@ -860,8 +862,9 @@ public void testcreateAndStoreSchoolReports_0() { mockTokenResponseObject(); - this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); + var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type); assertNotNull(type); + assertNotNull(result); } @Test From ac5e32c101957dd51b32ad3df77f88aff21e06ba Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Tue, 19 Sep 2023 22:49:35 +0530 Subject: [PATCH 26/26] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 04c81201..97eec32d 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-batch-graduation-api - 1.8.47 + 1.8.48 educ-grad-batch-graduation-api Ministry of Education GRAD BATCH GRADUATION API