From 3b333f13a6ff7f590bfe8b038f7c54a3e957dc55 Mon Sep 17 00:00:00 2001 From: Damon Date: Thu, 9 Apr 2026 11:19:39 +0200 Subject: [PATCH 1/4] OP-3766: added updated bestuurseenheden query to report --- config/reports/administrative-units-report.js | 187 ++++++++++++++++++ config/reports/index.js | 2 + config/reports/utils.js | 1 + 3 files changed, 190 insertions(+) create mode 100644 config/reports/administrative-units-report.js diff --git a/config/reports/administrative-units-report.js b/config/reports/administrative-units-report.js new file mode 100644 index 0000000..4e317db --- /dev/null +++ b/config/reports/administrative-units-report.js @@ -0,0 +1,187 @@ +import { generateReportFromData, batchedQuery } from "../helpers.js"; +import { PREFIXES } from "./utils"; + +export default { + cronPattern: "0 00 1 * * *", + name: "administrative units", + execute: async () => { + const reportData = { + title: "administrative units", + description: "List of the administrative units", + filePrefix: "exports/administrative-units", + }; + + console.log("Generating administrative units report"); + + const queryString = ` + ${PREFIXES} + + SELECT DISTINCT + ?Bestuurseenheid + ?Classificatie + ?Status + ?KBO_nr + ?OVO_nr + ?Sharepoint_id + ?NIS_code + ?Regio + ?Provincie + ?Straat + ?Huisnummer + ?Busnummer + ?Postcode + ?Gemeente + (STR(?GrensoverschrijdendBoolean) AS ?Grensoverschrijdend) + ?TypeEredienst + ?BestuurseenheidURI + ?Stekking + { + VALUES ?type { + besluit:Bestuurseenheid + ere:BestuurVanDeEredienst + org:Organization + ere:EredienstBestuurseenheid + ere:CentraalBestuurVanDeEredienst + } + + ?BestuurseenheidURI + a ?type. + OPTIONAL { ?BestuurseenheidURI skos:prefLabel ?Bestuurseenheid . } + OPTIONAL { ?BestuurseenheidURI org:classification/skos:prefLabel ?Classificatie. } + + OPTIONAL { + ?BestuurseenheidURI besluit:werkingsgebied ?werkingsgebiedURI. + ?werkingsgebiedURI rdfs:label ?werkingsgebied. + OPTIONAL { + ?werkingsgebiedURI geo:sfWithin ?regionURI. + ?regionURI + ext:werkingsgebiedNiveau "Referentieregio"@nl; + rdfs:label ?langRegio. + } + OPTIONAL { + ?werkingsgebiedURI skos:exactMatch ?nisArea. + ?nisArea skos:inScheme ?NISCodeScheme; + skos:notation ?NIS_code. + + FILTER (?NISCodeScheme IN ( , )) + } + } + OPTIONAL { + ?BestuurseenheidURI org:hasPrimarySite/organisatie:bestaatUit ?address . + ?address adres:gemeentenaam ?Gemeente . + + ?municipalityRegio a besluit:Bestuurseenheid ; + skos:prefLabel ?Gemeente ; + org:classification ; + besluit:werkingsgebied ?werkingsgebiedRegioURI. + + ?werkingsgebiedRegioURI geo:sfWithin ?regioViaAddressURI. + ?regioViaAddressURI + ext:werkingsgebiedNiveau "Referentieregio"@nl; + rdfs:label ?langRegioViaAddress. + } + + BIND(IF(BOUND(?langRegio) && strlen(?langRegio)>0, str(?langRegio), str(?langRegioViaAddress)) AS ?Regio) + + OPTIONAL { ?BestuurseenheidURI regorg:orgStatus/skos:prefLabel ?Status. } + OPTIONAL { ?BestuurseenheidURI ere:typeEredienst ?typeEredienstUri. + OPTIONAL { ?typeEredienstUri skos:prefLabel ?TypeEredienst. } + } + OPTIONAL { ?BestuurseenheidURI ere:grensoverschrijdend ?GrensoverschrijdendBoolean. } + OPTIONAL { ?BestuurseenheidURI org:hasPrimarySite/organisatie:bestaatUit ?address . + OPTIONAL { ?address locn:thoroughfare ?Straat } + OPTIONAL { ?address adres:Adresvoorstelling.huisnummer ?Huisnummer . } + OPTIONAL { ?address adres:Adresvoorstelling.busnummer ?Busnummer . } + OPTIONAL { ?address locn:postCode ?Postcode . } + OPTIONAL { ?address adres:gemeentenaam ?Gemeente . } + OPTIONAL { ?address locn:adminUnitL2 ?Provincie . } + OPTIONAL { ?address adres:land ?Land . } + } + OPTIONAL { + ?BestuurseenheidURI adms:identifier ?kbo_identifier . + ?kbo_identifier + skos:notation ?kbo_notation; + generiek:gestructureerdeIdentificator/generiek:lokaleIdentificator ?KBO_nr. + FILTER (str(?kbo_notation) = "KBO nummer") + } + OPTIONAL { + ?BestuurseenheidURI adms:identifier ?ovo_identifier . + ?ovo_identifier + skos:notation ?ovo_notation; + generiek:gestructureerdeIdentificator/generiek:lokaleIdentificator ?OVO_nr. + FILTER (str(?ovo_notation) = "OVO-nummer") + } + OPTIONAL { + ?BestuurseenheidURI adms:identifier ?sp_identifier . + ?sp_identifier + skos:notation ?sp_notation; + generiek:gestructureerdeIdentificator/generiek:lokaleIdentificator ?Sharepoint_id. + FILTER (str(?sp_notation) = "SharePoint identificator") + } + OPTIONAL { + ?changeEvent org:resultingOrganization ?BestuurseenheidURI; + ch:typeWijziging . + skos:prefLabel ?stadsTitel + } + OPTIONAL { ?BestuurseenheidURI ere:denominatie ?Stekking. } + } ORDER BY DESC(?Classificatie) ?Bestuurseenheid + `; + + const queryResponse = await batchedQuery(queryString); + + const data = queryResponse.results.bindings.map((row) => ({ + Bestuurseenheid: getSafeValue(row, "Bestuurseenheid"), + Classificatie: getSafeValue(row, "Classificatie"), + Status: getSafeValue(row, "Status"), + KBO_nr: getSafeValue(row, "KBO_nr"), + OVO_nr: getSafeValue(row, "OVO_nr"), + Sharepoint_id: getSafeValue(row, "Sharepoint_id"), + NIS_code: getSafeValue(row, "NIS_code"), + Regio: getSafeValue(row, "Regio"), + Provincie: getSafeValue(row, "Provincie"), + Straat: getSafeValue(row, "Straat"), + Huisnummer: getSafeValue(row, "Huisnummer"), + Busnummer: getSafeValue(row, "Busnummer"), + Postcode: getSafeValue(row, "Postcode"), + Gemeente: getSafeValue(row, "Gemeente"), + Grensoverschrijdend: getSafeValue(row, "Grensoverschrijdend"), + TypeEredienst: getSafeValue(row, "TypeEredienst"), + BestuurseenheidURI: getSafeValue(row, "BestuurseenheidURI"), + Stekking: getSafeValue(row, "Stekking"), + })); + + await generateReportFromData( + data, + [ + "Bestuurseenheid", + "Classificatie", + "Status", + "KBO_nr", + "OVO_nr", + "Sharepoint_id", + "NIS_code", + "Regio", + "Provincie", + "Straat", + "Huisnummer", + "Busnummer", + "Postcode", + "Gemeente", + "Grensoverschrijdend", + "TypeEredienst", + "BestuurseenheidURI", + "Stekking", + ], + reportData, + ); + }, +}; + +function getSafeValue(entry, property) { + return entry[property] ? wrapInQuote(entry[property].value) : null; +} + +// Some values might contain commas; wrapping them in escapes quotes doesn't disrupt the columns. +function wrapInQuote(value) { + return `\"${value}\"`; +} diff --git a/config/reports/index.js b/config/reports/index.js index a0d10a3..ed712fd 100644 --- a/config/reports/index.js +++ b/config/reports/index.js @@ -3,6 +3,7 @@ import RelatedOrganizationsReport from './related-organizations-report' import KboOrganizationsReport from './kbo-organizations-report' import OrganizationsDetailReport from './organizations-detail-report' import OrganizationsPlatformReport from './organizations-platform-report' +import AdministrativeUnitsReport from "./administrative-units-report"; export default [ OrganizationsReport, @@ -10,4 +11,5 @@ export default [ KboOrganizationsReport, OrganizationsDetailReport, OrganizationsPlatformReport, + AdministrativeUnitsReport ]; diff --git a/config/reports/utils.js b/config/reports/utils.js index 42c9732..f997873 100644 --- a/config/reports/utils.js +++ b/config/reports/utils.js @@ -26,4 +26,5 @@ export const PREFIXES = ` PREFIX skos: PREFIX vcard: PREFIX xsd: + PREFIX geo: `; From 334adafbba53b33000f9607764d8fd635ca171fa Mon Sep 17 00:00:00 2001 From: Damon Date: Thu, 9 Apr 2026 17:19:35 +0200 Subject: [PATCH 2/4] OP-3765: bump to kbo-data-sync --- CHANGELOG.md | 8 ++++++++ docker-compose.yml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 280bb2d..916cf1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Changelog +## Unreleased +- Bump to kbo-data-sync [OP-3765] + +### Deploy notes +``` +drc pull kbo-data-sync && drc up -d kbo-data-sync +``` + ## 1.39.0 (2026-04-02) - Add KBO organizations report to report generation service [OP-3738] - Add organizations detail report (addresses and contact info) to report generation service [OP-3738] diff --git a/docker-compose.yml b/docker-compose.yml index 485fc92..b754789 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -344,7 +344,7 @@ services: restart: always logging: *default-logging kbo-data-sync: - image: lblod/sync-wegwijs-organization-service:2.0.4 + image: lblod/sync-wegwijs-organization-service:2.0.5 links: - db:database labels: From 5eaae75cc3fa261aac5332a024d7ac1da6c93710 Mon Sep 17 00:00:00 2001 From: Damon Date: Mon, 13 Apr 2026 10:48:09 +0200 Subject: [PATCH 3/4] OP-3766: camelCase + changelog edit --- CHANGELOG.md | 8 ++++++++ config/reports/administrative-units-report.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 280bb2d..4634849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Changelog +## Unreleased +- added administrativeUnits report with strekking [OP-3766] + +### Deploy notes +``` +drc restart report-generation +``` + ## 1.39.0 (2026-04-02) - Add KBO organizations report to report generation service [OP-3738] - Add organizations detail report (addresses and contact info) to report generation service [OP-3738] diff --git a/config/reports/administrative-units-report.js b/config/reports/administrative-units-report.js index 4e317db..e0dfd77 100644 --- a/config/reports/administrative-units-report.js +++ b/config/reports/administrative-units-report.js @@ -3,7 +3,7 @@ import { PREFIXES } from "./utils"; export default { cronPattern: "0 00 1 * * *", - name: "administrative units", + name: "administrativeUnits", execute: async () => { const reportData = { title: "administrative units", From bd935ce795d333ee6d9b9254e5fb6370ac2b2130 Mon Sep 17 00:00:00 2001 From: wolfez Date: Wed, 15 Apr 2026 12:53:12 +0200 Subject: [PATCH 4/4] add migration to cleanup local involvement of oud heverlee --- CHANGELOG.md | 8 +++++ ...lete-local-involvement-oud-heverlee.sparql | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 config/migrations/2026/20260414100057-delete-local-involvement-oud-heverlee.sparql diff --git a/CHANGELOG.md b/CHANGELOG.md index 280bb2d..5798c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Changelog +## Unreleased +- Cleanup local involvement for oud heverlee [OP-3757] + +### Deploy notes +``` +drc restart migrations && drc logs -ft --tail=200 migrations +``` + ## 1.39.0 (2026-04-02) - Add KBO organizations report to report generation service [OP-3738] - Add organizations detail report (addresses and contact info) to report generation service [OP-3738] diff --git a/config/migrations/2026/20260414100057-delete-local-involvement-oud-heverlee.sparql b/config/migrations/2026/20260414100057-delete-local-involvement-oud-heverlee.sparql new file mode 100644 index 0000000..f653f70 --- /dev/null +++ b/config/migrations/2026/20260414100057-delete-local-involvement-oud-heverlee.sparql @@ -0,0 +1,35 @@ +DELETE WHERE { + graph { + ?p ?o. + } +} + +; + +DELETE WHERE { + graph { + . + } +} + +; + +DELETE { + GRAPH ?g { + ?localInvolvementOudHeverlee ?percentage. + } +} +INSERT { + GRAPH ?g { + ?localInvolvementOudHeverlee 100. + } +} +WHERE { + BIND( AS ?g) + GRAPH ?g { + ?localInvolvementOudHeverlee ?percentage. + } + VALUES ?localInvolvementOudHeverlee { + + } +}