-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: propose all streetnames for municipality merger within a si…
…ngle transaction
- Loading branch information
Showing
8 changed files
with
307 additions
and
268 deletions.
There are no files selected for viewing
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
67 changes: 0 additions & 67 deletions
67
src/StreetNameRegistry/Municipality/Commands/ProposeStreetNameForMunicipalityMerger.cs
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
src/StreetNameRegistry/Municipality/Commands/ProposeStreetNamesForMunicipalityMerger.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,93 @@ | ||
namespace StreetNameRegistry.Municipality.Commands | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Be.Vlaanderen.Basisregisters.Generators.Guid; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Be.Vlaanderen.Basisregisters.Utilities; | ||
|
||
public sealed class ProposeStreetNamesForMunicipalityMerger : IHasCommandProvenance | ||
{ | ||
private static readonly Guid Namespace = new Guid("eaf63006-10de-403f-a692-084707cc5ed4"); | ||
|
||
public MunicipalityId MunicipalityId { get; } | ||
public List<StreetNameToPropose> StreetNames { get; } | ||
public Provenance Provenance { get; } | ||
|
||
public ProposeStreetNamesForMunicipalityMerger( | ||
MunicipalityId municipalityId, | ||
List<StreetNameToPropose> streetNames, | ||
Provenance provenance) | ||
{ | ||
MunicipalityId = municipalityId; | ||
StreetNames = streetNames; | ||
Provenance = provenance; | ||
} | ||
|
||
public Guid CreateCommandId() | ||
=> Deterministic.Create(Namespace, $"ProposeStreetNamesForMunicipalityMerger-{ToString()}"); | ||
|
||
public override string? ToString() | ||
=> ToStringBuilder.ToString(IdentityFields()); | ||
|
||
private IEnumerable<object> IdentityFields() | ||
{ | ||
yield return MunicipalityId; | ||
|
||
foreach (var streetNameName in StreetNames.SelectMany(x => x.IdentityFields())) | ||
{ | ||
yield return streetNameName; | ||
} | ||
|
||
foreach (var field in Provenance.GetIdentityFields()) | ||
{ | ||
yield return field; | ||
} | ||
} | ||
|
||
public sealed class StreetNameToPropose | ||
{ | ||
public StreetNameStatus DesiredStatus { get; } | ||
public Names StreetNameNames { get; } | ||
public HomonymAdditions HomonymAdditions { get; } | ||
public PersistentLocalId PersistentLocalId { get; } | ||
public List<PersistentLocalId> MergedStreetNamePersistentLocalIds { get; } | ||
|
||
public StreetNameToPropose( | ||
StreetNameStatus desiredStatus, | ||
Names streetNameNames, | ||
HomonymAdditions homonymAdditions, | ||
PersistentLocalId persistentLocalId, | ||
List<PersistentLocalId> mergedStreetNamePersistentLocalIds) | ||
{ | ||
DesiredStatus = desiredStatus; | ||
StreetNameNames = streetNameNames; | ||
HomonymAdditions = homonymAdditions; | ||
PersistentLocalId = persistentLocalId; | ||
MergedStreetNamePersistentLocalIds = mergedStreetNamePersistentLocalIds; | ||
} | ||
|
||
internal IEnumerable<object> IdentityFields() | ||
{ | ||
yield return PersistentLocalId; | ||
yield return DesiredStatus; | ||
|
||
foreach (var streetNameName in StreetNameNames) | ||
{ | ||
yield return streetNameName; | ||
} | ||
|
||
foreach (var homonymAddition in HomonymAdditions) | ||
{ | ||
yield return homonymAddition; | ||
} | ||
|
||
foreach (var mergedStreetNamePersistentLocalId in MergedStreetNamePersistentLocalIds) | ||
{ | ||
yield return mergedStreetNamePersistentLocalId; | ||
} | ||
} | ||
} | ||
} | ||
} |
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.