@oslo-flanders/core 1.0.15 → 1.0.16
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/lib/store/QuadStore.d.ts +12 -0
- package/lib/store/QuadStore.js +24 -0
- package/lib/types/splitUri.d.ts +6 -0
- package/lib/types/splitUri.js +35 -0
- package/lib/utils/quadSort.d.ts +8 -0
- package/lib/utils/quadSort.js +17 -0
- package/package.json +1 -1
package/lib/store/QuadStore.d.ts
CHANGED
|
@@ -226,4 +226,16 @@ export declare class QuadStore {
|
|
|
226
226
|
* @param graph The RDF.Term of the named graph
|
|
227
227
|
*/
|
|
228
228
|
getChildAttribute(subject: RDF.Term, graph?: RDF.Term | null): RDF.Term | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Check if class is abstract
|
|
231
|
+
* @param subject The RDF.Term to determine if it is an abstract class
|
|
232
|
+
* @param graph The RDF.Term of the named graph
|
|
233
|
+
*/
|
|
234
|
+
isAbstractClass(subject: RDF.Term, graph?: RDF.Term | null): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Check if class is root object
|
|
237
|
+
* @param subject The RDF.Term to determine if it is an root object
|
|
238
|
+
* @param graph The RDF.Term of the named graph
|
|
239
|
+
*/
|
|
240
|
+
isRootClass(subject: RDF.Term, graph?: RDF.Term | null): boolean;
|
|
229
241
|
}
|
package/lib/store/QuadStore.js
CHANGED
|
@@ -389,6 +389,30 @@ let QuadStore = class QuadStore {
|
|
|
389
389
|
getChildAttribute(subject, graph = null) {
|
|
390
390
|
return (this.findObject(subject, namespaces_1.ns.oslo('childAttribute')));
|
|
391
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Check if class is abstract
|
|
394
|
+
* @param subject The RDF.Term to determine if it is an abstract class
|
|
395
|
+
* @param graph The RDF.Term of the named graph
|
|
396
|
+
*/
|
|
397
|
+
isAbstractClass(subject, graph = null) {
|
|
398
|
+
const types = this.findObjects(subject, namespaces_1.ns.rdf('type'));
|
|
399
|
+
for (const t of types)
|
|
400
|
+
if (t.value === namespaces_1.ns.oslo('AbstractClass').value)
|
|
401
|
+
return true;
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Check if class is root object
|
|
406
|
+
* @param subject The RDF.Term to determine if it is an root object
|
|
407
|
+
* @param graph The RDF.Term of the named graph
|
|
408
|
+
*/
|
|
409
|
+
isRootClass(subject, graph = null) {
|
|
410
|
+
const types = this.findObjects(subject, namespaces_1.ns.rdf('type'));
|
|
411
|
+
for (const t of types)
|
|
412
|
+
if (t.value === namespaces_1.ns.oslo('RootClass').value)
|
|
413
|
+
return true;
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
392
416
|
};
|
|
393
417
|
QuadStore = __decorate([
|
|
394
418
|
(0, inversify_1.injectable)(),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitUri = void 0;
|
|
4
|
+
const prefixes_1 = require("../constants/prefixes");
|
|
5
|
+
async function splitUri(uri) {
|
|
6
|
+
/* Extract prefix and element by finding the last occurrence of # or / */
|
|
7
|
+
const hashIndex = uri.lastIndexOf('#');
|
|
8
|
+
const slashIndex = uri.lastIndexOf('/');
|
|
9
|
+
const splitIndex = Math.max(hashIndex, slashIndex);
|
|
10
|
+
if (splitIndex > 0) {
|
|
11
|
+
const prefixUri = uri.slice(0, Math.max(0, splitIndex + 1));
|
|
12
|
+
const element = uri.replace(prefixUri, '');
|
|
13
|
+
const prefixes = await (0, prefixes_1.getPrefixes)();
|
|
14
|
+
let prefixLabel;
|
|
15
|
+
for (const [label, puri] of Object.entries(prefixes)) {
|
|
16
|
+
if (puri === prefixUri) {
|
|
17
|
+
prefixLabel = label;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/* No known prefix found for URI */
|
|
22
|
+
if (!prefixLabel) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
prefix: prefixLabel,
|
|
27
|
+
uri: prefixUri,
|
|
28
|
+
element,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/* Splitting failed */
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.splitUri = splitUri;
|
|
35
|
+
//# sourceMappingURL=splitUri.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as RDF from '@rdfjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Sort function used on an array of quads. First sorts named nodes alphabetically, then blank nodes alphabetically.
|
|
4
|
+
* @param quadA An RDF.Quad
|
|
5
|
+
* @param quadB An RDF.Quad
|
|
6
|
+
* @returns a number
|
|
7
|
+
*/
|
|
8
|
+
export declare const quadSort: (quadA: RDF.Quad, quadB: RDF.Quad) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quadSort = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sort function used on an array of quads. First sorts named nodes alphabetically, then blank nodes alphabetically.
|
|
6
|
+
* @param quadA An RDF.Quad
|
|
7
|
+
* @param quadB An RDF.Quad
|
|
8
|
+
* @returns a number
|
|
9
|
+
*/
|
|
10
|
+
const quadSort = (quadA, quadB) => {
|
|
11
|
+
if (quadA.subject.termType === quadB.subject.termType) {
|
|
12
|
+
return quadA.subject.value.localeCompare(quadB.subject.value);
|
|
13
|
+
}
|
|
14
|
+
return quadA.subject.termType === 'BlankNode' ? 1 : -1;
|
|
15
|
+
};
|
|
16
|
+
exports.quadSort = quadSort;
|
|
17
|
+
//# sourceMappingURL=quadSort.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslo-flanders/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Core interfaces and utilities",
|
|
5
5
|
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
|
|
6
6
|
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-core#readme",
|