From deed8caf9dff4da557fcb3396c46e2f72992e5f2 Mon Sep 17 00:00:00 2001 From: "kari.glover" Date: Thu, 28 Sep 2023 11:35:03 -0700 Subject: [PATCH 1/3] Include check for reference to non-existent competency during export, --- src/main/server/adapter/ceasn/ceasn.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/server/adapter/ceasn/ceasn.js b/src/main/server/adapter/ceasn/ceasn.js index c4f2bfe27..2b4a1a4a8 100644 --- a/src/main/server/adapter/ceasn/ceasn.js +++ b/src/main/server/adapter/ceasn/ceasn.js @@ -60,8 +60,12 @@ async function competencyPromise(compId, competencies, allCompetencies, f, ctx, return new Promise(async (resolve) => { try { var c = competencies[compId]; + if (!c) { + resolve(null); + return; + } if (c == null) resolve(c); - if (c["ceasn:hasChild"] != null && c["ceasn:hasChild"]["@list"] != null) + if (c["ceasn:hasChild"] != null && c["ceasn:hasChild"]["@list"] && c["ceasn:hasChild"]["@list"] != null) c["ceasn:hasChild"]["@list"].sort(function (a, b) { return allCompetencies.indexOf(a) - allCompetencies.indexOf(b); }); @@ -395,6 +399,9 @@ async function cassFrameworkAsCeasn() { }; } for (let c of competencies) { + if (!c) { + continue; + } if (!c["ceasn:isChildOf"] || c["ceasn:isChildOf"] == null) { f["ceasn:hasTopChild"]["@list"].push(await ceasnExportUriTransform(c["@id"])); } @@ -502,6 +509,9 @@ async function cassFrameworkAsCeasn() { results.push(f); for (var k in competencies) { var c = competencies[k]; + if (!c) { + continue; + } var found = false; for (var j = 0; j < results.length; j++) if (results[j]["@id"] == competencies[k]["@id"]) { From 91de853dfd817ee4fea126c055c6910244b6b46f Mon Sep 17 00:00:00 2001 From: "kari.glover" Date: Thu, 28 Sep 2023 12:21:05 -0700 Subject: [PATCH 2/3] Add uri of undefined competency to export, for consistency with data. --- src/main/server/adapter/ceasn/ceasn.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/server/adapter/ceasn/ceasn.js b/src/main/server/adapter/ceasn/ceasn.js index 2b4a1a4a8..8394ce3a4 100644 --- a/src/main/server/adapter/ceasn/ceasn.js +++ b/src/main/server/adapter/ceasn/ceasn.js @@ -61,7 +61,7 @@ async function competencyPromise(compId, competencies, allCompetencies, f, ctx, try { var c = competencies[compId]; if (!c) { - resolve(null); + resolve(compId); return; } if (c == null) resolve(c); @@ -402,10 +402,16 @@ async function cassFrameworkAsCeasn() { if (!c) { continue; } - if (!c["ceasn:isChildOf"] || c["ceasn:isChildOf"] == null) { - f["ceasn:hasTopChild"]["@list"].push(await ceasnExportUriTransform(c["@id"])); + if (!c["@id"]) { + // URI does not reference a valid competency. + // For consistency with the data and possible debugging purposes, it should still be included in JSON-LD export + f["ceasn:hasTopChild"]["@list"].push(await ceasnExportUriTransform(c)); + } else { + if (!c["ceasn:isChildOf"] || c["ceasn:isChildOf"] == null) { + f["ceasn:hasTopChild"]["@list"].push(await ceasnExportUriTransform(c["@id"])); + } + f.competency.push(await ceasnExportUriTransform(c["@id"])); } - f.competency.push(await ceasnExportUriTransform(c["@id"])); } f.context = "https://schema.cassproject.org/0.4/jsonld1.1/cass2ceasn.json"; delete f.relation; From 3595d2e1cadc24e4f369989d6015b4162dd865d8 Mon Sep 17 00:00:00 2001 From: "kari.glover" Date: Thu, 28 Sep 2023 12:26:22 -0700 Subject: [PATCH 3/3] Cleanup --- src/main/server/adapter/ceasn/ceasn.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/server/adapter/ceasn/ceasn.js b/src/main/server/adapter/ceasn/ceasn.js index 8394ce3a4..84dde4148 100644 --- a/src/main/server/adapter/ceasn/ceasn.js +++ b/src/main/server/adapter/ceasn/ceasn.js @@ -399,9 +399,6 @@ async function cassFrameworkAsCeasn() { }; } for (let c of competencies) { - if (!c) { - continue; - } if (!c["@id"]) { // URI does not reference a valid competency. // For consistency with the data and possible debugging purposes, it should still be included in JSON-LD export