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

feat: or-2031 registreer inschrijving when adding kbo verenigingen #633

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions AssociationRegistry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mappings", "mappings", "{9E
wiremock\mappings\GeefOnderneming.notfound.json = wiremock\mappings\GeefOnderneming.notfound.json
wiremock\mappings\GeefOnderneming.vestiging.json = wiremock\mappings\GeefOnderneming.vestiging.json
wiremock\mappings\projectionactions.json = wiremock\mappings\projectionactions.json
wiremock\mappings\RegistreerInschrijving.json = wiremock\mappings\RegistreerInschrijving.json
wiremock\mappings\RegistreerInschrijving.connection-failure.json = wiremock\mappings\RegistreerInschrijving.connection-failure.json
wiremock\mappings\RegistreerInschrijving.uitzondering.fout.json = wiremock\mappings\RegistreerInschrijving.uitzondering.fout.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssociationRegistry.Magda", "src\AssociationRegistry.Magda\AssociationRegistry.Magda.csproj", "{85139412-485D-4B23-8423-A0C2021B60DE}"
Expand All @@ -113,6 +116,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GeefOndernemingResponses",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssociationRegistry.Hosts", "src\AssociationRegistry.Hosts\AssociationRegistry.Hosts.csproj", "{F0853B2C-FEAB-4ACF-92D5-D9FBC3DA1427}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RegistreerInschrijvingResponses", "RegistreerInschrijvingResponses", "{598628E9-81AA-41EE-8F2A-C9607A2D294A}"
ProjectSection(SolutionItems) = preProject
wiremock\__files\RegistreerInschrijvingResponses\RegistreerInschrijvingResponse.xml = wiremock\__files\RegistreerInschrijvingResponses\RegistreerInschrijvingResponse.xml
wiremock\__files\RegistreerInschrijvingResponses\0725459040.uitzondering.fout.xml = wiremock\__files\RegistreerInschrijvingResponses\0725459040.uitzondering.fout.xml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssociationRegistry.Test.EmptyPack", "test\AssociationRegistry.Test.EmptyPack\AssociationRegistry.Test.EmptyPack.csproj", "{7F27E962-B067-4086-B730-4D94173EA2ED}"
EndProject
Global
Expand Down Expand Up @@ -217,6 +226,7 @@ Global
{85139412-485D-4B23-8423-A0C2021B60DE} = {1157AB42-EACF-454D-92D5-DBA9FF3D0E24}
{9C2CDA4C-FFF3-4AA1-B31A-8804D98F0469} = {A30C8928-5F0D-459A-BB1B-0AE24A160CBB}
{F0853B2C-FEAB-4ACF-92D5-D9FBC3DA1427} = {20B970CD-1737-4427-A924-D299A42346FE}
{598628E9-81AA-41EE-8F2A-C9607A2D294A} = {A30C8928-5F0D-459A-BB1B-0AE24A160CBB}
{7F27E962-B067-4086-B730-4D94173EA2ED} = {C812C887-6495-405A-8B99-4F686D243126}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions AssociationRegistry.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Feitelijke/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=foezie/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Geregistreerd/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=historiek/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hoofdactivititeit/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hoofdactivititeiten/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=identificator/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace AssociationRegistry.Admin.Api.Infrastructure.Extensions;
using Schema;
using Schema.Detail;
using Schema.Historiek;
using Schema.KboSync;
using System;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -38,6 +39,9 @@ private static ShardName GetShardName<T>() where T : IMetadata
if (typeof(T) == typeof(BeheerVerenigingHistoriekDocument))
return new ShardName("AssociationRegistry.Admin.ProjectionHost.Projections.Historiek.BeheerVerenigingHistoriekProjection");

if (typeof(T) == typeof(BeheerKboSyncHistoriekGebeurtenisDocument))
return new ShardName("AssociationRegistry.Admin.ProjectionHost.Projections.KboSync.BeheerKboSyncHistoriekProjection");

throw new NotImplementedException("ExpectedSequence is voor deze projectie niet ondersteund.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Marten.Events;
using Marten.Services;
using Metrics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
Expand All @@ -23,8 +22,7 @@ public static class MartenExtensions
{
public static IServiceCollection AddMarten(
this IServiceCollection services,
PostgreSqlOptionsSection postgreSqlOptions,
IConfiguration configuration)
PostgreSqlOptionsSection postgreSqlOptions)
{
var martenConfiguration = services.AddMarten(
serviceProvider =>
Expand Down
8 changes: 4 additions & 4 deletions src/AssociationRegistry.Admin.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace AssociationRegistry.Admin.Api;

using AssociationRegistry.Magda;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Be.Vlaanderen.Basisregisters.Api.Localization;
Expand Down Expand Up @@ -28,8 +29,6 @@ namespace AssociationRegistry.Admin.Api;
using JasperFx.CodeGeneration;
using Kbo;
using Lamar.Microsoft.DependencyInjection;
using Magda;
using Magda.Extensions;
using Marten;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -323,9 +322,10 @@ private static void ConfigureServices(WebApplicationBuilder builder)
.AddTransient<IVerenigingsRepository, VerenigingsRepository>()
.AddTransient<IDuplicateVerenigingDetectionService, SearchDuplicateVerenigingDetectionService>()
.AddTransient<IMagdaGeefVerenigingService, MagdaGeefVerenigingService>()
.AddTransient<IMagdaFacade, MagdaFacade>()
.AddTransient<IMagdaRegistreerInschrijvingService, MagdaRegistreerInschrijvingService>()
.AddTransient<IMagdaClient, MagdaClient>()
.AddTransient<IMagdaCallReferenceRepository, MagdaCallReferenceRepository>()
.AddMarten(postgreSqlOptionsSection, builder.Configuration)
.AddMarten(postgreSqlOptionsSection)
.AddElasticSearch(elasticSearchOptionsSection)
.AddOpenTelemetry(new Instrumentation())
.AddHttpContextAccessor()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync;

using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Historiek.Examples;
using Infrastructure.Swagger.Annotations;
using Marten;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ResponseModels;
using Schema.KboSync;
using Swashbuckle.AspNetCore.Filters;
using System.Threading.Tasks;
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails;

[ApiVersion("1.0")]
[AdvertiseApiVersions("1.0")]
[ApiRoute("verenigingen")]
[ApiExplorerSettings(IgnoreApi = true)]
[Authorize(Policy = Program.SuperAdminPolicyName)]
public class KboSyncHistoriekController : ApiController
{
private readonly KboSyncHistoriekResponseMapper _mapper;

public KboSyncHistoriekController(KboSyncHistoriekResponseMapper mapper)
{
_mapper = mapper;
}

/// <summary>
/// Vraag de historiek van de KBO sync op.
/// </summary>
/// <param name="documentStore"></param>
/// <param name="problemDetailsHelper"></param>
/// <response code="200">De historiek van de KBO sync</response>
/// <response code="500">Er is een interne fout opgetreden.</response>
[HttpGet("kbo/historiek")]
[SwaggerResponseExample(StatusCodes.Status200OK, typeof(HistoriekResponseExamples))]
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))]
[ProducesResponseType(typeof(KboSyncHistoriekResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
[ProducesJson]
public async Task<IActionResult> GetKboSyncHistoriek(
[FromServices] IDocumentStore documentStore,
[FromServices] ProblemDetailsHelper problemDetailsHelper
)
{
await using var session = documentStore.LightweightSession();

var gebeurtenissen = await session
.Query<BeheerKboSyncHistoriekGebeurtenisDocument>()
.OrderByDescending(nameof(BeheerKboSyncHistoriekGebeurtenisDocument.Sequence))
.ToListAsync();

var response = _mapper.Map(gebeurtenissen);

return Ok(response);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe return object

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync;

using Infrastructure.ConfigurationBindings;
using ResponseModels;
using Schema.KboSync;
using System.Collections.Generic;
using System.Linq;

public class KboSyncHistoriekResponseMapper
{
private readonly AppSettings _appSettings;

public KboSyncHistoriekResponseMapper(AppSettings appSettings)
{
_appSettings = appSettings;
}

public KboSyncHistoriekResponse Map(IEnumerable<BeheerKboSyncHistoriekGebeurtenisDocument> gebeurtenissen)
=> new(gebeurtenissen.Select(Map).ToArray());

private static KboSyncHistoriekGebeurtenisResponse Map(BeheerKboSyncHistoriekGebeurtenisDocument gebeurtenisDocument)
=> new()
{
Kbonummer = gebeurtenisDocument.Kbonummer,
VCode = gebeurtenisDocument.VCode,
Beschrijving = gebeurtenisDocument.Beschrijving,
Tijdstip = gebeurtenisDocument.Tijdstip,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync.ResponseModels;

using System.Runtime.Serialization;

/// <summary>Een gebeurtenis van een vereniging</summary>
[DataContract]
public class KboSyncHistoriekGebeurtenisResponse
{
/// <summary>Het KBO nummer waarop de gebeurtenis plaatsvond</summary>
[DataMember(Name = "kbonummer")]
public string Kbonummer { get; set; } = null!;

/// <summary>De unieke identificatie code van deze vereniging</summary>
[DataMember(Name = "vCode")]
public string VCode { get; init; } = null!;

/// <summary>De beschrijving van de gebeurtenis</summary>
[DataMember(Name = "beschrijving")]
public string Beschrijving { get; set; } = null!;

/// <summary>Het tijdstip waarop de gebeurtenis plaatsvond</summary>
[DataMember(Name = "tijdstip")]
public string Tijdstip { get; set; } = null!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace AssociationRegistry.Admin.Api.Verenigingen.KboSync.ResponseModels;

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

/// <summary>Alle gebeurtenissen van deze vereniging</summary>
[DataContract]
public class KboSyncHistoriekResponse : ReadOnlyCollection<KboSyncHistoriekGebeurtenisResponse>
{
public KboSyncHistoriekResponse(IList<KboSyncHistoriekGebeurtenisResponse> gebeurtenissen) : base(gebeurtenissen)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
"SuperAdminClientIds": [
"superAdminClient"
],

"MagdaOptions": {
"Afzender": "1234",
"Hoedanigheid": "1234",
"Ontvanger": "vip.vlaanderen.be",
"GeefOndernemingVkboEndpoint": "https://123.abc",
"GeefOndernemingVkboEndpoint": "http://localhost:8080/GeefOndernemingVkboDienst-02.00/soap/WebService",
"GeefOndernemingEndpoint": "http://localhost:8080/GeefOndernemingDienst-02.00/soap/WebService",
"RegistreerInschrijvingEndpoint": "http://localhost:8080/RegistreerInschrijvingDienst-02.01/soap/WebService",
"Timeout": 30
},
"TemporaryMagdaVertegenwoordigers": "{\"TemporaryVertegenwoordigers\": [{\"Insz\": \"1234567890\",\"Voornaam\": \"Ikkeltje\",\"Achternaam\": \"Persoon\"},{\"Insz\": \"0987654321\",\"Voornaam\": \"Kramikkeltje\",\"Achternaam\": \"Persoon\"}]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ namespace AssociationRegistry.Admin.ProjectionHost.Infrastructure.Program.WebApp
using Projections;
using Projections.Detail;
using Projections.Historiek;
using Projections.KboSync;
using Projections.Search;
using Projections.Search.DuplicateDetection;
using Projections.Search.Zoeken;
using Schema.Detail;
using Schema.Historiek;
using Schema.KboSync;
using System.Configuration;
using ConfigurationManager = ConfigurationManager;
using ConfigurationManager = Microsoft.Extensions.Configuration.ConfigurationManager;

public static class ConfigureMartenExtensions
{
Expand Down Expand Up @@ -90,6 +92,7 @@ static JsonNetSerializer CreateCustomMartenSerializer()

opts.Projections.Add<BeheerVerenigingHistoriekProjection>(ProjectionLifecycle.Async);
opts.Projections.Add<BeheerVerenigingDetailProjection>(ProjectionLifecycle.Async);
opts.Projections.Add<BeheerKboSyncHistoriekProjection>(ProjectionLifecycle.Async);

opts.Projections.Add(
new MartenSubscription(
Expand All @@ -115,6 +118,7 @@ static JsonNetSerializer CreateCustomMartenSerializer()

opts.RegisterDocumentType<BeheerVerenigingDetailDocument>();
opts.RegisterDocumentType<BeheerVerenigingHistoriekDocument>();
opts.RegisterDocumentType<BeheerKboSyncHistoriekGebeurtenisDocument>();

if (serviceProvider.GetRequiredService<IHostEnvironment>().IsDevelopment())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace AssociationRegistry.Admin.ProjectionHost.Projections.KboSync;

using Events;
using Framework;
using Marten.Events;
using Marten.Events.Projections;
using Schema.KboSync;

public class BeheerKboSyncHistoriekProjection : EventProjection
{
public BeheerKboSyncHistoriekProjection()
{
Project<IEvent<VerenigingWerdIngeschrevenOpWijzigingenUitKbo>>((geregistreerd, operations) =>
{
operations.Insert(new BeheerKboSyncHistoriekGebeurtenisDocument(
geregistreerd.Sequence.ToString(),
geregistreerd.Data.KboNummer,
geregistreerd.StreamKey!,
Beschrijving: "Registreer inschrijving geslaagd",
geregistreerd.GetHeaderString(MetadataHeaderNames.Tijdstip)
));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace AssociationRegistry.Admin.Schema.KboSync;

using Marten.Schema;

public record BeheerKboSyncHistoriekGebeurtenisDocument(
[property: Identity] string Sequence,
string Kbonummer,
string VCode,
string Beschrijving,
string Tijdstip
);
14 changes: 7 additions & 7 deletions src/AssociationRegistry.Magda/AssociationRegistry.Magda.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -11,22 +10,18 @@
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Duplex" Version="6.0.0" />
<PackageReference Include="System.ServiceModel.Http" Version="6.2.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="6.2.0" />
<PackageReference Include="System.ServiceModel.Security" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AssociationRegistry\AssociationRegistry.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="paket.template" CopyToOutputDirectory="Always" Condition=""/>
<Content Include="paket.template" CopyToOutputDirectory="Always" Condition="" />
</ItemGroup>

<ItemGroup>
<Folder Include="WSDL\Generiek-02.00\" />
<Folder Include="WSDL\Onderneming-02.00\" />
Expand All @@ -37,6 +32,11 @@
<Folder Include="WSDL\Repertorium.RegistreerUitschrijvingDienst-02.01\WebService\" />
<Folder Include="WSDL\Sleutel-02.00\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ServiceModel.Federation" Version="4.10.*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Wsdl\" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"providerId": "Microsoft.Tools.ServiceModel.Svcutil",
"version": "2.0.3",
"version": "2.1.0",
"ExtendedData": {
"inputs": [
"../../WSDL/Repertorium.RegistreerInschrijvingDienst-02.01/WebService/RegistreerInschrijving.wsdl"
Expand All @@ -14,4 +14,4 @@
"targetFramework": "net6.0",
"typeReuseMode": "All"
}
}
}
Loading
Loading