small changes discussed in personal reviews

This commit is contained in:
Elias Papanikitas
2024-03-21 11:33:54 +01:00
parent 63620ce061
commit d4ec2d5083
3 changed files with 33 additions and 53 deletions

View File

@@ -1,17 +1,17 @@
export const API_STATUS_CODES = {
STATUS_200:{
OK:{
STATUS: "OK",
CODE: 200
},
STATUS_402:{
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: 402
CODE: 500
},
STATUS_403:{
STATUS_NO_DATA_OP:{
STATUS: "no kbo number found in OP",
CODE: 403
CODE: 500,
},
STATUS_500:{
CUSTOM_SERVER_ERROR:{
STATUS: '',
CODE: 500
}

33
app.js
View File

@@ -26,7 +26,7 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
const AbbOrganizationInfo = await getAbbOrganizationInfo(kboStructuredIdUuid);
if (!AbbOrganizationInfo?.kbo) {
return throwServerError(API_STATUS_CODES.STATUS_403, res);
return throwServerError(API_STATUS_CODES.STATUS_NO_DATA_OP, res);
}
const wegwijsUrl = `${WEGWIJS_API}?q=kboNumber:${AbbOrganizationInfo.kbo}&fields=${WEGWIJS_API_FIELDS}`;
console.log("url: " + wegwijsUrl);
@@ -35,7 +35,7 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
const data = await response.json();
if (!data.length) {
return throwServerError(API_STATUS_CODES.STATUS_402, res);
return throwServerError(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
@@ -65,9 +65,9 @@ app.post("/sync-kbo-data/:kboStructuredIdUuid", async function (req, res) {
await updateOvoNumberAndUri(ovoStructuredIdUri, wegwijsOvo);
}
return throwServerError(API_STATUS_CODES.STATUS_200, res); // since we await, it should be 200
return throwServerError(API_STATUS_CODES.OK, res); // since we await, it should be 200
} catch (e) {
return throwServerError(API_STATUS_CODES.STATUS_500, res, e);
return throwServerError(API_STATUS_CODES.CUSTOM_SERVER_ERROR, res, e);
}
});
@@ -121,20 +121,19 @@ function getKboFields(data) {
//currently no commercial name available
return {
changeTime: changeTime ?? "",
commercialName: "",
shortName: shortName ?? organisationName,
ovoNumber: ovoNumber ?? "",
kboNumber: kboNumber ?? "",
formalName: formalName ?? "",
startDate: startDate ?? "",
changeTime: changeTime,
shortName: shortName,
ovoNumber: ovoNumber,
kboNumber: kboNumber,
formalName: formalName,
startDate: startDate,
activeState: activeState,
rechtsvorm: rechtsvorm ?? "",
email: email ?? "",
phone: phone ?? "",
website: website ?? "",
formattedAddress: formattedAddress ?? "",
adressComponent: adressComponent ?? "",
rechtsvorm: rechtsvorm,
email: email,
phone: phone,
website: website,
formattedAddress: formattedAddress,
adressComponent: adressComponent,
};
}

View File

@@ -338,24 +338,19 @@ export async function createNewKboOrg(kboOrg, kboId) {
kboOrg.rechtsvorm
)}`;
}
if (kboOrg.shortName) {
updateStr += `; <http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
kboOrg.shortName
)}`;
}
if (kboOrg.startDate) {
updateStr += `; <http://mu.semte.ch/vocabularies/ext/startDate> ${sparqlEscapeString(
kboOrg.startDate
)}`;
}
if (kboOrg.formalName) {
updateStr += `; <http://www.w3.org/2004/02/skos/core#prefLabel> ${sparqlEscapeString(
updateStr += `; <http://www.w3.org/ns/regorg#legalName> ${sparqlEscapeString(
kboOrg.formalName
)}`;
}
if (kboOrg.commercialName) {
updateStr += `; <http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
kboOrg.commercialName
if (kboOrg.shortName) {
updateStr += `; <http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
kboOrg.shortName
)}`;
}
if (kboOrg.changeTime) {
@@ -545,14 +540,6 @@ async function updateKboAdministrativeUnit(newKboInfo, identifiers) {
)}
`;
}
if (newKboInfo.shortName) {
updateStr += `
;
<http://mu.semte.ch/vocabularies/ext/shortName> ${sparqlEscapeString(
newKboInfo.shortName
)}
`;
}
if (newKboInfo.startDate) {
updateStr += `
;
@@ -561,21 +548,15 @@ async function updateKboAdministrativeUnit(newKboInfo, identifiers) {
)}
`;
}
if (newKboInfo.organisationName) {
updateStr += `
;
<http://www.w3.org/2004/02/skos/core#prefLabel> ${sparqlEscapeString(
newKboInfo.organisationName
)}
`;
}
if (newKboInfo.formalName) {
updateStr += `
;
<http://www.w3.org/2004/02/skos/core#altLabel> ${sparqlEscapeString(
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 += `