diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7c244f6d..e1da8b6c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,21 +70,6 @@ jobs: dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} secrets: inherit - build-api-legacy: - name: Build Api Legacy - uses: Informatievlaanderen/build-pipeline/.github/workflows/build-image.yml@main - needs: [ set-release-version ] - if: ${{ (github.repository_owner == 'Informatievlaanderen') && (needs.set-release-version.outputs.version != 'none') }} - with: - registry: ${{ vars.VBR_DEVOPS_DOCKER_REGISTRY }}/streetname-registry - image-file: sr-api-legacy-image.tar - image-name: api-legacy - test-project: StreetNameRegistry.Tests - build-project: StreetNameRegistry.Api.Legacy - semver: ${{ needs.set-release-version.outputs.version }} - dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} - secrets: inherit - build-api-oslo: name: Build Api Oslo uses: Informatievlaanderen/build-pipeline/.github/workflows/build-image.yml@main @@ -277,19 +262,6 @@ jobs: dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} secrets: inherit - pack-api-legacy: - name: Pack Api Legacy - uses: Informatievlaanderen/build-pipeline/.github/workflows/pack.yml@main - needs: [ set-release-version ] - if: ${{ (github.repository_owner == 'Informatievlaanderen') && (needs.set-release-version.outputs.version != 'none') }} - with: - pack-file: Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy - test-project: StreetNameRegistry.Tests - build-project: StreetNameRegistry.Api.Legacy - semver: ${{ needs.set-release-version.outputs.version }} - dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} - secrets: inherit - pack-api-oslo: name: Pack Api Oslo uses: Informatievlaanderen/build-pipeline/.github/workflows/pack.yml@main @@ -336,11 +308,9 @@ jobs: needs: [ set-release-version , pack-api-backoffice , pack-api-backoffice-abstractions - , pack-api-legacy , pack-api-oslo , pack-api-extract , build-api-backoffice - , build-api-legacy , build-api-oslo , build-api-extract , build-projector @@ -421,13 +391,6 @@ jobs: name: nuget-Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions-${{ needs.set-release-version.outputs.version }} path: dist/nuget/ - - name: Download NuGet Api Legacy - uses: actions/download-artifact@v4 - continue-on-error: false - with: - name: nuget-Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy-${{ needs.set-release-version.outputs.version }} - path: dist/nuget/ - - name: Download NuGet Api Oslo uses: actions/download-artifact@v4 continue-on-error: false @@ -544,12 +507,6 @@ jobs: name: nuget-Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions-${{ needs.release.outputs.version }} path: ~/ - - name: Download NuGet package api-legacy - uses: actions/download-artifact@v4 - with: - name: nuget-Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy-${{ needs.release.outputs.version }} - path: ~/ - - name: Download NuGet package api-oslo uses: actions/download-artifact@v4 with: @@ -567,7 +524,6 @@ jobs: run: | dotnet nuget push ~/Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY dotnet nuget push ~/Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.BackOffice.Abstractions.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY - dotnet nuget push ~/Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY dotnet nuget push ~/Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Oslo.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY dotnet nuget push ~/Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Extract.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY env: @@ -645,7 +601,6 @@ jobs: matrix: image: [ 'api-backoffice' - , 'api-legacy' , 'api-oslo' , 'api-extract' , 'projector' diff --git a/StreetNameRegistry.sln b/StreetNameRegistry.sln index 0e59c4b9d..108c8ca23 100755 --- a/StreetNameRegistry.sln +++ b/StreetNameRegistry.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetNameRegistry", "src\S EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetNameRegistry.Infrastructure", "src\StreetNameRegistry.Infrastructure\StreetNameRegistry.Infrastructure.csproj", "{E1FCCA44-C28C-487B-9940-C2DECDDDB5C4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetNameRegistry.Api.Legacy", "src\StreetNameRegistry.Api.Legacy\StreetNameRegistry.Api.Legacy.csproj", "{18DB6095-3226-4ABD-8344-B6D95E15B584}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetNameRegistry.Projections.Legacy", "src\StreetNameRegistry.Projections.Legacy\StreetNameRegistry.Projections.Legacy.csproj", "{0D30A3E9-D7BA-4B10-8D50-46A7916B838E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetNameRegistry.Tests", "test\StreetNameRegistry.Tests\StreetNameRegistry.Tests.csproj", "{91340EAA-A40A-4699-B63A-AD2E66F7BDF6}" @@ -95,10 +93,6 @@ Global {E1FCCA44-C28C-487B-9940-C2DECDDDB5C4}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1FCCA44-C28C-487B-9940-C2DECDDDB5C4}.Release|Any CPU.ActiveCfg = Release|Any CPU {E1FCCA44-C28C-487B-9940-C2DECDDDB5C4}.Release|Any CPU.Build.0 = Release|Any CPU - {18DB6095-3226-4ABD-8344-B6D95E15B584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18DB6095-3226-4ABD-8344-B6D95E15B584}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18DB6095-3226-4ABD-8344-B6D95E15B584}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18DB6095-3226-4ABD-8344-B6D95E15B584}.Release|Any CPU.Build.0 = Release|Any CPU {0D30A3E9-D7BA-4B10-8D50-46A7916B838E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0D30A3E9-D7BA-4B10-8D50-46A7916B838E}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D30A3E9-D7BA-4B10-8D50-46A7916B838E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -202,7 +196,6 @@ Global GlobalSection(NestedProjects) = preSolution {274FBBE0-6FCB-41CE-9E13-91BAF695B2D0} = {65EA04DE-5928-430F-92CA-24C11B6E5A00} {E1FCCA44-C28C-487B-9940-C2DECDDDB5C4} = {65EA04DE-5928-430F-92CA-24C11B6E5A00} - {18DB6095-3226-4ABD-8344-B6D95E15B584} = {65EA04DE-5928-430F-92CA-24C11B6E5A00} {0D30A3E9-D7BA-4B10-8D50-46A7916B838E} = {65EA04DE-5928-430F-92CA-24C11B6E5A00} {91340EAA-A40A-4699-B63A-AD2E66F7BDF6} = {81641B0B-BEFB-476D-8519-3774313E944B} {13300671-472A-4A2E-A4FE-B13DE3834175} = {B591EFE3-728F-4A40-BADF-3499F039C63A} diff --git a/src/StreetNameRegistry.Api.Legacy/Convertors/StraatnaamStatus.cs b/src/StreetNameRegistry.Api.Legacy/Convertors/StraatnaamStatus.cs deleted file mode 100644 index 8b3063844..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Convertors/StraatnaamStatus.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Convertors -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - - public static class StraatnaamStatusExtensions - { - public static StreetNameRegistry.StreetName.StreetNameStatus ConvertToStreetNameStatus(this StraatnaamStatus status) - { - switch (status) - { - default: - case StraatnaamStatus.InGebruik: - return StreetNameRegistry.StreetName.StreetNameStatus.Current; - - case StraatnaamStatus.Gehistoreerd: - return StreetNameRegistry.StreetName.StreetNameStatus.Retired; - - case StraatnaamStatus.Voorgesteld: - return StreetNameRegistry.StreetName.StreetNameStatus.Proposed; - } - } - - public static Municipality.StreetNameStatus ConvertToMunicipalityStreetNameStatus(this StraatnaamStatus status) - { - switch (status) - { - default: - case StraatnaamStatus.InGebruik: - return Municipality.StreetNameStatus.Current; - - case StraatnaamStatus.Gehistoreerd: - return Municipality.StreetNameStatus.Retired; - - case StraatnaamStatus.Voorgesteld: - return Municipality.StreetNameStatus.Proposed; - - case StraatnaamStatus.Afgekeurd: - return Municipality.StreetNameStatus.Rejected; - } - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Convertors/StreetNameStatus.cs b/src/StreetNameRegistry.Api.Legacy/Convertors/StreetNameStatus.cs deleted file mode 100644 index 6441dbac2..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Convertors/StreetNameStatus.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Convertors -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - - public static class StreetNameStatusExtensions - { - public static StraatnaamStatus ConvertFromMunicipalityStreetNameStatus(this Municipality.StreetNameStatus? status) - => ConvertFromMunicipalityStreetNameStatus(status ?? Municipality.StreetNameStatus.Current); - - public static StraatnaamStatus ConvertFromMunicipalityStreetNameStatus(this Municipality.StreetNameStatus status) - { - switch (status) - { - case Municipality.StreetNameStatus.Retired: - return StraatnaamStatus.Gehistoreerd; - - case Municipality.StreetNameStatus.Proposed: - return StraatnaamStatus.Voorgesteld; - - case Municipality.StreetNameStatus.Rejected: - return StraatnaamStatus.Afgekeurd; - - default: - case Municipality.StreetNameStatus.Current: - return StraatnaamStatus.InGebruik; - } - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Convertors/Taal.cs b/src/StreetNameRegistry.Api.Legacy/Convertors/Taal.cs deleted file mode 100644 index 9c3a512bd..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Convertors/Taal.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Convertors -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - - public static class TaalExtensions - { - public static Municipality.Language ConvertToMunicipalityLanguage(this Taal taal) - { - switch (taal) - { - default: - case Taal.NL: - return Municipality.Language.Dutch; - - case Taal.FR: - return Municipality.Language.French; - - case Taal.DE: - return Municipality.Language.German; - - case Taal.EN: - return Municipality.Language.English; - } - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Dockerfile b/src/StreetNameRegistry.Api.Legacy/Dockerfile deleted file mode 100644 index c3f0b9277..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM mcr.microsoft.com/dotnet/runtime-deps:8.0.2-bookworm-slim-amd64 -LABEL maintainer="Digitaal Vlaanderen " -LABEL registry="streetname-registry" - -COPY / /app -WORKDIR /app - -RUN apt-get update && \ - apt-get install curl jq -y && \ - chmod +x ./init.sh - -EXPOSE 4002/tcp -ENV ASPNETCORE_URLS http://*:4002 -ENV CORECLR_ENABLE_PROFILING=1 -ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} -ENV CORECLR_PROFILER_PATH=/app/datadog/linux-x64/Datadog.Trace.ClrProfiler.Native.so -ENV DD_DOTNET_TRACER_HOME=/app/datadog - -# Run the createLogPath script on Linux to ensure the automatic instrumentation logs are generated without permission issues -RUN /app/datadog/createLogPath.sh - -ENTRYPOINT ["./init.sh"] diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs deleted file mode 100644 index d4276f43e..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Be.Vlaanderen.Basisregisters.Api.Syndication; - using Microsoft.Extensions.Configuration; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - - public static class AtomFeedConfigurationBuilder - { - public static AtomFeedConfiguration CreateFrom(IConfigurationSection configuration, DateTimeOffset lastUpdated) - { - return new AtomFeedConfiguration( - configuration["Id"], - configuration["Title"], - configuration["Subtitle"], - configuration["GeneratorTitle"], - configuration["GeneratorUri"], - Assembly.GetEntryAssembly().GetName().Version.ToString(), - configuration["Rights"], - lastUpdated, - new SyndicationPerson(configuration["AuthorName"], configuration["AuthorEmail"], AtomContributorTypes.Author), - new SyndicationLink(new Uri(configuration["Self"]), AtomLinkTypes.Self), - new List(), - configuration - .GetSection("Related") - .GetChildren() - .Select(c => - new SyndicationLink(new Uri(c.Value), AtomLinkTypes.Related)) - .ToList() - ); - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs deleted file mode 100644 index b5a091f1e..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure.Configuration -{ - using System.Threading.Tasks; - using Microsoft.AspNetCore.Http; - - /// - /// Add headers to the response to prevent any caching. - /// - public class AddNoCacheHeadersMiddleware - { - private readonly RequestDelegate _next; - - public AddNoCacheHeadersMiddleware(RequestDelegate next) => _next = next; - - public Task Invoke(HttpContext context) - { - context.Response.Headers.Add("cache-control", "no-store, no-cache, must-revalidate"); - context.Response.Headers.Add("pragma", "no-cache"); - - return _next(context); - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/EmptyController.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/EmptyController.cs deleted file mode 100755 index 1f0c4009f..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/EmptyController.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure -{ - using System.Reflection; - using Asp.Versioning; - using Microsoft.AspNetCore.Mvc; - using Microsoft.Net.Http.Headers; - using Be.Vlaanderen.Basisregisters.Api; - - [ApiVersionNeutral] - [Route("")] - public class EmptyController : ApiController - { - [HttpGet] - [ApiExplorerSettings(IgnoreApi = true)] - public IActionResult Get() - => Request.Headers[HeaderNames.Accept].ToString().Contains("text/html") - ? (IActionResult)new RedirectResult("/docs") - : new OkObjectResult($"Welcome to the Basisregisters Vlaanderen StreetName Legacy Api {Assembly.GetEntryAssembly().GetVersionText()}."); - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs deleted file mode 100644 index 7c39dfc0c..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure.Modules -{ - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Logging; - using Projections.Legacy; - using Projections.Syndication; - - public class ApiModule : Module - { - private readonly IConfiguration _configuration; - private readonly IServiceCollection _services; - private readonly ILoggerFactory _loggerFactory; - - public ApiModule( - IConfiguration configuration, - IServiceCollection services, - ILoggerFactory loggerFactory) - { - _configuration = configuration; - _services = services; - _loggerFactory = loggerFactory; - } - - protected override void Load(ContainerBuilder builder) - { - builder - .RegisterModule(new LegacyModule(_configuration, _services, _loggerFactory)); - - builder - .RegisterModule(new SyndicationModule(_configuration, _services, _loggerFactory)); - - builder - .RegisterType() - .AsSelf(); - - builder.Populate(_services); - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs deleted file mode 100644 index db75e884c..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure.Modules -{ - using Autofac; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using MediatR; - using Microsoft.Extensions.Options; - using Options; - using Projections.Legacy; - using Projections.Syndication; - using StreetName.Count; - using StreetName.Detail; - using StreetName.List; - using StreetName.Sync; - - public sealed class MediatRModule : Module - { - protected override void Load(ContainerBuilder builder) - { - builder - .RegisterType() - .As() - .InstancePerLifetimeScope(); - - builder.RegisterType() - .AsImplementedInterfaces() - .InstancePerLifetimeScope(); - - builder.Register(c => (IRequestHandler) - new ListHandlerV2( - c.Resolve(), - c.Resolve(), - c.Resolve>())).InstancePerLifetimeScope(); - - builder.Register(c => (IRequestHandler) - new DetailHandlerV2( - c.Resolve(), - c.Resolve(), - c.Resolve>())).InstancePerLifetimeScope(); - - builder.Register(c => (IRequestHandler) - new CountHandlerV2( - c.Resolve(), - c.Resolve())).InstancePerLifetimeScope(); - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs deleted file mode 100644 index d9f18ee6d..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure.Options -{ - public class ResponseOptions - { - public string Naamruimte { get; set; } - public string GemeenteNaamruimte { get; set; } - public string VolgendeUrl { get; set; } - public string DetailUrl { get; set; } - public string GemeenteDetailUrl { get; set; } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Program.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Program.cs deleted file mode 100755 index 5901ae929..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Program.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure -{ - using Be.Vlaanderen.Basisregisters.Api; - using Microsoft.AspNetCore.Hosting; - - public static class Program - { - public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) - => new WebHostBuilder() - .UseDefaultForApi( - new ProgramOptions - { - Hosting = - { - HttpPort = 4002 - }, - Logging = - { - WriteTextToConsole = false, - WriteJsonToConsole = false - }, - Runtime = - { - CommandLineArgs = args - } - }); - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Startup.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Startup.cs deleted file mode 100755 index 637b7437f..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Startup.cs +++ /dev/null @@ -1,161 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.Infrastructure -{ - using System; - using System.Linq; - using System.Reflection; - using Asp.Versioning.ApiExplorer; - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Be.Vlaanderen.Basisregisters.Api; - using Configuration; - using Microsoft.AspNetCore.Builder; - using Microsoft.AspNetCore.Hosting; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Diagnostics.HealthChecks; - using Microsoft.Extensions.Hosting; - using Microsoft.Extensions.Logging; - using Microsoft.OpenApi.Models; - using Modules; - using Options; - - /// Represents the startup process for the application. - public class Startup - { - private const string DatabaseTag = "db"; - - private IContainer _applicationContainer; - - private readonly IConfiguration _configuration; - private readonly ILoggerFactory _loggerFactory; - - public Startup( - IConfiguration configuration, - ILoggerFactory loggerFactory) - { - _configuration = configuration; - _loggerFactory = loggerFactory; - } - - /// Configures services for the application. - /// The collection of services to configure the application with. - public IServiceProvider ConfigureServices(IServiceCollection services) - { - var baseUrl = _configuration.GetValue("BaseUrl"); - var baseUrlForExceptions = baseUrl.EndsWith("/") - ? baseUrl.Substring(0, baseUrl.Length - 1) - : baseUrl; - - services - .ConfigureDefaultForApi(new StartupConfigureOptions - { - Cors = - { - Origins = _configuration - .GetSection("Cors") - .GetChildren() - .Select(c => c.Value) - .ToArray() - }, - Server = - { - BaseUrl = baseUrlForExceptions - }, - Swagger = - { - ApiInfo = (provider, description) => new OpenApiInfo - { - Version = description.ApiVersion.ToString(), - Title = "Basisregisters Vlaanderen StreetName Registry API", - Description = GetApiLeadingText(description), - Contact = new OpenApiContact - { - Name = "Digitaal Vlaanderen", - Email = "digitaal.vlaanderen@vlaanderen.be", - Url = new Uri("https://legacy.basisregisters.vlaanderen") - } - }, - XmlCommentPaths = new[] { typeof(Startup).GetTypeInfo().Assembly.GetName().Name } - }, - MiddlewareHooks = - { - FluentValidation = fv => fv.RegisterValidatorsFromAssemblyContaining(), - - AfterHealthChecks = health => - { - var connectionStrings = _configuration - .GetSection("ConnectionStrings") - .GetChildren(); - - foreach (var connectionString in connectionStrings) - health.AddSqlServer( - connectionString.Value, - name: $"sqlserver-{connectionString.Key.ToLowerInvariant()}", - tags: new[] { DatabaseTag, "sql", "sqlserver" }); - } - } - }) - .Configure(_configuration); - - var containerBuilder = new ContainerBuilder(); - containerBuilder - .RegisterModule(new ApiModule(_configuration, services, _loggerFactory)) - .RegisterModule(new MediatRModule()); - - _applicationContainer = containerBuilder.Build(); - - return new AutofacServiceProvider(_applicationContainer); - } - - public void Configure( - IServiceProvider serviceProvider, - IApplicationBuilder app, - IWebHostEnvironment env, - IHostApplicationLifetime appLifetime, - ILoggerFactory loggerFactory, - IApiVersionDescriptionProvider apiVersionProvider, - HealthCheckService healthCheckService) - { - StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag, loggerFactory).GetAwaiter().GetResult(); - - app - .UseDefaultForApi(new StartupUseOptions - { - Common = - { - ApplicationContainer = _applicationContainer, - ServiceProvider = serviceProvider, - HostingEnvironment = env, - ApplicationLifetime = appLifetime, - LoggerFactory = loggerFactory, - }, - Api = - { - VersionProvider = apiVersionProvider, - Info = groupName => $"Basisregisters Vlaanderen - StreetName Registry API {groupName}", - CSharpClientOptions = - { - ClassName = "StreetNameRegistry", - Namespace = "Be.Vlaanderen.Basisregisters" - }, - TypeScriptClientOptions = - { - ClassName = "StreetNameRegistry" - } - }, - Server = - { - PoweredByName = "Vlaamse overheid - Basisregisters Vlaanderen", - ServerName = "Digitaal Vlaanderen" - }, - MiddlewareHooks = - { - AfterMiddleware = x => x.UseMiddleware(), - } - }); - } - - private static string GetApiLeadingText(ApiVersionDescription description) - => $"Momenteel leest u de documentatie voor versie {description.ApiVersion} van de Basisregisters Vlaanderen StreetName Registry API{string.Format(description.IsDeprecated ? ", **deze API versie is niet meer ondersteund * *." : ".")}"; - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/Properties/AssemblyInfo.cs b/src/StreetNameRegistry.Api.Legacy/Properties/AssemblyInfo.cs deleted file mode 100644 index d5caa321d..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyDescription("StreetNameRegistry Legacy API")] - -[assembly: AssemblyProduct("Basisregisters Vlaanderen")] -[assembly: AssemblyCopyright("Copyright (c) Vlaamse overheid")] -[assembly: AssemblyCompany("Vlaamse overheid")] -[assembly: ComVisible(false)] -[assembly: Guid("f8b1f1ad-4653-48ee-ae8e-c8971e66e169")] diff --git a/src/StreetNameRegistry.Api.Legacy/Properties/launchSettings.json b/src/StreetNameRegistry.Api.Legacy/Properties/launchSettings.json deleted file mode 100644 index 5ade8a2e1..000000000 --- a/src/StreetNameRegistry.Api.Legacy/Properties/launchSettings.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:13215/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "StreetNameRegistry.Api.Legacy": { - "commandName": "Project", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:5000/" - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs deleted file mode 100644 index f594aa58c..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Count -{ - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using MediatR; - using Microsoft.EntityFrameworkCore; - using Projections.Legacy; - using Projections.Legacy.StreetNameListV2; - using Projections.Syndication; - using Query; - - public sealed record CountRequest(FilteringHeader Filtering, SortingHeader Sorting) : IRequest; - - public sealed class CountHandlerV2 : IRequestHandler - { - private readonly LegacyContext _legacyContext; - private readonly SyndicationContext _syndicationContext; - - public CountHandlerV2(LegacyContext legacyContext, SyndicationContext syndicationContext) - { - _legacyContext = legacyContext; - _syndicationContext = syndicationContext; - } - - public async Task Handle(CountRequest request, CancellationToken cancellationToken) - { - var pagination = new NoPaginationRequest(); - - return - new TotaalAantalResponse - { - Aantal = await new StreetNameListQueryV2(_legacyContext, _syndicationContext) - .Fetch(request.Filtering, request.Sorting, pagination) - .Items - .CountAsync(cancellationToken) - }; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/TotalCountResponseExample.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/TotalCountResponseExample.cs deleted file mode 100644 index 221069745..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/TotalCountResponseExample.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Count -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Swashbuckle.AspNetCore.Filters; - - public sealed class TotalCountResponseExample : IExamplesProvider - { - public TotaalAantalResponse GetExamples() - { - return new TotaalAantalResponse - { - Aantal = 574512 - }; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/DetailHandlerV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/DetailHandlerV2.cs deleted file mode 100644 index 6cbcde062..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/DetailHandlerV2.cs +++ /dev/null @@ -1,110 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Detail -{ - using System.Collections.Generic; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Gemeente; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - using Convertors; - using Infrastructure.Options; - using MediatR; - using Microsoft.AspNetCore.Http; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Options; - using Projections.Legacy; - using Projections.Syndication; - using Projections.Syndication.Municipality; - - public sealed record DetailRequest(int PersistentLocalId) : IRequest; - - public sealed class DetailHandlerV2 : IRequestHandler - { - private readonly LegacyContext _legacyContext; - private readonly SyndicationContext _syndicationContext; - private readonly IOptions _responseOptions; - - public DetailHandlerV2( - LegacyContext legacyContext, - SyndicationContext syndicationContext, - IOptions responseOptions) - { - _legacyContext = legacyContext; - _syndicationContext = syndicationContext; - _responseOptions = responseOptions; - } - - public async Task Handle(DetailRequest request, CancellationToken cancellationToken) - { - var streetNameV2 = await _legacyContext - .StreetNameDetailV2 - .AsNoTracking() - .SingleOrDefaultAsync(x => x.PersistentLocalId == request.PersistentLocalId, cancellationToken); - - if (streetNameV2 == null) - { - throw new ApiException("Onbestaande straatnaam.", StatusCodes.Status404NotFound); - } - - if (streetNameV2.Removed) - { - throw new ApiException("Straatnaam verwijderd.", StatusCodes.Status410Gone); - } - - var gemeenteV2 = await GetStraatnaamDetailGemeente(_syndicationContext, streetNameV2.NisCode, _responseOptions.Value.GemeenteDetailUrl, cancellationToken); - return new StreetNameResponse( - _responseOptions.Value.Naamruimte, - request.PersistentLocalId, - streetNameV2.Status.ConvertFromMunicipalityStreetNameStatus(), - gemeenteV2, - streetNameV2.VersionTimestamp.ToBelgianDateTimeOffset(), - streetNameV2.NameDutch, - streetNameV2.NameFrench, - streetNameV2.NameGerman, - streetNameV2.NameEnglish, - streetNameV2.HomonymAdditionDutch, - streetNameV2.HomonymAdditionFrench, - streetNameV2.HomonymAdditionGerman, - streetNameV2.HomonymAdditionEnglish, - streetNameV2.LastEventHash); - } - - public async Task GetStraatnaamDetailGemeente(SyndicationContext syndicationContext, string nisCode, string gemeenteDetailUrl, CancellationToken ct) - { - var municipality = await syndicationContext - .MunicipalityLatestItems - .AsNoTracking() - .OrderByDescending(m => m.Position) - .FirstOrDefaultAsync(m => m.NisCode == nisCode, ct); - - var municipalityDefaultName = GetDefaultMunicipalityName(municipality); - var gemeente = new StraatnaamDetailGemeente - { - ObjectId = nisCode, - Detail = string.Format(gemeenteDetailUrl, nisCode), - Gemeentenaam = new Gemeentenaam(new GeografischeNaam(municipalityDefaultName.Value, municipalityDefaultName.Key)) - }; - return gemeente; - } - - private static KeyValuePair GetDefaultMunicipalityName(MunicipalityLatestItem? municipality) - { - switch (municipality?.PrimaryLanguage) - { - default: - case null: - case Taal.NL: - return new KeyValuePair(Taal.NL, municipality?.NameDutch ?? string.Empty); - case Taal.FR: - return new KeyValuePair(Taal.FR, municipality.NameFrench ?? string.Empty); - case Taal.DE: - return new KeyValuePair(Taal.DE, municipality.NameGerman ?? string.Empty); - case Taal.EN: - return new KeyValuePair(Taal.EN, municipality.NameEnglish ?? string.Empty); - } - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/StreetNameResponse.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/StreetNameResponse.cs deleted file mode 100644 index 37e4600aa..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Detail/StreetNameResponse.cs +++ /dev/null @@ -1,196 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Detail -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Runtime.Serialization; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Gemeente; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - using Infrastructure.Options; - using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.Options; - using Newtonsoft.Json; - using Swashbuckle.AspNetCore.Filters; - using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; - - [DataContract(Name = "StraatnaamDetail", Namespace = "")] - public class StreetNameResponse - { - /// - /// De identificator van de straatnaam. - /// - [DataMember(Name = "Identificator", Order = 1)] - [JsonProperty(Required = Required.DisallowNull)] - public StraatnaamIdentificator Identificator { get; set; } - - /// - /// De gemeente aan dewelke de straatnaam is toegewezen. - /// - [DataMember(Name = "Gemeente", Order = 2)] - [JsonProperty(Required = Required.DisallowNull)] - public StraatnaamDetailGemeente Gemeente { get; set; } - - /// - /// De straatnaam in verschillende talen. - /// - [DataMember(Name = "Straatnamen", Order = 3)] - [JsonProperty(Required = Required.DisallowNull)] - public List Straatnamen { get; set; } - - /// - /// De homoniem-toevoegingen aan de straatnaam in verschillende talen. - /// - [DataMember(Name = "HomoniemToevoegingen", Order = 4)] - [JsonProperty(Required = Required.DisallowNull)] - public List HomoniemToevoegingen { get; set; } - - /// - /// De huidige fase in de levensloop van een straatnaam. - /// - [DataMember(Name = "StraatnaamStatus", Order = 5)] - [JsonProperty(Required = Required.DisallowNull)] - public StraatnaamStatus StraatnaamStatus { get; set; } - - [IgnoreDataMember] - [JsonIgnore] - internal string? LastEventHash { get; } - - public StreetNameResponse( - string naamruimte, - int persistentLocalId, - StraatnaamStatus status, - StraatnaamDetailGemeente gemeente, - DateTimeOffset version, - string? nameDutch = null, - string? nameFrench = null, - string? nameGerman = null, - string? nameEnglish = null, - string? homonymAdditionDutch = null, - string? homonymAdditionFrench = null, - string? homonymAdditionGerman = null, - string? homonymAdditionEnglish = null, - string? lastEventHash = null) - { - Identificator = new StraatnaamIdentificator(naamruimte, persistentLocalId.ToString(), version); - StraatnaamStatus = status; - Gemeente = gemeente; - - var straatNamen = new List - { - new GeografischeNaam(nameDutch ?? string.Empty, Taal.NL), - new GeografischeNaam(nameFrench ?? string.Empty, Taal.FR), - new GeografischeNaam(nameGerman ?? string.Empty, Taal.DE), - new GeografischeNaam(nameEnglish ?? string.Empty, Taal.EN) - }; - - Straatnamen = straatNamen.Where(x => !string.IsNullOrEmpty(x.Spelling)).ToList(); - - var homoniemen = new List - { - new GeografischeNaam(homonymAdditionDutch ?? string.Empty, Taal.NL), - new GeografischeNaam(homonymAdditionFrench ?? string.Empty, Taal.FR), - new GeografischeNaam(homonymAdditionGerman ?? string.Empty, Taal.DE), - new GeografischeNaam(homonymAdditionEnglish ?? string.Empty, Taal.EN) - }; - - HomoniemToevoegingen = homoniemen.Where(x => !string.IsNullOrEmpty(x.Spelling)).ToList(); - - LastEventHash = lastEventHash; - } - } - - public class StreetNameResponseExamples : IExamplesProvider - { - private readonly ResponseOptions _responseOptions; - - public StreetNameResponseExamples(IOptions responseOptionsProvider) - => _responseOptions = responseOptionsProvider.Value; - - public StreetNameResponse GetExamples() - { - var gemeente = new StraatnaamDetailGemeente - { - ObjectId = "31005", - Detail = string.Format(_responseOptions.GemeenteDetailUrl, "31005"), - Gemeentenaam = new Gemeentenaam(new GeografischeNaam("Brugge", Taal.NL)) - }; - - var rnd = new Random(); - - return new StreetNameResponse( - _responseOptions.Naamruimte, - rnd.Next(10000, 15000), - StraatnaamStatus.InGebruik, - gemeente, - DateTimeOffset.Now.ToExampleOffset(), - "Baliestraat"); - } - } - - public class StreetNameNotFoundResponseExamples : IExamplesProvider - { - private readonly IHttpContextAccessor _httpContextAccessor; - private readonly ProblemDetailsHelper _problemDetailsHelper; - - public StreetNameNotFoundResponseExamples( - IHttpContextAccessor httpContextAccessor, - ProblemDetailsHelper problemDetailsHelper) - { - _httpContextAccessor = httpContextAccessor; - _problemDetailsHelper = problemDetailsHelper; - } - - public ProblemDetails GetExamples() - { - var httpContext = _httpContextAccessor.HttpContext; - if (httpContext is null) - { - return new ProblemDetails(); - } - - return new ProblemDetails - { - ProblemTypeUri = "urn:be.vlaanderen.basisregisters.api:streetname:not-found", - HttpStatus = StatusCodes.Status404NotFound, - Title = ProblemDetails.DefaultTitle, - Detail = "Onbestaande straatnaam.", - ProblemInstanceUri = _problemDetailsHelper.GetInstanceUri(httpContext, "v1") - }; - } - } - - public class StreetNameGoneResponseExamples : IExamplesProvider - { - private readonly IHttpContextAccessor _httpContextAccessor; - private readonly ProblemDetailsHelper _problemDetailsHelper; - - public StreetNameGoneResponseExamples( - IHttpContextAccessor httpContextAccessor, - ProblemDetailsHelper problemDetailsHelper) - { - _httpContextAccessor = httpContextAccessor; - _problemDetailsHelper = problemDetailsHelper; - } - - public ProblemDetails GetExamples() - { - var httpContext = _httpContextAccessor.HttpContext; - if (httpContext is null) - { - return new ProblemDetails(); - } - - return new ProblemDetails - { - ProblemTypeUri = "urn:be.vlaanderen.basisregisters.api:streetname:gone", - HttpStatus = StatusCodes.Status410Gone, - Title = ProblemDetails.DefaultTitle, - Detail = "Verwijderde straatnaam.", - ProblemInstanceUri = _problemDetailsHelper.GetInstanceUri(httpContext, "v1") - }; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs deleted file mode 100644 index 021864cf4..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs +++ /dev/null @@ -1,139 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.List -{ - using System; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Convertors; - using Infrastructure.Options; - using MediatR; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Options; - using Municipality; - using Projections.Legacy; - using Projections.Legacy.StreetNameListV2; - using Projections.Syndication; - using Query; - - public sealed record ListRequest(FilteringHeader Filtering, SortingHeader Sorting, IPaginationRequest Pagination) : IRequest; - - public sealed class ListHandlerV2 : IRequestHandler - { - private readonly LegacyContext _legacyContext; - private readonly SyndicationContext _syndicationContext; - - private readonly IOptions _responseOptions; - - public ListHandlerV2( - LegacyContext legacyContext, - SyndicationContext syndicationContext, - IOptions responseOptions) - { - _legacyContext = legacyContext; - _syndicationContext = syndicationContext; - _responseOptions = responseOptions; - } - - public async Task Handle(ListRequest request, CancellationToken cancellationToken) - { - var streetNameQuery = new StreetNameListQueryV2(_legacyContext, _syndicationContext) - .Fetch(request.Filtering, request.Sorting, request.Pagination); - - var pagedStreetNames = await streetNameQuery - .Items - .Select(m => new StreetNameListItemResponse( - m.PersistentLocalId, - _responseOptions.Value.Naamruimte, - _responseOptions.Value.DetailUrl, - GetGeografischeNaamByTaal(m, m.PrimaryLanguage), - GetHomoniemToevoegingByTaal(m, m.PrimaryLanguage), - m.Status.ConvertFromMunicipalityStreetNameStatus(), - m.VersionTimestamp.ToBelgianDateTimeOffset())) - .ToListAsync(cancellationToken); - - return - new StreetNameListResponse - { - Straatnamen = pagedStreetNames, - Volgende = BuildNextUri(streetNameQuery.PaginationInfo, pagedStreetNames.Count, _responseOptions.Value.VolgendeUrl), - Pagination = streetNameQuery.PaginationInfo, - Sorting = streetNameQuery.Sorting - }; - } - - private static GeografischeNaam GetGeografischeNaamByTaal(StreetNameListItemV2 item, Language? taal) - { - switch (taal) - { - case null when !string.IsNullOrEmpty(item.NameDutch): - case Language.Dutch when !string.IsNullOrEmpty(item.NameDutch): - return new GeografischeNaam( - item.NameDutch, - Taal.NL); - - case Language.French when !string.IsNullOrEmpty(item.NameFrench): - return new GeografischeNaam( - item.NameFrench, - Taal.FR); - - case Language.German when !string.IsNullOrEmpty(item.NameGerman): - return new GeografischeNaam( - item.NameGerman, - Taal.DE); - - case Language.English when !string.IsNullOrEmpty(item.NameEnglish): - return new GeografischeNaam( - item.NameEnglish, - Taal.EN); - - default: - return null; - } - } - - private static GeografischeNaam? GetHomoniemToevoegingByTaal(StreetNameListItemV2 item, Language? taal) - { - switch (taal) - { - case null when !string.IsNullOrEmpty(item.HomonymAdditionDutch): - case Language.Dutch when !string.IsNullOrEmpty(item.HomonymAdditionDutch): - return new GeografischeNaam( - item.HomonymAdditionDutch, - Taal.NL); - - case Language.French when !string.IsNullOrEmpty(item.HomonymAdditionFrench): - return new GeografischeNaam( - item.HomonymAdditionFrench, - Taal.FR); - - case Language.German when !string.IsNullOrEmpty(item.HomonymAdditionGerman): - return new GeografischeNaam( - item.HomonymAdditionGerman, - Taal.DE); - - case Language.English when !string.IsNullOrEmpty(item.HomonymAdditionEnglish): - return new GeografischeNaam( - item.HomonymAdditionEnglish, - Taal.EN); - - default: - return null; - } - } - - protected static Uri? BuildNextUri(PaginationInfo paginationInfo, int itemsInCollection, string nextUrlBase) - { - var offset = paginationInfo.Offset; - var limit = paginationInfo.Limit; - - return paginationInfo.HasNextPage(itemsInCollection) - ? new Uri(string.Format(nextUrlBase, offset + limit, limit)) - : null; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/List/StreetNameListResponse.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/List/StreetNameListResponse.cs deleted file mode 100644 index 9c41b8949..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/List/StreetNameListResponse.cs +++ /dev/null @@ -1,143 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.List -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - using Infrastructure.Options; - using Microsoft.Extensions.Options; - using Newtonsoft.Json; - using Swashbuckle.AspNetCore.Filters; - - [DataContract(Name = "StraatnaamCollectie", Namespace = "")] - public class StreetNameListResponse - { - /// - /// De verzameling van straatnamen. - /// - [DataMember(Name = "Straatnamen", Order = 1)] - [JsonProperty(Required = Required.DisallowNull)] - public List Straatnamen { get; set; } - - /// - /// Het totaal aantal gemeenten die overeenkomen met de vraag. - /// - //[DataMember(Name = "TotaalAantal", Order = 2)] - //[JsonProperty(Required = Required.DisallowNull)] - //public long TotaalAantal { get; set; } - - /// - /// De URL voor het ophalen van de volgende verzameling. - /// - [DataMember(Name = "Volgende", Order = 3, EmitDefaultValue = false)] - [JsonProperty(Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Ignore)] - public Uri Volgende { get; set; } - - [IgnoreDataMember] - [JsonIgnore] - internal SortingHeader Sorting { get; set; } - - [IgnoreDataMember] - [JsonIgnore] - internal PaginationInfo Pagination { get; set; } - } - - [DataContract(Name = "StraatnaamCollectieItem", Namespace = "")] - public class StreetNameListItemResponse - { - /// - /// De identificator van de straatnaam. - /// - [DataMember(Name = "Identificator", Order = 1)] - [JsonProperty(Required = Required.DisallowNull)] - public StraatnaamIdentificator Identificator { get; set; } - - /// - /// De URL die de details van de meest recente versie van de straatnaam weergeeft. - /// - [DataMember(Name = "Detail", Order = 2)] - [JsonProperty(Required = Required.DisallowNull)] - public Uri Detail { get; set; } - - /// - /// De straatnaam in de eerste officiële taal van de gemeente. - /// - [DataMember(Name = "Straatnaam", Order = 3)] - [JsonProperty(Required = Required.DisallowNull)] - public Straatnaam Straatnaam { get; set; } - - /// - /// De homoniemtoevoeging in de eerste officiële taal van de gemeente. - /// - [DataMember(Name = "HomoniemToevoeging", Order = 4, EmitDefaultValue = false)] - [JsonProperty(Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Ignore)] - public HomoniemToevoeging HomoniemToevoeging { get; set; } - - /// - /// De huidige fase in de levensloop van een straatnaam. - /// - [DataMember(Name = "StraatnaamStatus", Order = 5)] - [JsonProperty(Required = Required.DisallowNull)] - public StraatnaamStatus StraatnaamStatus { get; set; } - - public StreetNameListItemResponse( - int? id, - string naamruimte, - string detail, - GeografischeNaam geografischeNaam, - GeografischeNaam homoniemToevoeging, - StraatnaamStatus status, - DateTimeOffset? version) - { - Identificator = new StraatnaamIdentificator(naamruimte, id?.ToString(), version); - Detail = new Uri(string.Format(detail, id)); - Straatnaam = new Straatnaam(geografischeNaam); - StraatnaamStatus = status; - - if (homoniemToevoeging != null) - HomoniemToevoeging = new HomoniemToevoeging(homoniemToevoeging); - } - } - - public class StreetNameListResponseExamples : IExamplesProvider - { - private readonly ResponseOptions _responseOptions; - - public StreetNameListResponseExamples(IOptions responseOptionsProvider) - => _responseOptions = responseOptionsProvider.Value; - - public StreetNameListResponse GetExamples() - { - var streetNameSamples = new List - { - new StreetNameListItemResponse( - 1000, - _responseOptions.Naamruimte, - _responseOptions.DetailUrl, - new GeografischeNaam("Kerkstraat", Taal.NL), - null, - StraatnaamStatus.InGebruik, - DateTimeOffset.Now.ToExampleOffset()), - - new StreetNameListItemResponse( - 1001, - _responseOptions.Naamruimte, - _responseOptions.DetailUrl, - new GeografischeNaam("Wetstraat", Taal.NL), - new GeografischeNaam("BR", Taal.NL), - StraatnaamStatus.Voorgesteld, - DateTimeOffset.Now.ToExampleOffset()) - }; - - return new StreetNameListResponse - { - Straatnamen = streetNameSamples, - Volgende = new Uri(string.Format(_responseOptions.VolgendeUrl, 2, 10)) - }; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs deleted file mode 100644 index ff86c766f..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs +++ /dev/null @@ -1,148 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Query -{ - using System; - using System.Collections.Generic; - using System.Linq; - using Be.Vlaanderen.Basisregisters.Api.Search; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - using Convertors; - using Microsoft.EntityFrameworkCore; - using Projections.Legacy; - using Projections.Legacy.StreetNameList; - using Projections.Legacy.StreetNameListV2; - using Projections.Syndication; - - public sealed class StreetNameListQueryV2 : Query - { - private readonly LegacyContext _legacyContext; - private readonly SyndicationContext _syndicationContext; - - protected override ISorting Sorting => new StreetNameSorting(); - - public StreetNameListQueryV2(LegacyContext legacyContext, SyndicationContext syndicationContext) - { - _legacyContext = legacyContext; - _syndicationContext = syndicationContext; - } - - protected override IQueryable Filter(FilteringHeader filtering) - { - IQueryable? streetNames = default; - - streetNames = _legacyContext - .StreetNameListV2 - .AsNoTracking() - .OrderBy(x => x.PersistentLocalId) - .Where(s => !s.Removed); - - if (streetNames == null) - { - throw new NotImplementedException(); - } - - if (!filtering.ShouldFilter) - { - return streetNames; - } - - if (!string.IsNullOrEmpty(filtering.Filter.NisCode)) - { - streetNames = streetNames.Where(m => m.NisCode == filtering.Filter.NisCode); - } - - if (!string.IsNullOrEmpty(filtering.Filter.NameDutch)) - streetNames = streetNames.Where(s => s.NameDutch.Contains(filtering.Filter.NameDutch)); - - if (!string.IsNullOrEmpty(filtering.Filter.NameEnglish)) - streetNames = streetNames.Where(s => s.NameEnglish.Contains(filtering.Filter.NameEnglish)); - - if (!string.IsNullOrEmpty(filtering.Filter.NameFrench)) - streetNames = streetNames.Where(s => s.NameFrench.Contains(filtering.Filter.NameFrench)); - - if (!string.IsNullOrEmpty(filtering.Filter.NameGerman)) - streetNames = streetNames.Where(s => s.NameGerman.Contains(filtering.Filter.NameGerman)); - - if (filtering.Filter.IsInFlemishRegion.HasValue) - streetNames = streetNames.Where(x => x.IsInFlemishRegion); - - var filterMunicipalityName = filtering.Filter.MunicipalityName.RemoveDiacritics(); - if (!string.IsNullOrEmpty(filtering.Filter.MunicipalityName)) - { - var municipalityNisCodes = _syndicationContext - .MunicipalityLatestItems - .AsNoTracking() - .Where(x => x.NameDutchSearch == filterMunicipalityName || - x.NameFrenchSearch == filterMunicipalityName || - x.NameEnglishSearch == filterMunicipalityName || - x.NameGermanSearch == filterMunicipalityName) - .Select(x => x.NisCode) - .ToList(); - - - if (streetNames is IQueryable) - { - streetNames = streetNames.Where(m => municipalityNisCodes.Contains(m.NisCode)); - } - } - - var filterStreetName = filtering.Filter.StreetNameName.RemoveDiacritics(); - if (!string.IsNullOrEmpty(filtering.Filter.StreetNameName)) - { - streetNames = streetNames - .Where(x => x.NameDutchSearch == filterStreetName || - x.NameFrenchSearch == filterStreetName || - x.NameEnglishSearch == filterStreetName || - x.NameGermanSearch == filterStreetName); - } - - if (!string.IsNullOrEmpty(filtering.Filter.Status)) - { - if (Enum.TryParse(typeof(StraatnaamStatus), filtering.Filter.Status, true, out var status) && status != null) - { - var streetNameStatus = ((StraatnaamStatus)status).ConvertToMunicipalityStreetNameStatus(); - streetNames = streetNames.Where(m => m.Status.HasValue && m.Status.Value == streetNameStatus); - } - else - { - //have to filter on EF cannot return new List<>().AsQueryable() cause non-EF provider does not support .CountAsync() - streetNames = streetNames.Where(m => m.Status.HasValue && (int) m.Status.Value == -1); - } - } - - return streetNames; - } - } - - public sealed class StreetNameSorting : ISorting - { - public IEnumerable SortableFields { get; } = new[] - { - nameof(StreetNameListItem.NameDutch), - nameof(StreetNameListItem.NameEnglish), - nameof(StreetNameListItem.NameFrench), - nameof(StreetNameListItem.NameGerman), - nameof(StreetNameListItem.PersistentLocalId) - }; - - public SortingHeader DefaultSortingHeader { get; } = - new SortingHeader(nameof(StreetNameListItem.PersistentLocalId), SortOrder.Ascending); - } - - public sealed class StreetNameFilter - { - public string StreetNameName { get; set; } = string.Empty; - public string MunicipalityName { get; set; } = string.Empty; - public string NameDutch { get; set; } = string.Empty; - public string NameFrench { get; set; } = string.Empty; - public string NameGerman { get; set; } = string.Empty; - public string NameEnglish { get; set; } = string.Empty; - public string Status { get; set; } = string.Empty; - public string? NisCode { get; set; } = string.Empty; - public string? PostalCode { get; set; } = string.Empty; - - public bool? IsInFlemishRegion { get; set; } = null; - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameSyndicationQuery.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameSyndicationQuery.cs deleted file mode 100755 index ac5bc659d..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameSyndicationQuery.cs +++ /dev/null @@ -1,329 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Query -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Linq.Expressions; - using Be.Vlaanderen.Basisregisters.Api.Search; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Microsoft.EntityFrameworkCore; - using Municipality; - using NodaTime; - using Projections.Legacy; - using Projections.Legacy.StreetNameSyndication; - - public sealed class StreetNameSyndicationQueryResult - { - public bool ContainsEvent { get; } - public bool ContainsObject { get; } - - public Guid? MunicipalityId { get; } - public Guid? StreetNameId { get; } - public long Position { get; } - public string ChangeType { get; } - public int? PersistentLocalId { get; } - public string NisCode { get; } - public Instant RecordCreatedAt { get; } - public Instant LastChangedOn { get; } - public StreetNameStatus? Status { get; } - public string NameDutch { get; } - public string NameFrench { get; } - public string NameGerman { get; } - public string NameEnglish { get; } - public string HomonymAdditionDutch { get; } - public string HomonymAdditionFrench { get; } - public string HomonymAdditionGerman { get; } - public string HomonymAdditionEnglish { get; } - public bool IsComplete { get; } - public Organisation? Organisation { get; } - public string Reason { get; } - public string EventDataAsXml { get; } - - public StreetNameSyndicationQueryResult( - Guid? municipalityId, - Guid? streetNameId, - long position, - int? persistentLocalId, - string nisCode, - string changeType, - Instant recordCreatedAt, - Instant lastChangedOn, - bool isComplete, - Organisation? organisation, - string reason) - { - ContainsEvent = false; - ContainsObject = false; - MunicipalityId = municipalityId; - StreetNameId = streetNameId; - Position = position; - PersistentLocalId = persistentLocalId; - NisCode = nisCode; - ChangeType = changeType; - RecordCreatedAt = recordCreatedAt; - LastChangedOn = lastChangedOn; - IsComplete = isComplete; - Organisation = organisation; - Reason = reason; - } - - public StreetNameSyndicationQueryResult( - Guid? municipalityId, - Guid? streetNameId, - long position, - int? persistentLocalId, - string nisCode, - string changeType, - Instant recordCreatedAt, - Instant lastChangedOn, - bool isComplete, - Organisation? organisation, - string reason, - string eventDataAsXml) - : this( - municipalityId, - streetNameId, - position, - persistentLocalId, - nisCode, - changeType, - recordCreatedAt, - lastChangedOn, - isComplete, - organisation, - reason) - { - ContainsEvent = true; - EventDataAsXml = eventDataAsXml; - } - - public StreetNameSyndicationQueryResult( - Guid? municipalityId, - Guid? streetNameId, - long position, - int? persistentLocalId, - string nisCode, - string changeType, - Instant recordCreatedAt, - Instant lastChangedOn, - StreetNameStatus? status, - string nameDutch, - string nameFrench, - string nameGerman, - string nameEnglish, - string homonymAdditionDutch, - string homonymAdditionFrench, - string homonymAdditionGerman, - string homonymAdditionEnglish, - bool isComplete, - Organisation? organisation, - string reason) - : this( - municipalityId, - streetNameId, - position, - persistentLocalId, - nisCode, - changeType, - recordCreatedAt, - lastChangedOn, - isComplete, - organisation, - reason) - { - ContainsObject = true; - - Status = status; - NameDutch = nameDutch; - NameFrench = nameFrench; - NameGerman = nameGerman; - NameEnglish = nameEnglish; - HomonymAdditionDutch = homonymAdditionDutch; - HomonymAdditionFrench = homonymAdditionFrench; - HomonymAdditionGerman = homonymAdditionGerman; - HomonymAdditionEnglish = homonymAdditionEnglish; - } - - public StreetNameSyndicationQueryResult( - Guid? municipalityId, - Guid? streetNameId, - long position, - int? persistentLocalId, - string nisCode, - string changeType, - Instant recordCreatedAt, - Instant lastChangedOn, - StreetNameStatus? status, - string nameDutch, - string nameFrench, - string nameGerman, - string nameEnglish, - string homonymAdditionDutch, - string homonymAdditionFrench, - string homonymAdditionGerman, - string homonymAdditionEnglish, - bool isComplete, - Organisation? organisation, - string reason, - string eventDataAsXml) - : this( - municipalityId, - streetNameId, - position, - persistentLocalId, - nisCode, - changeType, - recordCreatedAt, - lastChangedOn, - status, - nameDutch, - nameFrench, - nameGerman, - nameEnglish, - homonymAdditionDutch, - homonymAdditionFrench, - homonymAdditionGerman, - homonymAdditionEnglish, - isComplete, - organisation, - reason) - { - ContainsEvent = true; - - EventDataAsXml = eventDataAsXml; - } - } - - public sealed class StreetNameSyndicationQuery : Query - { - private readonly LegacyContext _context; - private readonly bool _embedEvent; - private readonly bool _embedObject; - - public StreetNameSyndicationQuery( - LegacyContext context, - SyncEmbedValue? embed) - { - _context = context; - _embedEvent = embed?.Event ?? false; - _embedObject = embed?.Object ?? false; - } - - protected override ISorting Sorting => new StreetNameSyndicationSorting(); - - protected override Expression> Transformation - { - get - { - if (_embedEvent && _embedObject) - return x => new StreetNameSyndicationQueryResult( - x.MunicipalityId, - x.StreetNameId, - x.Position, - x.PersistentLocalId, - x.NisCode, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Status, - x.NameDutch, - x.NameFrench, - x.NameGerman, - x.NameEnglish, - x.HomonymAdditionDutch, - x.HomonymAdditionFrench, - x.HomonymAdditionGerman, - x.HomonymAdditionEnglish, - x.IsComplete, - x.Organisation, - x.Reason, - x.EventDataAsXml); - - if (_embedEvent) - return x => new StreetNameSyndicationQueryResult( - x.MunicipalityId, - x.StreetNameId, - x.Position, - x.PersistentLocalId, - x.NisCode, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.IsComplete, - x.Organisation, - x.Reason, - x.EventDataAsXml); - - if (_embedObject) - return x => new StreetNameSyndicationQueryResult( - x.MunicipalityId, - x.StreetNameId, - x.Position, - x.PersistentLocalId, - x.NisCode, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Status, - x.NameDutch, - x.NameFrench, - x.NameGerman, - x.NameEnglish, - x.HomonymAdditionDutch, - x.HomonymAdditionFrench, - x.HomonymAdditionGerman, - x.HomonymAdditionEnglish, - x.IsComplete, - x.Organisation, - x.Reason); - - return x => new StreetNameSyndicationQueryResult( - x.MunicipalityId, - x.StreetNameId, - x.Position, - x.PersistentLocalId, - x.NisCode, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.IsComplete, - x.Organisation, - x.Reason); - } - } - - protected override IQueryable Filter(FilteringHeader filtering) - { - var streetNames = _context - .StreetNameSyndication - .OrderBy(x => x.Position) - .AsNoTracking(); - - if (!filtering.ShouldFilter) - return streetNames; - - if (filtering.Filter.Position.HasValue) - streetNames = streetNames.Where(m => m.Position >= filtering.Filter.Position); - - return streetNames; - } - } - - public sealed class StreetNameSyndicationSorting : ISorting - { - public IEnumerable SortableFields { get; } = new[] - { - nameof(StreetNameSyndicationItem.Position) - }; - - public SortingHeader DefaultSortingHeader { get; } = new SortingHeader(nameof(StreetNameSyndicationItem.Position), SortOrder.Ascending); - } - - public sealed class StreetNameSyndicationFilter - { - public long? Position { get; set; } - public SyncEmbedValue? Embed { get; set; } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/StreetNameController.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/StreetNameController.cs deleted file mode 100755 index 7715c3d8e..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/StreetNameController.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName -{ - using System.Net.Mime; - using System.Threading; - using System.Threading.Tasks; - using Asp.Versioning; - using Be.Vlaanderen.Basisregisters.Api; - using Be.Vlaanderen.Basisregisters.Api.ETag; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Count; - using Detail; - using List; - using MediatR; - using Microsoft.AspNetCore.Http; - using Microsoft.AspNetCore.Mvc; - using Query; - using Swashbuckle.AspNetCore.Filters; - using Sync; - using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; - - [ApiVersion("1.0")] - [AdvertiseApiVersions("1.0")] - [ApiRoute("straatnamen")] - [ApiExplorerSettings(GroupName = "Straatnamen")] - public class StreetNameController : ApiController - { - private readonly IMediator _mediator; - - public StreetNameController(IMediator mediator) - { - _mediator = mediator; - } - - /// - /// Vraag een straatnaam op. - /// - /// De persistente lokale identificator van de straatnaam. - /// - /// Als de straatnaam gevonden is. - /// Als de straatnaam niet gevonden kan worden. - /// Als de straatnaam verwijderd is. - /// Als er een interne fout is opgetreden. - [HttpGet("{persistentLocalId}")] - [ProducesResponseType(typeof(StreetNameResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status410Gone)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(StreetNameResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status404NotFound, typeof(StreetNameNotFoundResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status410Gone, typeof(StreetNameGoneResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Get( - [FromRoute] int persistentLocalId, - CancellationToken cancellationToken = default) - { - var result = await _mediator.Send(new DetailRequest(persistentLocalId), cancellationToken); - - return string.IsNullOrWhiteSpace(result.LastEventHash) - ? Ok(result) - : new OkWithLastObservedPositionAsETagResult(result, result.LastEventHash); - } - - /// - /// Vraag een lijst met straatnamen op. - /// - /// - /// Als de opvraging van een lijst met straatnamen gelukt is. - /// Als er een interne fout is opgetreden. - [HttpGet] - [ProducesResponseType(typeof(StreetNameListResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(StreetNameListResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task List(CancellationToken cancellationToken = default) - { - var filtering = Request.ExtractFilteringRequest(); - var sorting = Request.ExtractSortingRequest(); - var pagination = Request.ExtractPaginationRequest(); - - var result = await _mediator.Send(new ListRequest(filtering, sorting, pagination), cancellationToken); - - Response.AddPaginationResponse(result.Pagination); - Response.AddSortingResponse(result.Sorting); - - return Ok(result); - } - - /// - /// Vraag het totaal aantal van straatnamen op. - /// - /// - /// Als de opvraging van het totaal aantal gelukt is. - /// Als er een interne fout is opgetreden. - [HttpGet("totaal-aantal")] - [ProducesResponseType(typeof(TotaalAantalResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(TotalCountResponseExample))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Count(CancellationToken cancellationToken = default) - { - var filtering = Request.ExtractFilteringRequest(); - var sorting = Request.ExtractSortingRequest(); - - var result = await _mediator.Send(new CountRequest(filtering, sorting), cancellationToken); - - return Ok(result); - } - - /// - /// Vraag een lijst met wijzigingen van straatnamen op. - /// - /// - /// - [HttpGet("sync")] - [Produces("text/xml")] - [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(StreetNameSyndicationResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Sync(CancellationToken cancellationToken = default) - { - var filtering = Request.ExtractFilteringRequest(); - var sorting = Request.ExtractSortingRequest(); - var pagination = Request.ExtractPaginationRequest(); - - var result = await _mediator.Send(new SyndicationRequest(filtering, sorting, pagination), cancellationToken); - - return new ContentResult - { - Content = result.Content, - ContentType = MediaTypeNames.Text.Xml, - StatusCode = StatusCodes.Status200OK - }; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/StreetNameSyndicationResponse.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/StreetNameSyndicationResponse.cs deleted file mode 100644 index 544bf51b0..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/StreetNameSyndicationResponse.cs +++ /dev/null @@ -1,289 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Sync -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Runtime.Serialization; - using System.Threading.Tasks; - using System.Xml; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Common.Syndication; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Convertors; - using Infrastructure.Options; - using Microsoft.Extensions.Options; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - using Municipality; - using Query; - using Swashbuckle.AspNetCore.Filters; - using Provenance = Be.Vlaanderen.Basisregisters.GrAr.Provenance.Syndication.Provenance; - - public static class StreetNameSyndicationResponse - { - public static async Task WriteStreetName( - this ISyndicationFeedWriter writer, - IOptions responseOptions, - AtomFormatter formatter, - string category, - StreetNameSyndicationQueryResult streetName) - { - var item = new SyndicationItem - { - Id = streetName.Position.ToString(CultureInfo.InvariantCulture), - Title = $"{streetName.ChangeType}-{streetName.Position}", - Published = streetName.RecordCreatedAt.ToBelgianDateTimeOffset(), - LastUpdated = streetName.LastChangedOn.ToBelgianDateTimeOffset(), - Description = BuildDescription(streetName, responseOptions.Value.Naamruimte) - }; - - if (streetName.PersistentLocalId.HasValue) - { - item.AddLink( - new SyndicationLink( - new Uri($"{responseOptions.Value.Naamruimte}/{streetName.PersistentLocalId.Value}"), - AtomLinkTypes.Related)); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format(responseOptions.Value.DetailUrl, streetName.PersistentLocalId.Value)), - // AtomLinkTypes.Self)); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", streetName.PersistentLocalId.Value)), - // AtomLinkTypes.Alternate) - // { MediaType = MediaTypeNames.Application.Xml }); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", streetName.PersistentLocalId.Value)), - // AtomLinkTypes.Alternate) - // { MediaType = MediaTypeNames.Application.Json }); - } - - item.AddCategory( - new SyndicationCategory(category)); - - item.AddContributor( - new SyndicationPerson( - streetName.Organisation == null ? Organisation.Unknown.ToName() : streetName.Organisation.Value.ToName(), - string.Empty, - AtomContributorTypes.Author)); - - await writer.Write(item); - } - - private static string BuildDescription(StreetNameSyndicationQueryResult streetName, string naamruimte) - { - if (!streetName.ContainsEvent && !streetName.ContainsObject) - return "No data embedded"; - - var content = new SyndicationContent(); - - if (streetName.ContainsObject) - content.Object = new StreetNameSyndicationContent( - streetName.StreetNameId.HasValue ? streetName.StreetNameId.Value.ToString("D") : streetName.PersistentLocalId.ToString(), - naamruimte, - streetName.PersistentLocalId, - streetName.Status, - streetName.NisCode, - streetName.NameDutch, - streetName.NameFrench, - streetName.NameGerman, - streetName.NameEnglish, - streetName.HomonymAdditionDutch, - streetName.HomonymAdditionFrench, - streetName.HomonymAdditionGerman, - streetName.HomonymAdditionEnglish, - streetName.IsComplete, - streetName.LastChangedOn.ToBelgianDateTimeOffset(), - streetName.Organisation, - streetName.Reason); - - if (streetName.ContainsEvent) - { - var doc = new XmlDocument(); - doc.LoadXml(streetName.EventDataAsXml); - content.Event = doc.DocumentElement; - } - - return content.ToXml(); - } - } - - [DataContract(Name = "Content", Namespace = "")] - public class SyndicationContent : SyndicationContentBase - { - [DataMember(Name = "Event")] - public XmlElement Event { get; set; } - - [DataMember(Name = "Object")] - public StreetNameSyndicationContent Object { get; set; } - } - - [DataContract(Name = "Straatnaam", Namespace = "")] - public class StreetNameSyndicationContent - { - /// - /// De technische id van de aggregate. - /// - [DataMember(Name = "Id", Order = 1)] - public string Id { get; set; } - - /// - /// De identificator van de straatnaam. - /// - [DataMember(Name = "Identificator", Order = 2)] - public StraatnaamIdentificator Identificator { get; set; } - - /// - /// De officiële namen van de straatnaam. - /// - [DataMember(Name = "Straatnamen", Order = 3)] - public List StreetNames { get; set; } - - /// - /// De huidige fase in het leven van de straatnaam. - /// - [DataMember(Name = "StraatnaamStatus", Order = 4)] - public StraatnaamStatus? StreetNameStatus { get; set; } - - /// - /// De homoniem-toevoegingen aan de straatnaam in verschillende talen. - /// - [DataMember(Name = "HomoniemToevoegingen", Order = 5)] - public List HomonymAdditions { get; set; } - - /// - /// De NisCode van de gerelateerde gemeente. - /// - [DataMember(Name = "NisCode", Order = 6)] - public string NisCode { get; set; } - - /// - /// Duidt aan of het item compleet is. - /// - [DataMember(Name = "IsCompleet", Order = 7)] - public bool IsComplete { get; set; } - - /// - /// Creatie data ivm het item. - /// - [DataMember(Name = "Creatie", Order = 8)] - public Provenance Provenance { get; set; } - - public StreetNameSyndicationContent( - string id, - string naamruimte, - int? persistentLocalId, - StreetNameStatus? status, - string nisCode, - string nameDutch, - string nameFrench, - string nameGerman, - string nameEnglish, - string homonymAdditionDutch, - string homonymAdditionFrench, - string homonymAdditionGerman, - string homonymAdditionEnglish, - bool isComplete, - DateTimeOffset version, - Organisation? organisation, - string reason) - { - Id = id; - NisCode = nisCode; - Identificator = new StraatnaamIdentificator(naamruimte, persistentLocalId?.ToString(CultureInfo.InvariantCulture), version); - StreetNameStatus = status?.ConvertFromMunicipalityStreetNameStatus(); - IsComplete = isComplete; - - var straatnamen = new List - { - new GeografischeNaam(nameDutch, Taal.NL), - new GeografischeNaam(nameFrench, Taal.FR), - new GeografischeNaam(nameGerman, Taal.DE), - new GeografischeNaam(nameEnglish, Taal.EN), - }; - - StreetNames = straatnamen.Where(x => !string.IsNullOrEmpty(x.Spelling)).ToList(); - - var homoniemToevoegingen = new List - { - new GeografischeNaam(homonymAdditionDutch, Taal.NL), - new GeografischeNaam(homonymAdditionFrench, Taal.FR), - new GeografischeNaam(homonymAdditionGerman, Taal.DE), - new GeografischeNaam(homonymAdditionEnglish, Taal.EN), - }; - - HomonymAdditions = homoniemToevoegingen.Where(x => !string.IsNullOrEmpty(x.Spelling)).ToList(); - - Provenance = new Provenance(version, organisation, new Reason(reason)); - } - } - - public class StreetNameSyndicationResponseExamples : IExamplesProvider - { - private const string RawXml = @" - - https://api.basisregisters.vlaanderen.be/v2/feeds/straatnamen.atom - Basisregisters Vlaanderen - feed 'straatnamen' - Deze Atom feed geeft leestoegang tot events op de resource 'straatnamen'. - Basisregisters Vlaanderen - Gratis hergebruik volgens https://overheid.vlaanderen.be/sites/default/files/documenten/ict-egov/licenties/hergebruik/modellicentie_gratis_hergebruik_v1_0.html - 2020-11-12T09:25:05Z - - Digitaal Vlaanderen - digitaal.vlaanderen@vlaanderen.be - - - - - - - - 0 - StreetNameWasRegistered-0 - 2002-11-21T11:23:45+01:00 - 2002-11-21T11:23:45+01:00 - - Vlaamse Landmaatschappij - - - - 2a2f28ac-f084-5404-a229-434bd194f213ca6a4d57-e46d-571f-98df-e64c0e5fa3da620222002-11-21T10:23:45ZVlmCentrale bijhouding CRAB - - 2a2f28ac-f084-5404-a229-434bd194f213https://data.vlaanderen.be/id/straatnaam/https://data.vlaanderen.be/id/straatnaam2002-11-21T11:23:45+01:0062022false2002-11-21T11:23:45+01:00Vlaamse LandmaatschappijCentrale bijhouding CRAB - ]]> - - - - 1 - StreetNameWasNamed-1 - 2002-11-21T11:23:45+01:00 - 2002-11-21T11:23:45+01:00 - - Vlaamse Landmaatschappij - - - - 2a2f28ac-f084-5404-a229-434bd194f213Drève de MéhagneFrench2002-11-21T10:23:45ZVlmCentrale bijhouding CRAB - - 2a2f28ac-f084-5404-a229-434bd194f213https://data.vlaanderen.be/id/straatnaam/https://data.vlaanderen.be/id/straatnaam2002-11-21T11:23:45+01:00Drève de Méhagnefr - 62022false2002-11-21T11:23:45+01:00Vlaamse LandmaatschappijCentrale bijhouding CRAB - ]]> - - -"; - - public XmlElement GetExamples() - { - var example = new XmlDocument(); - example.LoadXml(RawXml); - return example.DocumentElement; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/SyndicationHandler.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/SyndicationHandler.cs deleted file mode 100644 index d410275a2..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Sync/SyndicationHandler.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace StreetNameRegistry.Api.Legacy.StreetName.Sync -{ - using System; - using System.Linq; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.Api.Syndication; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Common.Syndication; - using Infrastructure; - using Infrastructure.Options; - using MediatR; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.Options; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - using Projections.Legacy; - using Query; - - public sealed record SyndicationAtomContent(string Content); - public sealed record SyndicationRequest(FilteringHeader Filter, SortingHeader Sorting, IPaginationRequest Pagination) : IRequest; - - public sealed class SyndicationHandler : IRequestHandler - { - private readonly LegacyContext _legacyContext; - private readonly IOptions _responseOptions; - private readonly IConfiguration _configuration; - - public SyndicationHandler( - LegacyContext legacyContext, - IOptions responseOptions, - IConfiguration configuration) - { - _legacyContext = legacyContext; - _responseOptions = responseOptions; - _configuration = configuration; - } - - public async Task Handle(SyndicationRequest request, CancellationToken cancellationToken) - { - var lastFeedUpdate = await _legacyContext - .StreetNameSyndication - .AsNoTracking() - .OrderByDescending(item => item.Position) - .Select(item => item.SyndicationItemCreatedAt) - .FirstOrDefaultAsync(cancellationToken); - - if (lastFeedUpdate == default) - { - lastFeedUpdate = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero); - } - - var pagedStreetNames = - new StreetNameSyndicationQuery(_legacyContext, request.Filter.Filter?.Embed) - .Fetch(request.Filter, request.Sorting, request.Pagination); - - return new SyndicationAtomContent(await BuildAtomFeed(lastFeedUpdate, pagedStreetNames)); - } - - private async Task BuildAtomFeed( - DateTimeOffset lastFeedUpdate, - PagedQueryable pagedStreetNames) - { - var sw = new StringWriterWithEncoding(Encoding.UTF8); - - await using (var xmlWriter = XmlWriter.Create(sw, - new XmlWriterSettings { Async = true, Indent = true, Encoding = sw.Encoding })) - { - var formatter = new AtomFormatter(null, xmlWriter.Settings) { UseCDATA = true }; - var writer = new AtomFeedWriter(xmlWriter, null, formatter); - var syndicationConfiguration = _configuration.GetSection("Syndication"); - var atomFeedConfig = AtomFeedConfigurationBuilder.CreateFrom(syndicationConfiguration, lastFeedUpdate); - - await writer.WriteDefaultMetadata(atomFeedConfig); - - var streetNames = pagedStreetNames.Items.ToList(); - - var nextFrom = streetNames.Any() - ? streetNames.Max(s => s.Position) + 1 - : (long?)null; - - var nextUri = BuildNextSyncUri(pagedStreetNames.PaginationInfo.Limit, nextFrom, syndicationConfiguration["NextUri"]); - if (nextUri != null) - { - await writer.Write(new SyndicationLink(nextUri, GrArAtomLinkTypes.Next)); - } - - foreach (var streetName in streetNames) - { - await writer.WriteStreetName(_responseOptions, formatter, syndicationConfiguration["Category"], streetName); - } - - // if we use await flush gets called sometimes after xmlWriter is disposed... - xmlWriter.Flush(); - } - - return sw.ToString(); - } - - private static Uri? BuildNextSyncUri(int limit, long? from, string nextUrlBase) - { - return from.HasValue - ? new Uri(string.Format(nextUrlBase, from, limit)) - : null; - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj b/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj deleted file mode 100644 index 0dbc14693..000000000 --- a/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - false - true - false - latest - - - - bin\Debug\net8.0\StreetNameRegistry.Api.Legacy.xml - 1701;1702;1705;1591 - TRACE;DEBUG - - - bin\Release\net8.0\StreetNameRegistry.Api.Legacy.xml - 1701;1702;1705;1591 - - - - false - https://github.com/informatievlaanderen/streetname-registry.git - https://github.com/informatievlaanderen/streetname-registry.git - git - - - - - - - - - - - - - - - - - - diff --git a/src/StreetNameRegistry.Api.Legacy/appsettings.json b/src/StreetNameRegistry.Api.Legacy/appsettings.json deleted file mode 100755 index 09016eec8..000000000 --- a/src/StreetNameRegistry.Api.Legacy/appsettings.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "ConnectionStrings": { - "Events": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;", - "LegacyProjections": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;", - "SyndicationProjections": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;", - "LegacyProjectionsAdmin": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;" - }, - - "BaseUrl": "https://api.staging-basisregisters.vlaanderen/", - - "Syndication": { - "Category": "https://data.vlaanderen.be/ns/straatnaam", - "Id": "https://legacy.staging-basisregisters.vlaanderen/v1/feeds/straatnamen.atom", - "Title": "Basisregisters Vlaanderen - Straatnamenregister", - "Subtitle": "Deze Atom feed geeft leestoegang tot events op de resource 'straatnamen'.", - "GeneratorTitle": "Basisregisters Vlaanderen", - "GeneratorUri": "", - "Rights": "Gratis hergebruik volgens https://overheid.vlaanderen.be/sites/default/files/documenten/ict-egov/licenties/hergebruik/modellicentie_gratis_hergebruik_v1_0.html", - "AuthorName": "Digitaal Vlaanderen", - "AuthorEmail": "digitaal.vlaanderen@vlaanderen.be", - "Self": "https://legacy.staging-basisregisters.vlaanderen/syndication/feed/streetname", - "NextUri": "https://legacy.staging-basisregisters.vlaanderen/v1/feeds/straatnamen.atom?from={0}&limit={1}", - "Related": [ - "https://legacy.staging-basisregisters.vlaanderen" - ] - }, - - "Cors": [ - "http://localhost:3000", - "http://localhost:5000" - ], - - "Naamruimte": "https://data.vlaanderen.be/id/straatnaam", - "GemeenteNaamruimte": "https://data.vlaanderen.be/id/gemeente", - "DetailUrl": "https://basisregisters.vlaanderen.be/api/v1/straatnamen/{0}", - "GemeenteDetailUrl": "https://basisregisters.vlaanderen.be/api/v1/gemeenten/{0}", - "VolgendeUrl": "https://basisregisters.vlaanderen.be/api/v1/straatnamen?offset={0}&limit={1}", - - "Serilog": { - "MinimumLevel": { - "Default": "Information" - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter, Serilog.Formatting.Compact" - } - } - ], - "Properties": { - "Application": "StreetNameRegistry - Legacy API", - "ContainerId": "REPLACE_CONTAINERID" - } - } -} diff --git a/src/StreetNameRegistry.Api.Legacy/init.sh b/src/StreetNameRegistry.Api.Legacy/init.sh deleted file mode 100755 index bd10ffcac..000000000 --- a/src/StreetNameRegistry.Api.Legacy/init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -CONTAINERID=$(curl -s http://169.254.170.2/v2/metadata | jq -r ".Containers[] | select(.Labels[\"com.amazonaws.ecs.container-name\"] | startswith(\"basisregisters-\") and endswith(\"-legacy\")) | .DockerId") - -sed -i "s/REPLACE_CONTAINERID/$CONTAINERID/g" appsettings.json - -./StreetNameRegistry.Api.Legacy diff --git a/src/StreetNameRegistry.Api.Legacy/paket.references b/src/StreetNameRegistry.Api.Legacy/paket.references deleted file mode 100644 index 97382c37d..000000000 --- a/src/StreetNameRegistry.Api.Legacy/paket.references +++ /dev/null @@ -1,13 +0,0 @@ -AspNetCore.HealthChecks.SqlServer - -Be.Vlaanderen.Basisregisters.Api - -Datadog.Trace.Bundle - -Microsoft.SyndicationFeed.ReaderWriter - -MediatR -MediatR.Contracts - -SourceLink.Embed.AllSourceFiles -SourceLink.Copy.PdbFiles diff --git a/src/StreetNameRegistry.Api.Legacy/paket.template b/src/StreetNameRegistry.Api.Legacy/paket.template deleted file mode 100644 index 00d20810e..000000000 --- a/src/StreetNameRegistry.Api.Legacy/paket.template +++ /dev/null @@ -1,35 +0,0 @@ -type file -version 1.0.0 - -id Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy -title Be.Vlaanderen.Basisregisters.StreetNameRegistry.Api.Legacy - -authors Basisregisters Vlaanderen -owners Digitaal Vlaanderen -copyright Copyright (c) Digitaal Vlaanderen -requireLicenseAcceptance false -projectUrl https://github.com/Informatievlaanderen/streetname-registry -iconUrl https://raw.githubusercontent.com/Informatievlaanderen/build-pipeline/master/logo.png -licenseUrl https://opensource.org/licenses/EUPL-1.2 - -description StreetName Registry. - -dependencies - framework: net8.0 - Be.Vlaanderen.Basisregisters.GrAr.Legacy >= LOCKEDVERSION - MediatR.Contracts >= LOCKEDVERSION - -files - StreetNameRegistry.Api.Legacy.dll => lib\net8.0 - StreetNameRegistry.Api.Legacy.pdb => lib\net8.0 - StreetNameRegistry.Api.Legacy.xml => lib\net8.0 - StreetNameRegistry.Api.Legacy.xml => content - - StreetNameRegistry.Projections.Legacy.dll => lib\net8.0 - StreetNameRegistry.Projections.Legacy.pdb => lib\net8.0 - - StreetNameRegistry.Projections.Syndication.dll => lib\net8.0 - StreetNameRegistry.Projections.Syndication.pdb => lib\net8.0 - - StreetNameRegistry.dll => lib\net8.0 - StreetNameRegistry.pdb => lib\net8.0