Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1caab1e7ba | ||
|
|
121a95e8b3 | ||
|
|
dd60850c5d | ||
|
|
66fa8df3b0 | ||
|
|
f989247576 | ||
|
|
c017f49593 | ||
|
|
16b9fc4eee | ||
|
|
d4ec2d5083 | ||
|
|
63620ce061 | ||
|
|
6b559889d7 | ||
|
|
9c5a6ac4f6 | ||
|
|
adcb348917 | ||
|
|
a93d4ab922 | ||
|
|
8fa52c7c55 | ||
|
|
4827f1bb9b | ||
|
|
0d3922d646 | ||
|
|
b7bbf41090 | ||
|
|
76437af462 | ||
|
|
adc49dbdc9 | ||
|
|
3ae00c1165 | ||
|
|
c0f99d7621 | ||
|
|
9c421e426b | ||
|
|
85e2ed2a05 | ||
|
|
85251f1dfd | ||
|
|
2f48d6b1a8 |
10
.woodpecker/.improvement.yml
Normal file
10
.woodpecker/.improvement.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
steps:
|
||||||
|
build-feature:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
repo: ${CI_REPO}
|
||||||
|
tags: "improvement-${CI_COMMIT_BRANCH##improvement/}"
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
when:
|
||||||
|
branch: improvement/api-expansion*
|
||||||
|
event: push
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
FROM semtech/mu-javascript-template:1.6.0
|
FROM semtech/mu-javascript-template:1.8.0
|
||||||
LABEL maintainer="redpencil.io <info@repdencil.io>"
|
LABEL maintainer="redpencil.io <info@repdencil.io>"
|
||||||
|
|
||||||
|
|||||||
18
api-error-handler.js
Normal file
18
api-error-handler.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export const API_STATUS_CODES = {
|
||||||
|
OK:{
|
||||||
|
STATUS: "OK",
|
||||||
|
CODE: 200
|
||||||
|
},
|
||||||
|
ERROR_NO_DATA_WEGWIJS:{
|
||||||
|
STATUS: "no data has been found, check if kbo numer is correct or organisation has OVO number. Organisation without OVO number are not in wegwijs",
|
||||||
|
CODE: 500
|
||||||
|
},
|
||||||
|
STATUS_NO_DATA_OP:{
|
||||||
|
STATUS: "no kbo number found in OP",
|
||||||
|
CODE: 400,
|
||||||
|
},
|
||||||
|
CUSTOM_SERVER_ERROR:{
|
||||||
|
STATUS: '',
|
||||||
|
CODE: 500
|
||||||
|
}
|
||||||
|
}
|
||||||
293
app.js
293
app.js
@@ -1,100 +1,285 @@
|
|||||||
import { app, errorHandler } from 'mu';
|
import { app, errorHandler } from "mu";
|
||||||
import fetch from 'node-fetch';
|
import fetch from "node-fetch";
|
||||||
import { CronJob } from 'cron';
|
import { CronJob } from "cron";
|
||||||
import {
|
import {
|
||||||
getIdentifiers,
|
getAbbOrganizationInfo,
|
||||||
constructOvoStructure,
|
constructOvoStructure,
|
||||||
updateOvoNumberAndUri,
|
updateOvoNumberAndUri,
|
||||||
getAllOvoAndKboCouples
|
createNewKboOrg,
|
||||||
|
linkAbbOrgToKboOrg,
|
||||||
|
getKboOrgnizationInfo,
|
||||||
|
updateKboOrg,
|
||||||
|
getAllAbbKboOrganizations,
|
||||||
} from "./lib/queries";
|
} from "./lib/queries";
|
||||||
import { CRON_PATTERN } from './config';
|
import {
|
||||||
|
CRON_PATTERN,
|
||||||
|
ORGANIZATION_STATUS,
|
||||||
|
WEGWIJS_API,
|
||||||
|
WEGWIJS_API_FIELDS,
|
||||||
|
} from "./config";
|
||||||
|
import { API_STATUS_CODES } from "./api-error-handler";
|
||||||
|
import { WEGWIJS_DATA_OBJECT_IDS } from "./wegwijs-object-data-ids";
|
||||||
|
|
||||||
app.post('/sync-from-kbo/:kboStructuredIdUuid', async function(req, res) {
|
app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
|
||||||
try {
|
try {
|
||||||
const kboStructuredIdUuid = req.params.kboStructuredIdUuid;
|
const kboStructuredIdUuid = req.params.kboStructuredIdUuid;
|
||||||
const identifiers = await getIdentifiers(kboStructuredIdUuid);
|
const abbOrganizationInfo = await getAbbOrganizationInfo(
|
||||||
|
kboStructuredIdUuid
|
||||||
|
);
|
||||||
|
|
||||||
const response = await fetch(`https://api.wegwijs.vlaanderen.be/v1/search/organisations?q=kboNumber:${identifiers.kbo}&fields=ovoNumber,kboNumber)`);
|
if (!abbOrganizationInfo?.kbo) {
|
||||||
|
return setServerStatus(API_STATUS_CODES.STATUS_NO_DATA_OP, res);
|
||||||
|
}
|
||||||
|
const wegwijsUrl = `${WEGWIJS_API}?q=kboNumber:${abbOrganizationInfo.kbo}&fields=${WEGWIJS_API_FIELDS}`;
|
||||||
|
console.log("url: " + wegwijsUrl);
|
||||||
|
|
||||||
|
const response = await fetch(wegwijsUrl);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
let wegwijsOvo = null;
|
if (!data.length) {
|
||||||
if (data.length) {
|
return setServerStatus(API_STATUS_CODES.ERROR_NO_DATA_WEGWIJS, res);
|
||||||
// We got a match on the KBO, getting the associated OVO back
|
}
|
||||||
const wegwijsInfo = data[0]; // Wegwijs should only have only one entry per KBO
|
// We got a match on the KBO, getting the associated OVO back
|
||||||
if (wegwijsInfo.ovoNumber)
|
const wegwijsInfo = data[0]; // Wegwijs should only have only one entry per KBO
|
||||||
wegwijsOvo = wegwijsInfo.ovoNumber;
|
const kboObject = getKboFields(wegwijsInfo);
|
||||||
|
const kboIdentifiers = await getKboOrgnizationInfo(
|
||||||
|
abbOrganizationInfo.adminUnit
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!kboIdentifiers && kboObject) {
|
||||||
|
await createKbo(
|
||||||
|
kboObject,
|
||||||
|
abbOrganizationInfo.kboId,
|
||||||
|
abbOrganizationInfo.adminUnit
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wegwijsOvo && (wegwijsOvo != identifiers.ovo)) {
|
if (isUpdateNeeded(kboObject, kboIdentifiers)) {
|
||||||
let ovoStructuredIdUri = identifiers.ovoStructuredId;
|
await updateKboOrg(kboObject, kboIdentifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
let wegwijsOvo = kboObject.ovoNumber ?? null;
|
||||||
|
|
||||||
|
//Update Ovo Number
|
||||||
|
if (wegwijsOvo && wegwijsOvo != abbOrganizationInfo.ovo) {
|
||||||
|
let ovoStructuredIdUri = abbOrganizationInfo.ovoStructuredId;
|
||||||
|
|
||||||
if (!ovoStructuredIdUri) {
|
if (!ovoStructuredIdUri) {
|
||||||
ovoStructuredIdUri = await constructOvoStructure(identifiers.kboStructuredId);
|
ovoStructuredIdUri = await constructOvoStructure(
|
||||||
|
abbOrganizationInfo.kboStructuredId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).send(); // since we await, it should be 200
|
return setServerStatus(API_STATUS_CODES.OK, res); // since we await, it should be 200
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Something went wrong while calling /sync-from-kbo", e);
|
return setServerStatus(API_STATUS_CODES.CUSTOM_SERVER_ERROR, res, e);
|
||||||
return res.status(500).send();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new CronJob(CRON_PATTERN, async function() {
|
function getKboFields(data) {
|
||||||
const now = new Date().toISOString();
|
const {
|
||||||
console.log(`OVO numbers healing triggered by cron job at ${now}`);
|
changeTime,
|
||||||
try {
|
shortName,
|
||||||
await healOvoNumbers();
|
ovoNumber,
|
||||||
} catch (err) {
|
kboNumber,
|
||||||
console.log(`An error occurred during OVO numbers healing at ${now}: ${err}`)
|
labels = [],
|
||||||
}
|
contacts = [],
|
||||||
}, null, true);
|
organisationClassifications = [],
|
||||||
|
locations = [],
|
||||||
|
} = data;
|
||||||
|
|
||||||
async function healOvoNumbers() {
|
//no labels = undefined
|
||||||
|
//formal name according to KBO
|
||||||
|
let formalName = extractObjectData(
|
||||||
|
labels,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.LABELS
|
||||||
|
)?.value;
|
||||||
|
let email = extractObjectData(
|
||||||
|
contacts,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.CONTACTS.EMAIL
|
||||||
|
)?.value;
|
||||||
|
let phone = extractObjectData(
|
||||||
|
contacts,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.CONTACTS.PHONE
|
||||||
|
)?.value;
|
||||||
|
let website = extractObjectData(
|
||||||
|
contacts,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.CONTACTS.WEBSITE
|
||||||
|
)?.value;
|
||||||
|
|
||||||
|
//main location according to KBO
|
||||||
|
let formattedAddress = extractObjectData(
|
||||||
|
locations,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.ADDRESS
|
||||||
|
)?.formattedAddress;
|
||||||
|
let adressComponent = extractObjectData(
|
||||||
|
locations,
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.ADDRESS
|
||||||
|
)?.components;
|
||||||
|
|
||||||
|
let rechtsvorm = organisationClassifications?.find((fields) => {
|
||||||
|
return (
|
||||||
|
fields[WEGWIJS_DATA_OBJECT_IDS.RECHTSVORM.NAME] ===
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.RECHTSVORM.ID_1 ||
|
||||||
|
fields.organisationClassificationTypeId ===
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.RECHTSVORM.ID_2
|
||||||
|
);
|
||||||
|
})?.organisationClassificationName;
|
||||||
|
|
||||||
|
let startDate = labels?.find((fields) => {
|
||||||
|
return (
|
||||||
|
fields[WEGWIJS_DATA_OBJECT_IDS.LABELS.NAME] ===
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.LABELS.ID
|
||||||
|
);
|
||||||
|
})?.validity?.start;
|
||||||
|
|
||||||
|
let activeState = labels?.find((fields) => {
|
||||||
|
return (
|
||||||
|
fields[WEGWIJS_DATA_OBJECT_IDS.LABELS.NAME] ===
|
||||||
|
WEGWIJS_DATA_OBJECT_IDS.LABELS.ID &&
|
||||||
|
!fields.validity.hasOwnProperty("end")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
? ORGANIZATION_STATUS.ACTIVE
|
||||||
|
: ORGANIZATION_STATUS.INACTIVE;
|
||||||
|
|
||||||
|
//currently no commercial name available
|
||||||
|
return {
|
||||||
|
changeTime,
|
||||||
|
shortName,
|
||||||
|
ovoNumber,
|
||||||
|
kboNumber,
|
||||||
|
formalName,
|
||||||
|
startDate,
|
||||||
|
activeState,
|
||||||
|
rechtsvorm,
|
||||||
|
email,
|
||||||
|
phone,
|
||||||
|
website,
|
||||||
|
formattedAddress,
|
||||||
|
adressComponent,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
new CronJob(
|
||||||
|
CRON_PATTERN,
|
||||||
|
async function () {
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
console.log(`Wegwijs data healing triggered by cron job at ${now}`);
|
||||||
|
try {
|
||||||
|
await healAbbWithWegWijsData();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(
|
||||||
|
`An error occurred during wegwijs data healing at ${now}: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
async function healAbbWithWegWijsData() {
|
||||||
try {
|
try {
|
||||||
console.log('Healing starting...');
|
console.log("Healing wegwijs info starting...");
|
||||||
const identifiersCouplesOP = await getAllOvoAndKboCouples();
|
const kboIdentifiersOP = await getAllAbbKboOrganizations();
|
||||||
const identifiersCouplesWegwijs = await getAllOvoAndKboCouplesWegwijs();
|
const kboIdentifiersWegwijs = await getAllOvoAndKboCouplesWegwijs();
|
||||||
|
|
||||||
for (const identifiersCoupleOP of identifiersCouplesOP) {
|
for (const kboIdentifierOP of kboIdentifiersOP) {
|
||||||
const wegwijsOvo = identifiersCouplesWegwijs[identifiersCoupleOP.kbo];
|
const wegwijsKboOrg = kboIdentifiersWegwijs[kboIdentifierOP.kbo];
|
||||||
// If a KBO can't be found in wegwijs but we already have an OVO for it in OP, we keep that OVO.
|
if (wegwijsKboOrg) {
|
||||||
// It happens especially a lot for worship services that sometimes lack data in Wegwijs
|
const wegwijsOvo = wegwijsKboOrg.ovoNumber;
|
||||||
if (wegwijsOvo && (identifiersCoupleOP.ovo != wegwijsOvo)) {
|
// If a KBO can't be found in wegwijs but we already have an OVO for it in OP, we keep that OVO.
|
||||||
// We have a mismatch, let's update the OVO number
|
// It happens especially a lot for worship services that sometimes lack data in Wegwijs
|
||||||
let ovoStructuredIdUri = identifiersCoupleOP.ovoStructuredId;
|
|
||||||
if (!ovoStructuredIdUri) {
|
if (wegwijsOvo && kboIdentifierOP.ovo != wegwijsOvo) {
|
||||||
ovoStructuredIdUri = await constructOvoStructure(identifiersCoupleOP.kboStructuredId);
|
// We have a mismatch, let's update the OVO number
|
||||||
|
let ovoStructuredIdUri = kboIdentifierOP.ovoStructuredId;
|
||||||
|
|
||||||
|
console.log(ovoStructuredIdUri);
|
||||||
|
|
||||||
|
if (!ovoStructuredIdUri) {
|
||||||
|
ovoStructuredIdUri = await constructOvoStructure(
|
||||||
|
kboIdentifierOP.kboStructuredId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
if (!kboIdentifierOP?.kboOrg) {
|
||||||
|
await createKbo(
|
||||||
|
wegwijsKboOrg,
|
||||||
|
kboIdentifierOP.kboId,
|
||||||
|
kboIdentifierOP.abbOrg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUpdateNeeded(wegwijsKboOrg, kboIdentifierOP)) {
|
||||||
|
const kboIdentifiers = await getKboOrgnizationInfo(
|
||||||
|
kboIdentifierOP.abbOrg
|
||||||
|
);
|
||||||
|
await updateKboOrg(wegwijsKboOrg, kboIdentifiers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('Healing complete!');
|
console.log("Healing complete!");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`An error occurred during OVO numbers healing: ${err}`)
|
console.log(`An error occurred during wegwijs info healing: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllOvoAndKboCouplesWegwijs() {
|
async function getAllOvoAndKboCouplesWegwijs() {
|
||||||
let couples = {};
|
let couples = {};
|
||||||
|
|
||||||
const response = await fetch(`https://api.wegwijs.vlaanderen.be/v1/search/organisations?q=kboNumber:/.*[0-9].*/&fields=ovoNumber,kboNumber&scroll=true`);
|
const response = await fetch(
|
||||||
const scrollId = JSON.parse(response.headers.get('x-search-metadata')).scrollId;
|
`${WEGWIJS_API}?q=kboNumber:/.*[0-9].*/&fields=${WEGWIJS_API_FIELDS},parents&scroll=true`
|
||||||
|
);
|
||||||
|
const scrollId = JSON.parse(
|
||||||
|
response.headers.get("x-search-metadata")
|
||||||
|
).scrollId;
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
data.forEach(unit => {
|
data.forEach((unit) => {
|
||||||
couples[unit.kboNumber] = unit.ovoNumber;
|
const wegwijsUnit = getKboFields(unit);
|
||||||
|
couples[wegwijsUnit.kboNumber] = wegwijsUnit;
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await fetch(`https://api.wegwijs.vlaanderen.be/v1/search/organisations/scroll?id=${scrollId}`);
|
const response = await fetch(`${WEGWIJS_API}/scroll?id=${scrollId}`);
|
||||||
data = await response.json();
|
data = await response.json();
|
||||||
} while (data.length)
|
} while (data.length);
|
||||||
|
|
||||||
return couples;
|
return couples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isUpdateNeeded(kboWegwijs, kboAbb) {
|
||||||
|
let update = false;
|
||||||
|
if (kboWegwijs?.changeTime && kboAbb?.changeTime) {
|
||||||
|
update =
|
||||||
|
new Date(kboWegwijs.changeTime).getTime() >
|
||||||
|
new Date(kboAbb.changeTime).getTime();
|
||||||
|
}
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createKbo(wegwijsKboOrg, kboId, abbOrg) {
|
||||||
|
let newKboOrgUri = await createNewKboOrg(wegwijsKboOrg, kboId);
|
||||||
|
await linkAbbOrgToKboOrg(abbOrg, newKboOrgUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setServerStatus(statusCode, res, message) {
|
||||||
|
if (statusCode.CODE === 500) {
|
||||||
|
console.log("Something went wrong while calling /sync-from-kbo", message);
|
||||||
|
}
|
||||||
|
return res.status(statusCode.CODE).send(statusCode.STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractObjectData(array, field) {
|
||||||
|
return array?.find((fields) => {
|
||||||
|
return fields[field.NAME] === field.ID;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.use(errorHandler);
|
app.use(errorHandler);
|
||||||
|
|||||||
11
config.js
11
config.js
@@ -1 +1,10 @@
|
|||||||
export const CRON_PATTERN = process.env.CRON_PATTERN || '0 0 0 * * *'; // every day at midnight
|
export const CRON_PATTERN = process.env.CRON_PATTERN || '0 0 0 * * *'; // every day at midnight
|
||||||
|
|
||||||
|
export const ORGANIZATION_STATUS = {
|
||||||
|
ACTIVE: "http://lblod.data.gift/concepts/63cc561de9188d64ba5840a42ae8f0d6",
|
||||||
|
INACTIVE: "http://lblod.data.gift/concepts/d02c4e12bf88d2fdf5123b07f29c9311"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WEGWIJS_API = "https://api.wegwijs.vlaanderen.be/v1/search/organisations";
|
||||||
|
export const WEGWIJS_API_FIELDS = "changeTime,name,shortName,ovoNumber,kboNumber,labels,contacts,organisationClassifications,locations"
|
||||||
|
|
||||||
|
|||||||
518
lib/queries.js
518
lib/queries.js
@@ -1,33 +1,35 @@
|
|||||||
import { uuid, sparqlEscapeUri, sparqlEscapeString } from "mu";
|
import { uuid, sparqlEscapeUri, sparqlEscapeString } from "mu";
|
||||||
import { querySudo as query, updateSudo as update } from '@lblod/mu-auth-sudo';
|
import { querySudo as query, updateSudo as update } from "@lblod/mu-auth-sudo";
|
||||||
|
|
||||||
export async function getIdentifiers(kboStructuredIdUuid) {
|
export async function getAbbOrganizationInfo(kboStructuredIdUuid) {
|
||||||
const queryStr = `
|
const queryStr = `
|
||||||
SELECT DISTINCT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId WHERE {
|
SELECT DISTINCT ?kbo ?kboId ?ovo ?kboStructuredId ?ovoStructuredId ?bestuurseenheid WHERE {
|
||||||
VALUES ?g {
|
VALUES ?g {
|
||||||
<http://mu.semte.ch/graphs/administrative-unit>
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
<http://mu.semte.ch/graphs/worship-service>
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
}
|
}
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(kboStructuredIdUuid)} ;
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
kboStructuredIdUuid
|
||||||
|
)} ;
|
||||||
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
||||||
|
|
||||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
||||||
|
|
||||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||||
|
|
||||||
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||||
|
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
||||||
|
|
||||||
?ovoId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?ovoStructuredId ;
|
?ovoId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?ovoStructuredId ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
||||||
|
|
||||||
OPTIONAL { ?ovoStructuredId <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo . }
|
OPTIONAL { ?ovoStructuredId <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo . }
|
||||||
|
|
||||||
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,29 +45,78 @@ export async function getIdentifiers(kboStructuredIdUuid) {
|
|||||||
kboStructuredId: binding.kboStructuredId.value,
|
kboStructuredId: binding.kboStructuredId.value,
|
||||||
ovo: binding.ovo?.value,
|
ovo: binding.ovo?.value,
|
||||||
ovoStructuredId: binding.ovoStructuredId?.value,
|
ovoStructuredId: binding.ovoStructuredId?.value,
|
||||||
|
kboId: binding.kboId?.value,
|
||||||
|
adminUnit: binding.bestuurseenheid.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getKboOrgnizationInfo(administrativeUnit) {
|
||||||
|
const queryStr = `
|
||||||
|
SELECT DISTINCT ?kboUnit ?abbUnit ?changeTime ?contactPointUri ?addressUri WHERE {
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
|
}
|
||||||
|
GRAPH ?g {
|
||||||
|
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/core/uuid> ?uuid ;
|
||||||
|
<http://schema.org/contactPoint> ?contactPointUri ;
|
||||||
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime .
|
||||||
|
|
||||||
|
?contactPointUri <http://www.w3.org/ns/locn#address> ?addressUri .
|
||||||
|
|
||||||
|
?kboUnit <http://www.w3.org/2002/07/owl#sameAs> ?abbUnit
|
||||||
|
|
||||||
|
FILTER(?abbUnit = ${sparqlEscapeUri(administrativeUnit)})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await query(queryStr);
|
||||||
|
|
||||||
|
if (result.results.bindings.length) {
|
||||||
|
const binding = result.results.bindings[0];
|
||||||
|
return {
|
||||||
|
kboUnit: binding.kboUnit?.value,
|
||||||
|
abbUnit: binding.abbUnit?.value,
|
||||||
|
changeTime: binding.changeTime?.value,
|
||||||
|
contactPointUri: binding.contactPointUri?.value,
|
||||||
|
addressUri: binding.addressUri?.value,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function constructOvoStructure(kboStructuredId) {
|
export async function constructOvoStructure(kboStructuredId) {
|
||||||
const idUuid = uuid();
|
const idUuid = uuid();
|
||||||
const idUri = `http://data.lblod.info/id/identificatoren/${idUuid}`
|
const idUri = `http://data.lblod.info/id/identificatoren/${idUuid}`;
|
||||||
const structuredIdUuid = uuid();
|
const structuredIdUuid = uuid();
|
||||||
const structuredIdUri = `http://data.lblod.info/id/gestructureerdeIdentificatoren/${structuredIdUuid}`
|
const structuredIdUri = `http://data.lblod.info/id/gestructureerdeIdentificatoren/${structuredIdUuid}`;
|
||||||
|
|
||||||
const updateStr = `
|
const updateStr = `
|
||||||
INSERT {
|
INSERT {
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(idUri)} .
|
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||||
|
idUri
|
||||||
|
)} .
|
||||||
|
|
||||||
${sparqlEscapeUri(idUri)} a <http://www.w3.org/ns/adms#Identifier> ;
|
${sparqlEscapeUri(idUri)} a <http://www.w3.org/ns/adms#Identifier> ;
|
||||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(idUuid)} ;
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
idUuid
|
||||||
|
)} ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> "OVO-nummer" ;
|
<http://www.w3.org/2004/02/skos/core#notation> "OVO-nummer" ;
|
||||||
<https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(structuredIdUri)} .
|
<https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(
|
||||||
|
structuredIdUri
|
||||||
|
)} .
|
||||||
|
|
||||||
${sparqlEscapeUri(structuredIdUri)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
${sparqlEscapeUri(
|
||||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(structuredIdUuid)} .
|
structuredIdUri
|
||||||
|
)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
structuredIdUuid
|
||||||
|
)} .
|
||||||
}
|
}
|
||||||
} WHERE {
|
} WHERE {
|
||||||
VALUES ?g {
|
VALUES ?g {
|
||||||
@@ -73,10 +124,14 @@ export async function constructOvoStructure(kboStructuredId) {
|
|||||||
<http://mu.semte.ch/graphs/worship-service>
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
}
|
}
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
${sparqlEscapeUri(kboStructuredId)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
${sparqlEscapeUri(
|
||||||
|
kboStructuredId
|
||||||
|
)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||||
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
||||||
|
|
||||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(kboStructuredId)} ;
|
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(
|
||||||
|
kboStructuredId
|
||||||
|
)} ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> ?notation .
|
<http://www.w3.org/2004/02/skos/core#notation> ?notation .
|
||||||
|
|
||||||
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||||
@@ -95,7 +150,9 @@ export async function updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo) {
|
|||||||
DELETE {
|
DELETE {
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ?ovoUri .
|
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ?ovoUri .
|
||||||
${sparqlEscapeUri(ovoStructuredIdUri)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo .
|
${sparqlEscapeUri(
|
||||||
|
ovoStructuredIdUri
|
||||||
|
)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -104,8 +161,14 @@ export async function updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo) {
|
|||||||
updateStr += `
|
updateStr += `
|
||||||
INSERT {
|
INSERT {
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ${sparqlEscapeUri(`http://data.vlaanderen.be/id/organisatie/${wegwijsOvo}`)} .
|
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ${sparqlEscapeUri(
|
||||||
${sparqlEscapeUri(ovoStructuredIdUri)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ${sparqlEscapeString(wegwijsOvo)} .
|
`http://data.vlaanderen.be/id/organisatie/${wegwijsOvo}`
|
||||||
|
)} .
|
||||||
|
${sparqlEscapeUri(
|
||||||
|
ovoStructuredIdUri
|
||||||
|
)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ${sparqlEscapeString(
|
||||||
|
wegwijsOvo
|
||||||
|
)} .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -119,15 +182,21 @@ export async function updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo) {
|
|||||||
}
|
}
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
|
|
||||||
${sparqlEscapeUri(ovoStructuredIdUri)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> .
|
${sparqlEscapeUri(
|
||||||
|
ovoStructuredIdUri
|
||||||
|
)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> .
|
||||||
|
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
?bestuureseenheid
|
?bestuureseenheid
|
||||||
<http://www.w3.org/ns/adms#identifier>/<https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(ovoStructuredIdUri)} ;
|
<http://www.w3.org/ns/adms#identifier>/<https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ${sparqlEscapeUri(
|
||||||
|
ovoStructuredIdUri
|
||||||
|
)} ;
|
||||||
<http://www.w3.org/2002/07/owl#sameAs> ?ovoUri .
|
<http://www.w3.org/2002/07/owl#sameAs> ?ovoUri .
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTIONAL { ${sparqlEscapeUri(ovoStructuredIdUri)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo . }
|
OPTIONAL { ${sparqlEscapeUri(
|
||||||
|
ovoStructuredIdUri
|
||||||
|
)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo . }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -135,27 +204,47 @@ export async function updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo) {
|
|||||||
await update(updateStr);
|
await update(updateStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllOvoAndKboCouples() {
|
export async function getAllAbbKboOrganizations() {
|
||||||
const queryStr = `
|
let queryStr = `
|
||||||
SELECT DISTINCT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId WHERE {
|
SELECT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId ?abbOrg ?kboOrg ?kboId ?changeTime where {
|
||||||
VALUES ?g {
|
VALUES ?g {
|
||||||
<http://mu.semte.ch/graphs/administrative-unit>
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
<http://mu.semte.ch/graphs/worship-service>
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
}
|
}
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
||||||
|
|
||||||
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||||
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
||||||
|
|
||||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
?abbOrg <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||||
|
|
||||||
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||||
|
FILTER (!regex(?abbOrg, "kboBestuurseenheden","i"))
|
||||||
OPTIONAL {
|
|
||||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
OPTIONAL{
|
||||||
|
?kboOrg owl:sameAs ?abbOrg .
|
||||||
|
?kboOrg <https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVrom ;
|
||||||
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
|
<http://www.w3.org/ns/regorg#legalName> ?legalName ;
|
||||||
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState ;
|
||||||
|
<http://schema.org/contactPoint> ?contact .
|
||||||
|
|
||||||
|
?contact <http://schema.org/email> ?email ;
|
||||||
|
<http://schema.org/telephone> ?phone ;
|
||||||
|
<http://schema.org/contactType> ?contactType ;
|
||||||
|
<http://xmlns.com/foaf/0.1/page> ?website ;
|
||||||
|
<http://www.w3.org/ns/locn#address> ?address .
|
||||||
|
|
||||||
|
?address <http://www.w3.org/ns/locn#fullAddress> ?fullAddress.
|
||||||
|
|
||||||
|
}
|
||||||
|
OPTIONAL{
|
||||||
|
?abbOrg <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
||||||
|
|
||||||
?ovoId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?ovoStructuredId ;
|
?ovoId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?ovoStructuredId ;
|
||||||
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
||||||
|
|
||||||
@@ -163,24 +252,353 @@ export async function getAllOvoAndKboCouples() {
|
|||||||
|
|
||||||
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
|
||||||
|
`;
|
||||||
const result = await query(queryStr);
|
const result = await query(queryStr);
|
||||||
|
|
||||||
if (result.results.bindings.length) {
|
if (result.results.bindings.length) {
|
||||||
const bindings = result.results.bindings;
|
const bindings = result.results.bindings;
|
||||||
return bindings.map(binding => {
|
return bindings.map((binding) => {
|
||||||
return {
|
return {
|
||||||
kbo: binding.kbo.value,
|
kbo: binding.kbo?.value,
|
||||||
kboStructuredId: binding.kboStructuredId.value,
|
kboStructuredId: binding.kboStructuredId.value,
|
||||||
ovo: binding.ovo?.value,
|
ovo: binding.ovo?.value,
|
||||||
ovoStructuredId: binding.ovoStructuredId?.value,
|
ovoStructuredId: binding.ovoStructuredId?.value,
|
||||||
}
|
kboOrg: binding.kboOrg?.value,
|
||||||
|
abbOrg: binding.abbOrg?.value,
|
||||||
|
kboId: binding.kboId?.value,
|
||||||
|
changeTime: binding.changeTime?.value,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function createNewKboOrg(kboOrg, kboId) {
|
||||||
|
const newKboOrgIdUuId = uuid();
|
||||||
|
const newKboIdUri = `http://data.lblod.info/id/kboBestuurseenheden/${newKboOrgIdUuId}`;
|
||||||
|
|
||||||
|
const contactPointUuidId = uuid();
|
||||||
|
const contactPointUri = `http://data.lblod.info/id/contact-punten/${contactPointUuidId}`;
|
||||||
|
|
||||||
|
const adressUuidId = uuid();
|
||||||
|
const adressUri = `http://data.lblod.info/id/adressen/${adressUuidId}`;
|
||||||
|
|
||||||
|
let updateStr = `
|
||||||
|
INSERT {
|
||||||
|
GRAPH ?g {
|
||||||
|
${sparqlEscapeUri(adressUri)} a <http://www.w3.org/ns/locn#Address> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
adressUuidId
|
||||||
|
)} `;
|
||||||
|
if (kboOrg.formattedAddress) {
|
||||||
|
updateStr += `;
|
||||||
|
<http://www.w3.org/ns/locn#fullAddress> ${sparqlEscapeString(
|
||||||
|
kboOrg.formattedAddress
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
updateStr += " .";
|
||||||
|
|
||||||
|
updateStr += `
|
||||||
|
${sparqlEscapeUri(contactPointUri)} a <http://schema.org/ContactPoint> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
contactPointUuidId
|
||||||
|
)} ;
|
||||||
|
<http://purl.org/dc/terms/source> <https://economie.fgov.be/>`;
|
||||||
|
if (kboOrg.email) {
|
||||||
|
updateStr += `; <http://schema.org/email> ${sparqlEscapeString(
|
||||||
|
kboOrg.email
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.phone) {
|
||||||
|
updateStr += `; <http://schema.org/telephone> ${sparqlEscapeString(
|
||||||
|
kboOrg.phone
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.website) {
|
||||||
|
updateStr += `; <http://xmlns.com/foaf/0.1/page> ${sparqlEscapeString(
|
||||||
|
kboOrg.website
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
updateStr += `
|
||||||
|
; <http://schema.org/contactType> ${sparqlEscapeString("Kbocontact")} ;
|
||||||
|
<http://www.w3.org/ns/locn#address> ${sparqlEscapeUri(adressUri)}.`;
|
||||||
|
|
||||||
|
updateStr += ` ${sparqlEscapeUri(
|
||||||
|
newKboIdUri
|
||||||
|
)} a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
|
newKboOrgIdUuId
|
||||||
|
)}`;
|
||||||
|
|
||||||
|
if (kboOrg.rechtsvorm) {
|
||||||
|
updateStr += `; <http://mu.semte.ch/vocabularies/ext/rechtsvorm> ${sparqlEscapeString(
|
||||||
|
kboOrg.rechtsvorm
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.startDate) {
|
||||||
|
updateStr += `; <http://mu.semte.ch/vocabularies/ext/startDate> ${sparqlEscapeString(
|
||||||
|
kboOrg.startDate
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.formalName) {
|
||||||
|
updateStr += `; <http://www.w3.org/ns/regorg#legalName> ${sparqlEscapeString(
|
||||||
|
kboOrg.formalName
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.shortName) {
|
||||||
|
updateStr += `; <http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
|
||||||
|
kboOrg.shortName
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.changeTime) {
|
||||||
|
updateStr += `; <https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ${sparqlEscapeString(
|
||||||
|
kboOrg.changeTime
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboId) {
|
||||||
|
updateStr += `; <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||||
|
kboId
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (kboOrg.activeState) {
|
||||||
|
updateStr += `; <http://www.w3.org/ns/regorg#orgStatus> ${sparqlEscapeUri(
|
||||||
|
kboOrg.activeState
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
updateStr += `; <http://schema.org/contactPoint> ${sparqlEscapeUri(
|
||||||
|
contactPointUri
|
||||||
|
)} .
|
||||||
|
}
|
||||||
|
}WHERE{
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
await update(updateStr);
|
||||||
|
return newKboIdUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateKboOrg(newKboInfo, identifiers) {
|
||||||
|
//update address
|
||||||
|
await updateKboAddress(newKboInfo, identifiers);
|
||||||
|
|
||||||
|
//update ContactPoint
|
||||||
|
await updateKboContact(newKboInfo, identifiers);
|
||||||
|
|
||||||
|
//update kboUnit
|
||||||
|
await updateKboAdministrativeUnit(newKboInfo, identifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function linkAbbOrgToKboOrg(abbOrgUri, kboOrgUri) {
|
||||||
|
if (abbOrgUri && kboOrgUri) {
|
||||||
|
let updateStr = `
|
||||||
|
INSERT {
|
||||||
|
GRAPH ?g {
|
||||||
|
${sparqlEscapeUri(
|
||||||
|
kboOrgUri
|
||||||
|
)} <http://www.w3.org/2002/07/owl#sameAs> ${sparqlEscapeUri(abbOrgUri)} .
|
||||||
|
}
|
||||||
|
}WHERE {
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
<http://mu.semte.ch/graphs/worship-service>
|
||||||
|
}
|
||||||
|
|
||||||
|
${sparqlEscapeUri(
|
||||||
|
kboOrgUri
|
||||||
|
)} a <http://mu.semte.ch/vocabularies/ext/KboEenheid> .
|
||||||
|
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
await update(updateStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateKboAddress(newKboInfo, identifiers) {
|
||||||
|
let updateStr = `
|
||||||
|
DELETE{
|
||||||
|
GRAPH ?g{
|
||||||
|
?adressUri a <http://www.w3.org/ns/locn#Address> ;
|
||||||
|
<http://www.w3.org/ns/locn#fullAddress> ?fulladdress .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
INSERT{
|
||||||
|
graph ?g{
|
||||||
|
?adressUri a <http://www.w3.org/ns/locn#Address>
|
||||||
|
`;
|
||||||
|
if (newKboInfo.formattedAddress) {
|
||||||
|
updateStr += `
|
||||||
|
;
|
||||||
|
<http://www.w3.org/ns/locn#fullAddress> ${sparqlEscapeString(
|
||||||
|
newKboInfo.formattedAddress
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
updateStr += `
|
||||||
|
.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
updateStr += `
|
||||||
|
WHERE{
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
}
|
||||||
|
GRAPH ?g {
|
||||||
|
?adressUri a <http://www.w3.org/ns/locn#Address> ;
|
||||||
|
<http://www.w3.org/ns/locn#fullAddress> ?fulladdress .
|
||||||
|
|
||||||
|
FILTER(?adressUri = ${sparqlEscapeUri(identifiers.addressUri)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
await update(updateStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateKboContact(newKboInfo, identifiers) {
|
||||||
|
let updateStr = `
|
||||||
|
DELETE{
|
||||||
|
GRAPH ?g{
|
||||||
|
?contact a <http://schema.org/ContactPoint> ;
|
||||||
|
<http://schema.org/email> ?email ;
|
||||||
|
<http://schema.org/telephone> ?phone ;
|
||||||
|
<http://xmlns.com/foaf/0.1/page> ?website .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
INSERT{
|
||||||
|
graph ?g{
|
||||||
|
?contact a <http://schema.org/ContactPoint>
|
||||||
|
`;
|
||||||
|
if (newKboInfo.email) {
|
||||||
|
updateStr += `; <http://schema.org/email> ${sparqlEscapeString(
|
||||||
|
newKboInfo.email
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.phone) {
|
||||||
|
updateStr += `; <http://schema.org/telephone> ${sparqlEscapeString(
|
||||||
|
newKboInfo.phone
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.phone) {
|
||||||
|
updateStr += `; <http://xmlns.com/foaf/0.1/page> ${sparqlEscapeString(
|
||||||
|
newKboInfo.website
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
updateStr += `
|
||||||
|
.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
updateStr += `
|
||||||
|
WHERE{
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
}
|
||||||
|
GRAPH ?g {
|
||||||
|
?contact a <http://schema.org/ContactPoint> ;
|
||||||
|
<http://schema.org/email> ?email ;
|
||||||
|
<http://schema.org/telephone> ?phone ;
|
||||||
|
<http://xmlns.com/foaf/0.1/page> ?website .
|
||||||
|
|
||||||
|
FILTER(?contact = ${sparqlEscapeUri(identifiers.contactPointUri)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
await update(updateStr);
|
||||||
|
}
|
||||||
|
async function updateKboAdministrativeUnit(newKboInfo, identifiers) {
|
||||||
|
let updateStr = `
|
||||||
|
DELETE{
|
||||||
|
GRAPH ?g{
|
||||||
|
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
||||||
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
|
<http://www.w3.org/ns/regorg#legalName> ?orgName ;
|
||||||
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
||||||
|
}
|
||||||
|
}
|
||||||
|
INSERT{
|
||||||
|
graph ?g{
|
||||||
|
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid>
|
||||||
|
`;
|
||||||
|
if (newKboInfo.rechtsvorm) {
|
||||||
|
updateStr += `
|
||||||
|
;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ${sparqlEscapeString(
|
||||||
|
newKboInfo.rechtsvorm
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.startDate) {
|
||||||
|
updateStr += `
|
||||||
|
;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/startDate> ${sparqlEscapeString(
|
||||||
|
newKboInfo.startDate
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.formalName) {
|
||||||
|
updateStr += `; <http://www.w3.org/ns/regorg#legalName> ${sparqlEscapeString(
|
||||||
|
newKboInfo.formalName
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.shortName) {
|
||||||
|
updateStr += `; <http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
|
||||||
|
newKboInfo.shortName
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.changeTime) {
|
||||||
|
updateStr += `
|
||||||
|
;
|
||||||
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ${sparqlEscapeString(
|
||||||
|
newKboInfo.changeTime
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (newKboInfo.activeState) {
|
||||||
|
updateStr += `
|
||||||
|
;
|
||||||
|
<http://www.w3.org/ns/regorg#orgStatus> ${sparqlEscapeUri(
|
||||||
|
newKboInfo.activeState
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
updateStr += `
|
||||||
|
.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
updateStr += `
|
||||||
|
WHERE{
|
||||||
|
VALUES ?g {
|
||||||
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
|
}
|
||||||
|
GRAPH ?g {
|
||||||
|
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
||||||
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
|
<http://www.w3.org/ns/regorg#legalName> ?orgName ;
|
||||||
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
||||||
|
|
||||||
|
FILTER(?kboUnit = ${sparqlEscapeUri(identifiers.kboUnit)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
await update(updateStr);
|
||||||
|
}
|
||||||
|
|
||||||
// Update queries: via mu-auth if it comes from the frontend ?
|
// Update queries: via mu-auth if it comes from the frontend ?
|
||||||
|
|||||||
29
wegwijs-object-data-ids.js
Normal file
29
wegwijs-object-data-ids.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export const WEGWIJS_DATA_OBJECT_IDS = {
|
||||||
|
LABELS: {
|
||||||
|
ID: "83c1c22a-6776-0ad6-68d2-819e1c6eec66",
|
||||||
|
NAME: "labelTypeId",
|
||||||
|
},
|
||||||
|
ADDRESS: {
|
||||||
|
ID: "537c0b5b-8ab8-fc3d-0b37-f8249cbdd3ba",
|
||||||
|
NAME: "locationTypeId",
|
||||||
|
},
|
||||||
|
RECHTSVORM: {
|
||||||
|
ID_1: "9bae7539-64fd-5759-743c-ad9dfa4143d4",
|
||||||
|
ID_2: "1131205e-9212-435d-b4cd-b0d955d08bcf",
|
||||||
|
NAME: "organisationClassificationTypeId",
|
||||||
|
},
|
||||||
|
CONTACTS: {
|
||||||
|
EMAIL: {
|
||||||
|
ID: "6763f372-02c5-478c-b7d7-802dc60a64b9",
|
||||||
|
NAME: "contactTypeId",
|
||||||
|
},
|
||||||
|
PHONE: {
|
||||||
|
ID: "d792d4ff-8c34-4336-8434-56ecb40f2fa4",
|
||||||
|
NAME: "contactTypeId",
|
||||||
|
},
|
||||||
|
WEBSITE: {
|
||||||
|
ID: "f611e91d-a811-4519-afa6-08f0e9dcdd9b",
|
||||||
|
NAME: "contactTypeId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user