Skip to content

Commit

Permalink
fix(bosa): add homonym addition
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Nov 13, 2024
1 parent 5fd451a commit bc2bf81
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -42,6 +45,9 @@ public StreetName(
string? nameDutch,
string? nameFrench,
string? nameGerman,
string? homonymAdditionDutch,
string? homonymAdditionFrench,
string? homonymAdditionGerman,
string nisCode,
string municipalityNamespace,
DateTimeOffset municipalityVersionTimestamp,
Expand All @@ -55,6 +61,9 @@ public StreetName(
NameDutch = nameDutch;
NameFrench = nameFrench;
NameGerman = nameGerman;
HomonymAdditionDutch = homonymAdditionDutch;
HomonymAdditionFrench = homonymAdditionFrench;
HomonymAdditionGerman = homonymAdditionGerman;
NisCode = nisCode;
MunicipalityNamespace = municipalityNamespace;
MunicipalityVersionTimestamp = municipalityVersionTimestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/Basisregisters.IntegrationDb.Bosa/StreetNameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void CreateXml(Stream outputStream)
ValidTo = endLifeSpanVersion
},
Type = "streetname",
HomonymAddition = GetHomonymAddition(streetName),
IsAssignedByMunicipality = new XmlCode
{
Namespace = FormatNamespace(streetName.MunicipalityNamespace),
Expand All @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions test/Basisregisters.IntegrationDb.Bosa.Tests/XmlStreetNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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)),
Expand All @@ -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)),
Expand All @@ -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)),
Expand Down Expand Up @@ -164,6 +176,7 @@ public async Task GivenStreetName_ThenSerializesCorrectly()
<com:validFrom>2024-01-31T14:16:03+01:00</com:validFrom>
</com:streetNameStatus>
<com:type>streetname</com:type>
<com:homonymAddition>HO</com:homonymAddition>
<com:isAssignedByMunicipality>
<com:namespace>https://data.vlaanderen.be/id/gemeente/</com:namespace>
<com:objectIdentifier>24059</com:objectIdentifier>
Expand Down

0 comments on commit bc2bf81

Please sign in to comment.