@oslo-flanders/core 1.3.1 → 1.3.2
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/utils/storeUtils.js +19 -3
- package/package.json +1 -1
package/lib/utils/storeUtils.js
CHANGED
|
@@ -116,6 +116,19 @@ function createList(items, store, df) {
|
|
|
116
116
|
return list[0];
|
|
117
117
|
}
|
|
118
118
|
exports.createList = createList;
|
|
119
|
+
// Checks whether node inherits from ancestor regardless of number of generations
|
|
120
|
+
function isSubclassOf(node, ancestor, store, seen = new Set()) {
|
|
121
|
+
for (const parent of store.findObjects(node, namespaces_1.ns.rdfs('subClassOf'))) {
|
|
122
|
+
if (parent.value === ancestor.value)
|
|
123
|
+
return true;
|
|
124
|
+
if (seen.has(parent.value))
|
|
125
|
+
continue;
|
|
126
|
+
seen.add(parent.value);
|
|
127
|
+
if (isSubclassOf(parent, ancestor, store, seen))
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
119
132
|
function findAllAttributes(subject, attributeIds, store, logger, visited = new Set()) {
|
|
120
133
|
let parentIds = store.findObjects(subject, namespaces_1.ns.rdfs('subClassOf'));
|
|
121
134
|
if (visited.has(subject.value)) {
|
|
@@ -129,11 +142,14 @@ function findAllAttributes(subject, attributeIds, store, logger, visited = new S
|
|
|
129
142
|
const assignedUri = store.findObject(parentId, namespaces_1.ns.oslo('assignedURI'));
|
|
130
143
|
if (!assignedUri)
|
|
131
144
|
continue;
|
|
145
|
+
// Can't be a dummy if it has attributes
|
|
146
|
+
if (store.findSubjects(namespaces_1.ns.rdfs('domain'), parentId).length > 0)
|
|
147
|
+
continue;
|
|
132
148
|
additionalParentIds = [
|
|
133
149
|
...additionalParentIds,
|
|
134
|
-
...store
|
|
135
|
-
.
|
|
136
|
-
|
|
150
|
+
...store.findSubjects(namespaces_1.ns.oslo('assignedURI'), assignedUri).filter((item) => item.value !== parentId.value && // not the potential dummy itself
|
|
151
|
+
!visited.has(item.value) && // not on the current path
|
|
152
|
+
!isSubclassOf(item, parentId, store)),
|
|
137
153
|
];
|
|
138
154
|
}
|
|
139
155
|
parentIds = [...parentIds, ...additionalParentIds];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslo-flanders/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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",
|