Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Or 1716 undodubbel #1036

Merged
merged 24 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6726106
test: or-1716 add all e2e tests for corrigeer markering als dubbel
emalfroy Dec 24, 2024
3e6533d
feat: or-1716 implement CorrigeerMarkeringAlsDubbelVanCommandHandler
emalfroy Dec 24, 2024
36dd66c
fix: or-2335 add message handler for VerwerkWeigeringDubbelDoorAuthen…
emalfroy Dec 25, 2024
91bce9f
refactor: or-1716 rename AanvaardCorrectieDubbeleVereniging
emalfroy Jan 3, 2025
34153ec
test: or-1716 add test for VerenigingMoetGemarkeerdZijnAlsDubbelOmGec…
emalfroy Jan 3, 2025
683c345
refactor: or-1716 check only on status of state for corrigeer dubbel van
emalfroy Jan 3, 2025
075f444
refactor: or-1716 migrate dubbel info to verenigingStatus
emalfroy Jan 3, 2025
5020343
refactor: or-1716 use const for VerenigingStatusNaam
emalfroy Jan 3, 2025
e203c42
feat: or-1716 throw application exception when authentieke vereniging…
emalfroy Jan 3, 2025
8e00339
fix: or-1716 use vorigeStatus when processing undo/weigering dubbels …
koenmetsu Jan 3, 2025
6502367
feat: or-1716 allow aanvaarding correctie dubbele vereniging in authe…
koenmetsu Jan 3, 2025
40070b7
feat: or-1716 throw exception when trying to accept correctie for unk…
koenmetsu Jan 3, 2025
290fcfb
refactor: or-1716 move dubbelbeheer stuff into dubbelbeheer folders
koenmetsu Jan 3, 2025
956fe52
test: or-1716 add projection test for MarkeringDubbeleVerengingWerdGe…
emalfroy Jan 6, 2025
fb5658e
feat: or-1716 implement beheer detail for correctie dubbels
emalfroy Jan 6, 2025
d98e953
feat: or-1716 implement beheer historiek for correctie dubbels
emalfroy Jan 6, 2025
639c131
feat: or-1716 implement publiek detail for corrigeer dubbels
emalfroy Jan 6, 2025
525a2f6
feat: or-1716 implement publiek zoeken for correctie dubbels
emalfroy Jan 6, 2025
69a8b5f
feat: or-1716 implement beheer zoeken for corrigeer dubbel
emalfroy Jan 6, 2025
e248434
feat: or-1716 implement acm for correctie dubbels
emalfroy Jan 6, 2025
2908f28
fix: or-1716 register verwerk weigering dubbel queue
emalfroy Jan 7, 2025
eee535b
refactor: or-1716 ConfigurePostgresQueues
emalfroy Jan 7, 2025
0a07a55
fix: or-1716 change message names for historiek
emalfroy Jan 7, 2025
50129d3
test: or-1716 fix test aanvaard dubbel
emalfroy Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ public async Task Project(
ops.StoreObjects(docs);
}

public async Task Project(IEvent<MarkeringDubbeleVerengingWerdGecorrigeerd> markeringDubbeleVerengingWerdGecorrigeerd, IDocumentOperations ops)
{
var docs = new List<object>();

docs.AddRange(await VerenigingenPerInszProjector.Apply(markeringDubbeleVerengingWerdGecorrigeerd, ops));

ops.StoreObjects(docs);
}

public async Task Project(IEvent<VerenigingAanvaarddeCorrectieDubbeleVereniging> VerenigingAanvaarddeCorrectieDubbeleVereniging, IDocumentOperations ops)
{
var docs = new List<object>();

docs.AddRange(await VerenigingenPerInszProjector.Apply(VerenigingAanvaarddeCorrectieDubbeleVereniging, ops));

ops.StoreObjects(docs);
}

