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