@oslo-flanders/core 0.0.4-alpha.0 → 0.0.5-alpha.0
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/README.md +75 -75
- package/index.d.ts +21 -20
- package/index.js +37 -36
- package/lib/ServiceIdentifier.d.ts +7 -7
- package/lib/ServiceIdentifier.js +14 -14
- package/lib/enums/PropertyTypes.d.ts +5 -5
- package/lib/enums/PropertyTypes.js +9 -9
- package/lib/enums/Scope.d.ts +6 -6
- package/lib/enums/Scope.js +10 -10
- package/lib/interfaces/AppRunner.d.ts +19 -19
- package/lib/interfaces/AppRunner.js +26 -26
- package/lib/interfaces/IConfiguration.d.ts +7 -7
- package/lib/interfaces/IConfiguration.js +2 -2
- package/lib/interfaces/IOutputHandler.d.ts +7 -7
- package/lib/interfaces/IOutputHandler.js +2 -2
- package/lib/interfaces/IService.d.ts +11 -11
- package/lib/interfaces/IService.js +2 -2
- package/lib/logging/LogLevel.d.ts +5 -5
- package/lib/logging/LogLevel.js +4 -4
- package/lib/logging/LogUtil.d.ts +4 -4
- package/lib/logging/LogUtil.js +16 -16
- package/lib/logging/Logger.d.ts +20 -20
- package/lib/logging/Logger.js +35 -35
- package/lib/logging/LoggerFactory.d.ts +11 -11
- package/lib/logging/LoggerFactory.js +2 -2
- package/lib/logging/VoidLogger.d.ts +7 -7
- package/lib/logging/VoidLogger.js +27 -27
- package/lib/logging/VoidLoggerFactory.d.ts +9 -9
- package/lib/logging/VoidLoggerFactory.js +16 -16
- package/lib/logging/WinstonLogger.d.ts +8 -8
- package/lib/logging/WinstonLogger.js +30 -30
- package/lib/logging/WinstonLoggerFactory.d.ts +10 -10
- package/lib/logging/WinstonLoggerFactory.js +23 -23
- package/lib/store/QuadStore.d.ts +165 -180
- package/lib/store/QuadStore.js +305 -329
- package/lib/utils/fetchFileOrUrl.d.ts +2 -2
- package/lib/utils/fetchFileOrUrl.js +22 -22
- package/lib/utils/namespaces.d.ts +24 -24
- package/lib/utils/namespaces.js +35 -35
- package/lib/utils/uniqueId.d.ts +1 -1
- package/lib/utils/uniqueId.js +13 -13
- package/package.json +8 -3
package/lib/store/QuadStore.js
CHANGED
|
@@ -1,330 +1,306 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.QuadStore = void 0;
|
|
39
|
-
const inversify_1 = require("inversify");
|
|
40
|
-
const N3 = __importStar(require("n3"));
|
|
41
|
-
const rdf_parse_1 = __importDefault(require("rdf-parse"));
|
|
42
|
-
const fetchFileOrUrl_1 = require("
|
|
43
|
-
const namespaces_1 = require("
|
|
44
|
-
let QuadStore = class QuadStore {
|
|
45
|
-
constructor() {
|
|
46
|
-
this.store = new N3.Store();
|
|
47
|
-
}
|
|
48
|
-
addQuads(quads) {
|
|
49
|
-
this.store.addQuads(quads);
|
|
50
|
-
}
|
|
51
|
-
addQuad(quad) {
|
|
52
|
-
this.store.addQuad(quad);
|
|
53
|
-
}
|
|
54
|
-
async addQuadsFromFile(file) {
|
|
55
|
-
const buffer = await (0, fetchFileOrUrl_1.fetchFileOrUrl)(file);
|
|
56
|
-
const textStream = require('streamify-string')(buffer.toString());
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
rdf_parse_1.default
|
|
59
|
-
.
|
|
60
|
-
.on('
|
|
61
|
-
.on('
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
* @param
|
|
114
|
-
* @
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
* @param
|
|
123
|
-
* @
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*
|
|
149
|
-
* @
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
161
|
-
* @returns An RDF.
|
|
162
|
-
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*
|
|
169
|
-
* @param
|
|
170
|
-
* @
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
*
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Finds the
|
|
204
|
-
* @param subject The RDF.Term to find the
|
|
205
|
-
* @
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
*
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
*
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*
|
|
292
|
-
* @
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Finds the vann:usageNote for an RDF.Term in rdf:Statements
|
|
309
|
-
* @param subject The statement subject
|
|
310
|
-
* @param predicate The statement predicate
|
|
311
|
-
* @param object The statement object for which the usage note must be found
|
|
312
|
-
* @param store A N3 quad store
|
|
313
|
-
* @param language A language tag
|
|
314
|
-
* @returns An RDF.Literal or undefined if not found
|
|
315
|
-
*/
|
|
316
|
-
getUsageNoteViaStatements(subject, predicate, object, language) {
|
|
317
|
-
const statementId = this.getTargetStatementId(subject, predicate, object);
|
|
318
|
-
if (!statementId) {
|
|
319
|
-
return undefined;
|
|
320
|
-
}
|
|
321
|
-
const usageNote = this.getUsageNote(statementId, language);
|
|
322
|
-
return usageNote || this.getUsageNote(statementId);
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
QuadStore = __decorate([
|
|
326
|
-
(0, inversify_1.injectable)(),
|
|
327
|
-
__metadata("design:paramtypes", [])
|
|
328
|
-
], QuadStore);
|
|
329
|
-
exports.QuadStore = QuadStore;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.QuadStore = void 0;
|
|
39
|
+
const inversify_1 = require("inversify");
|
|
40
|
+
const N3 = __importStar(require("n3"));
|
|
41
|
+
const rdf_parse_1 = __importDefault(require("rdf-parse"));
|
|
42
|
+
const fetchFileOrUrl_1 = require("@oslo-core/utils/fetchFileOrUrl");
|
|
43
|
+
const namespaces_1 = require("@oslo-core/utils/namespaces");
|
|
44
|
+
let QuadStore = class QuadStore {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.store = new N3.Store();
|
|
47
|
+
}
|
|
48
|
+
addQuads(quads) {
|
|
49
|
+
this.store.addQuads(quads);
|
|
50
|
+
}
|
|
51
|
+
addQuad(quad) {
|
|
52
|
+
this.store.addQuad(quad);
|
|
53
|
+
}
|
|
54
|
+
async addQuadsFromFile(file) {
|
|
55
|
+
const buffer = await (0, fetchFileOrUrl_1.fetchFileOrUrl)(file);
|
|
56
|
+
const textStream = require('streamify-string')(buffer.toString());
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
rdf_parse_1.default
|
|
59
|
+
.parse(textStream, { path: file })
|
|
60
|
+
.on('data', (quad) => this.store.addQuad(quad))
|
|
61
|
+
.on('error', (error) => reject(error))
|
|
62
|
+
.on('end', () => resolve());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
findQuads(subject, predicate, object, graph = null) {
|
|
66
|
+
return this.store.getQuads(subject, predicate, object, graph);
|
|
67
|
+
}
|
|
68
|
+
findQuad(subject, predicate, object, graph = null) {
|
|
69
|
+
return this.findQuads(subject, predicate, object, graph).shift();
|
|
70
|
+
}
|
|
71
|
+
findSubjects(predicate, object, graph = null) {
|
|
72
|
+
return this.store.getSubjects(predicate, object, graph);
|
|
73
|
+
}
|
|
74
|
+
findSubject(predicate, object, graph = null) {
|
|
75
|
+
return this.findSubjects(predicate, object, graph).shift();
|
|
76
|
+
}
|
|
77
|
+
findObjects(subject, predicate, graph = null) {
|
|
78
|
+
return this.store.getObjects(subject, predicate, graph);
|
|
79
|
+
}
|
|
80
|
+
findObject(subject, predicate, graph = null) {
|
|
81
|
+
return this.findObjects(subject, predicate, graph).shift();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Finds the subject where predicate is 'rdf:type' and object 'oslo:Package'
|
|
85
|
+
* @returns a RDF.NamedNode or undefined
|
|
86
|
+
*/
|
|
87
|
+
getPackageId() {
|
|
88
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.oslo('Package'), null).shift());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:Class'
|
|
92
|
+
* @returns an array of RDF.NamedNodes
|
|
93
|
+
*/
|
|
94
|
+
getClassIds(graph = null) {
|
|
95
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('Class'), graph));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:DatatypeProperty'
|
|
99
|
+
* @returns an array of RDF.NamedNodes
|
|
100
|
+
*/
|
|
101
|
+
getDatatypePropertyIds(graph = null) {
|
|
102
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('DatatypeProperty'), graph));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:ObjectProperty'
|
|
106
|
+
* @returns an array of RDF.NamedNodes
|
|
107
|
+
*/
|
|
108
|
+
getObjectPropertyIds(graph = null) {
|
|
109
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('ObjectProperty'), graph));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* For a given subject, the quad store is queried to find the assigned URI
|
|
113
|
+
* @param subject The subject for which the assigned URI is to be retrieved
|
|
114
|
+
* @param store The quad store
|
|
115
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
116
|
+
*/
|
|
117
|
+
getAssignedUri(subject, graph = null) {
|
|
118
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('assignedURI'), graph).shift());
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Find all quads with a label predicate (vocLabel, apLabel and diagramLabel) for a given subject
|
|
122
|
+
* @param subject The RDF.Term to find the labels for
|
|
123
|
+
* @param store A N3 quad store
|
|
124
|
+
* @returns An array of RDF.Quads
|
|
125
|
+
*/
|
|
126
|
+
getLabels(subject, graph = null) {
|
|
127
|
+
const vocLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('vocLabel'), null, graph);
|
|
128
|
+
const apLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('apLabel'), null, graph);
|
|
129
|
+
const diagramLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('diagramLabel'), null, graph);
|
|
130
|
+
return vocLabel.concat(apLabel).concat(diagramLabel);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Finds the oslo:vocLabel whose language tag matches the given language
|
|
134
|
+
* @param subject The RDF.Term to find the oslo:vocLabel for
|
|
135
|
+
* @param store A N3 quad store
|
|
136
|
+
* @param language A language tag
|
|
137
|
+
* @returns An RDF.Literal or undefined if not found
|
|
138
|
+
*/
|
|
139
|
+
getVocLabel(subject, language, graph = null) {
|
|
140
|
+
var _a;
|
|
141
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')) &&
|
|
142
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Finds the oslo:apLabel whose language tag matches the given language
|
|
146
|
+
* @param subject The RDF.Term to find the oslo:apLabel for
|
|
147
|
+
* @param store A N3 quad store
|
|
148
|
+
* @param language A language tag
|
|
149
|
+
* @returns An RDF.Literal or undefined if not found
|
|
150
|
+
*/
|
|
151
|
+
getApLabel(subject, language, graph = null) {
|
|
152
|
+
var _a;
|
|
153
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apLabel')) &&
|
|
154
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Finds the oslo:diagramLabel for a given subject
|
|
158
|
+
* @param subject The RDF.Term to find the oslo:diagramLabel for
|
|
159
|
+
* @param store A N3 quad store
|
|
160
|
+
* @param language A language tag
|
|
161
|
+
* @returns An RDF.Literal or undefined if not found
|
|
162
|
+
*/
|
|
163
|
+
getDiagramLabel(subject, graph = null) {
|
|
164
|
+
var _a;
|
|
165
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('diagramLabel')))) === null || _a === void 0 ? void 0 : _a.object;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Find all definitions for a given subject
|
|
169
|
+
* @param subject The RDF.Term to find the definitions for
|
|
170
|
+
* @param store A N3 quad store
|
|
171
|
+
* @returns An array of RDF.Literals
|
|
172
|
+
*/
|
|
173
|
+
getDefinitions(subject, graph = null) {
|
|
174
|
+
const vocDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('vocDefinition'), null, graph);
|
|
175
|
+
const apDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('apDefinition'), null, graph);
|
|
176
|
+
return vocDefinitions.concat(apDefinitions);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Finds the oslo:vocDefinition whose language tag matches the given language
|
|
180
|
+
* @param subject The RDF.Term to find the oslo:vocDefinition for
|
|
181
|
+
* @param store A N3 quad store
|
|
182
|
+
* @param language A language tag
|
|
183
|
+
* @returns An RDF.Literal or undefined if not found
|
|
184
|
+
*/
|
|
185
|
+
getVocDefinition(subject, language, graph = null) {
|
|
186
|
+
var _a;
|
|
187
|
+
return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')) &&
|
|
188
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Finds the oslo:apDefinition whose language tag matches the given language
|
|
192
|
+
* @param subject The RDF.Term to find the oslo:apDefinition for
|
|
193
|
+
* @param store A N3 quad store
|
|
194
|
+
* @param language A language tag
|
|
195
|
+
* @returns An RDF.Literal or undefined if not found
|
|
196
|
+
*/
|
|
197
|
+
getApDefinition(subject, language, graph = null) {
|
|
198
|
+
var _a;
|
|
199
|
+
return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apDefinition')) &&
|
|
200
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Finds the rdfs:range of a given RDF.Term
|
|
204
|
+
* @param subject The RDF.Term to find the range of
|
|
205
|
+
* @param store A N3 quad store
|
|
206
|
+
* @returns An RDF.Term or undefined if not found
|
|
207
|
+
*/
|
|
208
|
+
getRange(subject, graph = null) {
|
|
209
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('range'), graph).shift());
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Finds the rdfs:domain of a given RDF.Term
|
|
213
|
+
* @param subject The RDF.Term to find the domain of
|
|
214
|
+
* @param store A N3 quad store
|
|
215
|
+
* @returns An RDF.Term or undefined if not found
|
|
216
|
+
*/
|
|
217
|
+
getDomain(subject, graph = null) {
|
|
218
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('domain'), graph).shift());
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Finds all the usageNotes (voc and ap) of a given RDF.Term
|
|
222
|
+
* @param subject The RDF.Term to find the usage notes for
|
|
223
|
+
* @param store A N3 quad store
|
|
224
|
+
* @returns An array of RDF.Literals
|
|
225
|
+
*/
|
|
226
|
+
getUsageNotes(subject, graph = null) {
|
|
227
|
+
const vocUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('vocUsageNote'), null, graph);
|
|
228
|
+
const apUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('apUsageNote'), null, graph);
|
|
229
|
+
return vocUsageNotes.concat(apUsageNotes);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Finds the oslo:vocUsageNote of which the language tag matches the given language
|
|
233
|
+
* @param subject The RDF.Term to find the vocabulary usage note for
|
|
234
|
+
* @param store A N3 quad store
|
|
235
|
+
* @param language A language tag
|
|
236
|
+
* @returns An RDF.Literal or undefined if not found
|
|
237
|
+
*/
|
|
238
|
+
getVocUsageNote(subject, language, graph = null) {
|
|
239
|
+
var _a;
|
|
240
|
+
return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')) &&
|
|
241
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Finds the oslo:apUsageNote of which the language tag matches the given language
|
|
245
|
+
* @param subject The RDF.Term to find the application profile usage note for
|
|
246
|
+
* @param store A N3 quad store
|
|
247
|
+
* @param language A language tag
|
|
248
|
+
* @returns An RDF.Literal or undefined if not found
|
|
249
|
+
*/
|
|
250
|
+
getApUsageNote(subject, language, graph = null) {
|
|
251
|
+
var _a;
|
|
252
|
+
return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apUsageNote')) &&
|
|
253
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Finds the example:scope of a given subject
|
|
257
|
+
* @param subject The RDF.Term to find the scope for
|
|
258
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
259
|
+
*/
|
|
260
|
+
getScope(subject, graph = null) {
|
|
261
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('scope'), graph).shift());
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Finds the shacl:minCardinality for a given subject
|
|
265
|
+
* @param subject The RDF.Term to find the shacl:minCardinaly for
|
|
266
|
+
* @returns An RDF.Literal or undefined if not found
|
|
267
|
+
*/
|
|
268
|
+
getMinCardinality(subject, graph = null) {
|
|
269
|
+
return (this.store.getObjects(subject, namespaces_1.ns.shacl('minCount'), graph).shift());
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Finds the shacl:maxCardinality for a given subject
|
|
273
|
+
* @param subject The RDF.Term to find the shacl:maxCardinaly for
|
|
274
|
+
* @returns An RDF.Literal or undefined if not found
|
|
275
|
+
*/
|
|
276
|
+
getMaxCardinality(subject, graph = null) {
|
|
277
|
+
return (this.store.getObjects(subject, namespaces_1.ns.shacl('maxCount'), graph).shift());
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Finds all the rdfs:subClassOf of a given RDF.Term
|
|
281
|
+
* @param subject the RDF.Term to find the parents of
|
|
282
|
+
* @param store A N3 quad store
|
|
283
|
+
* @returns An array of RDF.Terms
|
|
284
|
+
*/
|
|
285
|
+
getParentsOfClass(subject, graph = null) {
|
|
286
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subClassOf'), graph));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Finds the rdfs:subPropertyOf of a given RDF.Term
|
|
290
|
+
* @param subject The RDF.Term to find the parent of
|
|
291
|
+
* @param store A N3 quad store
|
|
292
|
+
* @returns An RDF.Term or undefined if not found
|
|
293
|
+
*/
|
|
294
|
+
getParentOfProperty(subject, graph = null) {
|
|
295
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subPropertyOf'), graph).shift());
|
|
296
|
+
}
|
|
297
|
+
getCodelist(subject, graph = null) {
|
|
298
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('codelist'), graph).shift());
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
QuadStore = __decorate([
|
|
302
|
+
(0, inversify_1.injectable)(),
|
|
303
|
+
__metadata("design:paramtypes", [])
|
|
304
|
+
], QuadStore);
|
|
305
|
+
exports.QuadStore = QuadStore;
|
|
330
306
|
//# sourceMappingURL=QuadStore.js.map
|