Esempio n. 1
0
        public static MongoFhirIndex GetMongoFhirIndex(MongoDatabase database, IEnumerable <ModelInfo.SearchParamDefinition> searchparameters)
        {
            MongoIndexStore store       = new MongoIndexStore(database);
            Definitions     definitions = DefinitionsFactory.Generate(searchparameters);

            return(new MongoFhirIndex(store, definitions));
        }
Esempio n. 2
0
        public static FhirIndex CreateIndex()
        {
            MongoDatabase database = MongoDbConnector.Database;
            MongoCollection <BsonDocument> collection = database.GetCollection(Spark.Search.Config.MONGOINDEXCOLLECTION);

            Definitions definitions = DefinitionsFactory.GenerateFromMetadata();
            ISearcher   searcher    = new MongoSearcher(collection);
            IIndexer    indexer     = new MongoIndexer(collection, definitions);

            FhirIndex index = new FhirIndex(definitions, indexer, searcher);

            return(index);
        }
 public static void AddMongoFhirStore(this IServiceCollection services, StoreSettings settings)
 {
     services.TryAddSingleton <StoreSettings>(settings);
     services.TryAddTransient <IGenerator>((provider) => new MongoIdGenerator(settings.ConnectionString));
     services.TryAddTransient <IFhirStore>((provider) => new MongoFhirStore(settings.ConnectionString));
     services.TryAddTransient <IHistoryStore>((provider) => new HistoryStore(settings.ConnectionString));
     services.TryAddTransient <ISnapshotStore>((provider) => new MongoSnapshotStore(settings.ConnectionString));
     services.TryAddTransient <IFhirStoreAdministration>((provider) => new MongoStoreAdministration(settings.ConnectionString));
     services.TryAddTransient <MongoIndexMapper>();
     services.TryAddTransient <IIndexStore>((provider) => new MongoIndexStore(settings.ConnectionString, provider.GetRequiredService <MongoIndexMapper>()));
     services.TryAddTransient((provider) => new MongoIndexStore(settings.ConnectionString, provider.GetRequiredService <MongoIndexMapper>()));
     services.TryAddTransient((provider) => DefinitionsFactory.Generate(ModelInfo.SearchParameters));
     services.TryAddTransient <MongoIndexer>();
     services.TryAddTransient <MongoSearcher>();
     services.TryAddTransient <IFhirIndex, MongoFhirIndex>();
 }
Esempio n. 4
0
        public static void RegisterComponents()
        {
            var container = new UnityContainer();

#if DEBUG
            container.AddNewExtension <UnityLogExtension>();
#endif
            container.RegisterType <HomeController, HomeController>(new PerResolveLifetimeManager(),
                                                                    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IServiceListener, ServiceListener>(new ContainerControlledLifetimeManager());
            container.RegisterType <ILocalhost, Localhost>(new ContainerControlledLifetimeManager(),
                                                           new InjectionConstructor(Settings.Endpoint));
            container.RegisterType <MongoFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager(),
                                                                    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager());
            container.RegisterType <IGenerator, MongoFhirStore>(new ContainerControlledLifetimeManager());
            container.RegisterType <ISnapshotStore, MongoFhirStore>(new ContainerControlledLifetimeManager());
            container.RegisterType <IIndexStore, MongoIndexStore>(new ContainerControlledLifetimeManager());
            container.RegisterType <MongoIndexStore>(new ContainerControlledLifetimeManager(),
                                                     new InjectionConstructor(Settings.MongoUrl, container.Resolve <MongoIndexMapper>()));
            container.RegisterInstance <Definitions>(DefinitionsFactory.Generate(ModelInfo.SearchParameters));
            //TODO: Use FhirModel instead of ModelInfo
            container.RegisterType <IFhirIndex, MongoFhirIndex>(new ContainerControlledLifetimeManager());
            container.RegisterType <IFhirResponseFactory, FhirResponseFactory>();
            container.RegisterType <IFhirResponseInterceptorRunner, FhirResponseInterceptorRunner>();
            container.RegisterType <IFhirResponseInterceptor, ConditionalHeaderFhirResponseInterceptor>("ConditionalHeaderFhirResponseInterceptor");
            container.RegisterType <IFhirModel, FhirModel>(new ContainerControlledLifetimeManager(), new InjectionConstructor());
            container.RegisterType <FhirPropertyIndex>(new ContainerControlledLifetimeManager(), new InjectionConstructor(container.Resolve <IFhirModel>()));

            container.RegisterType <InitializeHub>(new HierarchicalLifetimeManager());
            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();
            IControllerFactory unityControllerFactory = new UnityControllerFactory(container);
            ControllerBuilder.Current.SetControllerFactory(unityControllerFactory);

            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
            GlobalHost.DependencyResolver = new SignalRUnityDependencyResolver(container);
        }
