-
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.
feat: refactor old domain + add register municipality
- Loading branch information
Showing
34 changed files
with
1,000 additions
and
438 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace MunicipalityRegistry | ||
{ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
[Serializable] | ||
public sealed class DuplicateLanguageException : MunicipalityRegistryException | ||
{ | ||
public DuplicateLanguageException() | ||
{ } | ||
|
||
public DuplicateLanguageException(string message) | ||
: base(message) | ||
{ } | ||
|
||
private DuplicateLanguageException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ } | ||
} | ||
} |
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,16 @@ | ||
namespace MunicipalityRegistry | ||
{ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
[Serializable] | ||
public sealed class InvalidPolygonException : MunicipalityRegistryException | ||
{ | ||
public InvalidPolygonException() | ||
{ } | ||
|
||
private InvalidPolygonException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ } | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/MunicipalityRegistry/Municipality/Commands/DefineMunicipalityPrimaryLanguage.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/MunicipalityRegistry/Municipality/Commands/DefineMunicipalitySecondaryLanguage.cs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/MunicipalityRegistry/Municipality/Commands/MergeMunicipalities.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,24 @@ | ||
namespace MunicipalityRegistry.Municipality.Commands | ||
{ | ||
using System.Collections.Generic; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
|
||
public sealed class MergeMunicipalities | ||
{ | ||
public IEnumerable<MunicipalityId> MunicipalityIdsToMerge { get; } | ||
|
||
public MunicipalityId NewMunicipalityId { get; } | ||
|
||
public Provenance Provenance { get; } | ||
|
||
public MergeMunicipalities( | ||
IEnumerable<MunicipalityId> municipalityIdsToMerge, | ||
MunicipalityId newMunicipalityId, | ||
Provenance provenance) | ||
{ | ||
MunicipalityIdsToMerge = municipalityIdsToMerge; | ||
NewMunicipalityId = newMunicipalityId; | ||
Provenance = provenance; | ||
} | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/MunicipalityRegistry/Municipality/Commands/NameMunicipality.cs
This file was deleted.
Oops, something went wrong.
50 changes: 43 additions & 7 deletions
50
src/MunicipalityRegistry/Municipality/Commands/RegisterMunicipality.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 |
---|---|---|
@@ -1,25 +1,61 @@ | ||
namespace MunicipalityRegistry.Municipality.Commands | ||
{ | ||
public sealed class RegisterMunicipality | ||
using System; | ||
using System.Collections.Generic; | ||
using Be.Vlaanderen.Basisregisters.Generators.Guid; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Be.Vlaanderen.Basisregisters.Utilities; | ||
|
||
public sealed class RegisterMunicipality : IHasCommandProvenance | ||
{ | ||
private static readonly Guid Namespace = new Guid("825968af-52b4-4a23-b4bd-d6c1dc0f26d8"); | ||
|
||
public MunicipalityId MunicipalityId { get; } | ||
|
||
public NisCode NisCode { get; } | ||
|
||
public Language? PrimaryLanguage { get; } | ||
public List<Language> OfficialLanguages { get; } | ||
|
||
public List<Language> FacilityLanguages { get; } | ||
|
||
public List<MunicipalityName> Names { get; } | ||
|
||
public ExtendedWkbGeometry Geometry { get; } | ||
|
||
public Language? SecondaryLanguage { get; } | ||
public Provenance Provenance { get; } | ||
|
||
public RegisterMunicipality( | ||
MunicipalityId municipalityId, | ||
NisCode nisCode, | ||
Language? primaryLanguage, | ||
Language? secondaryLanguage) | ||
List<Language> officialLanguages, | ||
List<Language> facilityLanguages, | ||
List<MunicipalityName> names, | ||
ExtendedWkbGeometry geometry, | ||
Provenance provenance) | ||
{ | ||
MunicipalityId = municipalityId; | ||
NisCode = nisCode; | ||
PrimaryLanguage = primaryLanguage; | ||
SecondaryLanguage = secondaryLanguage; | ||
OfficialLanguages = officialLanguages; | ||
FacilityLanguages = facilityLanguages; | ||
Names = names; | ||
Geometry = geometry; | ||
Provenance = provenance; | ||
} | ||
|
||
public Guid CreateCommandId() | ||
=> Deterministic.Create(Namespace, $"{nameof(RegisterMunicipality)}-{ToString()}"); | ||
|
||
public override string? ToString() | ||
=> ToStringBuilder.ToString(IdentityFields()); | ||
|
||
private IEnumerable<object> IdentityFields() | ||
{ | ||
yield return MunicipalityId; | ||
yield return NisCode; | ||
yield return OfficialLanguages; | ||
yield return FacilityLanguages; | ||
yield return Names; | ||
yield return Geometry; | ||
} | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/MunicipalityRegistry/Municipality/Commands/TerminateMunicipality.cs
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/MunicipalityRegistry/Municipality/GeometryValidator.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 MunicipalityRegistry.Municipality | ||
{ | ||
using NetTopologySuite.Geometries; | ||
|
||
public static class GeometryValidator | ||
{ | ||
public static bool IsValid(Geometry geometry) | ||
{ | ||
var validOp = | ||
new NetTopologySuite.Operation.Valid.IsValidOp(geometry) | ||
{ | ||
IsSelfTouchingRingFormingHoleValid = true, | ||
SelfTouchingRingFormingHoleValid = true | ||
}; | ||
|
||
return validOp.IsValid; | ||
} | ||
} | ||
} |
Oops, something went wrong.