private static class VerenigingenPerInszProjector
{
public static async Task<List<VerenigingenPerInszDocument>> Apply(
Expand Down Expand Up @@ -379,6 +397,52 @@ public static async Task<List<VerenigingenPerInszDocument>> Apply(

return docs;
}

public static async Task<List<VerenigingenPerInszDocument>> Apply(
IEvent<VerenigingAanvaarddeCorrectieDubbeleVereniging> verenigingAanvaarddeCorrectieDubbeleVereniging,
IDocumentOperations ops)
{
var docs = new List<VerenigingenPerInszDocument>();
var documents = await ops.GetVerenigingenPerInszDocuments(verenigingAanvaarddeCorrectieDubbeleVereniging.Data.VCode);

foreach (var verenigingenPerInszDocument in documents)
{
var vereniging =
verenigingenPerInszDocument.Verenigingen.Single(
vereniging => vereniging.VCode == verenigingAanvaarddeCorrectieDubbeleVereniging.StreamKey!);

vereniging.CorresponderendeVCodes =
vereniging.CorresponderendeVCodes
.Where(w => w != verenigingAanvaarddeCorrectieDubbeleVereniging.Data.VCodeDubbeleVereniging)
.ToArray();

docs.Add(verenigingenPerInszDocument);
}

return docs;
}

public static async Task<List<VerenigingenPerInszDocument>> Apply(
IEvent<MarkeringDubbeleVerengingWerdGecorrigeerd> markeringDubbeleVerengingWerdGecorrigeerd,
IDocumentOperations ops)
{
var docs = new List<VerenigingenPerInszDocument>();
var documents = await ops.GetVerenigingenPerInszDocuments(markeringDubbeleVerengingWerdGecorrigeerd.Data.VCode);

foreach (var verenigingenPerInszDocument in documents)
{
var vereniging =
verenigingenPerInszDocument.Verenigingen.Single(
vereniging => vereniging.VCode == markeringDubbeleVerengingWerdGecorrigeerd.StreamKey!);

vereniging.IsDubbel = false;

docs.Add(verenigingenPerInszDocument);
}

return docs;
}

}

private static class VerenigingDocumentProjector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static class WolverineExtensions
{
public static void AddWolverine(this WebApplicationBuilder builder)
{
const string AanvaardDubbeleVerenigingQueueName = "aanvaard-dubbele-vereniging-queue";
const string wolverineSchema = "public";

builder.Host.UseWolverine(
Expand All @@ -32,8 +31,6 @@ public static void AddWolverine(this WebApplicationBuilder builder)
options.Discovery.IncludeType<TeAdresMatchenLocatieMessageHandler>();
options.Discovery.IncludeType<OverkoepelendeGrarConsumerMessage>();
options.Discovery.IncludeType<OverkoepelendeGrarConsumerMessageHandler>();
options.Discovery.IncludeType<AanvaardDubbeleVerenigingMessage>();
options.Discovery.IncludeType<AanvaardDubbeleVerenigingMessageHandler>();

options.OnException<UnexpectedAggregateVersionDuringSyncException>().RetryWithCooldown(
TimeSpan.FromSeconds(1),
Expand All @@ -56,21 +53,9 @@ public static void AddWolverine(this WebApplicationBuilder builder)
if (grarOptions.Sqs.UseLocalStack)
transportConfiguration.Credentials(new BasicAWSCredentials(accessKey: "dummy", secretKey: "dummy"));

ConfigureAddressMatchPublisher(options, grarOptions.Sqs.AddressMatchQueueName);

ConfigureAddressMatchListener(options, grarOptions.Sqs.AddressMatchQueueName,
grarOptions.Sqs.AddressMatchDeadLetterQueueName);

ConfigureGrarSyncListener(options, grarOptions.Sqs.GrarSyncQueueName, grarOptions.Sqs.GrarSyncDeadLetterQueueName,
grarOptions.Sqs.GrarSyncQueueListenerEnabled);

var connectionString = context.Configuration.GetPostgreSqlOptionsSection().GetConnectionString();

options.UsePostgresqlPersistenceAndTransport(connectionString, wolverineSchema, wolverineSchema);
options.PublishMessage<AanvaardDubbeleVerenigingMessage>()
.ToPostgresqlQueue(AanvaardDubbeleVerenigingQueueName);
ConfigureSqsQueues(options, grarOptions);

options.ListenToPostgresqlQueue(AanvaardDubbeleVerenigingQueueName);
ConfigurePostgresQueues(options, context, wolverineSchema);

if (grarOptions.Wolverine.AutoProvision)
transportConfiguration.AutoProvision();
Expand All @@ -82,6 +67,36 @@ public static void AddWolverine(this WebApplicationBuilder builder)
});
}

private static void ConfigureSqsQueues(WolverineOptions options, GrarOptions grarOptions)
{
ConfigureAddressMatchPublisher(options, grarOptions.Sqs.AddressMatchQueueName);

ConfigureAddressMatchListener(options, grarOptions.Sqs.AddressMatchQueueName,
grarOptions.Sqs.AddressMatchDeadLetterQueueName);

ConfigureGrarSyncListener(options, grarOptions.Sqs.GrarSyncQueueName, grarOptions.Sqs.GrarSyncDeadLetterQueueName,
grarOptions.Sqs.GrarSyncQueueListenerEnabled);
}

private static void ConfigurePostgresQueues(
WolverineOptions options,
HostBuilderContext context,
string wolverineSchema)
{
const string AanvaardDubbeleVerenigingQueueName = "aanvaard-dubbele-vereniging-queue";

options.Discovery.IncludeType<AanvaardDubbeleVerenigingMessage>();
options.Discovery.IncludeType<AanvaardDubbeleVerenigingMessageHandler>();

var connectionString = context.Configuration.GetPostgreSqlOptionsSection().GetConnectionString();

options.UsePostgresqlPersistenceAndTransport(connectionString, wolverineSchema, wolverineSchema);

options.PublishMessage<AanvaardDubbeleVerenigingMessage>()
.ToPostgresqlQueue(AanvaardDubbeleVerenigingQueueName);
options.ListenToPostgresqlQueue(AanvaardDubbeleVerenigingQueueName);
}

private static void ConfigureAddressMatchPublisher(WolverineOptions options, string sqsQueueName)
{
options.PublishMessage<TeAdresMatchenLocatieMessage>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace AssociationRegistry.Admin.Api.MessageHandling.Postgres.Dubbels;

using Messages;
using Wolverine;

public class AanvaardCorrectieDubbeleVerenigingMessageHandler(IMessageBus messageBus)
{
public async Task Handle(AanvaardCorrectieDubbeleVerenigingMessage message, CancellationToken cancellationToken)
{
var command = message.ToCommand();

await messageBus.InvokeAsync(command, cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace AssociationRegistry.Admin.Api.MessageHandling.Postgres.Dubbels;

using Messages;
using Wolverine;

public class VerwerkWeigeringDubbelDoorAuthentiekeVerenigingMessageHandler(IMessageBus messageBus)
{
public async Task Handle(VerwerkWeigeringDubbelDoorAuthentiekeVerenigingMessage message, CancellationToken cancellationToken)
{
var command = message.ToCommand();

await messageBus.InvokeAsync(command, cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbelbeheer.FeitelijkeVereniging.CorrigeerMarkeringDubbel;

using Asp.Versioning;
using AssociationRegistry.Acties.Dubbelbeheer.CorrigeerMarkeringAlsDubbelVan;
using AssociationRegistry.Admin.Api.Infrastructure;
using AssociationRegistry.Admin.Api.Infrastructure.Extensions;
using AssociationRegistry.Admin.Api.Infrastructure.Middleware;
using AssociationRegistry.Admin.Api.Infrastructure.Swagger.Annotations;
using AssociationRegistry.Admin.Api.Infrastructure.Swagger.Examples;
using AssociationRegistry.Framework;
using AssociationRegistry.Hosts.Configuration.ConfigurationBindings;
using AssociationRegistry.Vereniging;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Filters;
using Wolverine;
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails;
using ValidationProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails;

[ApiVersion("1.0")]
[AdvertiseApiVersions("1.0")]
[ApiRoute("verenigingen")]
[ApiExplorerSettings(IgnoreApi = true)]
[Authorize(Policy = Program.SuperAdminPolicyName)]
public class MarkeerAlsDubbelVanController : ApiController
{
private readonly IMessageBus _messageBus;
private readonly AppSettings _appSettings;

public MarkeerAlsDubbelVanController(IMessageBus messageBus, AppSettings appSettings)
{
_messageBus = messageBus;
_appSettings = appSettings;
}

/// <summary>
/// Corrigeer de markering van een vereniging als dubbel van een andere vereniging.
/// </summary>
/// <remarks>
/// Na het uitvoeren van deze actie wordt een sequentie teruggegeven via de `VR-Sequence` header.
/// Deze waarde kan gebruikt worden in andere endpoints om op te volgen of de aanpassing
/// al is doorgestroomd naar deze endpoints.
/// </remarks>
/// <param name="vCode">De vCode van de vereniging.</param>
/// <param name="metadataProvider"></param>
/// <param name="ifMatch">If-Match header met ETag van de laatst gekende versie van de vereniging.</param>
/// <response code="202">De markering als dubbel werd gecorrigeerd.response>
/// <response code="400">Er was een probleem met de doorgestuurde waarden.</response>
/// <response code="412">De gevraagde vereniging heeft niet de verwachte sequentiewaarde.</response>
/// <response code="500">Er is een interne fout opgetreden.</response>
[HttpDelete("{vCode}/dubbelVan")]
[ConsumesJson]
[ProducesJson]
[SwaggerResponseHeader(StatusCodes.Status202Accepted, WellknownHeaderNames.Sequence, type: "string",
description: "Het sequence nummer van deze request.")]
[SwaggerResponseHeader(StatusCodes.Status202Accepted, name: "ETag", type: "string",
description: "De versie van de vereniging die als dubbel werd gemarkeerd.")]
[SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(ProblemAndValidationProblemDetailsExamples))]
[SwaggerResponseExample(StatusCodes.Status412PreconditionFailed, typeof(PreconditionFailedProblemDetailsExamples))]
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))]
[ProducesResponseType(StatusCodes.Status202Accepted)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status412PreconditionFailed)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> Corrigeer(
[FromRoute] string vCode,
[FromServices] ICommandMetadataProvider metadataProvider,
[FromHeader(Name = "If-Match")] string? ifMatch = null)
{
var metaData = metadataProvider.GetMetadata(IfMatchParser.ParseIfMatch(ifMatch));
var envelope = new CommandEnvelope<CorrigeerMarkeringAlsDubbelVanCommand>(new CorrigeerMarkeringAlsDubbelVanCommand(VCode.Create(vCode)), metaData);
var commandResult = await _messageBus.InvokeAsync<CommandResult>(envelope);

return this.AcceptedCommand(_appSettings, commandResult);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbels.FeitelijkeVereniging.MarkeerAlsDubbelVan.Examples;
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbelbeheer.FeitelijkeVereniging.MarkeerAlsDubbelVan.Examples;

using RequestModels;
using Swashbuckle.AspNetCore.Filters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbels.FeitelijkeVereniging.MarkeerAlsDubbelVan;
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbelbeheer.FeitelijkeVereniging.MarkeerAlsDubbelVan;

using Acties.MarkeerAlsDubbelVan;
using Asp.Versioning;
using AssociationRegistry.Acties.Dubbelbeheer.MarkeerAlsDubbelVan;
using AssociationRegistry.Admin.Api.Infrastructure;
using AssociationRegistry.Admin.Api.Infrastructure.Extensions;
using AssociationRegistry.Admin.Api.Infrastructure.Middleware;
using AssociationRegistry.Admin.Api.Infrastructure.Swagger.Annotations;
using AssociationRegistry.Admin.Api.Infrastructure.Swagger.Examples;
using AssociationRegistry.Admin.Api.Infrastructure.Validation;
using AssociationRegistry.Framework;
using AssociationRegistry.Hosts.Configuration.ConfigurationBindings;
using AssociationRegistry.Vereniging;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Examples;
using FluentValidation;
using Framework;
using Hosts.Configuration.ConfigurationBindings;
using Infrastructure;
using Infrastructure.Extensions;
using Infrastructure.Middleware;
using Infrastructure.Swagger.Annotations;
using Infrastructure.Swagger.Examples;
using Infrastructure.Validation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RequestModels;
using Swashbuckle.AspNetCore.Filters;
using Vereniging;
using Wolverine;
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails;
using ValidationProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbels.FeitelijkeVereniging.MarkeerAlsDubbelVan;
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbelbeheer.FeitelijkeVereniging.MarkeerAlsDubbelVan;

using AssociationRegistry.Admin.Api.Infrastructure.Validation;
using FluentValidation;
using Infrastructure.Validation;
using RequestModels;

// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbels.FeitelijkeVereniging.MarkeerAlsDubbelVan.RequestModels;
namespace AssociationRegistry.Admin.Api.Verenigingen.Dubbelbeheer.FeitelijkeVereniging.MarkeerAlsDubbelVan.RequestModels;

using Acties.MarkeerAlsDubbelVan;
using AssociationRegistry.Acties.Dubbelbeheer.MarkeerAlsDubbelVan;
using AssociationRegistry.Vereniging;
using System.Runtime.Serialization;
using Vereniging;

[DataContract]
public class MarkeerAlsDubbelVanRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,16 @@ public async Task Project(IEvent<VerenigingWerdGemarkeerdAlsDubbelVan> @event, I

public async Task Project(IEvent<VerenigingAanvaarddeDubbeleVereniging> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingDetailProjector.Apply);

public async Task Project(IEvent<WeigeringDubbelDoorAuthentiekeVerenigingWerdVerwerkt> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingDetailProjector.Apply);

public async Task Project(IEvent<MarkeringDubbeleVerengingWerdGecorrigeerd> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingDetailProjector.Apply);

public async Task Project(IEvent<VerenigingAanvaarddeCorrectieDubbeleVereniging> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingDetailProjector.Apply);

private async Task SoftDelete(string? streamKey, IDocumentOperations ops)
=> ops.Delete<BeheerVerenigingDetailDocument>(streamKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,4 +770,18 @@ public static void Apply(IEvent<WeigeringDubbelDoorAuthentiekeVerenigingWerdVerw
document.Status = weigeringDubbelDoorAuthentiekeVerenigingWerdVerwerkt.Data.VorigeStatus;
document.IsDubbelVan = string.Empty;
}

public static void Apply(IEvent<MarkeringDubbeleVerengingWerdGecorrigeerd> markeringDubbeleVerengingWerdGecorrigeerd, BeheerVerenigingDetailDocument document)
{
document.Status = markeringDubbeleVerengingWerdGecorrigeerd.Data.VorigeStatus;
document.IsDubbelVan = string.Empty;
}

public static void Apply(IEvent<VerenigingAanvaarddeCorrectieDubbeleVereniging> verenigingAanvaarddeCorrectieDubbeleVereniging, BeheerVerenigingDetailDocument document)
{
document.CorresponderendeVCodes =
document.CorresponderendeVCodes
.Where(x => x != verenigingAanvaarddeCorrectieDubbeleVereniging.Data.VCodeDubbeleVereniging)
.ToArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ public async Task Project(IEvent<VerenigingAanvaarddeDubbeleVereniging> @event,
public async Task Project(IEvent<WeigeringDubbelDoorAuthentiekeVerenigingWerdVerwerkt> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingHistoriekProjector.Apply);

public async Task Project(IEvent<MarkeringDubbeleVerengingWerdGecorrigeerd> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingHistoriekProjector.Apply);

public async Task Project(IEvent<VerenigingAanvaarddeCorrectieDubbeleVereniging> @event, IDocumentOperations ops)
=> await Update(@event, ops, BeheerVerenigingHistoriekProjector.Apply);

public async Task Project(
IEvent<VertegenwoordigerWerdOvergenomenUitKBO> @event,
IDocumentOperations ops)
Expand Down
Loading
Loading