001/*
002 * #%L
003 * HAPI FHIR JPA Server
004 * %%
005 * Copyright (C) 2014 - 2023 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.jpa.config;
021
022import ca.uhn.fhir.batch2.api.IJobPersistence;
023import ca.uhn.fhir.batch2.jobs.export.BulkDataExportProvider;
024import ca.uhn.fhir.batch2.jobs.expunge.DeleteExpungeJobSubmitterImpl;
025import ca.uhn.fhir.context.FhirContext;
026import ca.uhn.fhir.context.FhirVersionEnum;
027import ca.uhn.fhir.context.support.IValidationSupport;
028import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
029import ca.uhn.fhir.interceptor.api.IInterceptorService;
030import ca.uhn.fhir.interceptor.executor.InterceptorService;
031import ca.uhn.fhir.interceptor.model.RequestPartitionId;
032import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
033import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
034import ca.uhn.fhir.jpa.api.model.ExpungeOptions;
035import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc;
036import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
037import ca.uhn.fhir.jpa.api.svc.IMdmClearHelperSvc;
038import ca.uhn.fhir.jpa.api.svc.ISearchUrlJobMaintenanceSvc;
039import ca.uhn.fhir.jpa.binary.interceptor.BinaryStorageInterceptor;
040import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider;
041import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportJobSchedulingHelper;
042import ca.uhn.fhir.jpa.bulk.export.svc.BulkDataExportJobSchedulingHelperImpl;
043import ca.uhn.fhir.jpa.bulk.export.svc.BulkExportHelperService;
044import ca.uhn.fhir.jpa.bulk.imprt.api.IBulkDataImportSvc;
045import ca.uhn.fhir.jpa.bulk.imprt.svc.BulkDataImportSvcImpl;
046import ca.uhn.fhir.jpa.bulk.mdm.MdmClearHelperSvcImpl;
047import ca.uhn.fhir.jpa.cache.IResourceVersionSvc;
048import ca.uhn.fhir.jpa.cache.ResourceVersionSvcDaoImpl;
049import ca.uhn.fhir.jpa.dao.DaoSearchParamProvider;
050import ca.uhn.fhir.jpa.dao.HistoryBuilder;
051import ca.uhn.fhir.jpa.dao.HistoryBuilderFactory;
052import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
053import ca.uhn.fhir.jpa.dao.IJpaStorageResourceParser;
054import ca.uhn.fhir.jpa.dao.ISearchBuilder;
055import ca.uhn.fhir.jpa.dao.JpaStorageResourceParser;
056import ca.uhn.fhir.jpa.dao.MatchResourceUrlService;
057import ca.uhn.fhir.jpa.dao.ObservationLastNIndexPersistSvc;
058import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
059import ca.uhn.fhir.jpa.dao.TransactionProcessor;
060import ca.uhn.fhir.jpa.dao.data.IResourceSearchUrlDao;
061import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService;
062import ca.uhn.fhir.jpa.dao.expunge.ExpungeOperation;
063import ca.uhn.fhir.jpa.dao.expunge.ExpungeService;
064import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService;
065import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService;
066import ca.uhn.fhir.jpa.dao.expunge.JpaResourceExpungeService;
067import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider;
068import ca.uhn.fhir.jpa.dao.index.DaoResourceLinkResolver;
069import ca.uhn.fhir.jpa.dao.index.DaoSearchParamSynchronizer;
070import ca.uhn.fhir.jpa.dao.index.IdHelperService;
071import ca.uhn.fhir.jpa.dao.index.SearchParamWithInlineReferencesExtractor;
072import ca.uhn.fhir.jpa.dao.mdm.JpaMdmLinkImplFactory;
073import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl;
074import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService;
075import ca.uhn.fhir.jpa.dao.validation.SearchParameterDaoValidator;
076import ca.uhn.fhir.jpa.delete.DeleteConflictFinderService;
077import ca.uhn.fhir.jpa.delete.DeleteConflictService;
078import ca.uhn.fhir.jpa.delete.ThreadSafeResourceDeleterSvc;
079import ca.uhn.fhir.jpa.entity.MdmLink;
080import ca.uhn.fhir.jpa.entity.Search;
081import ca.uhn.fhir.jpa.esr.ExternallyStoredResourceServiceRegistry;
082import ca.uhn.fhir.jpa.graphql.DaoRegistryGraphQLStorageServices;
083import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor;
084import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices;
085import ca.uhn.fhir.jpa.interceptor.OverridePathBasedReferentialIntegrityForDeletesInterceptor;
086import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingRuleBuilder;
087import ca.uhn.fhir.jpa.model.dao.JpaPid;
088import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
089import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager;
090import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
091import ca.uhn.fhir.jpa.packages.JpaPackageCache;
092import ca.uhn.fhir.jpa.packages.NpmJpaValidationSupport;
093import ca.uhn.fhir.jpa.packages.PackageInstallerSvcImpl;
094import ca.uhn.fhir.jpa.packages.util.PackageUtils;
095import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc;
096import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc;
097import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl;
098import ca.uhn.fhir.jpa.partition.PartitionManagementProvider;
099import ca.uhn.fhir.jpa.partition.RequestPartitionHelperSvc;
100import ca.uhn.fhir.jpa.provider.DiffProvider;
101import ca.uhn.fhir.jpa.provider.InstanceReindexProvider;
102import ca.uhn.fhir.jpa.provider.ProcessMessageProvider;
103import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
104import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider;
105import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider;
106import ca.uhn.fhir.jpa.provider.ValueSetOperationProviderDstu2;
107import ca.uhn.fhir.jpa.sched.AutowiringSpringBeanJobFactory;
108import ca.uhn.fhir.jpa.sched.HapiSchedulerServiceImpl;
109import ca.uhn.fhir.jpa.search.ISynchronousSearchSvc;
110import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider;
111import ca.uhn.fhir.jpa.search.PersistedJpaBundleProviderFactory;
112import ca.uhn.fhir.jpa.search.PersistedJpaSearchFirstPageBundleProvider;
113import ca.uhn.fhir.jpa.search.ResourceSearchUrlSvc;
114import ca.uhn.fhir.jpa.search.SearchStrategyFactory;
115import ca.uhn.fhir.jpa.search.SearchUrlJobMaintenanceSvcImpl;
116import ca.uhn.fhir.jpa.search.SynchronousSearchSvcImpl;
117import ca.uhn.fhir.jpa.search.builder.QueryStack;
118import ca.uhn.fhir.jpa.search.builder.predicate.ComboNonUniqueSearchParameterPredicateBuilder;
119import ca.uhn.fhir.jpa.search.builder.predicate.ComboUniqueSearchParameterPredicateBuilder;
120import ca.uhn.fhir.jpa.search.builder.predicate.CoordsPredicateBuilder;
121import ca.uhn.fhir.jpa.search.builder.predicate.DatePredicateBuilder;
122import ca.uhn.fhir.jpa.search.builder.predicate.ForcedIdPredicateBuilder;
123import ca.uhn.fhir.jpa.search.builder.predicate.NumberPredicateBuilder;
124import ca.uhn.fhir.jpa.search.builder.predicate.QuantityNormalizedPredicateBuilder;
125import ca.uhn.fhir.jpa.search.builder.predicate.QuantityPredicateBuilder;
126import ca.uhn.fhir.jpa.search.builder.predicate.ResourceIdPredicateBuilder;
127import ca.uhn.fhir.jpa.search.builder.predicate.ResourceLinkPredicateBuilder;
128import ca.uhn.fhir.jpa.search.builder.predicate.ResourceTablePredicateBuilder;
129import ca.uhn.fhir.jpa.search.builder.predicate.SearchParamPresentPredicateBuilder;
130import ca.uhn.fhir.jpa.search.builder.predicate.SourcePredicateBuilder;
131import ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder;
132import ca.uhn.fhir.jpa.search.builder.predicate.TagPredicateBuilder;
133import ca.uhn.fhir.jpa.search.builder.predicate.TokenPredicateBuilder;
134import ca.uhn.fhir.jpa.search.builder.predicate.UriPredicateBuilder;
135import ca.uhn.fhir.jpa.search.builder.sql.GeneratedSql;
136import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder;
137import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryExecutor;
138import ca.uhn.fhir.jpa.search.builder.sql.SqlObjectFactory;
139import ca.uhn.fhir.jpa.search.builder.tasks.SearchTask;
140import ca.uhn.fhir.jpa.search.cache.DatabaseSearchCacheSvcImpl;
141import ca.uhn.fhir.jpa.search.cache.DatabaseSearchResultCacheSvcImpl;
142import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc;
143import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc;
144import ca.uhn.fhir.jpa.search.elastic.IndexNamePrefixLayoutStrategy;
145import ca.uhn.fhir.jpa.search.reindex.IInstanceReindexService;
146import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
147import ca.uhn.fhir.jpa.search.reindex.InstanceReindexServiceImpl;
148import ca.uhn.fhir.jpa.search.reindex.ResourceReindexer;
149import ca.uhn.fhir.jpa.search.reindex.ResourceReindexingSvcImpl;
150import ca.uhn.fhir.jpa.search.warm.CacheWarmingSvcImpl;
151import ca.uhn.fhir.jpa.search.warm.ICacheWarmingSvc;
152import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
153import ca.uhn.fhir.jpa.searchparam.config.SearchParamConfig;
154import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver;
155import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamProvider;
156import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
157import ca.uhn.fhir.jpa.sp.SearchParamPresenceSvcImpl;
158import ca.uhn.fhir.jpa.term.TermCodeSystemStorageSvcImpl;
159import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
160import ca.uhn.fhir.jpa.term.TermReadSvcImpl;
161import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl;
162import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
163import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc;
164import ca.uhn.fhir.jpa.term.api.ITermReadSvc;
165import ca.uhn.fhir.jpa.term.api.ITermReindexingSvc;
166import ca.uhn.fhir.jpa.term.config.TermCodeSystemConfig;
167import ca.uhn.fhir.jpa.util.JpaHapiTransactionService;
168import ca.uhn.fhir.jpa.util.MemoryCacheService;
169import ca.uhn.fhir.jpa.util.PersistenceContextProvider;
170import ca.uhn.fhir.jpa.validation.ResourceLoaderImpl;
171import ca.uhn.fhir.jpa.validation.ValidationSettings;
172import ca.uhn.fhir.mdm.dao.IMdmLinkDao;
173import ca.uhn.fhir.mdm.dao.IMdmLinkImplFactory;
174import ca.uhn.fhir.mdm.svc.MdmLinkExpandSvc;
175import ca.uhn.fhir.model.api.IPrimitiveDatatype;
176import ca.uhn.fhir.rest.api.server.RequestDetails;
177import ca.uhn.fhir.rest.api.server.storage.IDeleteExpungeJobSubmitter;
178import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
179import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterceptor;
180import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc;
181import ca.uhn.fhir.rest.server.interceptor.consent.IConsentContextServices;
182import ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInterceptor;
183import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
184import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
185import org.hl7.fhir.common.hapi.validation.support.UnknownCodeSystemWarningValidationSupport;
186import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices;
187import org.springframework.beans.factory.annotation.Autowired;
188import org.springframework.context.annotation.Bean;
189import org.springframework.context.annotation.Configuration;
190import org.springframework.context.annotation.Import;
191import org.springframework.context.annotation.Lazy;
192import org.springframework.context.annotation.Primary;
193import org.springframework.context.annotation.Scope;
194import org.springframework.core.task.AsyncTaskExecutor;
195import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
196import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
197import org.springframework.scheduling.TaskScheduler;
198import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
199import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
200import org.springframework.transaction.PlatformTransactionManager;
201
202import java.util.Date;
203import javax.annotation.Nullable;
204
205@Configuration
206// repositoryFactoryBeanClass: EnversRevisionRepositoryFactoryBean is needed primarily for unit testing
207@EnableJpaRepositories(
208                basePackages = "ca.uhn.fhir.jpa.dao.data",
209                repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
210@Import({
211        BeanPostProcessorConfig.class,
212        TermCodeSystemConfig.class,
213        SearchParamConfig.class,
214        ValidationSupportConfig.class,
215        Batch2SupportConfig.class,
216        JpaBulkExportConfig.class,
217        SearchConfig.class,
218        PackageLoaderConfig.class,
219        EnversAuditConfig.class
220})
221public class JpaConfig {
222        public static final String JPA_VALIDATION_SUPPORT_CHAIN = "myJpaValidationSupportChain";
223        public static final String JPA_VALIDATION_SUPPORT = "myJpaValidationSupport";
224        public static final String TASK_EXECUTOR_NAME = "hapiJpaTaskExecutor";
225        public static final String GRAPHQL_PROVIDER_NAME = "myGraphQLProvider";
226        public static final String PERSISTED_JPA_BUNDLE_PROVIDER = "PersistedJpaBundleProvider";
227        public static final String PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH = "PersistedJpaBundleProvider_BySearch";
228        public static final String PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER =
229                        "PersistedJpaSearchFirstPageBundleProvider";
230        public static final String SEARCH_BUILDER = "SearchBuilder";
231        public static final String HISTORY_BUILDER = "HistoryBuilder";
232        private static final String HAPI_DEFAULT_SCHEDULER_GROUP = "HAPI";
233
234        @Autowired
235        public JpaStorageSettings myStorageSettings;
236
237        @Bean("myDaoRegistry")
238        public DaoRegistry daoRegistry() {
239                return new DaoRegistry();
240        }
241
242        @Lazy
243        @Bean
244        public CascadingDeleteInterceptor cascadingDeleteInterceptor(
245                        FhirContext theFhirContext,
246                        DaoRegistry theDaoRegistry,
247                        IInterceptorBroadcaster theInterceptorBroadcaster,
248                        ThreadSafeResourceDeleterSvc threadSafeResourceDeleterSvc) {
249                return new CascadingDeleteInterceptor(
250                                theFhirContext, theDaoRegistry, theInterceptorBroadcaster, threadSafeResourceDeleterSvc);
251        }
252
253        @Bean
254        public ExternallyStoredResourceServiceRegistry ExternallyStoredResourceServiceRegistry() {
255                return new ExternallyStoredResourceServiceRegistry();
256        }
257
258        @Lazy
259        @Bean
260        public ThreadSafeResourceDeleterSvc safeDeleter(
261                        DaoRegistry theDaoRegistry,
262                        IInterceptorBroadcaster theInterceptorBroadcaster,
263                        HapiTransactionService hapiTransactionService) {
264                return new ThreadSafeResourceDeleterSvc(theDaoRegistry, theInterceptorBroadcaster, hapiTransactionService);
265        }
266
267        @Lazy
268        @Bean
269        public ResponseTerminologyTranslationInterceptor responseTerminologyTranslationInterceptor(
270                        IValidationSupport theValidationSupport,
271                        ResponseTerminologyTranslationSvc theResponseTerminologyTranslationSvc) {
272                return new ResponseTerminologyTranslationInterceptor(
273                                theValidationSupport, theResponseTerminologyTranslationSvc);
274        }
275
276        @Bean
277        public ResponseTerminologyTranslationSvc responseTerminologyTranslationSvc(
278                        IValidationSupport theValidationSupport) {
279                return new ResponseTerminologyTranslationSvc(theValidationSupport);
280        }
281
282        @Bean
283        @Lazy
284        public IGraphQLStorageServices graphqlStorageServices() {
285                return new DaoRegistryGraphQLStorageServices();
286        }
287
288        @Bean
289        public ScheduledExecutorFactoryBean scheduledExecutorService() {
290                ScheduledExecutorFactoryBean b = new ScheduledExecutorFactoryBean();
291                b.setPoolSize(5);
292                b.afterPropertiesSet();
293                return b;
294        }
295
296        @Bean(name = "mySubscriptionTriggeringProvider")
297        @Lazy
298        public SubscriptionTriggeringProvider subscriptionTriggeringProvider() {
299                return new SubscriptionTriggeringProvider();
300        }
301
302        @Bean
303        @Lazy
304        public ValueSetOperationProvider valueSetOperationProvider(FhirContext theFhirContext) {
305                if (theFhirContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2)) {
306                        return new ValueSetOperationProviderDstu2();
307                }
308                return new ValueSetOperationProvider();
309        }
310
311        @Bean
312        public IJpaStorageResourceParser jpaStorageResourceParser() {
313                return new JpaStorageResourceParser();
314        }
315
316        @Bean
317        public TransactionProcessor transactionProcessor() {
318                return new TransactionProcessor();
319        }
320
321        @Bean(name = "myAttachmentBinaryAccessProvider")
322        @Lazy
323        public BinaryAccessProvider binaryAccessProvider() {
324                return new BinaryAccessProvider();
325        }
326
327        @Bean(name = "myBinaryStorageInterceptor")
328        @Lazy
329        public BinaryStorageInterceptor<? extends IPrimitiveDatatype<byte[]>> binaryStorageInterceptor(
330                        JpaStorageSettings theStorageSettings, FhirContext theCtx) {
331                BinaryStorageInterceptor<? extends IPrimitiveDatatype<byte[]>> interceptor =
332                                new BinaryStorageInterceptor<>(theCtx);
333                interceptor.setAllowAutoInflateBinaries(theStorageSettings.isAllowAutoInflateBinaries());
334                interceptor.setAutoInflateBinariesMaximumSize(theStorageSettings.getAutoInflateBinariesMaximumBytes());
335                return interceptor;
336        }
337
338        @Bean
339        public MemoryCacheService memoryCacheService(JpaStorageSettings theStorageSettings) {
340                return new MemoryCacheService(theStorageSettings);
341        }
342
343        @Bean
344        @Primary
345        public IResourceLinkResolver daoResourceLinkResolver() {
346                return new DaoResourceLinkResolver<JpaPid>();
347        }
348
349        @Bean(name = PackageUtils.LOADER_WITH_CACHE)
350        public IHapiPackageCacheManager packageCacheManager() {
351                return new JpaPackageCache();
352        }
353
354        @Bean
355        public NpmJpaValidationSupport npmJpaValidationSupport() {
356                return new NpmJpaValidationSupport();
357        }
358
359        @Bean
360        public ValidationSettings validationSettings() {
361                return new ValidationSettings();
362        }
363
364        @Bean
365        public ISearchCacheSvc searchCacheSvc() {
366                return new DatabaseSearchCacheSvcImpl();
367        }
368
369        @Bean
370        public ISearchResultCacheSvc searchResultCacheSvc() {
371                return new DatabaseSearchResultCacheSvcImpl();
372        }
373
374        @Bean
375        public ITermConceptMappingSvc termConceptMappingSvc() {
376                return new TermConceptMappingSvcImpl();
377        }
378
379        @Bean
380        public TaskScheduler taskScheduler() {
381                ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler();
382                retVal.setConcurrentExecutor(scheduledExecutorService().getObject());
383                retVal.setScheduledExecutor(scheduledExecutorService().getObject());
384                return retVal;
385        }
386
387        @Bean(name = TASK_EXECUTOR_NAME)
388        public AsyncTaskExecutor taskExecutor() {
389                ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler();
390                retVal.setConcurrentExecutor(scheduledExecutorService().getObject());
391                retVal.setScheduledExecutor(scheduledExecutorService().getObject());
392                return retVal;
393        }
394
395        @Bean
396        public IResourceReindexingSvc resourceReindexingSvc() {
397                return new ResourceReindexingSvcImpl();
398        }
399
400        @Bean
401        @Lazy
402        public IInstanceReindexService instanceReindexService() {
403                return new InstanceReindexServiceImpl();
404        }
405
406        @Bean
407        @Lazy
408        public InstanceReindexProvider instanceReindexProvider(IInstanceReindexService theInstanceReindexService) {
409                return new InstanceReindexProvider(theInstanceReindexService);
410        }
411
412        @Bean
413        public ResourceReindexer resourceReindexer(FhirContext theFhirContext) {
414                return new ResourceReindexer(theFhirContext);
415        }
416
417        @Bean
418        public HapiFhirHibernateJpaDialect hibernateJpaDialect(FhirContext theFhirContext) {
419                return new HapiFhirHibernateJpaDialect(theFhirContext.getLocalizer());
420        }
421
422        @Bean
423        @Lazy
424        public OverridePathBasedReferentialIntegrityForDeletesInterceptor
425                        overridePathBasedReferentialIntegrityForDeletesInterceptor() {
426                return new OverridePathBasedReferentialIntegrityForDeletesInterceptor();
427        }
428
429        @Bean
430        public IRequestPartitionHelperSvc requestPartitionHelperService() {
431                return new RequestPartitionHelperSvc();
432        }
433
434        @Bean
435        public HapiTransactionService hapiTransactionService() {
436                return new JpaHapiTransactionService();
437        }
438
439        @Bean
440        public IInterceptorService jpaInterceptorService() {
441                return new InterceptorService("JPA");
442        }
443
444        @Bean
445        public IPackageInstallerSvc npmInstallerSvc() {
446                return new PackageInstallerSvcImpl();
447        }
448
449        @Bean
450        public IConsentContextServices consentContextServices() {
451                return new JpaConsentContextServices();
452        }
453
454        @Bean
455        @Lazy
456        public DiffProvider diffProvider() {
457                return new DiffProvider();
458        }
459
460        @Bean
461        @Lazy
462        public IPartitionLookupSvc partitionConfigSvc() {
463                return new PartitionLookupSvcImpl();
464        }
465
466        @Bean
467        @Lazy
468        public PartitionManagementProvider partitionManagementProvider() {
469                return new PartitionManagementProvider();
470        }
471
472        @Bean
473        @Lazy
474        public RequestTenantPartitionInterceptor requestTenantPartitionInterceptor() {
475                return new RequestTenantPartitionInterceptor();
476        }
477
478        @Bean
479        public MdmLinkExpandSvc mdmLinkExpandSvc() {
480                return new MdmLinkExpandSvc();
481        }
482
483        @Bean
484        @Lazy
485        public TerminologyUploaderProvider terminologyUploaderProvider() {
486                return new TerminologyUploaderProvider();
487        }
488
489        @Bean
490        @Lazy
491        public ProcessMessageProvider processMessageProvider() {
492                return new ProcessMessageProvider();
493        }
494
495        @Bean
496        public ISchedulerService schedulerService() {
497                return new HapiSchedulerServiceImpl().setDefaultGroup(HAPI_DEFAULT_SCHEDULER_GROUP);
498        }
499
500        @Bean
501        public AutowiringSpringBeanJobFactory schedulerJobFactory() {
502                return new AutowiringSpringBeanJobFactory();
503        }
504
505        @Bean
506        public IBulkDataExportJobSchedulingHelper bulkDataExportJobSchedulingHelper(
507                        DaoRegistry theDaoRegistry,
508                        PlatformTransactionManager theTxManager,
509                        JpaStorageSettings theStorageSettings,
510                        BulkExportHelperService theBulkExportHelperSvc,
511                        IJobPersistence theJpaJobPersistence) {
512                return new BulkDataExportJobSchedulingHelperImpl(
513                                theDaoRegistry, theTxManager, theStorageSettings, theBulkExportHelperSvc, theJpaJobPersistence, null);
514        }
515
516        @Bean
517        @Lazy
518        public BulkDataExportProvider bulkDataExportProvider() {
519                return new BulkDataExportProvider();
520        }
521
522        @Bean
523        @Lazy
524        public IDeleteExpungeJobSubmitter deleteExpungeJobSubmitter() {
525                return new DeleteExpungeJobSubmitterImpl();
526        }
527
528        @Bean
529        @Lazy
530        public IBulkDataImportSvc bulkDataImportSvc() {
531                return new BulkDataImportSvcImpl();
532        }
533
534        @Bean
535        public PersistedJpaBundleProviderFactory persistedJpaBundleProviderFactory() {
536                return new PersistedJpaBundleProviderFactory();
537        }
538
539        @Bean
540        public SearchBuilderFactory searchBuilderFactory() {
541                return new SearchBuilderFactory();
542        }
543
544        @Bean
545        public SqlObjectFactory sqlBuilderFactory() {
546                return new SqlObjectFactory();
547        }
548
549        @Bean
550        public HibernatePropertiesProvider HibernatePropertiesProvider() {
551                return new HibernatePropertiesProvider();
552        }
553
554        @Bean
555        public HistoryBuilderFactory historyBuilderFactory() {
556                return new HistoryBuilderFactory();
557        }
558
559        @Bean
560        public IResourceVersionSvc resourceVersionSvc() {
561                return new ResourceVersionSvcDaoImpl();
562        }
563
564        /* **************************************************************** *
565         * Prototype Beans Below                                            *
566         * **************************************************************** */
567
568        @Bean(name = PERSISTED_JPA_BUNDLE_PROVIDER)
569        @Scope("prototype")
570        public PersistedJpaBundleProvider newPersistedJpaBundleProvider(RequestDetails theRequest, String theUuid) {
571                return new PersistedJpaBundleProvider(theRequest, theUuid);
572        }
573
574        @Bean(name = PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH)
575        @Scope("prototype")
576        public PersistedJpaBundleProvider newPersistedJpaBundleProvider(RequestDetails theRequest, Search theSearch) {
577                return new PersistedJpaBundleProvider(theRequest, theSearch);
578        }
579
580        @Bean(name = PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER)
581        @Scope("prototype")
582        public PersistedJpaSearchFirstPageBundleProvider newPersistedJpaSearchFirstPageBundleProvider(
583                        RequestDetails theRequest,
584                        Search theSearch,
585                        SearchTask theSearchTask,
586                        ISearchBuilder theSearchBuilder,
587                        RequestPartitionId theRequestPartitionId) {
588                return new PersistedJpaSearchFirstPageBundleProvider(
589                                theSearch, theSearchTask, theSearchBuilder, theRequest, theRequestPartitionId);
590        }
591
592        @Bean(name = RepositoryValidatingRuleBuilder.REPOSITORY_VALIDATING_RULE_BUILDER)
593        @Scope("prototype")
594        public RepositoryValidatingRuleBuilder repositoryValidatingRuleBuilder(IValidationSupport theValidationSupport) {
595                return new RepositoryValidatingRuleBuilder(theValidationSupport);
596        }
597
598        @Bean
599        @Scope("prototype")
600        public ComboUniqueSearchParameterPredicateBuilder newComboUniqueSearchParameterPredicateBuilder(
601                        SearchQueryBuilder theSearchSqlBuilder) {
602                return new ComboUniqueSearchParameterPredicateBuilder(theSearchSqlBuilder);
603        }
604
605        @Bean
606        @Scope("prototype")
607        public ComboNonUniqueSearchParameterPredicateBuilder newComboNonUniqueSearchParameterPredicateBuilder(
608                        SearchQueryBuilder theSearchSqlBuilder) {
609                return new ComboNonUniqueSearchParameterPredicateBuilder(theSearchSqlBuilder);
610        }
611
612        @Bean
613        @Scope("prototype")
614        public CoordsPredicateBuilder newCoordsPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
615                return new CoordsPredicateBuilder(theSearchBuilder);
616        }
617
618        @Bean
619        @Scope("prototype")
620        public DatePredicateBuilder newDatePredicateBuilder(SearchQueryBuilder theSearchBuilder) {
621                return new DatePredicateBuilder(theSearchBuilder);
622        }
623
624        @Bean
625        @Scope("prototype")
626        public ForcedIdPredicateBuilder newForcedIdPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
627                return new ForcedIdPredicateBuilder(theSearchBuilder);
628        }
629
630        @Bean
631        @Scope("prototype")
632        public NumberPredicateBuilder newNumberPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
633                return new NumberPredicateBuilder(theSearchBuilder);
634        }
635
636        @Bean
637        @Scope("prototype")
638        public QuantityPredicateBuilder newQuantityPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
639                return new QuantityPredicateBuilder(theSearchBuilder);
640        }
641
642        @Bean
643        @Scope("prototype")
644        public QuantityNormalizedPredicateBuilder newQuantityNormalizedPredicateBuilder(
645                        SearchQueryBuilder theSearchBuilder) {
646                return new QuantityNormalizedPredicateBuilder(theSearchBuilder);
647        }
648
649        @Bean
650        @Scope("prototype")
651        public ResourceLinkPredicateBuilder newResourceLinkPredicateBuilder(
652                        QueryStack theQueryStack, SearchQueryBuilder theSearchBuilder, boolean theReversed) {
653                return new ResourceLinkPredicateBuilder(theQueryStack, theSearchBuilder, theReversed);
654        }
655
656        @Bean
657        @Scope("prototype")
658        public ResourceTablePredicateBuilder newResourceTablePredicateBuilder(SearchQueryBuilder theSearchBuilder) {
659                return new ResourceTablePredicateBuilder(theSearchBuilder);
660        }
661
662        @Bean
663        @Scope("prototype")
664        public TagPredicateBuilder newTagPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
665                return new TagPredicateBuilder(theSearchBuilder);
666        }
667
668        @Bean
669        @Scope("prototype")
670        public ResourceIdPredicateBuilder newResourceIdPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
671                return new ResourceIdPredicateBuilder(theSearchBuilder);
672        }
673
674        @Bean
675        @Scope("prototype")
676        public SearchParamPresentPredicateBuilder newSearchParamPresentPredicateBuilder(
677                        SearchQueryBuilder theSearchBuilder) {
678                return new SearchParamPresentPredicateBuilder(theSearchBuilder);
679        }
680
681        @Bean
682        @Scope("prototype")
683        public StringPredicateBuilder newStringPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
684                return new StringPredicateBuilder(theSearchBuilder);
685        }
686
687        @Bean
688        @Scope("prototype")
689        public TokenPredicateBuilder newTokenPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
690                return new TokenPredicateBuilder(theSearchBuilder);
691        }
692
693        @Bean
694        @Scope("prototype")
695        public SourcePredicateBuilder newSourcePredicateBuilder(SearchQueryBuilder theSearchBuilder) {
696                return new SourcePredicateBuilder(theSearchBuilder);
697        }
698
699        @Bean
700        @Scope("prototype")
701        public UriPredicateBuilder newUriPredicateBuilder(SearchQueryBuilder theSearchBuilder) {
702                return new UriPredicateBuilder(theSearchBuilder);
703        }
704
705        @Bean
706        @Scope("prototype")
707        public SearchQueryExecutor newSearchQueryExecutor(GeneratedSql theGeneratedSql, Integer theMaxResultsToFetch) {
708                return new SearchQueryExecutor(theGeneratedSql, theMaxResultsToFetch);
709        }
710
711        @Bean(name = HISTORY_BUILDER)
712        @Scope("prototype")
713        public HistoryBuilder newPersistedJpaSearchFirstPageBundleProvider(
714                        @Nullable String theResourceType,
715                        @Nullable Long theResourceId,
716                        @Nullable Date theRangeStartInclusive,
717                        @Nullable Date theRangeEndInclusive) {
718                return new HistoryBuilder(theResourceType, theResourceId, theRangeStartInclusive, theRangeEndInclusive);
719        }
720
721        @Bean
722        @Primary
723        public ISearchParamProvider searchParamProvider() {
724                return new DaoSearchParamProvider();
725        }
726
727        @Bean
728        public IIdHelperService idHelperService() {
729                return new IdHelperService();
730        }
731
732        @Bean
733        public SearchStrategyFactory searchStrategyFactory(@Autowired(required = false) IFulltextSearchSvc theFulltextSvc) {
734                return new SearchStrategyFactory(myStorageSettings, theFulltextSvc);
735        }
736
737        @Bean
738        public DeleteConflictService deleteConflictService() {
739                return new DeleteConflictService();
740        }
741
742        @Bean
743        public DeleteConflictFinderService deleteConflictFinderService() {
744                return new DeleteConflictFinderService();
745        }
746
747        @Bean
748        public ExpungeService expungeService() {
749                return new ExpungeService();
750        }
751
752        @Bean
753        @Scope("prototype")
754        public ExpungeOperation expungeOperation(
755                        String theResourceName,
756                        IResourcePersistentId theResourceId,
757                        ExpungeOptions theExpungeOptions,
758                        RequestDetails theRequestDetails) {
759                return new ExpungeOperation(theResourceName, theResourceId, theExpungeOptions, theRequestDetails);
760        }
761
762        @Bean
763        public IExpungeEverythingService expungeEverythingService() {
764                return new ExpungeEverythingService();
765        }
766
767        @Bean
768        public IResourceExpungeService resourceExpungeService() {
769                return new JpaResourceExpungeService();
770        }
771
772        @Bean
773        public ISearchParamPresenceSvc searchParamPresenceService() {
774                return new SearchParamPresenceSvcImpl();
775        }
776
777        @Bean
778        public SearchParamWithInlineReferencesExtractor searchParamWithInlineReferencesExtractor() {
779                return new SearchParamWithInlineReferencesExtractor();
780        }
781
782        @Bean
783        public MatchResourceUrlService matchResourceUrlService() {
784                return new MatchResourceUrlService();
785        }
786
787        @Bean
788        public DaoSearchParamSynchronizer daoSearchParamSynchronizer() {
789                return new DaoSearchParamSynchronizer();
790        }
791
792        @Bean
793        public ResourceTableFKProvider resourceTableFKProvider() {
794                return new ResourceTableFKProvider();
795        }
796
797        @Bean
798        public ICacheWarmingSvc cacheWarmingSvc() {
799                return new CacheWarmingSvcImpl();
800        }
801
802        @Bean
803        public IndexNamePrefixLayoutStrategy indexLayoutStrategy() {
804                return new IndexNamePrefixLayoutStrategy();
805        }
806
807        @Bean
808        public ResourceLoaderImpl jpaResourceLoader() {
809                return new ResourceLoaderImpl();
810        }
811
812        @Bean
813        public UnknownCodeSystemWarningValidationSupport unknownCodeSystemWarningValidationSupport(
814                        FhirContext theFhirContext) {
815                return new UnknownCodeSystemWarningValidationSupport(theFhirContext);
816        }
817
818        @Bean
819        public ISynchronousSearchSvc synchronousSearchSvc() {
820                return new SynchronousSearchSvcImpl();
821        }
822
823        @Bean
824        public VersionCanonicalizer versionCanonicalizer(FhirContext theFhirContext) {
825                return new VersionCanonicalizer(theFhirContext);
826        }
827
828        @Bean
829        public SearchParameterDaoValidator searchParameterDaoValidator(
830                        FhirContext theFhirContext,
831                        JpaStorageSettings theStorageSettings,
832                        ISearchParamRegistry theSearchParamRegistry) {
833                return new SearchParameterDaoValidator(theFhirContext, theStorageSettings, theSearchParamRegistry);
834        }
835
836        @Bean
837        public ITermReadSvc terminologyService() {
838                return new TermReadSvcImpl();
839        }
840
841        @Bean
842        public ITermCodeSystemStorageSvc termCodeSystemStorageSvc() {
843                return new TermCodeSystemStorageSvcImpl();
844        }
845
846        @Bean
847        public ITermReindexingSvc termReindexingSvc() {
848                return new TermReindexingSvcImpl();
849        }
850
851        @Bean
852        public ObservationLastNIndexPersistSvc baseObservationLastNIndexpersistSvc() {
853                return new ObservationLastNIndexPersistSvc();
854        }
855
856        @Bean
857        public IMdmLinkDao<JpaPid, MdmLink> mdmLinkDao() {
858                return new MdmLinkDaoJpaImpl();
859        }
860
861        @Bean
862        IMdmLinkImplFactory<MdmLink> mdmLinkImplFactory() {
863                return new JpaMdmLinkImplFactory();
864        }
865
866        @Bean
867        @Scope("prototype")
868        public PersistenceContextProvider persistenceContextProvider() {
869                return new PersistenceContextProvider();
870        }
871
872        @Bean
873        public ResourceSearchUrlSvc resourceSearchUrlSvc(
874                        PersistenceContextProvider thePersistenceContextProvider,
875                        IResourceSearchUrlDao theResourceSearchUrlDao,
876                        MatchUrlService theMatchUrlService,
877                        FhirContext theFhirContext) {
878                return new ResourceSearchUrlSvc(
879                                thePersistenceContextProvider.getEntityManager(),
880                                theResourceSearchUrlDao,
881                                theMatchUrlService,
882                                theFhirContext);
883        }
884
885        @Bean
886        public ISearchUrlJobMaintenanceSvc searchUrlJobMaintenanceSvc(ResourceSearchUrlSvc theResourceSearchUrlSvc) {
887                return new SearchUrlJobMaintenanceSvcImpl(theResourceSearchUrlSvc);
888        }
889
890        @Bean
891        public IMdmClearHelperSvc<JpaPid> helperSvc(IDeleteExpungeSvc<JpaPid> theDeleteExpungeSvc) {
892                return new MdmClearHelperSvcImpl(theDeleteExpungeSvc);
893        }
894}