Skip to content

Commit

Permalink
Improve parsing for dataset #18
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sroertgen committed Feb 7, 2024
1 parent 7ebd89b commit 0702cc2
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/publishToReconciliation/buildJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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`
Expand All @@ -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;

Expand Down

0 comments on commit 0702cc2

Please sign in to comment.