Merge pull request #593 from lblod/OP-3758-Add-column-to-query-organizations-in-Dashboard
OP-3758: updated organizations-report query + fix to dev migration
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
DELETE {
|
DELETE {
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?s a <http://www.w3.org/ns/org#Organization>.
|
|
||||||
?s <http://www.w3.org/ns/regorg#orgStatus> ?status.
|
?s <http://www.w3.org/ns/regorg#orgStatus> ?status.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,93 +6,68 @@ export default {
|
|||||||
name: "organizations",
|
name: "organizations",
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
const reportData = {
|
const reportData = {
|
||||||
title: "organizations",
|
title: "organisations in database",
|
||||||
description: "List of the Organizations",
|
description: "List of the Organisations in the database",
|
||||||
filePrefix: "exports/organizations",
|
filePrefix: "exports/organizations",
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("Generating organizations report");
|
console.log("Generating organizations report");
|
||||||
|
|
||||||
const queryStringPart1 = `
|
const queryString = `
|
||||||
${PREFIXES}
|
${PREFIXES}
|
||||||
|
PREFIX org: <http://www.w3.org/ns/org#>
|
||||||
SELECT DISTINCT ?bestuur ?label ?classification ?typeEredienst
|
PREFIX adms: <http://www.w3.org/ns/adms#>
|
||||||
|
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||||
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
||||||
|
SELECT DISTINCT
|
||||||
|
?bestuur
|
||||||
|
?label
|
||||||
|
?classification
|
||||||
|
?typeEredienst
|
||||||
|
?provincie
|
||||||
|
?status
|
||||||
WHERE {
|
WHERE {
|
||||||
GRAPH ?g {
|
?bestuur a org:Organization .
|
||||||
?bestuur a org:Organization .
|
|
||||||
OPTIONAL { ?bestuur skos:prefLabel ?label. }
|
|
||||||
}
|
|
||||||
|
|
||||||
OPTIONAL {
|
|
||||||
?bestuur org:classification ?classificationUri .
|
|
||||||
?classificationUri skos:prefLabel ?classification.
|
|
||||||
}
|
|
||||||
|
|
||||||
OPTIONAL {
|
|
||||||
?bestuur ere:typeEredienst ?typeEredienstUri.
|
|
||||||
?typeEredienstUri skos:prefLabel ?typeEredienst.
|
|
||||||
}
|
|
||||||
|
|
||||||
FILTER (?g IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service>, <http://mu.semte.ch/graphs/shared>))
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const queryResponsePart1 = await batchedQuery(queryStringPart1);
|
|
||||||
|
|
||||||
const dataPart1 = queryResponsePart1.results.bindings.reduce((acc, row) => {
|
|
||||||
acc[getSafeValue(row, "bestuur")] = {
|
|
||||||
bestuur: getSafeValue(row, "bestuur"),
|
|
||||||
label: getSafeValue(row, "label"),
|
|
||||||
classification: getSafeValue(row, "classification"),
|
|
||||||
typeEredienst: getSafeValue(row, "typeEredienst"),
|
|
||||||
};
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const queryStringPart2 = `
|
|
||||||
${PREFIXES}
|
|
||||||
|
|
||||||
SELECT DISTINCT ?bestuur ?provincie
|
|
||||||
WHERE {
|
|
||||||
GRAPH ?g {
|
|
||||||
?bestuur a org:Organization .
|
|
||||||
}
|
|
||||||
|
|
||||||
OPTIONAL {
|
|
||||||
GRAPH ?h {
|
|
||||||
?bestuur org:hasPrimarySite ?primarySite.
|
|
||||||
|
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
?primarySite organisatie:bestaatUit ?sa.
|
?bestuur <http://www.w3.org/ns/org#hasPrimarySite> ?site.
|
||||||
OPTIONAL { ?sa locn:adminUnitL2 ?provincie. }
|
?site <https://data.vlaanderen.be/ns/organisatie#bestaatUit> ?address.
|
||||||
|
?address <http://www.w3.org/ns/locn#adminUnitL2> ?provincie
|
||||||
}
|
}
|
||||||
}
|
OPTIONAL {?bestuur <http://data.lblod.info/vocabularies/erediensten/typeEredienst> ?typeEredienst.}
|
||||||
FILTER (?h IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service> ))
|
OPTIONAL {?bestuur skos:prefLabel ?label}
|
||||||
}
|
OPTIONAL {
|
||||||
|
?bestuur <http://www.w3.org/ns/org#classification> ?org_classification .
|
||||||
FILTER (?g IN ( <http://mu.semte.ch/graphs/administrative-unit>, <http://mu.semte.ch/graphs/worship-service>, <http://mu.semte.ch/graphs/shared>))
|
?org_classification skos:prefLabel ?classification
|
||||||
|
}
|
||||||
|
OPTIONAL {
|
||||||
|
?bestuur <http://www.w3.org/ns/regorg#orgStatus> ?org_status.
|
||||||
|
?org_status skos:prefLabel ?status.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const queryResponsePart2 = await batchedQuery(queryStringPart2);
|
const queryResponse = await batchedQuery(queryString);
|
||||||
const dataPart2 = queryResponsePart2.results.bindings.reduce((acc, row) => {
|
|
||||||
let dataPart = {
|
|
||||||
bestuur: getSafeValue(row, "bestuur"),
|
|
||||||
provincie: getSafeValue(row, "provincie"),
|
|
||||||
};
|
|
||||||
|
|
||||||
acc[getSafeValue(row, "bestuur")] = Object.assign(
|
const data = queryResponse.results.bindings.map((row) => ({
|
||||||
dataPart,
|
"bestuur": getSafeValue(row, "bestuur"),
|
||||||
dataPart1[getSafeValue(row, "bestuur")],
|
"label": getSafeValue(row, "label"),
|
||||||
);
|
"classification": getSafeValue(row, "classification"),
|
||||||
return acc;
|
"typeEredienst": getSafeValue(row, "typeEredienst"),
|
||||||
}, {});
|
"provincie": getSafeValue(row, "provincie"),
|
||||||
|
"status": getSafeValue(row, "status"),
|
||||||
|
}));
|
||||||
|
|
||||||
await generateReportFromData(
|
await generateReportFromData(
|
||||||
Object.values(dataPart2),
|
data,
|
||||||
["bestuur", "label", "classification", "typeEredienst", "provincie"],
|
[
|
||||||
reportData,
|
"bestuur",
|
||||||
|
"label",
|
||||||
|
"classification",
|
||||||
|
"typeEredienst",
|
||||||
|
"provincie",
|
||||||
|
"status",
|
||||||
|
],
|
||||||
|
reportData,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user