Skip to content

Commit

Permalink
Check templates for inLanguage field on import
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristin committed Aug 23, 2019
1 parent db296d5 commit 4f53342
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/main/resources/c-adapter/asn/asn.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,12 @@ function importJsonLdGraph(graph, context) {
objToSave.addOwner(EcPk.fromPem(owner));

if (objToSave["dcterms:language"] == null || objToSave["dcterms:language"] === undefined) {
objToSave["dcterms:language"] = "en";
if (EcConceptScheme.template["dcterms:language"] != null) {
objToSave["dcterms:language"] = EcConceptScheme.template["dcterms:language"];
}
else {
objToSave["dcterms:language"] = "en";
}
}
else {
lang = objToSave["dcterms:language"];
Expand Down
16 changes: 10 additions & 6 deletions src/main/resources/c-adapter/case/caseIngest.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ setDateCreated = function(object) {
};

getTimestamp = function(object) {
var timestamp = object["@id"].substring(object["@id"].lastIndexOf("/") + 1);
var timestamp = object["id"].substring(object["id"].lastIndexOf("/") + 1);
if (timestamp.matches("[0-9]+")) {
return Integer.parseInt(timestamp);
} else {
Expand All @@ -88,10 +88,14 @@ convertCFDocumentToFramework = function (document) {
document["@context"] = caseToCassSchema;
document = jsonLdExpand(JSON.stringify(document));
document = jsonLdCompact(JSON.stringify(document), cassContext);
f.copyFrom(document);
if ((f["schema:inLanguage"] == null || f["schema:inLanguage"] === undefined)
&& EcFramework.template != null && EcFramework.template["schema:inLanguage"] != null) {
f["schema:inLanguage"] = EcFramework.template["schema:inLanguage"];
}
if (EcFramework.template != null && EcFramework.template["schema:dateCreated"] != null) {
setDateCreated(document);
setDateCreated(f);
}
f.copyFrom(document);
return f;
}

Expand Down Expand Up @@ -129,11 +133,11 @@ convertCFItemIntoCompetency = function (a) {
}
a = jsonLdExpand(JSON.stringify(a));
a = jsonLdCompact(JSON.stringify(a), cassContext);
if (EcCompetency.template != null && EcCompetency.template["schema:dateCreated"] != null) {
setDateCreated(a);
}
var r = new EcCompetency();
r.copyFrom(a);
if (EcCompetency.template != null && EcCompetency.template["schema:dateCreated"] != null) {
setDateCreated(r);
}
return r;
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/c-adapter/ceasn/ceasn.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,12 @@ function importCeFrameworkToCass(frameworkObj, competencyList) {
f.addOwner(EcPk.fromPem(owner));

if (f["schema:inLanguage"] == null || f["schema:inLanguage"] === undefined) {
f["schema:inLanguage"] = "en";
if (EcFramework.template["schema:inLanguage"] != null) {
f["schema:inLanguage"] = EcFramework.template["schema:inLanguage"];
}
else {
f["schema:inLanguage"] = "en";
}
}

if (f["schema:dateCreated"] == null || f["schema:dateCreated"] === undefined) {
Expand Down

0 comments on commit 4f53342

Please sign in to comment.