Skip to content

Commit

Permalink
Merge pull request #284 from cassproject/ce-1328.1
Browse files Browse the repository at this point in the history
Ce 1328.1
  • Loading branch information
gloverkari authored Sep 28, 2023
2 parents 8f857bf + 3595d2e commit 0068627
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/server/adapter/ceasn/ceasn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(compId);
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);
});
Expand Down Expand Up @@ -395,10 +399,16 @@ async function cassFrameworkAsCeasn() {
};
}
for (let c of competencies) {
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;
Expand Down Expand Up @@ -502,6 +512,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"]) {
Expand Down

0 comments on commit 0068627

Please sign in to comment.