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

fix: migrate parcel unknown by grb #713

Merged
merged 1 commit into from
Oct 17, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ await backOfficeContext
_logger.LogWarning($"Parcel geometry not found for '{aggregateId}', retiring parcel.");
}

var migrateParcel = legacyParcelAggregate.CreateMigrateCommand(
Array.Empty<AddressPersistentLocalId>(),
ExtendedWkbGeometry.CreateDummyForRetiredParcel(),
Legacy.ParcelStatus.Retired);

var provenance = new Provenance(
SystemClock.Instance.GetCurrentInstant(),
Application.ParcelRegistry,
Expand All @@ -233,7 +238,8 @@ await backOfficeContext
Organisation.DigitaalVlaanderen);

await DispatchCommand(new RetireParcel(parcelId, provenance), CancellationToken.None);
await DispatchCommand(new MarkParcelAsMigrated(parcelId, provenance), CancellationToken.None); //TODO: do we mark it or not?
await DispatchCommand(new MarkParcelAsMigrated(parcelId, provenance), CancellationToken.None);
await DispatchCommand(migrateParcel, CancellationToken.None);

await _processedIdsTable.Add(internalId);
processedItems.Add(internalId);
Expand Down
5 changes: 3 additions & 2 deletions src/ParcelRegistry/Legacy/Parcel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ public partial class Parcel : AggregateRootEntity, ISnapshotable
{
public MigrateParcel CreateMigrateCommand(
IEnumerable<AddressPersistentLocalId> addressPersistentLocalIds,
ExtendedWkbGeometry extendedWkbGeometry)
ExtendedWkbGeometry extendedWkbGeometry,
ParcelStatus? parcelStatus = null)
{
return new MigrateParcel(
ParcelId,
CaPaKey,
ParcelStatus.Realized, // Migrated parcels cannot be retired as we found a geometry in the GRB list.
parcelStatus ?? ParcelStatus.Realized, // Migrated parcels cannot be retired as we found a geometry in the GRB list.
IsRemoved,
addressPersistentLocalIds,
extendedWkbGeometry,
Expand Down
14 changes: 14 additions & 0 deletions src/ParcelRegistry/Parcel/ValueObjects/ExtendedWkbGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System;
using Be.Vlaanderen.Basisregisters.AggregateSource;
using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor;
using NetTopologySuite;
using NetTopologySuite.Geometries;
using NetTopologySuite.Geometries.Implementation;
using NetTopologySuite.IO;
using Newtonsoft.Json;

Expand Down Expand Up @@ -37,5 +40,16 @@ public ExtendedWkbGeometry(string ewkbBytesHex) : base(ewkbBytesHex.ToByteArray(
return null;
}
}

public static ExtendedWkbGeometry CreateDummyForRetiredParcel()
{
var geometry = new WKTReader(new NtsGeometryServices(
new DotSpatialAffineCoordinateSequenceFactory(Ordinates.XY),
new PrecisionModel(PrecisionModels.Floating),
SridLambert72))
.Read("POLYGON ((0 0,0 1,1 1,1 0,0 0))");

return CreateEWkb(geometry.AsBinary())!;
}
}
}
Loading