Skip to content

Commit

Permalink
Removed the legacy search. (#134)
Browse files Browse the repository at this point in the history
Removed the legacy search code. Also added a few unit tests that were missing.
  • Loading branch information
jackliums authored Oct 25, 2018
1 parent a0113dc commit ca52d9f
Show file tree
Hide file tree
Showing 126 changed files with 181 additions and 23,088 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class FhirServerConfiguration

public ConformanceConfiguration Conformance { get; } = new ConformanceConfiguration();

public SearchConfiguration Search { get; } = new SearchConfiguration();

public SecurityConfiguration Security { get; } = new SecurityConfiguration();
}
}
72 changes: 20 additions & 52 deletions src/Microsoft.Health.Fhir.Api/Modules/SearchModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@
using EnsureThat;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Health.Extensions.DependencyInjection;
using Microsoft.Health.Fhir.Api.Configs;
using Microsoft.Health.Fhir.Api.Features.Routing;
using Microsoft.Health.Fhir.Core.Configs;
using Microsoft.Health.Fhir.Core.Features.Conformance;
using Microsoft.Health.Fhir.Core.Features.Definition;
using Microsoft.Health.Fhir.Core.Features.Routing;
using Microsoft.Health.Fhir.Core.Features.Search;
using Microsoft.Health.Fhir.Core.Features.Search.Converters;
using Microsoft.Health.Fhir.Core.Features.Search.Expressions.Parsers;
using Microsoft.Health.Fhir.Core.Features.Search.Legacy;
using Microsoft.Health.Fhir.Core.Features.Search.Legacy.Expressions;
using Microsoft.Health.Fhir.Core.Features.Search.Legacy.SearchValues;
using Microsoft.Health.Fhir.Core.Features.Search.SearchValues;

namespace Microsoft.Health.Fhir.Api.Modules
Expand All @@ -28,14 +23,6 @@ namespace Microsoft.Health.Fhir.Api.Modules
/// </summary>
public class SearchModule : IStartupModule
{
private readonly SearchConfiguration _searchConfiguration;

public SearchModule(FhirServerConfiguration fhirServerConfiguration)
{
EnsureArg.IsNotNull(fhirServerConfiguration, nameof(fhirServerConfiguration));
_searchConfiguration = fhirServerConfiguration.Search;
}

/// <inheritdoc />
public void Load(IServiceCollection services)
{
Expand All @@ -44,48 +31,30 @@ public void Load(IServiceCollection services)
services.AddSingleton<IUrlResolver, UrlResolver>();
services.AddSingleton<IBundleFactory, BundleFactory>();

if (_searchConfiguration.UseLegacySearch)
{
services.AddSingleton<ISearchParamDefinitionManager, SearchParamDefinitionManager>();
services.AddSingleton<ISearchParamFactory, SearchParamFactory>();
services.Add<ResourceTypeManifestManager>()
.Singleton()
.AsSelf()
.AsService<IResourceTypeManifestManager>()
.AsService<IProvideCapability>();
services.AddSingleton<ISearchIndexer, LegacySearchIndexer>();
services.AddSingleton<ILegacySearchValueParser, LegacySearchValueParser>();
services.AddTransient<ILegacySearchValueExpressionBuilder, LegacySearchValueExpressionBuilder>();
services.AddSingleton<ILegacyExpressionParser, LegacyExpressionParser>();
services.AddSingleton<ISearchOptionsFactory, LegacySearchOptionsFactory>();
}
else
{
services.AddSingleton<IReferenceSearchValueParser, ReferenceSearchValueParser>();
services.AddSingleton<IReferenceSearchValueParser, ReferenceSearchValueParser>();

services.Add<SearchParameterDefinitionManager>()
.Singleton()
.AsSelf()
.AsService<IStartable>()
.AsService<IProvideCapability>()
.AsService<ISearchParameterDefinitionManager>();
services.Add<SearchParameterDefinitionManager>()
.Singleton()
.AsSelf()
.AsService<IStartable>()
.AsService<IProvideCapability>()
.AsService<ISearchParameterDefinitionManager>();

services.TypesInSameAssemblyAs<IFhirElementToSearchValueTypeConverter>()
.AssignableTo<IFhirElementToSearchValueTypeConverter>()
.Singleton()
.AsSelf()
.AsService<IFhirElementToSearchValueTypeConverter>();
services.TypesInSameAssemblyAs<IFhirElementToSearchValueTypeConverter>()
.AssignableTo<IFhirElementToSearchValueTypeConverter>()
.Singleton()
.AsSelf()
.AsService<IFhirElementToSearchValueTypeConverter>();

services.Add<FhirElementToSearchValueTypeConverterManager>()
.Singleton()
.AsSelf()
.AsService<IFhirElementToSearchValueTypeConverterManager>();
services.Add<FhirElementToSearchValueTypeConverterManager>()
.Singleton()
.AsSelf()
.AsService<IFhirElementToSearchValueTypeConverterManager>();

services.AddSingleton<ISearchIndexer, SearchIndexer>();
services.AddSingleton<ISearchValueExpressionBuilder, SearchValueExpressionBuilder>();
services.AddSingleton<IExpressionParser, ExpressionParser>();
services.AddSingleton<ISearchOptionsFactory, SearchOptionsFactory>();
}
services.AddSingleton<ISearchIndexer, SearchIndexer>();
services.AddSingleton<ISearchValueExpressionBuilder, SearchValueExpressionBuilder>();
services.AddSingleton<IExpressionParser, ExpressionParser>();
services.AddSingleton<ISearchOptionsFactory, SearchOptionsFactory>();

// TODO: Remove the following once bug 65143 is fixed.
// All of the classes that implement IProvideCapability will be automatically be picked up and registered.
Expand All @@ -94,7 +63,6 @@ public void Load(IServiceCollection services)
// at the logic for automatically registering types since different component could have different life time.
// For now, just manually remove the registration.
RemoveRegistration(typeof(IProvideCapability), typeof(SearchParameterDefinitionManager), ServiceLifetime.Transient);
RemoveRegistration(typeof(IProvideCapability), typeof(ResourceTypeManifestManager), ServiceLifetime.Transient);

void RemoveRegistration(Type serviceType, Type implementationType, ServiceLifetime lifetime)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public static IFhirServerBuilder AddFhirServer(
services.AddSingleton(Options.Options.Create(fhirServerConfiguration.Security));
services.AddSingleton(Options.Options.Create(fhirServerConfiguration.Conformance));
services.AddSingleton(Options.Options.Create(fhirServerConfiguration.Features));
services.AddSingleton(Options.Options.Create(fhirServerConfiguration.Search));
services.AddTransient<IStartupFilter, FhirServerStartupFilter>();

services.RegisterAssemblyModules(Assembly.GetExecutingAssembly(), fhirServerConfiguration);
Expand Down
Loading

0 comments on commit ca52d9f

Please sign in to comment.