diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d6860..d1111e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog ## Unreleased +- Islamitisch eredienstbestuur: only offer relevant imam roles based on status (erkenningszoekend -> Waarnemende imam; erkend -> Eerste/Tweede/Derde imam in rang); bump construct-organization-relationships [OP-XXXX] - Added service to link addresses to addressregister uris [OP-3795] - Derive an organization's reference region(s) from its werkingsgebied; bump scope-of-operation to 0.2.0 [OP-3799] - Site type changes [OP-3818] @@ -30,6 +31,11 @@ drc restart migrations drc restart resource cache scripts/reset-elastic.sh ``` + +``` +drc pull construct-organization-relationships && drc up -d construct-organization-relationships +drc restart migrations +``` ``` drc restart migrations frontend db resource cache # reindex elastic search: diff --git a/config/migrations/2026/20260720100000-fix-islam-imam-roles-by-status.sparql b/config/migrations/2026/20260720100000-fix-islam-imam-roles-by-status.sparql new file mode 100644 index 0000000..eb2e5f4 --- /dev/null +++ b/config/migrations/2026/20260720100000-fix-islam-imam-roles-by-status.sparql @@ -0,0 +1,220 @@ +PREFIX ere: +PREFIX mu: +PREFIX org: +PREFIX regorg: + +# Deduplicate islamitisch minister positions: if an eredienstbestuur has more +# than one position for the same function (e.g. 2 "Waarnemende Imam"), keep +# only one - deterministically the lowest-URI position - and merge the rest +# into it: any minister (org:holds) on a non-kept position is reparented onto +# the kept position instead of being dropped. Ministers and their conditions +# (ere:voldoetAan) are left fully intact, just re-pointed to survive the dedup. +DELETE { + GRAPH { + ?minister org:holds ?position . + } +} +INSERT { + GRAPH { + ?minister org:holds ?keptPosition . + } +} +WHERE { + GRAPH { + ?worshipService a ere:BestuurVanDeEredienst ; + ere:typeEredienst ; # Islamitisch + ere:wordtBediendDoor ?position . + + ?position ere:functie ?functie . + ?minister org:holds ?position . + + { + SELECT ?worshipService ?functie (IRI(MIN(STR(?anyPosition))) AS ?keptPosition) WHERE { + GRAPH { + ?worshipService ere:wordtBediendDoor ?anyPosition . + ?anyPosition ere:functie ?functie . + } + } + GROUP BY ?worshipService ?functie + } + + FILTER(?position != ?keptPosition) + } +} +; + +# Delete the now-empty duplicate positions left behind by the reparenting +# above (same "lowest URI wins" rule, kept in sync with it). Since ministers +# were already moved off in the previous step, this only drops the position +# shells and their own triples (org:Post, mu:uuid, ere:functie). +DELETE { + GRAPH { + ?worshipService ere:wordtBediendDoor ?position . + ?position ?p ?o . + } +} +WHERE { + GRAPH { + ?worshipService a ere:BestuurVanDeEredienst ; + ere:typeEredienst ; # Islamitisch + ere:wordtBediendDoor ?position . + + ?position ?p ?o ; + ere:functie ?functie . + + { + SELECT ?worshipService ?functie (IRI(MIN(STR(?anyPosition))) AS ?keptPosition) WHERE { + GRAPH { + ?worshipService ere:wordtBediendDoor ?anyPosition . + ?anyPosition ere:functie ?functie . + } + } + GROUP BY ?worshipService ?functie + } + + FILTER(?position != ?keptPosition) + } +} +; + +## Islamitisch eredienstbesturen "In Oprichting" (erkenningszoekend) should only +## have the "Waarnemende Imam" minister position. Remove the 3 ranked-imam +## positions that were always created before this fix. Any minister +## (ere:RolBedienaar) currently holding such a position is removed along with +## its own conditions (ere:VoorwaardenBedienaar); the person they link to +## (org:heldBy) is left untouched, since that's a shared, reusable resource, +## not owned by this position/minister. +#DELETE { +# GRAPH { +# ?worshipService ere:wordtBediendDoor ?position . +# ?position ?p ?o . +# ?minister ?mp ?mo . +# ?condition ?cp ?co . +# } +#} +#WHERE { +# GRAPH { +# ?worshipService a ere:BestuurVanDeEredienst ; +# ere:typeEredienst ; # Islamitisch +# regorg:orgStatus ; # In Oprichting +# ere:wordtBediendDoor ?position . +# +# ?position ?p ?o ; +# ere:functie ?functie . +# +# VALUES ?functie { +# # Eerste Imam in rang +# # Tweede Imam in rang +# # Derde Imam in rang +# } +# +# OPTIONAL { +# ?minister org:holds ?position ; +# ?mp ?mo . +# +# OPTIONAL { +# ?minister ere:voldoetAan ?condition . +# ?condition ?cp ?co . +# } +# } +# } +#} +#; +# +## Islamitisch eredienstbesturen that are "Actief" (erkend) should only have the +## 3 ranked-imam positions. Remove the "Waarnemende Imam" position that was +## always created before this fix. Same cascade as above: any minister holding +## it (and its conditions) is removed, the person is left untouched. +#DELETE { +# GRAPH { +# ?worshipService ere:wordtBediendDoor ?position . +# ?position ?p ?o . +# ?minister ?mp ?mo . +# ?condition ?cp ?co . +# } +#} +#WHERE { +# GRAPH { +# ?worshipService a ere:BestuurVanDeEredienst ; +# ere:typeEredienst ; # Islamitisch +# regorg:orgStatus ; # Actief +# ere:wordtBediendDoor ?position . +# +# ?position ?p ?o ; +# ere:functie . # Waarnemende Imam +# +# OPTIONAL { +# ?minister org:holds ?position ; +# ?mp ?mo . +# +# OPTIONAL { +# ?minister ere:voldoetAan ?condition . +# ?condition ?cp ?co . +# } +# } +# } +#} +#; +# +## Create the 3 ranked-imam positions for "Actief" islamitisch eredienstbesturen +## that are missing one or more of them (idempotent: MD5-derived deterministic +## UUID + FILTER NOT EXISTS, matching 20221004113653-create-missing-bedienaren-positions.sparql). +#INSERT { +# GRAPH { +# ?worshipService ere:wordtBediendDoor ?newMinisterPosition . +# +# ?newMinisterPosition a org:Post , ere:PositieBedienaar ; +# mu:uuid ?uuidNewMinisterPosition ; +# ere:functie ?functie . +# } +#} +#WHERE { +# GRAPH { +# ?worshipService a ere:BestuurVanDeEredienst ; +# ere:typeEredienst ; # Islamitisch +# regorg:orgStatus . # Actief +# +# VALUES ?functie { +# # Eerste Imam in rang +# # Tweede Imam in rang +# # Derde Imam in rang +# } +# +# FILTER NOT EXISTS { +# ?worshipService ere:wordtBediendDoor ?ministerPosition . +# ?ministerPosition ere:functie ?functie . +# } +# +# BIND(MD5(CONCAT(?worshipService, ?functie)) as ?uuidNewMinisterPosition) +# BIND(IRI(CONCAT("http://data.lblod.info/id/positiesBedienaar/", ?uuidNewMinisterPosition)) AS ?newMinisterPosition) +# } +#} +#; +# +## Create the "Waarnemende Imam" position for "In Oprichting" islamitisch +## eredienstbesturen that are missing it (should be rare, kept for +## completeness/idempotency). +#INSERT { +# GRAPH { +# ?worshipService ere:wordtBediendDoor ?newMinisterPosition . +# +# ?newMinisterPosition a org:Post , ere:PositieBedienaar ; +# mu:uuid ?uuidNewMinisterPosition ; +# ere:functie . # Waarnemende Imam +# } +#} +#WHERE { +# GRAPH { +# ?worshipService a ere:BestuurVanDeEredienst ; +# ere:typeEredienst ; # Islamitisch +# regorg:orgStatus . # In Oprichting +# +# FILTER NOT EXISTS { +# ?worshipService ere:wordtBediendDoor ?ministerPosition . +# ?ministerPosition ere:functie . +# } +# +# BIND(MD5(?worshipService) as ?uuidNewMinisterPosition) +# BIND(IRI(CONCAT("http://data.lblod.info/id/positiesBedienaar/", ?uuidNewMinisterPosition)) AS ?newMinisterPosition) +# } +#}