-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: or-1349 split duplicate detection (#616)
* feat: or-1349 split duplicate detection * chore: or-1349 clean up code
- Loading branch information
Showing
5 changed files
with
103 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...AssociationRegistry.Admin.ProjectionHost/Projections/Search/BeheerZoekenEventsConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace AssociationRegistry.Admin.ProjectionHost.Projections.Search; | ||
|
||
using DuplicateDetection; | ||
using Events; | ||
using Marten.Events; | ||
using Wolverine; | ||
using Wolverine.Runtime.Routing; | ||
using Zoeken; | ||
using IEvent = Framework.IEvent; | ||
|
||
public class BeheerZoekenEventsConsumer : IMartenEventsConsumer | ||
{ | ||
private readonly BeheerZoekProjectionHandler _zoekProjectionHandler; | ||
|
||
public BeheerZoekenEventsConsumer(BeheerZoekProjectionHandler zoekProjectionHandler) | ||
{ | ||
_zoekProjectionHandler = zoekProjectionHandler; | ||
} | ||
|
||
public async Task ConsumeAsync(IReadOnlyList<StreamAction> streamActions) | ||
{ | ||
foreach (var @event in streamActions.SelectMany(streamAction => streamAction.Events)) | ||
{ | ||
dynamic eventEnvelope = | ||
Activator.CreateInstance(typeof(EventEnvelope<>).MakeGenericType(@event.EventType), @event)!; | ||
|
||
switch (@event.EventType.Name) | ||
{ | ||
case nameof(DoelgroepWerdGewijzigd): | ||
case nameof(FeitelijkeVerenigingWerdGeregistreerd): | ||
case nameof(HoofdactiviteitenVerenigingsloketWerdenGewijzigd): | ||
case nameof(KorteNaamWerdGewijzigd): | ||
case nameof(LocatieWerdGewijzigd): | ||
case nameof(LocatieWerdToegevoegd): | ||
case nameof(LocatieWerdVerwijderd): | ||
case nameof(MaatschappelijkeZetelVolgensKBOWerdGewijzigd): | ||
case nameof(MaatschappelijkeZetelWerdOvergenomenUitKbo): | ||
case nameof(NaamWerdGewijzigd): | ||
case nameof(RoepnaamWerdGewijzigd): | ||
case nameof(VerenigingMetRechtspersoonlijkheidWerdGeregistreerd): | ||
case nameof(VerenigingWerdGestopt): | ||
case nameof(VerenigingWerdIngeschrevenInPubliekeDatastroom): | ||
case nameof(VerenigingWerdUitgeschrevenUitPubliekeDatastroom): | ||
case nameof(VerenigingWerdVerwijderd): | ||
await _zoekProjectionHandler.Handle(eventEnvelope); | ||
break; | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ationRegistry.Admin.ProjectionHost/Projections/Search/DuplicateDetectionEventsConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace AssociationRegistry.Admin.ProjectionHost.Projections.Search; | ||
|
||
using DuplicateDetection; | ||
using Events; | ||
using Marten.Events; | ||
|
||
public class DuplicateDetectionEventsConsumer : IMartenEventsConsumer | ||
{ | ||
private readonly DuplicateDetectionProjectionHandler _duplicateDetectionProjectionHandler; | ||
|
||
public DuplicateDetectionEventsConsumer(DuplicateDetectionProjectionHandler duplicateDetectionProjectionHandler) | ||
{ | ||
_duplicateDetectionProjectionHandler = duplicateDetectionProjectionHandler; | ||
} | ||
|
||
public async Task ConsumeAsync(IReadOnlyList<StreamAction> streamActions) | ||
{ | ||
foreach (var @event in streamActions.SelectMany(streamAction => streamAction.Events)) | ||
{ | ||
dynamic eventEnvelope = | ||
(IEventEnvelope)Activator.CreateInstance(typeof(EventEnvelope<>).MakeGenericType(@event.EventType), @event)!; | ||
|
||
switch (@event.EventType.Name) | ||
{ | ||
case nameof(FeitelijkeVerenigingWerdGeregistreerd): | ||
case nameof(HoofdactiviteitenVerenigingsloketWerdenGewijzigd): | ||
case nameof(KorteNaamWerdGewijzigd): | ||
case nameof(LocatieWerdGewijzigd): | ||
case nameof(LocatieWerdToegevoegd): | ||
case nameof(LocatieWerdVerwijderd): | ||
case nameof(MaatschappelijkeZetelWerdOvergenomenUitKbo): | ||
case nameof(NaamWerdGewijzigd): | ||
case nameof(VerenigingMetRechtspersoonlijkheidWerdGeregistreerd): | ||
case nameof(VerenigingWerdGestopt): | ||
case nameof(VerenigingWerdVerwijderd): | ||
await _duplicateDetectionProjectionHandler.Handle(eventEnvelope); | ||
break; | ||
} | ||
} | ||
} | ||
} |
115 changes: 0 additions & 115 deletions
115
src/AssociationRegistry.Admin.ProjectionHost/Projections/Search/MartenEventsConsumer.cs
This file was deleted.
Oops, something went wrong.