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