This migration regenerates the `locn:fullAddress` triples for addresses in a municipality involved in a merger. In essences this migration updates the `locn:fullAddress` triple for each address changed by the migrations in the previous commit. Notes - The migration is split over two queries, one for addresses without a box number and one for addresses with a box number. This avoids complicating the query with conditional logic at the cost of code duplication in the queries. - In the existing full address triples two different notations are used to separate the box and building number. OP currently separates them simply by a space, which is what this migration matches for. But some historical data uses a dash "-" to separate building and box number. Consequently, this migration might match more address resources than strictly updated for the municipality merges.
93 lines
3.3 KiB
SPARQL
93 lines
3.3 KiB
SPARQL
PREFIX locn: <http://www.w3.org/ns/locn#>
|
|
PREFIX adres: <https://data.vlaanderen.be/ns/adres#>
|
|
PREFIX organisatie: <https://data.vlaanderen.be/ns/organisatie#>
|
|
PREFIX org: <http://www.w3.org/ns/org#>
|
|
|
|
DELETE {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?fullAddress.
|
|
}
|
|
} INSERT {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?newFullAddress.
|
|
}
|
|
} WHERE {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?fullAddress;
|
|
locn:thoroughfare ?street;
|
|
adres:Adresvoorstelling.huisnummer ?buildingNo;
|
|
locn:postCode ?postalCode;
|
|
adres:gemeentenaam ?municipality;
|
|
adres:land ?country.
|
|
FILTER NOT EXISTS { ?address adres:Adresvoorstelling.busnummer ?boxNo. }
|
|
FILTER (EXISTS { ?site organisatie:bestaatUit ?address. } ||
|
|
EXISTS { ?site org:siteAddress/locn:address ?address. })
|
|
FILTER (?municipality IN (
|
|
"Antwerpen",
|
|
"Pajottegem",
|
|
"Wingene",
|
|
"Tielt",
|
|
"Nazareth-De Pinte",
|
|
"Lochristi",
|
|
"Lokeren",
|
|
"Merelbeke-Melle",
|
|
"Beveren-Kruibeke-Zwijndrecht",
|
|
"Bilzen-Hoeselt",
|
|
"Tongeren-Borgloon",
|
|
"Tessenderlo-Ham",
|
|
"Hasselt"
|
|
))
|
|
BIND (CONCAT(?street, " ", ?buildingNo, ", ", ?postalCode, " ", ?municipality, ", ", ?country) AS ?newFullAddress)
|
|
FILTER (?fullAddress != ?newFullAddress)
|
|
}
|
|
|
|
VALUES ?g {
|
|
<http://mu.semte.ch/graphs/administrative-unit>
|
|
<http://mu.semte.ch/graphs/worship-service>
|
|
}
|
|
}
|
|
;
|
|
DELETE {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?fullAddress.
|
|
}
|
|
} INSERT {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?newFullAddress.
|
|
}
|
|
} WHERE {
|
|
GRAPH ?g {
|
|
?address locn:fullAddress ?fullAddress;
|
|
locn:thoroughfare ?street;
|
|
adres:Adresvoorstelling.huisnummer ?buildingNo;
|
|
adres:Adresvoorstelling.busnummer ?boxNo;
|
|
locn:postCode ?postalCode;
|
|
adres:gemeentenaam ?municipality;
|
|
adres:land ?country.
|
|
FILTER (EXISTS { ?site organisatie:bestaatUit ?address. } ||
|
|
EXISTS { ?site org:siteAddress/locn:address ?address. })
|
|
FILTER (?municipality IN (
|
|
"Antwerpen",
|
|
"Pajottegem",
|
|
"Wingene",
|
|
"Tielt",
|
|
"Nazareth-De Pinte",
|
|
"Lochristi",
|
|
"Lokeren",
|
|
"Merelbeke-Melle",
|
|
"Beveren-Kruibeke-Zwijndrecht",
|
|
"Bilzen-Hoeselt",
|
|
"Tongeren-Borgloon",
|
|
"Tessenderlo-Ham",
|
|
"Hasselt"
|
|
))
|
|
BIND (CONCAT(?street, " ", ?buildingNo, " ", ?boxNo, ", ", ?postalCode, " ", ?municipality, ", ", ?country) AS ?newFullAddress)
|
|
FILTER (?fullAddress != ?newFullAddress)
|
|
}
|
|
|
|
VALUES ?g {
|
|
<http://mu.semte.ch/graphs/administrative-unit>
|
|
<http://mu.semte.ch/graphs/worship-service>
|
|
}
|
|
}
|