Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9fc97995 | ||
|
|
0baaec1614 | ||
|
|
1caab1e7ba | ||
|
|
121a95e8b3 |
11
app.js
11
app.js
@@ -7,7 +7,7 @@ import {
|
|||||||
updateOvoNumberAndUri,
|
updateOvoNumberAndUri,
|
||||||
createNewKboOrg,
|
createNewKboOrg,
|
||||||
linkAbbOrgToKboOrg,
|
linkAbbOrgToKboOrg,
|
||||||
getKboOrgnizationInfo,
|
getKboOrganizationInfo,
|
||||||
updateKboOrg,
|
updateKboOrg,
|
||||||
getAllAbbKboOrganizations,
|
getAllAbbKboOrganizations,
|
||||||
} from "./lib/queries";
|
} from "./lib/queries";
|
||||||
@@ -42,7 +42,7 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
|
|||||||
// We got a match on the KBO, getting the associated OVO back
|
// 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 wegwijsInfo = data[0]; // Wegwijs should only have only one entry per KBO
|
||||||
const kboObject = getKboFields(wegwijsInfo);
|
const kboObject = getKboFields(wegwijsInfo);
|
||||||
const kboIdentifiers = await getKboOrgnizationInfo(
|
const kboIdentifiers = await getKboOrganizationInfo(
|
||||||
abbOrganizationInfo.adminUnit
|
abbOrganizationInfo.adminUnit
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -52,8 +52,9 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
|
|||||||
abbOrganizationInfo.kboId,
|
abbOrganizationInfo.kboId,
|
||||||
abbOrganizationInfo.adminUnit
|
abbOrganizationInfo.adminUnit
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isUpdateNeeded(kboObject, kboIdentifiers)) {
|
if (isUpdateNeeded(kboObject, kboIdentifiers)) {
|
||||||
await updateKboOrg(kboObject, kboIdentifiers);
|
await updateKboOrg(kboObject, kboIdentifiers);
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
|
|||||||
}
|
}
|
||||||
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return setServerStatus(API_STATUS_CODES.OK, res); // 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) {
|
||||||
return setServerStatus(API_STATUS_CODES.CUSTOM_SERVER_ERROR, res, e);
|
return setServerStatus(API_STATUS_CODES.CUSTOM_SERVER_ERROR, res, e);
|
||||||
@@ -217,7 +218,7 @@ async function healAbbWithWegWijsData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isUpdateNeeded(wegwijsKboOrg, kboIdentifierOP)) {
|
if (isUpdateNeeded(wegwijsKboOrg, kboIdentifierOP)) {
|
||||||
const kboIdentifiers = await getKboOrgnizationInfo(
|
const kboIdentifiers = await getKboOrganizationInfo(
|
||||||
kboIdentifierOP.abbOrg
|
kboIdentifierOP.abbOrg
|
||||||
);
|
);
|
||||||
await updateKboOrg(wegwijsKboOrg, kboIdentifiers);
|
await updateKboOrg(wegwijsKboOrg, kboIdentifiers);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { querySudo as query, updateSudo as update } from "@lblod/mu-auth-sudo";
|
|||||||
|
|
||||||
export async function getAbbOrganizationInfo(kboStructuredIdUuid) {
|
export async function getAbbOrganizationInfo(kboStructuredIdUuid) {
|
||||||
const queryStr = `
|
const queryStr = `
|
||||||
SELECT DISTINCT ?kbo ?kboId ?ovo ?kboStructuredId ?ovoStructuredId ?bestuurseenheid WHERE {
|
SELECT DISTINCT ?kbo ?kboId ?ovo ?kboStructuredId ?ovoStructuredId ?organization 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>
|
||||||
@@ -18,12 +18,12 @@ export async function getAbbOrganizationInfo(kboStructuredIdUuid) {
|
|||||||
?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 .
|
||||||
|
|
||||||
?bestuurseenheid <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"))
|
FILTER (?kboNotation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||||
|
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
?bestuurseenheid <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 ;
|
?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 .
|
||||||
@@ -46,28 +46,28 @@ export async function getAbbOrganizationInfo(kboStructuredIdUuid) {
|
|||||||
ovo: binding.ovo?.value,
|
ovo: binding.ovo?.value,
|
||||||
ovoStructuredId: binding.ovoStructuredId?.value,
|
ovoStructuredId: binding.ovoStructuredId?.value,
|
||||||
kboId: binding.kboId?.value,
|
kboId: binding.kboId?.value,
|
||||||
adminUnit: binding.bestuurseenheid.value,
|
adminUnit: binding.organization.value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getKboOrgnizationInfo(administrativeUnit) {
|
export async function getKboOrganizationInfo(administrativeUnit) {
|
||||||
const queryStr = `
|
const queryStr = `
|
||||||
SELECT DISTINCT ?kboUnit ?abbUnit ?changeTime ?contactPointUri ?addressUri WHERE {
|
SELECT DISTINCT ?kboOrg ?abbUnit ?changeTime ?contactPointUri ?addressUri 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 {
|
||||||
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||||
<http://mu.semte.ch/vocabularies/core/uuid> ?uuid ;
|
<http://mu.semte.ch/vocabularies/core/uuid> ?uuid ;
|
||||||
<http://schema.org/contactPoint> ?contactPointUri ;
|
<http://schema.org/contactPoint> ?contactPointUri ;
|
||||||
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime .
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime .
|
||||||
|
|
||||||
?contactPointUri <http://www.w3.org/ns/locn#address> ?addressUri .
|
?contactPointUri <http://www.w3.org/ns/locn#address> ?addressUri .
|
||||||
|
|
||||||
?kboUnit <http://www.w3.org/2002/07/owl#sameAs> ?abbUnit
|
?kboOrg <http://www.w3.org/2002/07/owl#sameAs> ?abbUnit
|
||||||
|
|
||||||
FILTER(?abbUnit = ${sparqlEscapeUri(administrativeUnit)})
|
FILTER(?abbUnit = ${sparqlEscapeUri(administrativeUnit)})
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ export async function getKboOrgnizationInfo(administrativeUnit) {
|
|||||||
if (result.results.bindings.length) {
|
if (result.results.bindings.length) {
|
||||||
const binding = result.results.bindings[0];
|
const binding = result.results.bindings[0];
|
||||||
return {
|
return {
|
||||||
kboUnit: binding.kboUnit?.value,
|
kboOrg: binding.kboOrg?.value,
|
||||||
abbUnit: binding.abbUnit?.value,
|
abbUnit: binding.abbUnit?.value,
|
||||||
changeTime: binding.changeTime?.value,
|
changeTime: binding.changeTime?.value,
|
||||||
contactPointUri: binding.contactPointUri?.value,
|
contactPointUri: binding.contactPointUri?.value,
|
||||||
@@ -98,7 +98,7 @@ export async function constructOvoStructure(kboStructuredId) {
|
|||||||
const updateStr = `
|
const updateStr = `
|
||||||
INSERT {
|
INSERT {
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?bestuurseenheid <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
?organization <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||||
idUri
|
idUri
|
||||||
)} .
|
)} .
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ export async function constructOvoStructure(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 .
|
?organization <http://www.w3.org/ns/adms#identifier> ?kboId .
|
||||||
|
|
||||||
FILTER (?notation IN ("KBO nummer"@nl, "KBO nummer"))
|
FILTER (?notation IN ("KBO nummer"@nl, "KBO nummer"))
|
||||||
}
|
}
|
||||||
@@ -221,18 +221,17 @@ export async function getAllAbbKboOrganizations() {
|
|||||||
?abbOrg <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"))
|
FILTER (!regex(?abbOrg, "kboOrganisaties","i"))
|
||||||
|
|
||||||
OPTIONAL{
|
OPTIONAL{
|
||||||
?kboOrg owl:sameAs ?abbOrg .
|
?kboOrg owl:sameAs ?abbOrg .
|
||||||
?kboOrg <https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
?kboOrg <https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVrom ;
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVrom ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/shortName> ?shortName ;
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
<http://www.w3.org/2004/02/skos/core#prefLabel> ?commercialName ;
|
<http://www.w3.org/ns/regorg#legalName> ?legalName ;
|
||||||
<http://www.w3.org/2004/02/skos/core#altLabel> ?legalName ;
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState ;
|
||||||
<http://www.w3.org/ns/regorg#orgStatus> ?activeState ;
|
<http://schema.org/contactPoint> ?contact .
|
||||||
<http://schema.org/contactPoint> ?contact .
|
|
||||||
|
|
||||||
?contact <http://schema.org/email> ?email ;
|
?contact <http://schema.org/email> ?email ;
|
||||||
<http://schema.org/telephone> ?phone ;
|
<http://schema.org/telephone> ?phone ;
|
||||||
@@ -277,9 +276,9 @@ export async function getAllAbbKboOrganizations() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createNewKboOrg(kboOrg, kboId) {
|
export async function createNewKboOrg(kboOrg, kboId, kboStructuredId) {
|
||||||
const newKboOrgIdUuId = uuid();
|
const newKboOrgIdUuId = uuid();
|
||||||
const newKboIdUri = `http://data.lblod.info/id/kboBestuurseenheden/${newKboOrgIdUuId}`;
|
const newKboIdUri = `http://data.lblod.info/id/kboOrganisaties/${newKboOrgIdUuId}`;
|
||||||
|
|
||||||
const contactPointUuidId = uuid();
|
const contactPointUuidId = uuid();
|
||||||
const contactPointUri = `http://data.lblod.info/id/contact-punten/${contactPointUuidId}`;
|
const contactPointUri = `http://data.lblod.info/id/contact-punten/${contactPointUuidId}`;
|
||||||
@@ -329,7 +328,7 @@ export async function createNewKboOrg(kboOrg, kboId) {
|
|||||||
|
|
||||||
updateStr += ` ${sparqlEscapeUri(
|
updateStr += ` ${sparqlEscapeUri(
|
||||||
newKboIdUri
|
newKboIdUri
|
||||||
)} a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
)} a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||||
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
<http://mu.semte.ch/vocabularies/core/uuid> ${sparqlEscapeString(
|
||||||
newKboOrgIdUuId
|
newKboOrgIdUuId
|
||||||
)}`;
|
)}`;
|
||||||
@@ -378,8 +377,11 @@ export async function createNewKboOrg(kboOrg, kboId) {
|
|||||||
<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 {
|
||||||
|
?organization <http://www.w3.org/ns/adms#identifier> ${sparqlEscapeUri(
|
||||||
|
kboId
|
||||||
|
)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -394,8 +396,8 @@ export async function updateKboOrg(newKboInfo, identifiers) {
|
|||||||
//update ContactPoint
|
//update ContactPoint
|
||||||
await updateKboContact(newKboInfo, identifiers);
|
await updateKboContact(newKboInfo, identifiers);
|
||||||
|
|
||||||
//update kboUnit
|
//update kboOrg
|
||||||
await updateKboAdministrativeUnit(newKboInfo, identifiers);
|
await updateKboOrganization(newKboInfo, identifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function linkAbbOrgToKboOrg(abbOrgUri, kboOrgUri) {
|
export async function linkAbbOrgToKboOrg(abbOrgUri, kboOrgUri) {
|
||||||
@@ -415,7 +417,7 @@ export async function linkAbbOrgToKboOrg(abbOrgUri, kboOrgUri) {
|
|||||||
|
|
||||||
${sparqlEscapeUri(
|
${sparqlEscapeUri(
|
||||||
kboOrgUri
|
kboOrgUri
|
||||||
)} a <http://mu.semte.ch/vocabularies/ext/KboEenheid> .
|
)} a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> .
|
||||||
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -431,6 +433,7 @@ async function updateKboAddress(newKboInfo, identifiers) {
|
|||||||
?adressUri a <http://www.w3.org/ns/locn#Address> ;
|
?adressUri a <http://www.w3.org/ns/locn#Address> ;
|
||||||
<http://www.w3.org/ns/locn#fullAddress> ?fulladdress .
|
<http://www.w3.org/ns/locn#fullAddress> ?fulladdress .
|
||||||
}
|
}
|
||||||
|
}
|
||||||
INSERT{
|
INSERT{
|
||||||
graph ?g{
|
graph ?g{
|
||||||
?adressUri a <http://www.w3.org/ns/locn#Address>
|
?adressUri a <http://www.w3.org/ns/locn#Address>
|
||||||
@@ -515,23 +518,22 @@ WHERE{
|
|||||||
`;
|
`;
|
||||||
await update(updateStr);
|
await update(updateStr);
|
||||||
}
|
}
|
||||||
async function updateKboAdministrativeUnit(newKboInfo, identifiers) {
|
async function updateKboOrganization(newKboInfo, identifiers) {
|
||||||
let updateStr = `
|
let updateStr = `
|
||||||
DELETE{
|
DELETE{
|
||||||
GRAPH ?g{
|
GRAPH ?g{
|
||||||
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/shortName> ?shortName ;
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
<http://www.w3.org/2004/02/skos/core#prefLabel> ?orgName ;
|
<http://www.w3.org/ns/regorg#legalName> ?orgName ;
|
||||||
<http://www.w3.org/2004/02/skos/core#altLabel> ?commercialName ;
|
|
||||||
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
INSERT{
|
INSERT{
|
||||||
graph ?g{
|
graph ?g{
|
||||||
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid>
|
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie>
|
||||||
`;
|
`;
|
||||||
if (newKboInfo.rechtsvorm) {
|
if (newKboInfo.rechtsvorm) {
|
||||||
updateStr += `
|
updateStr += `
|
||||||
@@ -586,16 +588,15 @@ async function updateKboAdministrativeUnit(newKboInfo, identifiers) {
|
|||||||
<http://mu.semte.ch/graphs/administrative-unit>
|
<http://mu.semte.ch/graphs/administrative-unit>
|
||||||
}
|
}
|
||||||
GRAPH ?g {
|
GRAPH ?g {
|
||||||
?kboUnit a <http://mu.semte.ch/vocabularies/ext/KboEenheid> ;
|
?kboOrg a <http://mu.semte.ch/vocabularies/ext/KboOrganisatie> ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
<http://mu.semte.ch/vocabularies/ext/rechtsvorm> ?rechtsVorm ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/shortName> ?shortName ;
|
<http://www.w3.org/2004/02/skos/core#altLabel> ?shortName ;
|
||||||
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
<http://mu.semte.ch/vocabularies/ext/startDate> ?startDate ;
|
||||||
<http://www.w3.org/2004/02/skos/core#prefLabel> ?orgName ;
|
<http://www.w3.org/ns/regorg#legalName> ?orgName ;
|
||||||
<http://www.w3.org/2004/02/skos/core#altLabel> ?commercialName ;
|
|
||||||
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
<https://data.lblod.info/vocabularies/generiek/geplandeEindDatum> ?changeTime ;
|
||||||
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
<http://www.w3.org/ns/regorg#orgStatus> ?activeState .
|
||||||
|
|
||||||
FILTER(?kboUnit = ${sparqlEscapeUri(identifiers.kboUnit)})
|
FILTER(?kboOrg = ${sparqlEscapeUri(identifiers.kboOrg)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user