From 0d3ba99048fdbb4c34591b17810a3aae2ed4d50a Mon Sep 17 00:00:00 2001 From: Claire Lovisa Date: Tue, 1 Aug 2023 20:53:52 +0200 Subject: [PATCH] Fix date format and missing data on AGBs/APBs --- .../20230801135516-update-agb-uri.sparql | 27 ++ ...ganen-and-functies-to-agbs-and-apbs.sparql | 301 ++++++++++++++++++ ...ime-to-date-agb-apb-organen-in-time.sparql | 24 ++ 3 files changed, 352 insertions(+) create mode 100644 config/migrations/2023/20230320135902-onboarding-agb-apb/20230801135516-update-agb-uri.sparql create mode 100644 config/migrations/2023/20230320135902-onboarding-agb-apb/20230801140025-add-missing-organen-and-functies-to-agbs-and-apbs.sparql create mode 100644 config/migrations/2023/20230320135902-onboarding-agb-apb/20230801181808-convert-datetime-to-date-agb-apb-organen-in-time.sparql diff --git a/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801135516-update-agb-uri.sparql b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801135516-update-agb-uri.sparql new file mode 100644 index 0000000..7dd5785 --- /dev/null +++ b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801135516-update-agb-uri.sparql @@ -0,0 +1,27 @@ +# AGB AG2B has been added in Loket in the meantime. I'm adapting to Loket's URI + +DELETE { + GRAPH ?g { + ?p ?o . + } +} INSERT { + GRAPH ?g { + ?p ?o . + } +} WHERE { + GRAPH ?g { + ?p ?o . + } +} +; +DELETE DATA { + GRAPH { + "a7aaef2f-6e8f-4351-9303-bdc4288bc6f0" . + } +} +; +INSERT DATA { + GRAPH { + "e0920e46-85b9-4736-a906-b254cc7f1855" . + } +} diff --git a/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801140025-add-missing-organen-and-functies-to-agbs-and-apbs.sparql b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801140025-add-missing-organen-and-functies-to-agbs-and-apbs.sparql new file mode 100644 index 0000000..678aa72 --- /dev/null +++ b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801140025-add-missing-organen-and-functies-to-agbs-and-apbs.sparql @@ -0,0 +1,301 @@ +# Classification Raad van bestuur + +INSERT { + GRAPH { + ?orgaanInTime a ; + ?uuidOrgaanInTime ; + ?orgaan ; + "2019-01-01T00:00:00"^^xsd:dateTime . + + ?orgaan a ; + ?uuidOrgaan ; + ?orgaanLabel ; + ?classificationOrgaan ; + ?bestuurseenheid . + } +} WHERE { + VALUES ?classificationBestuurseenheid { + + + } + + VALUES ?classificationOrgaan { + + } + + VALUES ?bestuurseenheid { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + ?bestuurseenheid a ; + skos:prefLabel ?bestuurseenheidLabel . + + ?classificationOrgaan skos:prefLabel ?classificationOrgaanLabel . + + BIND(CONCAT(?bestuurseenheidLabel, " Leidend ambtenaar") as ?functieLabel) + BIND(CONCAT(?classificationOrgaanLabel, " ", ?bestuurseenheidLabel) as ?orgaanLabel) + + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaanInTime")) as ?uuidOrgaanInTime) + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaan")) as ?uuidOrgaan) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaanInTime)) AS ?orgaanInTime) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaan)) AS ?orgaan) +} + +; + +# Classification Bevoegd beslissingsorgaan + +INSERT { + GRAPH { + ?orgaanInTime a ; + ?uuidOrgaanInTime ; + ?orgaan ; + "2019-01-01T00:00:00"^^xsd:dateTime . + + ?orgaan a ; + ?uuidOrgaan ; + ?orgaanLabel ; + ?classificationOrgaan ; + ?bestuurseenheid . + } +} WHERE { + VALUES ?classificationBestuurseenheid { + + + } + + VALUES ?classificationOrgaan { + + } + + VALUES ?bestuurseenheid { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + ?bestuurseenheid a ; + skos:prefLabel ?bestuurseenheidLabel . + + ?classificationOrgaan skos:prefLabel ?classificationOrgaanLabel . + + BIND(CONCAT(?bestuurseenheidLabel, " Leidend ambtenaar") as ?functieLabel) + BIND(CONCAT(?classificationOrgaanLabel, " ", ?bestuurseenheidLabel) as ?orgaanLabel) + + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaanInTime")) as ?uuidOrgaanInTime) + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaan")) as ?uuidOrgaan) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaanInTime)) AS ?orgaanInTime) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaan)) AS ?orgaan) +} + +; + +# Classification Algemene vergadering + +INSERT { + GRAPH { + ?orgaanInTime a ; + ?uuidOrgaanInTime ; + ?orgaan ; + "2019-01-01T00:00:00"^^xsd:dateTime . + + ?orgaan a ; + ?uuidOrgaan ; + ?orgaanLabel ; + ?classificationOrgaan ; + ?bestuurseenheid . + } +} WHERE { + VALUES ?classificationBestuurseenheid { + + + } + + VALUES ?classificationOrgaan { + + } + + VALUES ?bestuurseenheid { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + ?bestuurseenheid a ; + skos:prefLabel ?bestuurseenheidLabel . + + ?classificationOrgaan skos:prefLabel ?classificationOrgaanLabel . + + BIND(CONCAT(?bestuurseenheidLabel, " Leidend ambtenaar") as ?functieLabel) + BIND(CONCAT(?classificationOrgaanLabel, " ", ?bestuurseenheidLabel) as ?orgaanLabel) + + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaanInTime")) as ?uuidOrgaanInTime) + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaan")) as ?uuidOrgaan) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaanInTime)) AS ?orgaanInTime) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaan)) AS ?orgaan) +} + +; + +# Classification Leidend Ambtenaar + +INSERT { + GRAPH { + ?orgaanInTime a ; + ?uuidOrgaanInTime ; + ?orgaan ; + "2019-01-01T00:00:00"^^xsd:dateTime . + + ?orgaan a ; + ?uuidOrgaan ; + ?orgaanLabel ; + ?classificationOrgaan ; + ?bestuurseenheid . + } +} WHERE { + VALUES ?classificationBestuurseenheid { + + + } + + VALUES ?classificationOrgaan { + + } + + VALUES ?bestuurseenheid { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + ?bestuurseenheid a ; + skos:prefLabel ?bestuurseenheidLabel . + + ?classificationOrgaan skos:prefLabel ?classificationOrgaanLabel . + + BIND(CONCAT(?bestuurseenheidLabel, " Leidend ambtenaar") as ?functieLabel) + BIND(CONCAT(?classificationOrgaanLabel, " ", ?bestuurseenheidLabel) as ?orgaanLabel) + + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaanInTime")) as ?uuidOrgaanInTime) + BIND(MD5(CONCAT(?bestuurseenheid, ?classificationOrgaan, "orgaan")) as ?uuidOrgaan) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaanInTime)) AS ?orgaanInTime) + BIND(IRI(CONCAT("http://data.lblod.info/id/bestuursorganen/", ?uuidOrgaan)) AS ?orgaan) +} \ No newline at end of file diff --git a/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801181808-convert-datetime-to-date-agb-apb-organen-in-time.sparql b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801181808-convert-datetime-to-date-agb-apb-organen-in-time.sparql new file mode 100644 index 0000000..334d15d --- /dev/null +++ b/config/migrations/2023/20230320135902-onboarding-agb-apb/20230801181808-convert-datetime-to-date-agb-apb-organen-in-time.sparql @@ -0,0 +1,24 @@ +DELETE { + GRAPH { + ?orgaanInTime ?start . + } +} INSERT { + GRAPH { + ?orgaanInTime ?startDateTime . + } +} WHERE { + GRAPH { + VALUES ?classificationBestuurseenheid { + + + } + + ?orgaanInTime / ?bestuurseenheid ; + ?start . + + ?bestuurseenheid ?classificationBestuurseenheid . + + # The hour is arbitrary, but there is a bug in virtuoso when if the time is `T00:00:00` it doesn't apply the type change at all + BIND(IF(strlen(str(?start)) = 10, strdt(concat(str(?start), 'T02:00:00'), xsd:dateTime), ?start) as ?startDateTime) + } +}