-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
821 additions
and
14 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/ParcelRegistry.Api.BackOffice.Abstractions/Requests/CreateOsloSnapshotsRequest.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 ParcelRegistry.Api.BackOffice.Abstractions.Requests | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public class CreateOsloSnapshotsRequest | ||
{ | ||
public List<string> CaPaKeys { get; set; } | ||
|
||
public string Reden { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/ParcelRegistry.Api.BackOffice.Abstractions/SqsRequests/CreateOsloSnapshotsSqsRequest.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 ParcelRegistry.Api.BackOffice.Abstractions.SqsRequests | ||
{ | ||
using Be.Vlaanderen.Basisregisters.Sqs.Requests; | ||
using Requests; | ||
|
||
public class CreateOsloSnapshotsSqsRequest : SqsRequest | ||
{ | ||
public CreateOsloSnapshotsRequest Request { get; set; } | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/ParcelRegistry.Api.BackOffice.Handlers.Lambda/Handlers/CreateOsloSnapshotsHandler.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 ParcelRegistry.Api.BackOffice.Handlers.Lambda.Handlers | ||
{ | ||
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; | ||
using TicketingService.Abstractions; | ||
|
||
public sealed class CreateOsloSnapshotsLambdaHandler : SqsLambdaHandlerBase<CreateOsloSnapshotsLambdaRequest> | ||
{ | ||
public CreateOsloSnapshotsLambdaHandler( | ||
ICustomRetryPolicy retryPolicy, | ||
ITicketing ticketing, | ||
IIdempotentCommandHandler idempotentCommandHandler) | ||
: base(retryPolicy, ticketing, idempotentCommandHandler) | ||
{ | ||
} | ||
|
||
protected override async Task<object> InnerHandle(CreateOsloSnapshotsLambdaRequest 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, CreateOsloSnapshotsLambdaRequest request) => null; | ||
|
||
protected override Task HandleAggregateIdIsNotFoundException(CreateOsloSnapshotsLambdaRequest request, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override Task ValidateIfMatchHeaderValue(CreateOsloSnapshotsLambdaRequest 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
37 changes: 37 additions & 0 deletions
37
...arcelRegistry.Api.BackOffice.Handlers.Lambda/Requests/CreateOsloSnapshotsLambdaRequest.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,37 @@ | ||
namespace ParcelRegistry.Api.BackOffice.Handlers.Lambda.Requests | ||
{ | ||
using Abstractions.Requests; | ||
using Abstractions.SqsRequests; | ||
using AllStream.Commands; | ||
using Be.Vlaanderen.Basisregisters.Sqs.Lambda.Requests; | ||
|
||
public sealed record CreateOsloSnapshotsLambdaRequest : SqsLambdaRequest | ||
{ | ||
public CreateOsloSnapshotsRequest Request { get; } | ||
|
||
|
||
public CreateOsloSnapshotsLambdaRequest( | ||
string messageGroupId, | ||
CreateOsloSnapshotsSqsRequest 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.CaPaKeys.Select(x => new VbrCaPaKey(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
35 changes: 35 additions & 0 deletions
35
src/ParcelRegistry.Api.BackOffice/Handlers/CreateOsloSnapshotsHandler.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 ParcelRegistry.Api.BackOffice.Handlers | ||
{ | ||
using System.Collections.Generic; | ||
using Abstractions.SqsRequests; | ||
using AllStream; | ||
using Be.Vlaanderen.Basisregisters.Sqs; | ||
using Be.Vlaanderen.Basisregisters.Sqs.Handlers; | ||
using TicketingService.Abstractions; | ||
|
||
public sealed class CreateOsloSnapshotsHandler : SqsHandler<CreateOsloSnapshotsSqsRequest> | ||
{ | ||
public const string Action = "CreateOsloSnapshots"; | ||
|
||
public CreateOsloSnapshotsHandler( | ||
ISqsQueue sqsQueue, | ||
ITicketing ticketing, | ||
ITicketingUrl ticketingUrl) : base(sqsQueue, ticketing, ticketingUrl) | ||
{ } | ||
|
||
protected override string? WithAggregateId(CreateOsloSnapshotsSqsRequest request) | ||
{ | ||
return AllStreamId.Instance; | ||
} | ||
|
||
protected override IDictionary<string, string> WithTicketMetadata(string aggregateId, CreateOsloSnapshotsSqsRequest sqsRequest) | ||
{ | ||
return new Dictionary<string, string> | ||
{ | ||
{ RegistryKey, nameof(ParcelRegistry) }, | ||
{ 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
41 changes: 41 additions & 0 deletions
41
src/ParcelRegistry.Api.BackOffice/ParcelController-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 ParcelRegistry.Api.BackOffice | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Abstractions.Requests; | ||
using Abstractions.SqsRequests; | ||
using Be.Vlaanderen.Basisregisters.Auth.AcmIdm; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
public partial class ParcelController | ||
{ | ||
/// <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.Adres.InterneBijwerker)] | ||
public async Task<IActionResult> CreateOsloSnapshots( | ||
[FromBody] CreateOsloSnapshotsRequest request, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var provenance = _provenanceFactory.Create(new Reason(request.Reden), Modification.Unknown); | ||
|
||
var sqsRequest = new CreateOsloSnapshotsSqsRequest | ||
{ | ||
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
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
19 changes: 19 additions & 0 deletions
19
src/ParcelRegistry.Infrastructure/Repositories/AllStreamRepository.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,19 @@ | ||
namespace ParcelRegistry.Infrastructure.Repositories | ||
{ | ||
using AllStream; | ||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Be.Vlaanderen.Basisregisters.AggregateSource.SqlStreamStore; | ||
using Be.Vlaanderen.Basisregisters.EventHandling; | ||
using Parcel; | ||
using SqlStreamStore; | ||
|
||
public class AllStreamRepository : Repository<AllStream, AllStreamId>, IAllStreamRepository | ||
{ | ||
public AllStreamRepository( | ||
ConcurrentUnitOfWork unitOfWork, | ||
IStreamStore eventStore, | ||
EventMapping eventMapping, | ||
EventDeserializer eventDeserializer) | ||
: base(() => new AllStream(), unitOfWork, eventStore, eventMapping, eventDeserializer) { } | ||
} | ||
} |
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
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,17 @@ | ||
namespace ParcelRegistry.AllStream | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Events; | ||
using Parcel; | ||
|
||
public sealed class AllStream : AggregateRootEntity | ||
{ | ||
public void CreateOsloSnapshots(IReadOnlyList<VbrCaPaKey> caPaKeys) | ||
{ | ||
ApplyChange(new ParcelOsloSnapshotsWereRequested( | ||
caPaKeys.ToDictionary(ParcelId.CreateFor, x => x))); | ||
} | ||
} | ||
} |
Oops, something went wrong.