Skip to content

Commit

Permalink
feat: refactor old domain + add register municipality
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Jul 3, 2024
1 parent 6ab5467 commit 1bab548
Show file tree
Hide file tree
Showing 34 changed files with 1,000 additions and 438 deletions.
4 changes: 4 additions & 0 deletions src/MunicipalityRegistry/CommandHandlerModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public static class CommandHandlerModules
{
public static void Register(ContainerBuilder containerBuilder)
{
containerBuilder
.RegisterType<MunicipalityCrabProvenanceFactory>()
.SingleInstance();

containerBuilder
.RegisterType<MunicipalityProvenanceFactory>()
.SingleInstance();
Expand Down
20 changes: 20 additions & 0 deletions src/MunicipalityRegistry/DuplicateLanguageException.cs
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)
{ }
}
}
16 changes: 16 additions & 0 deletions src/MunicipalityRegistry/InvalidPolygonException.cs
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)
{ }
}
}

This file was deleted.

This file was deleted.

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 src/MunicipalityRegistry/Municipality/Commands/NameMunicipality.cs

This file was deleted.

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;
}
}
}

This file was deleted.

19 changes: 19 additions & 0 deletions src/MunicipalityRegistry/Municipality/GeometryValidator.cs
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;
}
}
}
Loading

0 comments on commit 1bab548

Please sign in to comment.