Skip to content

Commit

Permalink
cassproject/cass-editor#514 SKOS import now assigns owner and server …
Browse files Browse the repository at this point in the history
…owner.
  • Loading branch information
Lomilar committed Mar 27, 2019
1 parent f4e1d24 commit 72c5766
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/resources/c-adapter/asn/asn.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,14 @@ function asnFrameworkToCass() {
*/
function importJsonLdGraph(graph, context) {
debug("importing jsonld graph")

var owner = fileToString.call(this,(fileFromDatastream).call(this,"owner"));

var skosIdentity = new EcIdentity();
skosIdentity.ppk = EcPpk.fromPem(keyFor("adapter.skos.private"));
skosIdentity.displayName = "SKOS Server Identity";
EcIdentityManager.addIdentity(skosIdentity);

var conceptSchemeGuid;

for (var idx in graph) {
Expand All @@ -480,9 +488,7 @@ function importJsonLdGraph(graph, context) {

graphObj["@context"] = context;

print(JSON.stringify(graphObj));
var expanded = jsonLdExpand(JSON.stringify(graphObj))[0];
print(JSON.stringify(expanded));
var compacted;
if (graphObj["@type"].indexOf("Concept") != -1) {
compacted = jsonLdCompact(JSON.stringify(expanded), "http://schema.cassproject.org/0.3/skos/");
Expand All @@ -502,14 +508,20 @@ function importJsonLdGraph(graph, context) {
objToSave["@context"] = "http://schema.cassproject.org/0.3/skos/";
objToSave = new EcConceptScheme();
objToSave.copyFrom(compacted);
print(objToSave.toJson());
objToSave.addOwner(skosIdentity.ppk.toPk());
if (owner != null)
objToSave.addOwner(EcPk.fromPem(owner));

repo.saveTo(objToSave,print,print);
}
else if (type == "Concept") {
objToSave["@context"] = "http://schema.cassproject.org/0.3/skos/";
objToSave = new EcConcept();
objToSave.copyFrom(compacted);
print(objToSave.toJson());
objToSave.addOwner(skosIdentity.ppk.toPk());
if (owner != null)
objToSave.addOwner(EcPk.fromPem(owner));

repo.saveTo(objToSave,print,print);
}
}
Expand Down

0 comments on commit 72c5766

Please sign in to comment.