Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9fc97995 | ||
|
|
0baaec1614 | ||
|
|
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>"
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
296
app.js
296
app.js
@@ -1,100 +1,286 @@
|
||||
import { app, errorHandler } from 'mu';
|
||||
import fetch from 'node-fetch';
|
||||
import { CronJob } from 'cron';
|
||||
import { app, errorHandler } from "mu";
|
||||
import fetch from "node-fetch";
|
||||
import { CronJob } from "cron";
|
||||
import {
|
||||
getIdentifiers,
|
||||
getAbbOrganizationInfo,
|
||||
constructOvoStructure,
|
||||
updateOvoNumberAndUri,
|
||||
getAllOvoAndKboCouples
|
||||
createNewKboOrg,
|
||||
linkAbbOrgToKboOrg,
|
||||
getKboOrganizationInfo,
|
||||
updateKboOrg,
|
||||
getAllAbbKboOrganizations,
|
||||
} 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 {
|
||||
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();
|
||||
|
||||
let wegwijsOvo = null;
|
||||
if (data.length) {
|
||||
// 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
|
||||
if (wegwijsInfo.ovoNumber)
|
||||
wegwijsOvo = wegwijsInfo.ovoNumber;
|
||||
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
|
||||
const kboObject = getKboFields(wegwijsInfo);
|
||||
const kboIdentifiers = await getKboOrganizationInfo(
|
||||
abbOrganizationInfo.adminUnit
|
||||
);
|
||||
|
||||
if (!kboIdentifiers && kboObject) {
|
||||
await createKbo(
|
||||
kboObject,
|
||||
abbOrganizationInfo.kboId,
|
||||
abbOrganizationInfo.adminUnit
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (isUpdateNeeded(kboObject, kboIdentifiers)) {
|
||||
await updateKboOrg(kboObject, kboIdentifiers);
|
||||
}
|
||||
|
||||
if (wegwijsOvo && (wegwijsOvo != identifiers.ovo)) {
|
||||
let ovoStructuredIdUri = identifiers.ovoStructuredId;
|
||||
let wegwijsOvo = kboObject.ovoNumber ?? null;
|
||||
|
||||
//Update Ovo Number
|
||||
if (wegwijsOvo && wegwijsOvo != abbOrganizationInfo.ovo) {
|
||||
let ovoStructuredIdUri = abbOrganizationInfo.ovoStructuredId;
|
||||
|
||||
if (!ovoStructuredIdUri) {
|
||||
ovoStructuredIdUri = await constructOvoStructure(identifiers.kboStructuredId);
|
||||
ovoStructuredIdUri = await constructOvoStructure(
|
||||
abbOrganizationInfo.kboStructuredId
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
console.log("Something went wrong while calling /sync-from-kbo", e);
|
||||
return res.status(500).send();
|
||||
return setServerStatus(API_STATUS_CODES.CUSTOM_SERVER_ERROR, res, e);
|
||||
}
|
||||
});
|
||||
|
||||
new CronJob(CRON_PATTERN, async function() {
|
||||
const now = new Date().toISOString();
|
||||
console.log(`OVO numbers healing triggered by cron job at ${now}`);
|
||||
try {
|
||||
await healOvoNumbers();
|
||||
} catch (err) {
|
||||
console.log(`An error occurred during OVO numbers healing at ${now}: ${err}`)
|
||||
}
|
||||
}, null, true);
|
||||
function getKboFields(data) {
|
||||
const {
|
||||
changeTime,
|
||||
shortName,
|
||||
ovoNumber,
|
||||
kboNumber,
|
||||
labels = [],
|
||||
contacts = [],
|
||||
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 {
|
||||
console.log('Healing starting...');
|
||||
const identifiersCouplesOP = await getAllOvoAndKboCouples();
|
||||
const identifiersCouplesWegwijs = await getAllOvoAndKboCouplesWegwijs();
|
||||
|
||||
for (const identifiersCoupleOP of identifiersCouplesOP) {
|
||||
const wegwijsOvo = identifiersCouplesWegwijs[identifiersCoupleOP.kbo];
|
||||
// If a KBO can't be found in wegwijs but we already have an OVO for it in OP, we keep that OVO.
|
||||
// It happens especially a lot for worship services that sometimes lack data in Wegwijs
|
||||
if (wegwijsOvo && (identifiersCoupleOP.ovo != wegwijsOvo)) {
|
||||
// We have a mismatch, let's update the OVO number
|
||||
let ovoStructuredIdUri = identifiersCoupleOP.ovoStructuredId;
|
||||
if (!ovoStructuredIdUri) {
|
||||
ovoStructuredIdUri = await constructOvoStructure(identifiersCoupleOP.kboStructuredId);
|
||||
console.log("Healing wegwijs info starting...");
|
||||
const kboIdentifiersOP = await getAllAbbKboOrganizations();
|
||||
const kboIdentifiersWegwijs = await getAllOvoAndKboCouplesWegwijs();
|
||||
|
||||
for (const kboIdentifierOP of kboIdentifiersOP) {
|
||||
const wegwijsKboOrg = kboIdentifiersWegwijs[kboIdentifierOP.kbo];
|
||||
if (wegwijsKboOrg) {
|
||||
const wegwijsOvo = wegwijsKboOrg.ovoNumber;
|
||||
// If a KBO can't be found in wegwijs but we already have an OVO for it in OP, we keep that OVO.
|
||||
// It happens especially a lot for worship services that sometimes lack data in Wegwijs
|
||||
|
||||
if (wegwijsOvo && kboIdentifierOP.ovo != wegwijsOvo) {
|
||||
// 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 getKboOrganizationInfo(
|
||||
kboIdentifierOP.abbOrg
|
||||
);
|
||||
await updateKboOrg(wegwijsKboOrg, kboIdentifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('Healing complete!');
|
||||
console.log("Healing complete!");
|
||||
} 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() {
|
||||
let couples = {};
|
||||
|
||||
const response = await fetch(`https://api.wegwijs.vlaanderen.be/v1/search/organisations?q=kboNumber:/.*[0-9].*/&fields=ovoNumber,kboNumber&scroll=true`);
|
||||
const scrollId = JSON.parse(response.headers.get('x-search-metadata')).scrollId;
|
||||
const response = await fetch(
|
||||
`${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();
|
||||
|
||||
do {
|
||||
data.forEach(unit => {
|
||||
couples[unit.kboNumber] = unit.ovoNumber;
|
||||
data.forEach((unit) => {
|
||||
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();
|
||||
} while (data.length)
|
||||
} while (data.length);
|
||||
|
||||
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);
|
||||
|
||||
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"
|
||||
|
||||
|
||||
523
lib/queries.js
523
lib/queries.js
@@ -1,33 +1,35 @@
|
||||
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 = `
|
||||
SELECT DISTINCT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId WHERE {
|
||||
SELECT DISTINCT ?kbo ?kboId ?ovo ?kboStructuredId ?ovoStructuredId ?organization WHERE {
|
||||
VALUES ?g {
|
||||
<http://mu.semte.ch/graphs/administrative-unit>
|
||||
<http://mu.semte.ch/graphs/worship-service>
|
||||
}
|
||||
GRAPH ?g {
|
||||
?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 .
|
||||
|
||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
||||
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
||||
|
||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
?organization <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
|
||||
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||
|
||||
OPTIONAL {
|
||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
||||
?organization <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
||||
|
||||
?ovoId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?ovoStructuredId ;
|
||||
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
||||
|
||||
OPTIONAL { ?ovoStructuredId <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?ovo . }
|
||||
|
||||
|
||||
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
||||
}
|
||||
}
|
||||
@@ -43,29 +45,78 @@ export async function getIdentifiers(kboStructuredIdUuid) {
|
||||
kboStructuredId: binding.kboStructuredId.value,
|
||||
ovo: binding.ovo?.value,
|
||||
ovoStructuredId: binding.ovoStructuredId?.value,
|
||||
kboId: binding.kboId?.value,
|
||||
adminUnit: binding.organization.value,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function getKboOrganizationInfo(administrativeUnit) {
|
||||
const queryStr = `
|
||||
SELECT DISTINCT ?kboOrg ?abbUnit ?changeTime ?contactPointUri ?addressUri WHERE {
|
||||
VALUES ?g {
|
||||
<http://mu.semte.ch/graphs/administrative-unit>
|
||||
<http://mu.semte.ch/graphs/worship-service>
|
||||
}
|
||||
GRAPH ?g {
|
||||
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||
<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 .
|
||||
|
||||
?kboOrg <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 {
|
||||
kboOrg: binding.kboOrg?.value,
|
||||
abbUnit: binding.abbUnit?.value,
|
||||
changeTime: binding.changeTime?.value,
|
||||
contactPointUri: binding.contactPointUri?.value,
|
||||
addressUri: binding.addressUri?.value,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function constructOvoStructure(kboStructuredId) {
|
||||
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 structuredIdUri = `http://data.lblod.info/id/gestructureerdeIdentificatoren/${structuredIdUuid}`
|
||||
const structuredIdUri = `http://data.lblod.info/id/gestructureerdeIdentificatoren/${structuredIdUuid}`;
|
||||
|
||||
const updateStr = `
|
||||
INSERT {
|
||||
GRAPH ?g {
|
||||
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(idUri)} .
|
||||
?organization <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||
idUri
|
||||
)} .
|
||||
|
||||
${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" ;
|
||||
<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> ;
|
||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(structuredIdUuid)} .
|
||||
${sparqlEscapeUri(
|
||||
structuredIdUri
|
||||
)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||
structuredIdUuid
|
||||
)} .
|
||||
}
|
||||
} WHERE {
|
||||
VALUES ?g {
|
||||
@@ -73,13 +124,17 @@ export async function constructOvoStructure(kboStructuredId) {
|
||||
<http://mu.semte.ch/graphs/worship-service>
|
||||
}
|
||||
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 .
|
||||
|
||||
?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 .
|
||||
|
||||
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
?organization <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
|
||||
FILTER (?notation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||
}
|
||||
@@ -95,7 +150,9 @@ export async function updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo) {
|
||||
DELETE {
|
||||
GRAPH ?g {
|
||||
?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 += `
|
||||
INSERT {
|
||||
GRAPH ?g {
|
||||
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ${sparqlEscapeUri(`http://data.vlaanderen.be/id/organisatie/${wegwijsOvo}`)} .
|
||||
${sparqlEscapeUri(ovoStructuredIdUri)} <https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ${sparqlEscapeString(wegwijsOvo)} .
|
||||
?bestuureseenheid <http://www.w3.org/2002/07/owl#sameAs> ${sparqlEscapeUri(
|
||||
`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 {
|
||||
|
||||
${sparqlEscapeUri(ovoStructuredIdUri)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> .
|
||||
${sparqlEscapeUri(
|
||||
ovoStructuredIdUri
|
||||
)} a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> .
|
||||
|
||||
OPTIONAL {
|
||||
?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 .
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
export async function getAllOvoAndKboCouples() {
|
||||
const queryStr = `
|
||||
SELECT DISTINCT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId WHERE {
|
||||
VALUES ?g {
|
||||
<http://mu.semte.ch/graphs/administrative-unit>
|
||||
<http://mu.semte.ch/graphs/worship-service>
|
||||
}
|
||||
GRAPH ?g {
|
||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
||||
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
||||
|
||||
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
||||
|
||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
|
||||
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||
|
||||
OPTIONAL {
|
||||
?bestuurseeheid <http://www.w3.org/ns/adms#identifier> ?ovoId .
|
||||
|
||||
export async function getAllAbbKboOrganizations() {
|
||||
let queryStr = `
|
||||
SELECT ?kbo ?ovo ?kboStructuredId ?ovoStructuredId ?abbOrg ?kboOrg ?kboId ?changeTime where {
|
||||
VALUES ?g {
|
||||
<http://mu.semte.ch/graphs/administrative-unit>
|
||||
<http://mu.semte.ch/graphs/worship-service>
|
||||
}
|
||||
GRAPH ?g {
|
||||
?kboId <https://data.vlaanderen.be/ns/generiek#gestructureerdeIdentificator> ?kboStructuredId ;
|
||||
<http://www.w3.org/2004/02/skos/core#notation> ?kboNotation .
|
||||
|
||||
?kboStructuredId a <https://data.vlaanderen.be/ns/generiek#GestructureerdeIdentificator> ;
|
||||
<https://data.vlaanderen.be/ns/generiek#lokaleIdentificator> ?kbo .
|
||||
|
||||
?abbOrg <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||
|
||||
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||
FILTER (!regex(?abbOrg, "kboOrganisaties","i"))
|
||||
|
||||
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 ;
|
||||
<http://www.w3.org/2004/02/skos/core#notation> ?ovoNotation .
|
||||
|
||||
@@ -163,24 +252,356 @@ export async function getAllOvoAndKboCouples() {
|
||||
|
||||
FILTER (?ovoNotation IN ("OVO-nummer"@nl, "OVO-nummer"))
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
const result = await query(queryStr);
|
||||
|
||||
if (result.results.bindings.length) {
|
||||
const bindings = result.results.bindings;
|
||||
return bindings.map(binding => {
|
||||
return bindings.map((binding) => {
|
||||
return {
|
||||
kbo: binding.kbo.value,
|
||||
kbo: binding.kbo?.value,
|
||||
kboStructuredId: binding.kboStructuredId.value,
|
||||
ovo: binding.ovo?.value,
|
||||
ovoStructuredId: binding.ovoStructuredId?.value,
|
||||
}
|
||||
kboOrg: binding.kboOrg?.value,
|
||||
abbOrg: binding.abbOrg?.value,
|
||||
kboId: binding.kboId?.value,
|
||||
changeTime: binding.changeTime?.value,
|
||||
};
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function createNewKboOrg(kboOrg, kboId, kboStructuredId) {
|
||||
const newKboOrgIdUuId = uuid();
|
||||
const newKboIdUri = `http://data.lblod.info/id/kboOrganisaties/${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/KboOrganisatie> ;
|
||||
<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>
|
||||
}
|
||||
GRAPH ?g {
|
||||
?organization <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||
kboId
|
||||
)}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
await update(updateStr);
|
||||
return newKboIdUri;
|
||||
}
|
||||
|
||||
export async function updateKboOrg(newKboInfo, identifiers) {
|
||||
//update address
|
||||
await updateKboAddress(newKboInfo, identifiers);
|
||||
|
||||
//update ContactPoint
|
||||
await updateKboContact(newKboInfo, identifiers);
|
||||
|
||||
//update kboOrg
|
||||
await updateKboOrganization(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/KboOrganisatie> .
|
||||
|
||||
}
|
||||
`;
|
||||
|
||||
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 updateKboOrganization(newKboInfo, identifiers) {
|
||||
let updateStr = `
|
||||
DELETE{
|
||||
GRAPH ?g{
|
||||
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||
<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{
|
||||
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie>
|
||||
`;
|
||||
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 {
|
||||
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||
<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(?kboOrg = ${sparqlEscapeUri(identifiers.kboOrg)})
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
await update(updateStr);
|
||||
}
|
||||
|
||||
// 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