diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 317816b6a..0c68779f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -249,7 +249,7 @@ jobs: secrets: inherit build-consumer-read-postal: - name: Build Snapshot Verifier + name: Build Consumer Read Postal 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') }} @@ -259,7 +259,7 @@ jobs: image-file: sr-consumer-read-postal-image.tar image-name: consumer-read-postal test-project: StreetNameRegistry.Tests - build-project: StreetNameRegistry.Snapshot.Verifier + build-project: StreetNameRegistry.Consumer.Read.Postal semver: ${{ needs.set-release-version.outputs.version }} secrets: inherit diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs index bc0767043..e6385d47f 100644 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs +++ b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Legacy.Infrastructure.Modules using Autofac.Extensions.DependencyInjection; using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Be.Vlaanderen.Basisregisters.DependencyInjection; + using Consumer.Read.Postal.Infrastructure.Modules; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -35,7 +36,8 @@ protected override void Load(ContainerBuilder builder) .RegisterModule(new LegacyModule(_configuration, _services, _loggerFactory)); builder - .RegisterModule(new SyndicationModule(_configuration, _services, _loggerFactory)); + .RegisterModule(new SyndicationModule(_configuration, _services, _loggerFactory)) + .RegisterModule(new ConsumerPostalModule(_configuration, _services, _loggerFactory)); builder .RegisterType() diff --git a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs index 9034201d4..adf589b9a 100644 --- a/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs +++ b/src/StreetNameRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs @@ -2,6 +2,7 @@ namespace StreetNameRegistry.Api.Legacy.Infrastructure.Modules { using Autofac; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using FeatureToggles; using MediatR; using Microsoft.Extensions.Options; @@ -36,6 +37,7 @@ protected override void Load(ContainerBuilder builder) new ListHandlerV2( c.Resolve(), c.Resolve(), + c.Resolve(), c.Resolve>()); } @@ -43,6 +45,7 @@ protected override void Load(ContainerBuilder builder) new ListHandler( c.Resolve(), c.Resolve(), + c.Resolve(), c.Resolve>()); }).InstancePerLifetimeScope(); @@ -72,13 +75,16 @@ protected override void Load(ContainerBuilder builder) return (IRequestHandler) new CountHandlerV2( c.Resolve(), - c.Resolve()); + c.Resolve(), + c.Resolve()); } return (IRequestHandler) new CountHandler( c.Resolve(), - c.Resolve()); + c.Resolve(), + c.Resolve()); + }).InstancePerLifetimeScope(); builder.Register(c => diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandler.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandler.cs index a2838b4a4..0d407dac7 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandler.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandler.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.Count using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Microsoft.EntityFrameworkCore; using Projections.Legacy; using Projections.Legacy.StreetNameList; @@ -15,11 +16,13 @@ public sealed class CountHandler : CountHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; - public CountHandler(LegacyContext legacyContext, SyndicationContext syndicationContext) + public CountHandler(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } public override async Task Handle(CountRequest request, CancellationToken cancellationToken) @@ -29,7 +32,7 @@ public override async Task Handle(CountRequest request, Ca return new TotaalAantalResponse { Aantal = request.Filtering.ShouldFilter - ? await new StreetNameListQuery(_legacyContext, _syndicationContext) + ? await new StreetNameListQuery(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, pagination) .Items .CountAsync(cancellationToken) diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs index dbd03d315..31a565c0e 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/Count/CountHandlerV2.cs @@ -4,6 +4,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.Count using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Microsoft.EntityFrameworkCore; using Projections.Legacy; using Projections.Legacy.StreetNameListV2; @@ -14,11 +15,13 @@ public sealed class CountHandlerV2 : CountHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; - public CountHandlerV2(LegacyContext legacyContext, SyndicationContext syndicationContext) + public CountHandlerV2(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } public override async Task Handle(CountRequest request, CancellationToken cancellationToken) @@ -28,7 +31,7 @@ public override async Task Handle(CountRequest request, Ca return new TotaalAantalResponse { - Aantal = await new StreetNameListQueryV2(_legacyContext, _syndicationContext) + Aantal = await new StreetNameListQueryV2(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, pagination) .Items .CountAsync(cancellationToken) diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandler.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandler.cs index 4cb37d74c..21cee7f10 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandler.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandler.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.List using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Convertors; using Infrastructure.Options; using Microsoft.EntityFrameworkCore; @@ -19,21 +20,24 @@ public sealed class ListHandler : ListHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _PostalContext; private readonly IOptions _responseOptions; public ListHandler( LegacyContext legacyContext, SyndicationContext syndicationContext, + ConsumerPostalContext postalContext, IOptions responseOptions) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _PostalContext = postalContext; _responseOptions = responseOptions; } public override async Task Handle(ListRequest request, CancellationToken cancellationToken) { - var streetNameQuery = new StreetNameListQuery(_legacyContext, _syndicationContext) + var streetNameQuery = new StreetNameListQuery(_legacyContext, _syndicationContext, _PostalContext) .Fetch(request.Filtering, request.Sorting, request.Pagination); var pagedStreetNames = await streetNameQuery diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs index 89355e0cc..ba27e5101 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/List/ListHandlerV2.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.List using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Convertors; using Infrastructure.Options; using Microsoft.EntityFrameworkCore; @@ -19,21 +20,25 @@ public sealed class ListHandlerV2 : ListHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; + private readonly IOptions _responseOptions; public ListHandlerV2( LegacyContext legacyContext, SyndicationContext syndicationContext, + ConsumerPostalContext postalContext, IOptions responseOptions) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; _responseOptions = responseOptions; } public override async Task Handle(ListRequest request, CancellationToken cancellationToken) { - var streetNameQuery = new StreetNameListQueryV2(_legacyContext, _syndicationContext) + var streetNameQuery = new StreetNameListQueryV2(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, request.Pagination); var pagedStreetNames = await streetNameQuery diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQuery.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQuery.cs index f5d5a6df5..e5c399c22 100755 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQuery.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQuery.cs @@ -8,6 +8,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.Query using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; + using Consumer.Read.Postal; using Convertors; using Microsoft.EntityFrameworkCore; using Projections.Legacy; @@ -18,13 +19,15 @@ public sealed class StreetNameListQuery : Query new StreetNameSorting(); - public StreetNameListQuery(LegacyContext legacyContext, SyndicationContext syndicationContext) + public StreetNameListQuery(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } protected override IQueryable Filter(FilteringHeader filtering) @@ -89,6 +92,15 @@ protected override IQueryable Filter(FilteringHeader m.NisCode == postalConsumerItem.NisCode); + } + } + return streetNames; } @@ -138,5 +150,6 @@ public sealed class StreetNameFilter 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; } } diff --git a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs index 5a0dc2688..998a6cc46 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs +++ b/src/StreetNameRegistry.Api.Legacy/StreetName/Query/StreetNameListQueryV2.cs @@ -7,6 +7,7 @@ namespace StreetNameRegistry.Api.Legacy.StreetName.Query using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; + using Consumer.Read.Postal; using Convertors; using Microsoft.EntityFrameworkCore; using Projections.Legacy; @@ -17,13 +18,15 @@ public sealed class StreetNameListQueryV2 : Query new StreetNameSorting(); - public StreetNameListQueryV2(LegacyContext legacyContext, SyndicationContext syndicationContext) + public StreetNameListQueryV2(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } protected override IQueryable Filter(FilteringHeader filtering) @@ -77,7 +80,7 @@ protected override IQueryable Filter(FilteringHeader streetNamesV2)) + if (streetNames is IQueryable) { streetNames = streetNames.Where(m => municipalityNisCodes.Contains(m.NisCode)); } @@ -107,6 +110,16 @@ protected override IQueryable Filter(FilteringHeader m.NisCode == postalConsumerItem.NisCode); + } + } + return streetNames; } } diff --git a/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj b/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj index 7d580434e..a2083934a 100644 --- a/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj +++ b/src/StreetNameRegistry.Api.Legacy/StreetNameRegistry.Api.Legacy.csproj @@ -35,6 +35,7 @@ + diff --git a/src/StreetNameRegistry.Api.Legacy/appsettings.json b/src/StreetNameRegistry.Api.Legacy/appsettings.json index 85cf7b473..c2f69a55b 100755 --- a/src/StreetNameRegistry.Api.Legacy/appsettings.json +++ b/src/StreetNameRegistry.Api.Legacy/appsettings.json @@ -3,7 +3,8 @@ "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;" + "LegacyProjectionsAdmin": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;", + "ConsumerPostal": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.StreetNameRegistry;Trusted_Connection=True;TrustServerCertificate=True;" }, "DataDog": { diff --git a/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/ApiModule.cs b/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/ApiModule.cs index e769e1891..995c566b6 100644 --- a/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/ApiModule.cs +++ b/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/ApiModule.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Oslo.Infrastructure.Modules using Be.Vlaanderen.Basisregisters.Api.Exceptions; using Be.Vlaanderen.Basisregisters.DataDog.Tracing.Microsoft; using Be.Vlaanderen.Basisregisters.DependencyInjection; + using Consumer.Read.Postal.Infrastructure.Modules; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -33,7 +34,8 @@ protected override void Load(ContainerBuilder builder) builder .RegisterModule(new LegacyModule(_configuration, _services, _loggerFactory)) - .RegisterModule(new SyndicationModule(_configuration, _services, _loggerFactory)); + .RegisterModule(new SyndicationModule(_configuration, _services, _loggerFactory)) + .RegisterModule(new ConsumerPostalModule(_configuration, _services, _loggerFactory)); builder .RegisterType() diff --git a/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/MediatRModule.cs b/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/MediatRModule.cs index b4a87de86..57d0e6ed2 100644 --- a/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/MediatRModule.cs +++ b/src/StreetNameRegistry.Api.Oslo/Infrastructure/Modules/MediatRModule.cs @@ -3,6 +3,7 @@ namespace StreetNameRegistry.Api.Oslo.Infrastructure.Modules using Abstractions.Infrastructure.Options; using Autofac; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using FeatureToggles; using MediatR; using Microsoft.Extensions.Options; @@ -33,6 +34,7 @@ protected override void Load(ContainerBuilder builder) new OsloListHandlerV2( c.Resolve(), c.Resolve(), + c.Resolve(), c.Resolve>()); } @@ -40,6 +42,7 @@ protected override void Load(ContainerBuilder builder) new OsloListHandler( c.Resolve(), c.Resolve(), + c.Resolve(), c.Resolve>()); }).InstancePerLifetimeScope(); @@ -69,13 +72,15 @@ protected override void Load(ContainerBuilder builder) return (IRequestHandler) new OsloCountHandlerV2( c.Resolve(), - c.Resolve()); + c.Resolve(), + c.Resolve()); } return (IRequestHandler) new OsloCountHandler( c.Resolve(), - c.Resolve()); + c.Resolve(), + c.Resolve()); }).InstancePerLifetimeScope(); } } diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandler.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandler.cs index e19854c30..2864f7580 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandler.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandler.cs @@ -5,6 +5,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.Count using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Microsoft.EntityFrameworkCore; using Projections.Legacy; using Projections.Legacy.StreetNameList; @@ -15,11 +16,13 @@ public sealed class OsloCountHandler : OsloCountHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; - public OsloCountHandler(LegacyContext legacyContext, SyndicationContext syndicationContext) + public OsloCountHandler(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } public override async Task Handle(OsloCountRequest request, CancellationToken cancellationToken) @@ -30,7 +33,7 @@ public override async Task Handle(OsloCountRequest request new TotaalAantalResponse { Aantal = request.Filtering.ShouldFilter - ? await new StreetNameListOsloQuery(_legacyContext, _syndicationContext) + ? await new StreetNameListOsloQuery(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, pagination) .Items .CountAsync(cancellationToken) diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandlerV2.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandlerV2.cs index 3a03faf0e..193b52432 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandlerV2.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/Count/OsloCountHandlerV2.cs @@ -4,6 +4,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.Count using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Microsoft.EntityFrameworkCore; using Projections.Legacy; using Projections.Legacy.StreetNameListV2; @@ -14,11 +15,13 @@ public sealed class OsloCountHandlerV2 : OsloCountHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; - public OsloCountHandlerV2(LegacyContext legacyContext, SyndicationContext syndicationContext) + public OsloCountHandlerV2(LegacyContext legacyContext, SyndicationContext syndicationContext, ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } public override async Task Handle(OsloCountRequest request, CancellationToken cancellationToken) @@ -28,7 +31,7 @@ public override async Task Handle(OsloCountRequest request return new TotaalAantalResponse { - Aantal = await new StreetNameListOsloQueryV2(_legacyContext, _syndicationContext) + Aantal = await new StreetNameListOsloQueryV2(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, pagination) .Items .CountAsync(cancellationToken) diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandler.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandler.cs index 0e5603722..6ffedc114 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandler.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandler.cs @@ -6,6 +6,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.List using Abstractions.Infrastructure.Options; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Converters; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; @@ -19,21 +20,24 @@ public sealed class OsloListHandler : OsloListHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; private readonly IOptions _responseOptions; public OsloListHandler( LegacyContext legacyContext, SyndicationContext syndicationContext, + ConsumerPostalContext postalContext, IOptions responseOptions) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; _responseOptions = responseOptions; } public override async Task Handle(OsloListRequest request, CancellationToken cancellationToken) { - var streetNameQuery = new StreetNameListOsloQuery(_legacyContext, _syndicationContext) + var streetNameQuery = new StreetNameListOsloQuery(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, request.PaginationRequest); var pagedStreetNames = await streetNameQuery diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandlerV2.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandlerV2.cs index ac12aaae8..ef68227f0 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandlerV2.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/List/OsloListHandlerV2.cs @@ -6,6 +6,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.List using Abstractions.Infrastructure.Options; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy; + using Consumer.Read.Postal; using Converters; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; @@ -19,21 +20,24 @@ public sealed class OsloListHandlerV2 : OsloListHandlerBase { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; private readonly IOptions _responseOptions; public OsloListHandlerV2( LegacyContext legacyContext, SyndicationContext syndicationContext, + ConsumerPostalContext postalContext, IOptions responseOptions) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; _responseOptions = responseOptions; } public override async Task Handle(OsloListRequest request, CancellationToken cancellationToken) { - var streetNameQuery = new StreetNameListOsloQueryV2(_legacyContext, _syndicationContext) + var streetNameQuery = new StreetNameListOsloQueryV2(_legacyContext, _syndicationContext, _postalContext) .Fetch(request.Filtering, request.Sorting, request.PaginationRequest); var pagedStreetNames = await streetNameQuery diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQuery.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQuery.cs index 8eee70d7e..7bd377dc6 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQuery.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQuery.cs @@ -7,6 +7,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.Query using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; + using Consumer.Read.Postal; using Converters; using Microsoft.EntityFrameworkCore; using Projections.Legacy; @@ -17,13 +18,18 @@ public sealed class StreetNameListOsloQuery : Be.Vlaanderen.Basisregisters.Api.S { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; protected override ISorting Sorting => new StreetNameSorting(); - public StreetNameListOsloQuery(LegacyContext legacyContext, SyndicationContext syndicationContext) + public StreetNameListOsloQuery( + LegacyContext legacyContext, + SyndicationContext syndicationContext, + ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } protected override IQueryable Filter(FilteringHeader filtering) @@ -94,6 +100,15 @@ protected override IQueryable Filter(FilteringHeader m.Status.HasValue && (int)m.Status.Value == -1); } + if (!string.IsNullOrWhiteSpace(filtering.Filter.PostalCode)) + { + var postalConsumerItem = _postalContext.PostalConsumerItems.Find(filtering.Filter.PostalCode); + if (postalConsumerItem?.NisCode != null) + { + streetNames = streetNames.Where(m => m.NisCode == postalConsumerItem.NisCode); + } + } + return streetNames; } } @@ -123,5 +138,6 @@ public class StreetNameFilter public string NameEnglish { get; set; } public string Status { get; set; } public string? NisCode { get; set; } + public string? PostalCode { get; set; } } } diff --git a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs index 1d26e333e..79d1536bb 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs +++ b/src/StreetNameRegistry.Api.Oslo/StreetName/Query/StreetNameListOsloQueryV2.cs @@ -6,6 +6,7 @@ namespace StreetNameRegistry.Api.Oslo.StreetName.Query using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; using Be.Vlaanderen.Basisregisters.GrAr.Common; using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Straatnaam; + using Consumer.Read.Postal; using Converters; using Microsoft.EntityFrameworkCore; using Projections.Legacy; @@ -16,13 +17,18 @@ public sealed class StreetNameListOsloQueryV2 : Be.Vlaanderen.Basisregisters.Api { private readonly LegacyContext _legacyContext; private readonly SyndicationContext _syndicationContext; + private readonly ConsumerPostalContext _postalContext; protected override ISorting Sorting => new StreetNameSorting(); - public StreetNameListOsloQueryV2(LegacyContext legacyContext, SyndicationContext syndicationContext) + public StreetNameListOsloQueryV2( + LegacyContext legacyContext, + SyndicationContext syndicationContext, + ConsumerPostalContext postalContext) { _legacyContext = legacyContext; _syndicationContext = syndicationContext; + _postalContext = postalContext; } protected override IQueryable Filter(FilteringHeader filtering) @@ -114,6 +120,15 @@ protected override IQueryable Filter(FilteringHeader m.NisCode == postalConsumerItem.NisCode); + } + } + return streetNames; } } diff --git a/src/StreetNameRegistry.Api.Oslo/StreetNameRegistry.Api.Oslo.csproj b/src/StreetNameRegistry.Api.Oslo/StreetNameRegistry.Api.Oslo.csproj index cf516e082..d4d5d1eb1 100644 --- a/src/StreetNameRegistry.Api.Oslo/StreetNameRegistry.Api.Oslo.csproj +++ b/src/StreetNameRegistry.Api.Oslo/StreetNameRegistry.Api.Oslo.csproj @@ -35,6 +35,7 @@ + diff --git a/src/StreetNameRegistry.Consumer.Read.Postal/StreetNameRegistry.Consumer.Read.Postal.csproj b/src/StreetNameRegistry.Consumer.Read.Postal/StreetNameRegistry.Consumer.Read.Postal.csproj index e7fa95c1f..c6e239f1d 100644 --- a/src/StreetNameRegistry.Consumer.Read.Postal/StreetNameRegistry.Consumer.Read.Postal.csproj +++ b/src/StreetNameRegistry.Consumer.Read.Postal/StreetNameRegistry.Consumer.Read.Postal.csproj @@ -24,9 +24,5 @@ - - - - diff --git a/src/StreetNameRegistry.Consumer.Read.Postal/appsettings.json b/src/StreetNameRegistry.Consumer.Read.Postal/appsettings.json index 577e1b801..9043e5519 100644 --- a/src/StreetNameRegistry.Consumer.Read.Postal/appsettings.json +++ b/src/StreetNameRegistry.Consumer.Read.Postal/appsettings.json @@ -7,7 +7,7 @@ "DataDog": { "Enabled": false, "Debug": false, - "ServiceName": "streetname-registry-consumer-read-Postal-dev" + "ServiceName": "streetname-registry-consumer-read-postal-dev" }, "Kafka": { @@ -15,7 +15,7 @@ }, "GroupSuffix": "", - "Topic": "dev.Postal", + "Topic": "dev.postal", "TopicOffset": "", "BaseUrl": "https://api.staging-basisregisters.vlaanderen/", diff --git a/src/StreetNameRegistry.Consumer.Read.Postal/init.sh b/src/StreetNameRegistry.Consumer.Read.Postal/init.sh index 5fe303ce2..12f782b60 100644 --- a/src/StreetNameRegistry.Consumer.Read.Postal/init.sh +++ b/src/StreetNameRegistry.Consumer.Read.Postal/init.sh @@ -1,6 +1,6 @@ #!/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(\"-consumer-read-Postal\")) | .DockerId") +CONTAINERID=$(curl -s http://169.254.170.2/v2/metadata | jq -r ".Containers[] | select(.Labels[\"com.amazonaws.ecs.container-name\"] | startswith(\"basisregisters-\") and endswith(\"-consumer-read-postal\")) | .DockerId") sed -i "s/REPLACE_CONTAINERID/$CONTAINERID/g" appsettings.json