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
diff --git a/api/pom.xml b/api/pom.xml
index 0f03557a..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
@@ -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
@@ -48,7 +50,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 +59,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.7.1
+ 3.0.2
@@ -97,19 +99,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
@@ -145,7 +138,11 @@
org.springframework.boot
spring-boot-starter-aop
-
+
+ org.hibernate.validator
+ hibernate-validator
+ 8.0.0.Final
+
org.springframework.boot
spring-boot-starter-actuator
@@ -157,12 +154,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..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
@@ -1,35 +1,45 @@
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.core.task.SyncTaskExecutor;
import org.springframework.stereotype.Component;
+import org.springframework.transaction.TransactionManager;
import javax.sql.DataSource;
@Configuration
@Profile("!test")
@Component
-public class BatchConfig extends DefaultBatchConfigurer {
+public class BatchConfig {
@Autowired
- public BatchConfig(@Qualifier("batchDataSource") DataSource batchDataSource) {
- super(batchDataSource);
- }
+ DataSource dataSource;
+
+ @Autowired
+ TransactionManager transactionManager;
@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(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..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
@@ -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("batchTransactionManager")
+ public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(batchEntityManager().getObject());
return transactionManager;
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..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
@@ -4,34 +4,32 @@
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.core.context.SecurityContextHolder;
+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.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
- .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/controller/JobLauncherController.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/controller/JobLauncherController.java
index 1e646cf8..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
@@ -7,16 +7,14 @@
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;
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;
@@ -37,7 +35,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;
@@ -91,6 +89,9 @@ public class JobLauncherController {
@Autowired
JsonTransformer jsonTransformer;
+ @Autowired
+ GradSchoolOfRecordFilter gradSchoolOfRecordFilter;
+
@Autowired
public JobLauncherController(
JobLauncher jobLauncher,
@@ -124,7 +125,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 +154,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 +223,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 +281,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 +314,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 +370,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 {
@@ -414,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);
@@ -430,6 +431,23 @@ 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, @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(finalSchoolDistricts, schoolReportType);
+ return ResponseEntity.ok(numberOfReports + " school reports " + schoolReportType + " created successfully");
+ } catch (Exception e) {
+ return ResponseEntity.status(500).body(e.getLocalizedMessage());
+ }
+ }
+
@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" })
@@ -453,6 +471,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 +501,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 +531,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 +561,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 +611,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 +648,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 +687,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();
@@ -671,7 +724,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 {
@@ -699,7 +752,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 1ab8c459..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
@@ -2,12 +2,12 @@
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;
+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 d5f07523..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
@@ -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.time.LocalDateTime;
+import java.util.UUID;
@Data
@Entity
@@ -36,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/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..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
@@ -1,11 +1,11 @@
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;
+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/entity/BatchJobExecutionParamEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchJobExecutionParamEntity.java
index a831f10c..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
@@ -1,14 +1,13 @@
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;
@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/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..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
@@ -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")
@@ -13,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/entity/BatchStepExecutionEntity.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/entity/BatchStepExecutionEntity.java
index f8e4dda5..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
@@ -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
@@ -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/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..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,14 +5,17 @@
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;
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;
@@ -42,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);
@@ -131,6 +134,10 @@ 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) {
+ 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..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
@@ -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");
@@ -76,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) {
@@ -89,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);
@@ -106,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/listener/DistributionRunCompletionNotificationListener.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/listener/DistributionRunCompletionNotificationListener.java
index 9c5fe779..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
@@ -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();
@@ -72,11 +71,11 @@ 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);
- 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 6fe6392e..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
@@ -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);
@@ -81,11 +82,11 @@ 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);
- 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 40b98156..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
@@ -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);
@@ -85,11 +86,11 @@ 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);
- 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());
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..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
@@ -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();
@@ -57,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/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..6e5248da 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,8 @@
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 ca.bc.gov.educ.api.batchgraduation.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.BatchStatus;
@@ -42,7 +44,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 +53,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");
@@ -76,6 +78,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 +139,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/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/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/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/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/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")
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 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, Logger logger) {
+ Map getStringExecutionContextMap(int gridSize, List credentialList, String credentialType) {
filterStudentCredentialDistribution(credentialList);
sortStudentCredentialDistributionByNames(credentialList);
int partitionSize = credentialList.size()/gridSize + 1;
@@ -200,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,6 +52,9 @@ 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
@@ -55,7 +65,7 @@ public Map partition(int gridSize) {
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");
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/DistributionRunYearlyNonGradPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/DistributionRunYearlyNonGradPartitioner.java
index f065fd6e..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,24 +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()) {
- eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getDistricts().contains(StringUtils.substring(scr, 0, 3)));
- }
- if(searchRequest != null && searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) {
- eligibleStudentSchoolDistricts.removeIf(scr->!searchRequest.getSchoolOfRecords().contains(scr));
- }
+ 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/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/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java
index 4afdbe9b..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
@@ -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;
@@ -28,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 {
@@ -36,6 +38,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";
@@ -75,7 +78,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 +112,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
@@ -478,18 +481,32 @@ public GraduationStudentRecordDistribution getStudentData(String studentID, Stri
return result;
}
- public void createAndStoreSchoolReports(String accessToken, List uniqueSchools,String type) {
+ public Integer createAndStoreSchoolReports(List uniqueSchools, String type) {
UUID correlationID = UUID.randomUUID();
- Integer result = webClient.post()
- .uri(String.format(constants.getCreateAndStore(),type))
- .headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); })
- .body(BodyInserters.fromValue(uniqueSchools))
- .retrieve()
- .bodyToMono(Integer.class)
- .block();
-
- if(result != null && result != 0)
- LOGGER.info("Create and Store School Report Success {}",result);
+ Integer result = 0;
+ if(uniqueSchools == null || uniqueSchools.isEmpty()) {
+ LOGGER.info("{} Schools selected for School Reports", result);
+ return result;
+ }
+ 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(getAccessToken()); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); })
+ .body(BodyInserters.fromValue(mincodes))
+ .retrieve()
+ .bodyToMono(Integer.class)
+ .block();
+ }
+ LOGGER.info("Created and Stored {} School Reports", result);
+ return result;
}
//Grad2-1931 sending transmissionType with the webclient.
@@ -652,7 +669,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 +687,25 @@ 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<>();
+ }
+ }
+
+ 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_DOWN, e.getLocalizedMessage());
return new ArrayList<>();
}
}
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/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/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/EducGradBatchGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/EducGradBatchGraduationApiConstants.java
index efcb1f19..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
@@ -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;
@@ -252,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
new file mode 100644
index 00000000..51ac7aa1
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/util/GradSchoolOfRecordFilter.java
@@ -0,0 +1,64 @@
+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 {
+ 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()) {
+ if(!eligibleStudentSchoolDistricts.isEmpty()) {
+ eligibleStudentSchoolDistricts.removeIf(scr -> !searchRequest.getSchoolOfRecords().contains(scr));
+ } else {
+ eligibleStudentSchoolDistricts = searchRequest.getSchoolOfRecords();
+ }
+ }
+ return eligibleStudentSchoolDistricts;
+ }
+
+}
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..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
@@ -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;
@@ -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/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/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/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 extends BlankCredentialDistribution> 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 extends StudentCredentialDistribution> 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 extends List> list) {
+ public void write(Chunk extends List> 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 extends PsiCredentialDistribution> 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 extends GraduationStudentRecord> list) throws Exception {
+ public void write(Chunk extends GraduationStudentRecord> 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 extends Integer> list) throws Exception {
+ public void write(Chunk extends Integer> 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 extends GraduationStudentRecord> list) throws Exception {
+ public void write(Chunk extends GraduationStudentRecord> 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 extends UserScheduledJobs> list) throws Exception {
+ public void write(Chunk extends UserScheduledJobs> list) {
LOGGER.debug("Recording Distribution Processed Data");
if(!list.isEmpty()) {
LOGGER.debug("Rescheduling Done\n");
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..f56412db
--- /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 java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+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)jsonTransformer.unmarshall(decodedContext, HashMap.class);
+ }
+}
diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml
index dbef4df1..1093a677 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:
@@ -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/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..550a9f8e
--- /dev/null
+++ b/api/src/main/resources/db/migration/1.0/V1.0.40__DDL-ALTER_TABLES_BATCH5-MIGRATION.sql
@@ -0,0 +1,49 @@
+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
+);
+
+ALTER TABLE BATCH_JOB_EXECUTION_PARAMS
+ ADD CONSTRAINT BATCH_JOB_EXECUTION_PARAMS_FK FOREIGN KEY (JOB_EXECUTION_ID)
+ REFERENCES BATCH_JOB_EXECUTION (JOB_EXECUTION_ID) DISABLE;
+
+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;
+
+COMMIT;
+
+ALTER TABLE BATCH_JOB_EXECUTION_PARAMS MODIFY CONSTRAINT BATCH_JOB_EXECUTION_PARAMS_FK ENABLE NOVALIDATE;
+
+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);
+
+
+
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..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
@@ -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");
@@ -129,13 +131,13 @@ 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);
- 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..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
@@ -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");
@@ -93,17 +98,17 @@ 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);
- 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");
@@ -151,17 +156,17 @@ 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);
- 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..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
@@ -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");
@@ -93,17 +98,17 @@ 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);
- 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");
@@ -153,17 +158,17 @@ 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);
- 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..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
@@ -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");
@@ -93,17 +98,17 @@ 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);
- 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");
@@ -151,17 +156,17 @@ 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);
- 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..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
@@ -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");
@@ -145,13 +149,13 @@ 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);
- 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");
@@ -235,13 +239,13 @@ 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);
- 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..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
@@ -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");
@@ -153,13 +155,13 @@ 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);
- 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");
@@ -268,13 +270,13 @@ 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);
- 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..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
@@ -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");
@@ -132,13 +136,13 @@ 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);
- 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/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);
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;
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..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
@@ -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);
@@ -822,8 +822,11 @@ 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();
+
+ var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type);
assertNotNull(type);
+ assertNotNull(result);
}
@Test
@@ -831,15 +834,18 @@ 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);
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();
+
+ var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type);
assertNotNull(type);
+ assertNotNull(result);
}
@Test
@@ -847,15 +853,18 @@ 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);
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();
+
+ var result = this.restUtils.createAndStoreSchoolReports(new ArrayList<>(),type);
assertNotNull(type);
+ assertNotNull(result);
}
@Test
@@ -1280,6 +1289,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: