-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add create building oslo snapshots
- Loading branch information
Showing
29 changed files
with
665 additions
and
59 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...istry.Api.BackOffice.Abstractions/Building/Requests/CreateBuildingOsloSnapshotsRequest.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,11 @@ | ||
namespace BuildingRegistry.Api.BackOffice.Abstractions.Building.Requests | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public class CreateBuildingOsloSnapshotsRequest | ||
{ | ||
public List<int> BuildingPersistentLocalIds { get; set; } | ||
|
||
public string Reden { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...Api.BackOffice.Abstractions/Building/SqsRequests/CreateBuildingOsloSnapshotsSqsRequest.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,10 @@ | ||
namespace BuildingRegistry.Api.BackOffice.Abstractions.Building.SqsRequests | ||
{ | ||
using Be.Vlaanderen.Basisregisters.Sqs.Requests; | ||
using Requests; | ||
|
||
public class CreateBuildingOsloSnapshotsSqsRequest : SqsRequest | ||
{ | ||
public CreateBuildingOsloSnapshotsRequest Request { get; set; } | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
....BackOffice.Handlers.Lambda/Handlers/Building/CreateBuildingOsloSnapshotsLambdaHandler.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,52 @@ | ||
namespace BuildingRegistry.Api.BackOffice.Handlers.Lambda.Handlers.Building | ||
{ | ||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Be.Vlaanderen.Basisregisters.CommandHandling.Idempotency; | ||
using Be.Vlaanderen.Basisregisters.Sqs.Lambda.Handlers; | ||
using Be.Vlaanderen.Basisregisters.Sqs.Lambda.Infrastructure; | ||
using Requests.Building; | ||
using TicketingService.Abstractions; | ||
|
||
public sealed class CreateBuildingOsloSnapshotsLambdaHandler : SqsLambdaHandlerBase<CreateBuildingOsloSnapshotsLambdaRequest> | ||
{ | ||
public CreateBuildingOsloSnapshotsLambdaHandler( | ||
ICustomRetryPolicy retryPolicy, | ||
ITicketing ticketing, | ||
IIdempotentCommandHandler idempotentCommandHandler) | ||
: base(retryPolicy, ticketing, idempotentCommandHandler) | ||
{ | ||
} | ||
|
||
protected override async Task<object> InnerHandle(CreateBuildingOsloSnapshotsLambdaRequest request, CancellationToken cancellationToken) | ||
{ | ||
var cmd = request.ToCommand(); | ||
|
||
try | ||
{ | ||
await IdempotentCommandHandler.Dispatch( | ||
cmd.CreateCommandId(), | ||
cmd, | ||
request.Metadata!, | ||
cancellationToken); | ||
} | ||
catch (IdempotencyException) | ||
{ | ||
// Idempotent: Do Nothing return last etag | ||
} | ||
|
||
return "done"; | ||
} | ||
|
||
protected override TicketError? MapDomainException(DomainException exception, CreateBuildingOsloSnapshotsLambdaRequest request) => null; | ||
|
||
protected override Task HandleAggregateIdIsNotFoundException(CreateBuildingOsloSnapshotsLambdaRequest request, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override Task ValidateIfMatchHeaderValue(CreateBuildingOsloSnapshotsLambdaRequest request, CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
....BackOffice.Handlers.Lambda/Requests/Building/CreateBuildingOsloSnapshotsLambdaRequest.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,38 @@ | ||
namespace BuildingRegistry.Api.BackOffice.Handlers.Lambda.Requests.Building | ||
{ | ||
using Be.Vlaanderen.Basisregisters.Sqs.Lambda.Requests; | ||
using BuildingRegistry.AllStream.Commands; | ||
using BuildingRegistry.Api.BackOffice.Abstractions.Building.Requests; | ||
using BuildingRegistry.Api.BackOffice.Abstractions.Building.SqsRequests; | ||
using BuildingRegistry.Building; | ||
|
||
public sealed record CreateBuildingOsloSnapshotsLambdaRequest : SqsLambdaRequest | ||
{ | ||
public CreateBuildingOsloSnapshotsRequest Request { get; } | ||
|
||
public CreateBuildingOsloSnapshotsLambdaRequest( | ||
string messageGroupId, | ||
CreateBuildingOsloSnapshotsSqsRequest sqsRequest) | ||
: base( | ||
messageGroupId, | ||
sqsRequest.TicketId, | ||
null, | ||
sqsRequest.ProvenanceData.ToProvenance(), | ||
sqsRequest.Metadata) | ||
{ | ||
Request = sqsRequest.Request; | ||
} | ||
|
||
/// <summary> | ||
/// Map to CreateOsloSnapshots command | ||
/// </summary> | ||
/// <returns>CreateOsloSnapshots</returns> | ||
public CreateOsloSnapshots ToCommand() | ||
{ | ||
return new CreateOsloSnapshots( | ||
Request.BuildingPersistentLocalIds.Select(x => new BuildingPersistentLocalId(x)), | ||
[], | ||
Provenance); | ||
} | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/BuildingRegistry.Api.BackOffice/Building/BuildingController-CreateOsloSnapshots.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 BuildingRegistry.Api.BackOffice.Building | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Be.Vlaanderen.Basisregisters.Auth.AcmIdm; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using BuildingRegistry.Api.BackOffice.Abstractions.Building.Requests; | ||
using BuildingRegistry.Api.BackOffice.Abstractions.Building.SqsRequests; | ||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
public partial class BuildingController | ||
{ | ||
/// <summary> | ||
/// Creëer nieuwe OSLO snapshots. | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpPost("acties/oslosnapshots")] | ||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Policy = PolicyNames.GeschetstGebouw.InterneBijwerker)] | ||
public async Task<IActionResult> CreateOsloSnapshots( | ||
[FromBody] CreateBuildingOsloSnapshotsRequest request, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var provenance = ProvenanceFactory.Create(new Reason(request.Reden), Modification.Unknown); | ||
|
||
var sqsRequest = new CreateBuildingOsloSnapshotsSqsRequest | ||
{ | ||
Request = request, | ||
Metadata = GetMetadata(), | ||
ProvenanceData = new ProvenanceData(provenance) | ||
}; | ||
|
||
var sqsResult = await Mediator.Send(sqsRequest, cancellationToken); | ||
|
||
return Accepted(sqsResult); | ||
} | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...ingRegistry.Api.BackOffice/Handlers/Building/CreateBuildingUnitOsloSnapshotsSqsHandler.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,35 @@ | ||
namespace BuildingRegistry.Api.BackOffice.Handlers.Building | ||
{ | ||
using System.Collections.Generic; | ||
using Abstractions.Building.SqsRequests; | ||
using AllStream; | ||
using Be.Vlaanderen.Basisregisters.Sqs; | ||
using Be.Vlaanderen.Basisregisters.Sqs.Handlers; | ||
using TicketingService.Abstractions; | ||
|
||
public sealed class CreateBuildingOsloSnapshotsSqsHandler : SqsHandler<CreateBuildingOsloSnapshotsSqsRequest> | ||
{ | ||
public const string Action = "CreateBuildingOsloSnapshots"; | ||
|
||
public CreateBuildingOsloSnapshotsSqsHandler( | ||
ISqsQueue sqsQueue, | ||
ITicketing ticketing, | ||
ITicketingUrl ticketingUrl) : base(sqsQueue, ticketing, ticketingUrl) | ||
{ } | ||
|
||
protected override string? WithAggregateId(CreateBuildingOsloSnapshotsSqsRequest request) | ||
{ | ||
return AllStreamId.Instance; | ||
} | ||
|
||
protected override IDictionary<string, string> WithTicketMetadata(string aggregateId, CreateBuildingOsloSnapshotsSqsRequest sqsRequest) | ||
{ | ||
return new Dictionary<string, string> | ||
{ | ||
{ RegistryKey, nameof(BuildingRegistry) }, | ||
{ ActionKey, Action }, | ||
{ AggregateIdKey, aggregateId } | ||
}; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.