This commit is contained in:
Tadgh 2020-06-01 12:13:55 -07:00
parent aa7d1cbcb7
commit 0fc2e04e65
10 changed files with 67 additions and 25 deletions

View File

@ -1,5 +1,7 @@
package ca.uhn.fhir.jpa.config;
import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
import ca.uhn.fhir.jpa.subscription.match.deliver.email.JavaMailEmailSender;
@ -35,6 +37,11 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
return new CircularQueueCaptureQueriesListener();
}
@Bean
public IBatchJobSubmitter batchJobSubmitter() {
return new BatchJobSubmitterImpl();
}
@Bean
public BasicDataSource basicDataSource() {
BasicDataSource retVal = new BasicDataSource() {

View File

@ -12,6 +12,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoSubscription;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
import ca.uhn.fhir.jpa.bulk.IBulkDataExportSvc;
import ca.uhn.fhir.jpa.config.TestDstu3Config;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
@ -106,6 +107,7 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
@ -132,6 +134,8 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
private static IValidationSupport ourJpaValidationSupportChainDstu3;
private static IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> ourValueSetDao;
//@Autowired
//protected IBatchJobSubmitter myBatchJobSubmitter;
@Autowired
protected ITermDeferredStorageSvc myTerminologyDeferredStorageSvc;
@Autowired

View File

@ -89,4 +89,9 @@ public class ExpungeHookTest extends BaseJpaDstu3Test {
IIdType hookId = hookParams.get(IIdType.class);
assertEquals(expungeId.getValue(), hookId.getValue());
}
@Test
public void testSubmitJob() {
//myBatchJobSubmitter.runJob(null, null);
}
}

View File

@ -65,6 +65,10 @@
<artifactId>javax.annotation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,10 @@
package ca.uhn.fhir.jpa.batch.api;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
public interface IBatchJobSubmitter {
JobExecution runJob(Job theJob, JobParameters theJobParameters);
}

View File

@ -11,7 +11,6 @@ import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
@ -26,13 +25,6 @@ public class InMemoryJobRepositoryBatchConfig implements BatchConfigurer {
private JobRepository myJobRepository;
private JobExplorer myJobExplorer;
@Autowired
private JobBuilderFactory myJobBuilderFactory;
@Autowired
private StepBuilderFactory myStepBuilderFactory;
@Override
public PlatformTransactionManager getTransactionManager() {
return myPlatformTransactionManager;

View File

@ -0,0 +1,37 @@
package ca.uhn.fhir.jpa.batch.svc;
import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.factory.annotation.Autowired;
public class BatchJobSubmitterImpl implements IBatchJobSubmitter {
@Autowired
private JobLauncher myJobLauncher;
@Override
public JobExecution runJob(Job theJob, JobParameters theJobParameters) {
try {
System.out.println("WTF");
return myJobLauncher.run(theJob, theJobParameters);
} catch (JobExecutionAlreadyRunningException theE) {
//FIXME properly handle these
theE.printStackTrace();
} catch (JobRestartException theE) {
theE.printStackTrace();
} catch (JobInstanceAlreadyCompleteException theE) {
theE.printStackTrace();
} catch (JobParametersInvalidException theE) {
theE.printStackTrace();
}
return null;
}
}

View File

@ -5,11 +5,3 @@ import org.springframework.stereotype.Service;
import static org.slf4j.LoggerFactory.getLogger;
@Service
public class DummyService {
private static final Logger ourLog = getLogger(DummyService.class);
public void test() {
ourLog.warn("test testing again");
}
}

View File

@ -1,9 +1,7 @@
package ca.uhn.fhir.jpa.batch;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.batch.config.BatchJobConfig;
import ca.uhn.fhir.jpa.batch.config.InMemoryJobRepositoryBatchConfig;
import ca.uhn.fhir.jpa.batch.svc.DummyService;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.springframework.batch.core.Job;
@ -23,8 +21,6 @@ abstract public class BaseBatchR4Test {
@Autowired
protected PlatformTransactionManager myPlatformTransactionManager;
@Autowired
protected DummyService myDummyService;
@Autowired
protected JobLauncher myJobLauncher;
@Autowired

View File

@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.batch.config;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.jpa.batch.svc.DummyService;
import ca.uhn.test.concurrency.IPointcutLatch;
import ca.uhn.test.concurrency.PointcutLatch;
import org.springframework.batch.core.Job;
@ -26,10 +25,6 @@ public class BatchJobConfig implements IPointcutLatch {
private final PointcutLatch myPointcutLatch = new PointcutLatch("batchJobLatch");
@Bean
public DummyService myDummyService() {
return new DummyService();
}
@Bean
public Job datJob() {