diff --git a/config/migrations/2024/20241023123140-add-end-dates-bestuursorganen.sparql b/config/migrations/2024/20241023123140-add-end-dates-bestuursorganen.sparql new file mode 100644 index 0000000..e095eba --- /dev/null +++ b/config/migrations/2024/20241023123140-add-end-dates-bestuursorganen.sparql @@ -0,0 +1,59 @@ +PREFIX besluit: +PREFIX mandaat: +PREFIX generiek: +PREFIX org: +PREFIX skos: + +INSERT { + GRAPH { + ?oldVersion mandaat:bindingEinde ?newStartDate . + } +} +WHERE { + + VALUES ?orgaanClass { + #Gouverneur + # Provincieraad + # deputatie + + # Burgemeester + # gemeenteraad + # college + + # rmw + # Vast Bureau + # Voorzitter van het Bijzonder Comité voor de Sociale Dienst + # Bijzonder Comité voor de Sociale Dienst + + #districtburgemeester + # Districtsraad + # Districtscollege + } + + GRAPH { + + ?bestuursorgaan besluit:bestuurt ?bestuurseenheid; + skos:prefLabel ?orgaanLabel; + ?orgaanClass. + + # Find the bestuursorgaan version without an end date + ?oldVersion a besluit:Bestuursorgaan ; + generiek:isTijdspecialisatieVan ?bestuursorgaan ; + mandaat:bindingStart ?oldStartDate . + FILTER NOT EXISTS { ?oldVersion mandaat:bindingEinde ?_ } + + # Find newer bestuursorgaan version + ?newVersion a besluit:Bestuursorgaan ; + generiek:isTijdspecialisatieVan ?bestuursorgaan ; + mandaat:bindingStart ?newStartDate . + FILTER (?newStartDate > ?oldStartDate) + + # Ensure there's no version with an earlier or same start date than the new one + FILTER NOT EXISTS { + ?otherVersion a besluit:Bestuursorgaan ; + generiek:isTijdspecialisatieVan ?bestuursorgaan ; + mandaat:bindingStart ?otherStartDate . + FILTER (?otherStartDate > ?oldStartDate && ?otherStartDate < ?newStartDate) + } + } +} \ No newline at end of file diff --git a/config/migrations/2024/20241028125621-remove-functionarissen-newly-created-organen.sparql b/config/migrations/2024/20241028125621-remove-functionarissen-newly-created-organen.sparql new file mode 100644 index 0000000..ac9e148 --- /dev/null +++ b/config/migrations/2024/20241028125621-remove-functionarissen-newly-created-organen.sparql @@ -0,0 +1,38 @@ +PREFIX skos: +PREFIX generiek: + +DELETE { + GRAPH { + ?orgIntijdNew ?orgIntijdNewP ?orgIntijdNewO. + ?bestuursfunctie ?bestuursfunctieP ?bestuursfunctieO. + } +} +WHERE { + VALUES ?class { + # "Adjunct-algemeen directeur" + # "Algemeen directeur" + # "Leidend Ambtenaar" + # "Financieel directeu" + # "Adjunct-financieel directeur" + # "Financieel beheerder" + # Griffier + } + + GRAPH { + + ?s a ; + ?class. + + ?orgIntijdOld generiek:isTijdspecialisatieVan ?s; + ?old. + + ?orgIntijdNew generiek:isTijdspecialisatieVan ?s; + ?new. + + FILTER(?new > ?old) + + ?orgIntijdNew ?orgIntijdNewP ?orgIntijdNewO. + ?orgIntijdNew ?bestuursfunctie. + ?bestuursfunctie ?bestuursfunctieP ?bestuursfunctieO. + } +} \ No newline at end of file