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