Esempio n. 5
0
        public static UnityContainer GetUnityContainer()
        {
            var container = new UnityContainer();

#if DEBUG
            container.AddNewExtension <UnityLogExtension>();
#endif
            container.RegisterType <HomeController, HomeController>(new PerResolveLifetimeManager(),
                                                                    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IServiceListener, ServiceListener>(new ContainerControlledLifetimeManager());
            container.RegisterType <ILocalhost, Localhost>(new ContainerControlledLifetimeManager(),
                                                           new InjectionConstructor(Settings.Endpoint));
            //container.RegisterType<MongoFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager(),
            //    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager(),
                                                                new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IGenerator, MongoIdGenerator>(new ContainerControlledLifetimeManager(),
                                                                  new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <ISnapshotStore, MongoSnapshotStore>(new ContainerControlledLifetimeManager(),
                                                                        new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirStoreAdministration, MongoStoreAdministration>(new ContainerControlledLifetimeManager(),
                                                                                        new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IIndexStore, MongoIndexStore>(new ContainerControlledLifetimeManager());
            container.RegisterType <IIndexService, IndexService>(new ContainerControlledLifetimeManager());

            container.RegisterType <ITransfer, Transfer>(new ContainerControlledLifetimeManager());
            container.RegisterType <MongoIndexStore>(new ContainerControlledLifetimeManager(),
                                                     new InjectionConstructor(Settings.MongoUrl, container.Resolve <MongoIndexMapper>()));
            container.RegisterInstance <Definitions>(DefinitionsFactory.Generate(ModelInfo.SearchParameters));
            //TODO: Use FhirModel instead of ModelInfo
            container.RegisterType <IReferenceNormalizationService, ReferenceNormalizationService>();
            container.RegisterType <IFhirModel, FhirModel>(new ContainerControlledLifetimeManager(),
                                                           new InjectionConstructor(SparkModelInfo.SparkSearchParameters));
            container.RegisterType <IFhirIndex, MongoFhirIndex>(new ContainerControlledLifetimeManager(),
                                                                new InjectionConstructor(
                                                                    container.Resolve <IIndexStore>(),
                                                                    container.Resolve <MongoSearcher>(),
                                                                    new SparkSettings
            {
                Search = new SearchSettings
                {
                    CheckReferences    = Settings.SearchCheckReferences,
                    CheckReferencesFor = Settings.SearchCheckReferencesFor
                }
            }));
            container.RegisterType <IFhirStorePagedReader, MongoFhirStorePagedReader>(new ContainerControlledLifetimeManager(),
                                                                                      new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirResponseFactory, FhirResponseFactory>();
            container.RegisterType <IFhirResponseInterceptorRunner, FhirResponseInterceptorRunner>();
            container.RegisterType <IFhirResponseInterceptor, ConditionalHeaderFhirResponseInterceptor>("ConditionalHeaderFhirResponseInterceptor");
            container.RegisterType <FhirPropertyIndex>(new ContainerControlledLifetimeManager(),
                                                       new InjectionConstructor(container.Resolve <IFhirModel>()));

            container.RegisterType <ElementIndexer>(new ContainerControlledLifetimeManager());
            container.RegisterType <ResourceVisitor>(new ContainerControlledLifetimeManager());

            container.RegisterType <CompressionHandler>(new ContainerControlledLifetimeManager(),
                                                        new InjectionConstructor(Settings.MaximumDecompressedBodySizeInBytes));

            container.RegisterType <InitializerHub>(new HierarchicalLifetimeManager());
            container.RegisterType <IHistoryStore, HistoryStore>(new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirService, FhirService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IIndexRebuildService, IndexRebuildService>(new ContainerControlledLifetimeManager(),
                                                                               new InjectionConstructor(
                                                                                   container.Resolve <IIndexStore>(),
                                                                                   container.Resolve <IIndexService>(),
                                                                                   container.Resolve <IFhirStorePagedReader>(),
                                                                                   new SparkSettings
            {
                IndexSettings = new IndexSettings
                {
                    ClearIndexOnRebuild = Settings.ClearIndexOnRebuild,
                    ReindexBatchSize    = Settings.ReindexBatchSize
                }
            }));

            container.RegisterType <IServiceListener, SearchService>("searchListener");
            container.RegisterType <IFhirServiceExtension, SearchService>("search");
            container.RegisterType <ISearchService, SearchService>();
            container.RegisterType <IFhirServiceExtension, TransactionService>("transaction");
            container.RegisterType <IFhirServiceExtension, HistoryService>("history");
            container.RegisterType <IFhirServiceExtension, PagingService>("paging");
            container.RegisterType <ISnapshotPaginationProvider, SnapshotPaginationProvider>();
            container.RegisterType <ISnapshotPaginationCalculator, SnapshotPaginationCalculator>();
            container.RegisterType <IFhirServiceExtension, ResourceStorageService>("storage");
            container.RegisterType <IFhirServiceExtension, ConformanceService>("conformance");
            container.RegisterType <ICompositeServiceListener, ServiceListener>(new ContainerControlledLifetimeManager());

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            return(container);
        }
Esempio n. 6
0
        public static UnityContainer GetUnityContainer()
        {
            var container = new UnityContainer();

#if DEBUG
            container.AddNewExtension <UnityLogExtension>();
#endif
            container.RegisterType <HomeController, HomeController>(new PerResolveLifetimeManager(),
                                                                    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IServiceListener, ServiceListener>(new ContainerControlledLifetimeManager());
            container.RegisterType <ILocalhost, Localhost>(new ContainerControlledLifetimeManager(),
                                                           new InjectionConstructor(Settings.Endpoint));
            //container.RegisterType<MongoFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager(),
            //    new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirStore, MongoFhirStore>(new ContainerControlledLifetimeManager(),
                                                                new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IGenerator, MongoIdGenerator>(new ContainerControlledLifetimeManager(),
                                                                  new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <ISnapshotStore, MongoSnapshotStore>(new ContainerControlledLifetimeManager(),
                                                                        new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirStoreAdministration, MongoStoreAdministration>(new ContainerControlledLifetimeManager(),
                                                                                        new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IIndexStore, MongoIndexStore>(new ContainerControlledLifetimeManager());

            container.RegisterType <ITransfer, Transfer>(new ContainerControlledLifetimeManager());
            container.RegisterType <MongoIndexStore>(new ContainerControlledLifetimeManager(),
                                                     new InjectionConstructor(Settings.MongoUrl, container.Resolve <MongoIndexMapper>()));
            container.RegisterInstance <Definitions>(DefinitionsFactory.Generate(ModelInfo.SearchParameters));
            //TODO: Use FhirModel instead of ModelInfo
            container.RegisterType <IFhirIndex, MongoFhirIndex>(new ContainerControlledLifetimeManager());
            container.RegisterType <IFhirResponseFactoryOld, FhirResponseFactoryOld>();
            container.RegisterType <IFhirResponseFactory, FhirResponseFactory>();
            container.RegisterType <IFhirResponseInterceptorRunner, FhirResponseInterceptorRunner>();
            container.RegisterType <IFhirResponseInterceptor, ConditionalHeaderFhirResponseInterceptor>("ConditionalHeaderFhirResponseInterceptor");
            container.RegisterType <IFhirModel, FhirModel>(new ContainerControlledLifetimeManager(),
                                                           new InjectionConstructor(SparkModelInfo.SparkSearchParameters));
            container.RegisterType <FhirPropertyIndex>(new ContainerControlledLifetimeManager(),
                                                       new InjectionConstructor(container.Resolve <IFhirModel>()));

            container.RegisterType <CompressionHandler>(new ContainerControlledLifetimeManager(),
                                                        new InjectionConstructor(Settings.MaximumDecompressedBodySizeInBytes));

            container.RegisterType <InitializerHub>(new HierarchicalLifetimeManager());
            container.RegisterType <IHistoryStore, HistoryStore>(new InjectionConstructor(Settings.MongoUrl));
            container.RegisterType <IFhirService, FhirService>(new ContainerControlledLifetimeManager());
            //new InjectionFactory(unityContainer => unityContainer.Resolve<IFhirService>
            //(new DependencyOverride(typeof(IFhirServiceExtension[]),
            //unityContainer.Resolve<IFhirExtensionsBuilder>().GetExtensions()))));

            container.RegisterType <IServiceListener, SearchService>("searchListener");
            container.RegisterType <IFhirServiceExtension, SearchService>("search");
            container.RegisterType <ISearchService, SearchService>();
            container.RegisterType <IFhirServiceExtension, TransactionService>("transaction");
            container.RegisterType <IFhirServiceExtension, HistoryService>("history");
            container.RegisterType <IFhirServiceExtension, PagingService>("paging");
            container.RegisterType <ISnapshotPaginationProvider, SnapshotPaginationProvider>();
            container.RegisterType <ISnapshotPaginationCalculator, SnapshotPaginationCalculator>();
            container.RegisterType <IFhirServiceExtension, ResourceStorageService>("storage");
            container.RegisterType <IFhirServiceExtension, CapabilityStatementService>("capabilityStatement");
            container.RegisterType <ICompositeServiceListener, ServiceListener>(new ContainerControlledLifetimeManager());

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            return(container);
        }