From 0702cc2ef481d68ca0670bf40154cfd267792e94 Mon Sep 17 00:00:00 2001 From: "@s.roertgen" Date: Wed, 7 Feb 2024 11:46:00 +0100 Subject: [PATCH] Improve parsing for dataset #18 If concepts have multiple topConcepts of inScheme entries, it was kind of arbitrary until now, what would be chosen as the dataset. This is now improved by setting the dataset to the concept scheme id. --- src/publishToReconciliation/buildJSON.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/publishToReconciliation/buildJSON.js b/src/publishToReconciliation/buildJSON.js index d5f3cdf..edad70b 100644 --- a/src/publishToReconciliation/buildJSON.js +++ b/src/publishToReconciliation/buildJSON.js @@ -13,7 +13,8 @@ export const buildJSON = async (ttlString, account) => { const compacted = await jsonld.compact(expanded, context); // TODO get all available languages and store them as attribute for Concept Scheme let entries = []; - let dataset = ""; + const dataset = compacted["@graph"].find(g => g.type === "ConceptScheme").id; + console.log("found dataset", dataset) compacted["@graph"].forEach((graph, _) => { const { ...properties } = graph; @@ -68,7 +69,6 @@ export const buildJSON = async (ttlString, account) => { }; if (node.type === "ConceptScheme") { - dataset = node.id; if (node?.preferredNamespaceUri === undefined) { throw new NoPrefNamespaceUriError( `ConceptScheme ${node.id} does not have a preferredNamespaceUri` @@ -82,17 +82,8 @@ export const buildJSON = async (ttlString, account) => { if (node.topConceptOf) { node.inScheme = node.topConceptOf; } - try { - - dataset = node?.inScheme?.[0]?.id ?? node.topConceptOf[0].id; - } - catch (e) { - console.error(e) - console.error(node) - } } - node["dataset"] = dataset; node["account"] = account;