Files
app-organization-portal/config/migrations/2025/20250603161306-fix--move-memberships-for-municipalities-and-provinces-to-shared/20250603163337-feat--cleanup-job-insert-suborganization-province-municipality.ttl
mirdono 5f1bfe96c7 feat: cleanup jobs municipality and province relations
Add cleanup jobs to automatically insert and delete `org:hasSubOrganization`
relations between provinces and municipalities. These memberships were moved to
the `shared` graph causing the existing cleanup jobs to no longer work for them.
2025-06-04 11:41:21 +02:00

37 lines
1.6 KiB
Turtle

@prefix cleanup: <http://mu.semte.ch/vocabularies/ext/cleanup/> .
@prefix mu: <http://mu.semte.ch/vocabularies/core/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
# Insert triples of the form
# <Province> <http://www.w3.org/ns/org#hasSubOrganization> <Municipality>
# matching memberships for which no such triple exists.
# Province: <http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000000>
#
# Municipality: <http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000001>
<http://data.lblod.info/id/cleanup-job/0cc5e981-a61e-433e-b6f2-c59fd8599944> a cleanup:Job ;
mu:uuid "0cc5e981-a61e-433e-b6f2-c59fd8599944" ;
dcterms:title "Insert missing `org:hasSubOrganization` triples relating provinces and municipalities." ;
cleanup:randomQuery """
PREFIX org: <http://www.w3.org/ns/org#>
INSERT {
GRAPH <http://mu.semte.ch/graphs/shared> {
?province org:hasSubOrganization ?municipality .
}
} WHERE {
GRAPH <http://mu.semte.ch/graphs/shared> {
?membership a org:Membership ;
org:organization ?province ;
org:member ?municipality ;
org:role <http://data.lblod.info/id/rollen/4ec7d5c39bdc4e84b4174379b9e22ad8> .
FILTER NOT EXISTS { ?province org:hasSubOrganization ?municipality . }
?municipality org:classification <http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000001> .
?province org:classification <http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/5ab0e9b8a3b2ca7c5e000000> .
}
}
""" .