From bc2bf816b77f75d64e3b240a9b126640fc7dc068 Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Wed, 13 Nov 2024 11:29:58 +0100 Subject: [PATCH] fix(bosa): add homonym addition --- .../Model/Database/StreetName.cs | 9 +++++++++ .../Model/Xml/XmlStreetName.cs | 3 +++ .../Repositories/StreetNameRepository.cs | 3 +++ .../StreetNameService.cs | 15 +++++++++++++++ .../XmlStreetNameTests.cs | 13 +++++++++++++ 5 files changed, 43 insertions(+) diff --git a/src/Basisregisters.IntegrationDb.Bosa/Model/Database/StreetName.cs b/src/Basisregisters.IntegrationDb.Bosa/Model/Database/StreetName.cs index a5c5d1c..8d611cf 100644 --- a/src/Basisregisters.IntegrationDb.Bosa/Model/Database/StreetName.cs +++ b/src/Basisregisters.IntegrationDb.Bosa/Model/Database/StreetName.cs @@ -23,6 +23,9 @@ public class StreetName public string? NameDutch { get; init; } public string? NameFrench { get; init; } public string? NameGerman { get; init; } + public string? HomonymAdditionDutch { get; init; } + public string? HomonymAdditionFrench { get; init; } + public string? HomonymAdditionGerman { get; init; } public string NisCode { get; init; } public string MunicipalityNamespace { get; init; } @@ -42,6 +45,9 @@ public StreetName( string? nameDutch, string? nameFrench, string? nameGerman, + string? homonymAdditionDutch, + string? homonymAdditionFrench, + string? homonymAdditionGerman, string nisCode, string municipalityNamespace, DateTimeOffset municipalityVersionTimestamp, @@ -55,6 +61,9 @@ public StreetName( NameDutch = nameDutch; NameFrench = nameFrench; NameGerman = nameGerman; + HomonymAdditionDutch = homonymAdditionDutch; + HomonymAdditionFrench = homonymAdditionFrench; + HomonymAdditionGerman = homonymAdditionGerman; NisCode = nisCode; MunicipalityNamespace = municipalityNamespace; MunicipalityVersionTimestamp = municipalityVersionTimestamp; diff --git a/src/Basisregisters.IntegrationDb.Bosa/Model/Xml/XmlStreetName.cs b/src/Basisregisters.IntegrationDb.Bosa/Model/Xml/XmlStreetName.cs index c85d34a..2d4a5ed 100644 --- a/src/Basisregisters.IntegrationDb.Bosa/Model/Xml/XmlStreetName.cs +++ b/src/Basisregisters.IntegrationDb.Bosa/Model/Xml/XmlStreetName.cs @@ -37,6 +37,9 @@ public class XmlStreetName [XmlElement(Namespace = KnownNamespaces.Com, ElementName = "type")] public string Type { get; set; } + [XmlElement(Namespace = KnownNamespaces.Com, ElementName = "homonymAddition")] + public string? HomonymAddition { get; set; } + [XmlElement(Namespace = KnownNamespaces.Com, ElementName = "isAssignedByMunicipality")] public XmlCode IsAssignedByMunicipality { get; set; } } diff --git a/src/Basisregisters.IntegrationDb.Bosa/Repositories/StreetNameRepository.cs b/src/Basisregisters.IntegrationDb.Bosa/Repositories/StreetNameRepository.cs index 2ef0f66..d49148f 100644 --- a/src/Basisregisters.IntegrationDb.Bosa/Repositories/StreetNameRepository.cs +++ b/src/Basisregisters.IntegrationDb.Bosa/Repositories/StreetNameRepository.cs @@ -32,6 +32,9 @@ s.namespace as Namespace , s.name_dutch as NameDutch , s.name_french as NameFrench , s.name_german as NameGerman + , s.homonym_addition_dutch as HomonymAdditionDutch + , s.homonym_addition_french as HomonymAdditionFrench + , s.homonym_addition_german as HomonymAdditionGerman , m.nis_code as NisCode , m.namespace as MunicipalityNamespace , m.version_timestamp as MunicipalityVersionTimestamp diff --git a/src/Basisregisters.IntegrationDb.Bosa/StreetNameService.cs b/src/Basisregisters.IntegrationDb.Bosa/StreetNameService.cs index 9bbe66f..9c76938 100644 --- a/src/Basisregisters.IntegrationDb.Bosa/StreetNameService.cs +++ b/src/Basisregisters.IntegrationDb.Bosa/StreetNameService.cs @@ -51,6 +51,7 @@ public void CreateXml(Stream outputStream) ValidTo = endLifeSpanVersion }, Type = "streetname", + HomonymAddition = GetHomonymAddition(streetName), IsAssignedByMunicipality = new XmlCode { Namespace = FormatNamespace(streetName.MunicipalityNamespace), @@ -65,6 +66,20 @@ public void CreateXml(Stream outputStream) RegistryXmlSerializer.Serialize(serializable, outputStream); } + private static string? GetHomonymAddition(StreetName streetName) + { + if (!string.IsNullOrWhiteSpace(streetName.HomonymAdditionDutch)) + return streetName.HomonymAdditionDutch; + + if (!string.IsNullOrWhiteSpace(streetName.HomonymAdditionFrench)) + return streetName.HomonymAdditionFrench; + + if (!string.IsNullOrWhiteSpace(streetName.HomonymAdditionGerman)) + return streetName.HomonymAdditionGerman; + + return null; + } + private static string GetBeginLifeSpanVersion(StreetName streetName) => GetVersionAsString(streetName.CreatedOn); diff --git a/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlStreetNameTests.cs b/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlStreetNameTests.cs index 061962a..0472c75 100644 --- a/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlStreetNameTests.cs +++ b/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlStreetNameTests.cs @@ -31,6 +31,9 @@ public XmlStreetNameTests() "NIjverheidslaan", nameFrench:null, nameGerman:null, + homonymAdditionDutch:null, + homonymAdditionFrench:null, + homonymAdditionGerman:null, "23044", MunicipalityNamespace, new DateTimeOffset(2024, 08, 13, 17, 32, 32, TimeSpan.FromHours(2)), @@ -44,6 +47,9 @@ public XmlStreetNameTests() "Anderlechtstraat", "Rue d'Anderlecht", nameGerman:null, + homonymAdditionDutch:null, + homonymAdditionFrench:null, + homonymAdditionGerman:null, "23098", MunicipalityNamespace, new DateTimeOffset(2002, 08, 13, 17, 32, 32, TimeSpan.FromHours(2)), @@ -58,6 +64,9 @@ public XmlStreetNameTests() "Hassyweg", nameFrench:null, nameGerman:null, + homonymAdditionDutch:"HO", + homonymAdditionFrench:null, + homonymAdditionGerman:null, "24059", MunicipalityNamespace, new DateTimeOffset(2010, 08, 13, 17, 32, 32, TimeSpan.FromHours(2)), @@ -71,6 +80,9 @@ public XmlStreetNameTests() "Hassyweg", nameFrench:null, nameGerman:null, + homonymAdditionDutch:null, + homonymAdditionFrench:null, + homonymAdditionGerman:null, "24059", MunicipalityNamespace, new DateTimeOffset(2010, 08, 13, 17, 32, 32, TimeSpan.FromHours(2)), @@ -164,6 +176,7 @@ public async Task GivenStreetName_ThenSerializesCorrectly() 2024-01-31T14:16:03+01:00 streetname + HO https://data.vlaanderen.be/id/gemeente/ 24059