From 54b02dbc2ee0c255f0459f4078e7e24606537ef1 Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Thu, 8 Aug 2024 13:20:44 +0200 Subject: [PATCH] Implement workaround for issue with non-supported schemes --- src/App.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index 10211c6..d0e53cb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -68,7 +68,7 @@ const initPromise = (async () => { bartocRegistry.init() concordanceRegistry.init() // Load supported schemes from subjects-api - const schemes = await (await fetch(`${subjectsApi}/voc`)).json() + const schemes = (await (await fetch(`${subjectsApi}/voc`)).json()).filter(({ uri }) => uri) const schemesFromBARTOC = await bartocRegistry.getSchemes({ params: { uri: schemes.map(scheme => scheme.uri).join("|"), @@ -179,12 +179,19 @@ watch(() => state.ppn, async (ppn) => { console.time("Load mappings") state.loadingPhase = 3 const subjects = state.subjects.reduce((prev, cur) => prev.concat(cur.subjects), []) - const mappings = subjects.length ? await concordanceRegistry.getMappings({ - from: subjects.map(s => s.uri).join("|"), - toScheme: state.schemes.map(s => s.uri).join("|"), - direction: "both", - cardinality: "1-to-1", - }) : [] + // TODO: This is currently a workaround for a suspected bug with direction=both + const mappings = subjects.length ? [ + ...await concordanceRegistry.getMappings({ + from: subjects.map(s => s.uri).join("|"), + toScheme: state.schemes.map(s => s.uri).join("|"), + cardinality: "1-to-1", + }), + ...await concordanceRegistry.getMappings({ + to: subjects.map(s => s.uri).join("|"), + fromScheme: state.schemes.map(s => s.uri).join("|"), + cardinality: "1-to-1", + }), + ] : [] // TODO: This needs to be fixed in the data! const mappingsWithoutType = mappings.filter(mapping => !mapping.type?.[0]) if (mappingsWithoutType.length) {