001package ca.uhn.fhir.jpa.batch;
002
003/*-
004 * #%L
005 * HAPI FHIR JPA Server
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
024import ca.uhn.fhir.jpa.batch.mdm.job.MdmClearJobConfig;
025import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl;
026import ca.uhn.fhir.jpa.bulk.export.job.BulkExportJobConfig;
027import ca.uhn.fhir.jpa.bulk.imprt.job.BulkImportJobConfig;
028import ca.uhn.fhir.jpa.config.BatchJobRegisterer;
029import ca.uhn.fhir.jpa.delete.job.DeleteExpungeJobConfig;
030import ca.uhn.fhir.jpa.term.job.TermCodeSystemDeleteJobConfig;
031import ca.uhn.fhir.jpa.term.job.TermCodeSystemVersionDeleteJobConfig;
032import org.springframework.batch.core.configuration.JobRegistry;
033import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
034import org.springframework.batch.core.explore.JobExplorer;
035import org.springframework.batch.core.launch.JobLauncher;
036import org.springframework.batch.core.launch.support.SimpleJobOperator;
037import org.springframework.batch.core.repository.JobRepository;
038import org.springframework.context.annotation.Bean;
039import org.springframework.context.annotation.Configuration;
040import org.springframework.context.annotation.Import;
041
042@Configuration
043@EnableBatchProcessing
044@Import({
045        CommonBatchJobConfig.class,
046        BulkExportJobConfig.class,
047        BulkImportJobConfig.class,
048        DeleteExpungeJobConfig.class,
049        MdmClearJobConfig.class,
050        TermCodeSystemDeleteJobConfig.class,
051        TermCodeSystemVersionDeleteJobConfig.class
052  // When you define a new batch job, add it here.
053})
054public class BatchJobsConfig {
055        @Bean
056        public IBatchJobSubmitter batchJobSubmitter() {
057                return new BatchJobSubmitterImpl();
058        }
059
060        @Bean
061        public BatchJobRegisterer batchJobRegisterer() {
062                return new BatchJobRegisterer();
063        }
064
065        @Bean
066        public SimpleJobOperator jobOperator(JobExplorer theJobExplorer, JobRepository theJobRepository, JobRegistry theJobRegistry, JobLauncher theJobLauncher) {
067                SimpleJobOperator jobOperator = new SimpleJobOperator();
068
069                jobOperator.setJobExplorer(theJobExplorer);
070                jobOperator.setJobRepository(theJobRepository);
071                jobOperator.setJobRegistry(theJobRegistry);
072                jobOperator.setJobLauncher(theJobLauncher);
073
074                return jobOperator;
075        }
076}