Files
app-organization-portal/config/migrations/2024/20240604100500-delete-duplicate-identifier.sparql
2024-06-05 08:38:22 +02:00

33 lines
1.2 KiB
SPARQL

DELETE {
GRAPH ?g {
?org <http://www.w3.org/ns/adms#identifier> ?identifier .
?identifier ?pi ?oi .
?structured ?ps ?os .
}
}
WHERE {
GRAPH ?g {
{
# Select one identifier by organization and local identifier
SELECT ?org ?li (MAX(?i) AS ?keepIdentifier) WHERE {
?org <http://www.w3.org/ns/adms#identifier> ?i .
?i <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator>/<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?li .
} GROUP BY ?org ?li
}
?org <http://www.w3.org/ns/adms#identifier> ?identifier .
?identifier <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?structured .
?structured <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?li .
FILTER(?identifier != ?keepIdentifier)
# All properties of the duplicate identifier and structured identifier
?identifier ?pi ?oi .
?structured ?ps ?os .
}
VALUES ?g {
<http://mu.semte.ch/graphs/worship-service>
<http://mu.semte.ch/graphs/administrative-unit>
}
}