cassproject 0.5.28 → 0.5.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cassproject",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.29",
|
|
4
4
|
"description": "Competency and Skills Service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"automocha": "nodemon --exec \"npm run mocha\"",
|
|
25
25
|
"automocha:clientSideCertificates": "set CASS_LOOPBACK=https://localhost/api/&& nodemon --exec \"npm run mocha\"",
|
|
26
26
|
"lint": "eslint src -c .eslintrc.js --ext .js --fix",
|
|
27
|
-
"docs": "
|
|
28
|
-
"doclint": "
|
|
27
|
+
"docs": "yuidoc -c yuidoc.json -o docs -e .js src",
|
|
28
|
+
"doclint": "yuidoc --lint -c yuidoc.json -o docs -e .js src",
|
|
29
29
|
"browserify:cypress:open": "cypress open --config-file cypressBrowserify.json",
|
|
30
30
|
"webpack:cypress:open": "cypress open --config-file cypressWebpack.json",
|
|
31
31
|
"browserify:cypress": "cypress run --config-file cypressBrowserify.json --headless --browser chrome",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"forge": "^2.3.0",
|
|
58
58
|
"form-data": "^4.0.0",
|
|
59
59
|
"jsonld": "^5.2.0",
|
|
60
|
-
"node-forge": "^
|
|
60
|
+
"node-forge": "^1.2.1",
|
|
61
61
|
"papaparse": "^5.3.1",
|
|
62
62
|
"pem-jwk": "^2.0.0",
|
|
63
63
|
"promise-worker": "^2.0.1",
|
|
@@ -67,226 +67,226 @@ module.exports = class CTDLASNCSVConceptImport {
|
|
|
67
67
|
Papa.parse(file, {
|
|
68
68
|
header: true,
|
|
69
69
|
encoding: "UTF-8",
|
|
70
|
-
complete: function(results) {
|
|
70
|
+
complete: async function(results) {
|
|
71
71
|
var tabularData = results["data"];
|
|
72
|
+
const terms = JSON.parse(JSON.stringify((await EcRemote.getExpectingObject("https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConceptsTerms"))));
|
|
72
73
|
var schemeArray = [];
|
|
73
74
|
var concepts = [];
|
|
74
|
-
|
|
75
|
-
tabularData
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
for (let each = 0; each < tabularData.length; each++) {
|
|
76
|
+
let pretranslatedE = tabularData[each];
|
|
77
|
+
if (pretranslatedE["@type"] == "skos:ConceptScheme") {
|
|
78
|
+
var translator = new EcLinkedData(null, null);
|
|
79
|
+
translator.copyFrom(pretranslatedE);
|
|
80
|
+
CTDLASNCSVImport.cleanUpTranslator(
|
|
81
|
+
translator,
|
|
82
|
+
endpoint,
|
|
83
|
+
repo
|
|
84
|
+
);
|
|
85
|
+
if (translator["ceasn:name"] != null) {
|
|
86
|
+
var name = translator["ceasn:name"];
|
|
87
|
+
var nameWithLanguage = {};
|
|
88
|
+
nameWithLanguage["en-US"] = name;
|
|
89
|
+
translator["ceasn:name"] = nameWithLanguage;
|
|
90
|
+
}
|
|
91
|
+
for (let each in translator) {
|
|
92
|
+
if (terms[each]) {
|
|
93
|
+
translator[terms[each]] = translator[each];
|
|
94
|
+
delete translator[each];
|
|
90
95
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
];
|
|
104
|
-
} else {
|
|
105
|
-
f[key] =
|
|
106
|
-
EcConceptScheme.template[
|
|
107
|
-
key
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (e["owner"] != null) {
|
|
113
|
-
var id = new EcIdentity();
|
|
114
|
-
id.ppk = EcPpk.fromPem(e["owner"]);
|
|
115
|
-
f.addOwner(id.ppk.toPk());
|
|
116
|
-
eim.addIdentityQuietly(
|
|
117
|
-
id
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (ceo != null) f.addOwner(ceo.ppk.toPk());
|
|
121
|
-
f[
|
|
122
|
-
"schema:dateModified"
|
|
123
|
-
] = new Date().toISOString();
|
|
124
|
-
if (
|
|
125
|
-
EcConceptScheme.template != null &&
|
|
96
|
+
}
|
|
97
|
+
let e = await translator.recast(
|
|
98
|
+
"https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConcepts.json",
|
|
99
|
+
"https://schema.cassproject.org/0.4/skos"
|
|
100
|
+
);
|
|
101
|
+
e.type = "ConceptScheme";
|
|
102
|
+
var f = new EcConceptScheme();
|
|
103
|
+
f.copyFrom(e);
|
|
104
|
+
if (EcConceptScheme.template != null) {
|
|
105
|
+
for (var key in EcConceptScheme.template) {
|
|
106
|
+
if (key.equals("@owner")) {
|
|
107
|
+
f["owner"] =
|
|
126
108
|
EcConceptScheme.template[
|
|
127
|
-
|
|
128
|
-
]
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
109
|
+
key
|
|
110
|
+
];
|
|
111
|
+
} else {
|
|
112
|
+
f[key] =
|
|
113
|
+
EcConceptScheme.template[
|
|
114
|
+
key
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (e["owner"] != null) {
|
|
120
|
+
var id = new EcIdentity();
|
|
121
|
+
id.ppk = EcPpk.fromPem(e["owner"]);
|
|
122
|
+
f.addOwner(id.ppk.toPk());
|
|
123
|
+
eim.addIdentityQuietly(
|
|
124
|
+
id
|
|
136
125
|
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
126
|
+
}
|
|
127
|
+
if (ceo != null) f.addOwner(ceo.ppk.toPk());
|
|
128
|
+
f[
|
|
129
|
+
"schema:dateModified"
|
|
130
|
+
] = new Date().toISOString();
|
|
131
|
+
if (
|
|
132
|
+
EcConceptScheme.template != null &&
|
|
133
|
+
EcConceptScheme.template[
|
|
134
|
+
"schema:dateCreated"
|
|
135
|
+
] != null
|
|
136
|
+
) {
|
|
137
|
+
CTDLASNCSVImport.setDateCreated(e, f);
|
|
138
|
+
}
|
|
139
|
+
schemeArray.push(f);
|
|
140
|
+
} else if (pretranslatedE["@type"] == "skos:Concept") {
|
|
141
|
+
var translator = new EcLinkedData(null, null);
|
|
142
|
+
translator.copyFrom(pretranslatedE);
|
|
143
|
+
CTDLASNCSVImport.cleanUpTranslator(
|
|
144
|
+
translator,
|
|
145
|
+
endpoint,
|
|
146
|
+
repo
|
|
147
|
+
);
|
|
148
|
+
if (translator["skos:prefLabel"] != null) {
|
|
149
|
+
var name = translator["skos:prefLabel"];
|
|
150
|
+
var nameWithLanguage = {};
|
|
151
|
+
nameWithLanguage["en-US"] = name;
|
|
152
|
+
translator["skos:prefLabel"] = nameWithLanguage;
|
|
153
|
+
}
|
|
154
|
+
for (let each in translator) {
|
|
155
|
+
if (terms[each]) {
|
|
156
|
+
translator[terms[each]] = translator[each];
|
|
157
|
+
delete translator[each];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let e = await translator.recast(
|
|
161
|
+
"https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConcepts.json",
|
|
162
|
+
"https://schema.cassproject.org/0.4/skos"
|
|
163
|
+
);
|
|
164
|
+
e.type = "Concept";
|
|
165
|
+
var f = new EcConcept();
|
|
166
|
+
f.copyFrom(e);
|
|
167
|
+
if (e["id"] == null) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (
|
|
171
|
+
EcConcept.template != null &&
|
|
172
|
+
EcConcept.template["@owner"] != null
|
|
173
|
+
) {
|
|
174
|
+
f["owner"] =
|
|
175
|
+
EcConcept.template["@owner"];
|
|
176
|
+
}
|
|
177
|
+
if (e["owner"] != null) {
|
|
178
|
+
var id = new EcIdentity();
|
|
179
|
+
id.ppk = EcPpk.fromPem(e["owner"]);
|
|
180
|
+
if (id.ppk != null)
|
|
181
|
+
f.addOwner(id.ppk.toPk());
|
|
182
|
+
eim.addIdentityQuietly(
|
|
183
|
+
id
|
|
144
184
|
);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
185
|
+
}
|
|
186
|
+
if (ceo != null) f.addOwner(ceo.ppk.toPk());
|
|
187
|
+
if (
|
|
188
|
+
EcConcept.template != null &&
|
|
189
|
+
EcConcept.template[
|
|
190
|
+
"schema:dateCreated"
|
|
191
|
+
] != null
|
|
192
|
+
) {
|
|
193
|
+
CTDLASNCSVImport.setDateCreated(e, f);
|
|
194
|
+
}
|
|
195
|
+
if (e["skos:narrower"] != null) {
|
|
196
|
+
var relation = e["skos:narrower"];
|
|
197
|
+
if (!EcArray.isArray(relation)) {
|
|
198
|
+
var array = [relation];
|
|
199
|
+
f["skos:narrower"] = array;
|
|
150
200
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
201
|
+
}
|
|
202
|
+
if (e["skos:broader"] != null) {
|
|
203
|
+
var relation = e["skos:broader"];
|
|
204
|
+
if (!EcArray.isArray(relation)) {
|
|
205
|
+
var array = [relation];
|
|
206
|
+
f["skos:broader"] = array;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (e["skos:broadMatch"] != null) {
|
|
210
|
+
var relation = e["skos:broadMatch"];
|
|
211
|
+
if (!EcArray.isArray(relation)) {
|
|
212
|
+
var array = [relation];
|
|
213
|
+
f["skos:broadMatch"] = array;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (e["skos:closeMatch"] != null) {
|
|
217
|
+
var relation = e["skos:closeMatch"];
|
|
218
|
+
if (!EcArray.isArray(relation)) {
|
|
219
|
+
var array = [relation];
|
|
220
|
+
f["skos:closeMatch"] = array;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (e["skos:exactMatch"] != null) {
|
|
224
|
+
var relation = e["skos:exactMatch"];
|
|
225
|
+
if (!EcArray.isArray(relation)) {
|
|
226
|
+
var array = [relation];
|
|
227
|
+
f["skos:exactMatch"] = array;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (e["skos:narrowMatch"] != null) {
|
|
231
|
+
var relation = e["skos:narrowMatch"];
|
|
232
|
+
if (!EcArray.isArray(relation)) {
|
|
233
|
+
var array = [relation];
|
|
234
|
+
f["skos:narrowMatch"] = array;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (e["skos:related"] != null) {
|
|
238
|
+
var relation = e["skos:related"];
|
|
239
|
+
if (!EcArray.isArray(relation)) {
|
|
240
|
+
var array = [relation];
|
|
241
|
+
f["skos:related"] = array;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (e["skos:topConceptOf"] != null) {
|
|
245
|
+
var scheme = e["skos:topConceptOf"];
|
|
246
|
+
for (
|
|
247
|
+
var i = 0;
|
|
248
|
+
i < schemeArray.length;
|
|
249
|
+
i++
|
|
250
|
+
) {
|
|
251
|
+
var schemeObj = schemeArray[i];
|
|
252
|
+
if (scheme == schemeObj["id"]) {
|
|
178
253
|
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
] != null
|
|
254
|
+
schemeObj[
|
|
255
|
+
"skos:hasTopConcept"
|
|
256
|
+
] == null
|
|
183
257
|
) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (!EcArray.isArray(relation)) {
|
|
189
|
-
var array = [relation];
|
|
190
|
-
f["skos:narrower"] = array;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (e["skos:broader"] != null) {
|
|
194
|
-
var relation = e["skos:broader"];
|
|
195
|
-
if (!EcArray.isArray(relation)) {
|
|
196
|
-
var array = [relation];
|
|
197
|
-
f["skos:broader"] = array;
|
|
198
|
-
}
|
|
258
|
+
var hasTopConcept = [];
|
|
259
|
+
schemeObj[
|
|
260
|
+
"skos:hasTopConcept"
|
|
261
|
+
] = hasTopConcept;
|
|
199
262
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!EcArray.isArray(relation)) {
|
|
210
|
-
var array = [relation];
|
|
211
|
-
f["skos:closeMatch"] = array;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (e["skos:exactMatch"] != null) {
|
|
215
|
-
var relation = e["skos:exactMatch"];
|
|
216
|
-
if (!EcArray.isArray(relation)) {
|
|
217
|
-
var array = [relation];
|
|
218
|
-
f["skos:exactMatch"] = array;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (e["skos:narrowMatch"] != null) {
|
|
222
|
-
var relation = e["skos:narrowMatch"];
|
|
223
|
-
if (!EcArray.isArray(relation)) {
|
|
224
|
-
var array = [relation];
|
|
225
|
-
f["skos:narrowMatch"] = array;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (e["skos:related"] != null) {
|
|
229
|
-
var relation = e["skos:related"];
|
|
230
|
-
if (!EcArray.isArray(relation)) {
|
|
231
|
-
var array = [relation];
|
|
232
|
-
f["skos:related"] = array;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (e["skos:topConceptOf"] != null) {
|
|
236
|
-
var scheme = e["skos:topConceptOf"];
|
|
237
|
-
for (
|
|
238
|
-
var i = 0;
|
|
239
|
-
i < schemeArray.length;
|
|
240
|
-
i++
|
|
241
|
-
) {
|
|
242
|
-
var schemeObj = schemeArray[i];
|
|
243
|
-
if (scheme == schemeObj["id"]) {
|
|
244
|
-
if (
|
|
245
|
-
schemeObj[
|
|
246
|
-
"skos:hasTopConcept"
|
|
247
|
-
] == null
|
|
248
|
-
) {
|
|
249
|
-
var hasTopConcept = [];
|
|
250
|
-
schemeObj[
|
|
251
|
-
"skos:hasTopConcept"
|
|
252
|
-
] = hasTopConcept;
|
|
253
|
-
}
|
|
254
|
-
var conceptId = f.shortId();
|
|
255
|
-
EcArray.setAdd(
|
|
256
|
-
schemeObj[
|
|
257
|
-
"skos:hasTopConcept"
|
|
258
|
-
],
|
|
259
|
-
conceptId
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
f[
|
|
265
|
-
"schema:dateModified"
|
|
266
|
-
] = new Date().toISOString();
|
|
267
|
-
concepts.push(f);
|
|
268
|
-
callback0();
|
|
269
|
-
},
|
|
270
|
-
failure
|
|
271
|
-
);
|
|
272
|
-
} else if (
|
|
273
|
-
pretranslatedE["@type"] == null ||
|
|
274
|
-
pretranslatedE["@type"] == ""
|
|
275
|
-
) {
|
|
276
|
-
callback0();
|
|
277
|
-
return;
|
|
278
|
-
} else {
|
|
279
|
-
this.error(
|
|
280
|
-
"Found unknown type:" + pretranslatedE["@type"]
|
|
281
|
-
);
|
|
282
|
-
callback0();
|
|
283
|
-
return;
|
|
263
|
+
var conceptId = f.shortId();
|
|
264
|
+
EcArray.setAdd(
|
|
265
|
+
schemeObj[
|
|
266
|
+
"skos:hasTopConcept"
|
|
267
|
+
],
|
|
268
|
+
conceptId
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
284
272
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
273
|
+
f[
|
|
274
|
+
"schema:dateModified"
|
|
275
|
+
] = new Date().toISOString();
|
|
276
|
+
concepts.push(f);
|
|
277
|
+
} else if (
|
|
278
|
+
pretranslatedE["@type"] == null ||
|
|
279
|
+
pretranslatedE["@type"] == ""
|
|
280
|
+
) {
|
|
281
|
+
return;
|
|
282
|
+
} else {
|
|
283
|
+
this.error(
|
|
284
|
+
"Found unknown type:" + pretranslatedE["@type"]
|
|
285
|
+
);
|
|
286
|
+
return;
|
|
288
287
|
}
|
|
289
|
-
|
|
288
|
+
}
|
|
289
|
+
success(schemeArray, concepts);
|
|
290
290
|
},
|
|
291
291
|
error: failure
|
|
292
292
|
});
|