Skip to content

Commit

Permalink
fix: wfs/wms road segment projection deal with unknown roadsegments i…
Browse files Browse the repository at this point in the history
…nstead of error (#1547)
  • Loading branch information
rikdepeuter authored Sep 27, 2024
1 parent cc6c561 commit 5a8dacc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/RoadRegistry.Wfs.Projections/RoadSegmentRecordProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static async Task AddRoadSegment(IStreetNameCache streetNameCache,

var leftSideStreetNameRecord = await TryGetFromCache(streetNameCache, roadSegmentAdded.LeftSide.StreetNameId, token);
var rightSideStreetNameRecord = await TryGetFromCache(streetNameCache, roadSegmentAdded.RightSide.StreetNameId, token);

dbRecord.MaintainerId = roadSegmentAdded.MaintenanceAuthority.Code;
dbRecord.MaintainerName = OrganizationName.FromValueWithFallback(roadSegmentAdded.MaintenanceAuthority.Name);
dbRecord.MethodDutchName = method.Translation.Name;
Expand Down Expand Up @@ -159,7 +159,11 @@ private static async Task ModifyRoadSegment(IStreetNameCache streetNameCache,
.ConfigureAwait(false);
if (dbRecord is null)
{
throw new InvalidOperationException($"RoadSegmentRecord with id {roadSegmentModified.Id} is not found");
dbRecord = new RoadSegmentRecord
{
Id = roadSegmentModified.Id
};
await context.RoadSegments.AddAsync(dbRecord, token);
}

var method = RoadSegmentGeometryDrawMethod.Parse(roadSegmentModified.GeometryDrawMethod);
Expand All @@ -170,7 +174,7 @@ private static async Task ModifyRoadSegment(IStreetNameCache streetNameCache,

var leftSideStreetNameRecord = await TryGetFromCache(streetNameCache, roadSegmentModified.LeftSide.StreetNameId, token);
var rightSideStreetNameRecord = await TryGetFromCache(streetNameCache, roadSegmentModified.RightSide.StreetNameId, token);

dbRecord.Id = roadSegmentModified.Id;
dbRecord.MaintainerId = roadSegmentModified.MaintenanceAuthority.Code;
dbRecord.MaintainerName = OrganizationName.FromValueWithFallback(roadSegmentModified.MaintenanceAuthority.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ private static async Task ModifyRoadSegment(IStreetNameCache streetNameCache,
.ConfigureAwait(false);
if (dbRecord is null)
{
throw new InvalidOperationException($"RoadSegmentRecord with id {roadSegmentModified.Id} is not found");
dbRecord = new RoadSegmentRecord
{
Id = roadSegmentModified.Id
};
await context.RoadSegments.AddAsync(dbRecord, token);
}

var transactionId = new TransactionId(envelope.Message.TransactionId);
Expand Down

0 comments on commit 5a8dacc

Please sign in to comment.