Skip to content

Commit

Permalink
Order of fields for CTDL-ASN concept export
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristin committed Mar 8, 2019
1 parent dfd2803 commit c745bb5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/resources/c-adapter/ceasn/ceasn.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,19 @@ function stripNonCe(f) {
else
delete f[k];
}
return orderFields(f);
}

function orderFields(object) {
var ordered = {};
Object.keys(f).sort().forEach(function (key) {
ordered[key] = f[key];
delete f[key];
Object.keys(object).sort().forEach(function (key) {
ordered[key] = object[key];
delete object[key];
});
Object.keys(ordered).forEach(function (key) {
f[key] = ordered[key];
object[key] = ordered[key];
});
return f;
return object;
}

function cassConceptSchemeAsCeasn(framework) {
Expand Down Expand Up @@ -455,7 +459,7 @@ function cassConceptSchemeAsCeasn(framework) {
concepts[id]["skos:inLanguage"] = "en";
}
delete concepts[id]["@context"];
//competencies[id] = stripNonCe(competencies[id]);
concepts[id] = orderFields(concepts[id]);
}

cs.context = "http://schema.cassproject.org/0.3/cass2ceasnConcepts";
Expand Down Expand Up @@ -483,7 +487,7 @@ function cassConceptSchemeAsCeasn(framework) {
cs["@id"] = ceasnExportUriTransform(cs["@id"]);

var results = [];
//cs = stripNonCe(cs);
cs = orderFields(cs);
results.push(cs);
for (var k in concepts) {
var c = concepts[k];
Expand Down

0 comments on commit c745bb5

Please sign in to comment.