Skip to content

Commit e096ad6

Browse files
committed
Fix bug in node service when looking up uris for equivalent classes.
1 parent ccee5f2 commit e096ad6

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

app/services/model/nodes.srv.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
1414

1515
let classUriIdMap = new Map();
16-
let nodes = new Map();
16+
let nodeMap = new Map();
1717
let equivalentClasses = new Map();
1818

1919
const classDatatypesMap = new Map();
@@ -33,10 +33,10 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
3333

3434
if (sessionNodes !== undefined && sessionNodes !== null) {
3535
$log.debug('[Nodes] Use nodes from session or local storage!');
36-
nodes = new Map(JSON.parse(sessionNodes));
36+
nodeMap = new Map(JSON.parse(sessionNodes));
3737

3838
// rebuild the class uri map
39-
for (let node of nodes.values()) {
39+
for (let node of nodeMap.values()) {
4040
if (node.type === 'class' || node.type === 'disjointNode') {
4141
classUriIdMap.set(node.uri, node.id);
4242
} else if (node.type === 'subClassProperty') {
@@ -56,7 +56,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
5656
that.buildPrefixMap = function () {
5757
Prefixes.clear();
5858

59-
for (let node of nodes.values()) {
59+
for (let node of nodeMap.values()) {
6060
if (node.uri !== undefined && node.uri.length > 0 &&
6161
(node.uri !== Properties.SUBCLASS_URI && node.uri !== that.DISJOINT_NODE_URI)) {
6262
let pre = node.uri.replace(that.suffixRegEx, '');
@@ -71,7 +71,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
7171
};
7272

7373
that.updateStorage = function () {
74-
Storage.setItem(RequestConfig.getEndpointURL() + '_nodes', JSON.stringify([...nodes]));
74+
Storage.setItem(RequestConfig.getEndpointURL() + '_nodes', JSON.stringify([...nodeMap]));
7575
};
7676

7777
that.addDatatypeForClass = function(dataTypeNode, classId) {
@@ -88,7 +88,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
8888
let newId = '';
8989
const connTypes = classDatatypesMap.get(classId);
9090
if (connTypes !== undefined && connTypes.length > 0 && connTypes.indexOf(dataTypeNode.uri) !== -1) {
91-
$log.warn(`[Nodes] There already is a data type '${dataTypeNode.uri}' connected to class '${classId}'!`);
91+
$log.debug(`[Nodes] There already is a data type '${dataTypeNode.uri}' connected to class '${classId}'!`);
9292
} else {
9393

9494
// doesn't exist yet, so its okay to add it
@@ -98,9 +98,9 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
9898
classDatatypesMap.set(classId, connTypes.concat([dataTypeNode.uri]));
9999
}
100100

101-
newId = dataTypeNode.type + nodes.size;
101+
newId = dataTypeNode.type + nodeMap.size;
102102
dataTypeNode.id = newId;
103-
nodes.set(newId, dataTypeNode);
103+
nodeMap.set(newId, dataTypeNode);
104104

105105
$log.debug(`[Nodes] Add new data type node '${dataTypeNode.uri}'.`);
106106

@@ -126,9 +126,9 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
126126
if (idByUri !== undefined) {
127127
return idByUri;
128128
} else {
129-
newId = newNode.type + nodes.size;
129+
newId = newNode.type + nodeMap.size;
130130
newNode.id = newId;
131-
nodes.set(newId, newNode);
131+
nodeMap.set(newId, newNode);
132132
classUriIdMap.set(newNode.uri, newId);
133133

134134
if (newNode.uri !== that.DISJOINT_NODE_URI) {
@@ -152,7 +152,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
152152

153153
newId = combination;
154154
newNode.id = newId;
155-
nodes.set(newId, newNode);
155+
nodeMap.set(newId, newNode);
156156
$log.debug(`[Nodes] Add new Node '${newNode.uri}' with id '${newId}'.`);
157157
} else {
158158
$log.warn(`[Nodes] Sub-class rel between ${newNode.childId} & ${newNode.parentId} does already exist!`);
@@ -161,9 +161,9 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
161161
$log.error(`[Nodes] Missing parent child info for subclass relation!`);
162162
}
163163
} else {
164-
newId = newNode.type + nodes.size;
164+
newId = newNode.type + nodeMap.size;
165165
newNode.id = newId;
166-
nodes.set(newId, newNode);
166+
nodeMap.set(newId, newNode);
167167
$log.debug(`[Nodes] Add new Node '${newNode.uri}'.`);
168168
}
169169

@@ -178,7 +178,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
178178
* @returns {Map}
179179
*/
180180
that.getNodes = function () {
181-
return nodes;
181+
return nodeMap;
182182
};
183183

184184
/**
@@ -191,7 +191,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
191191
let nodeToReturn = null;
192192

193193
if (idToSearch !== undefined && typeof idToSearch === 'string') {
194-
nodeToReturn = nodes.get(idToSearch);
194+
nodeToReturn = nodeMap.get(idToSearch);
195195
}
196196
return nodeToReturn;
197197
};
@@ -205,7 +205,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
205205
that.getInstanceCountById = function (id) {
206206
let instanceCount = -1;
207207

208-
const searchedItem = nodes.get(id);
208+
const searchedItem = nodeMap.get(id);
209209

210210
if (searchedItem !== undefined && searchedItem.hasOwnProperty('value')) {
211211
instanceCount = searchedItem.value;
@@ -223,13 +223,13 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
223223
that.getURIById = function (id) {
224224
let uri = '';
225225

226-
let searchedItem = nodes.get(id);
226+
let searchedItem = nodeMap.get(id);
227227

228228
if (searchedItem !== undefined && searchedItem.hasOwnProperty('uri')) {
229229
uri = searchedItem.uri;
230230
} else {
231231
$log.debug(`[Nodes] Can not resolve uri of node with id '${id}'! Search for equivalent nodes...`);
232-
const eqNode = nodes.getClassNodeOrEquivalent(id);
232+
const eqNode = that.getClassNodeOrEquivalent(id);
233233

234234
if (eqNode !== undefined && eqNode.uri !== undefined) {
235235
uri = eqNode.uri;
@@ -248,7 +248,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
248248
* @param {string} label - the label for the node with the given id
249249
*/
250250
that.insertLabel = function (id, label) {
251-
const searchedItem = nodes.get(id);
251+
const searchedItem = nodeMap.get(id);
252252

253253
if (searchedItem !== undefined) {
254254
searchedItem.name = label;
@@ -264,7 +264,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
264264
* @param {string} commentToAdd - the comment to add to the node with the given id
265265
*/
266266
that.insertComment = function (id, commentToAdd) {
267-
const searchedItem = nodes.get(id);
267+
const searchedItem = nodeMap.get(id);
268268

269269
if (searchedItem !== undefined) {
270270
searchedItem.comment = commentToAdd;
@@ -281,7 +281,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
281281
* @param {string} newUri
282282
*/
283283
that.setURI = function (id, newUri) {
284-
const nodeToChange = nodes.get(id);
284+
const nodeToChange = nodeMap.get(id);
285285

286286
if (nodeToChange !== undefined) {
287287
nodeToChange.uri = newUri;
@@ -299,7 +299,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
299299
that.setTypesLoaded = function (classId) {
300300
if (classId !== undefined && typeof classId === 'string') {
301301

302-
const clazz = nodes.get(classId);
302+
const clazz = nodeMap.get(classId);
303303

304304
if (clazz !== undefined && clazz.type === 'class') {
305305
clazz.typesLoaded = true;
@@ -315,7 +315,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
315315
*/
316316
that.getTypesLoaded = function (classId) {
317317
if (classId !== undefined && typeof classId === 'string') {
318-
const clazz = nodes.get(classId);
318+
const clazz = nodeMap.get(classId);
319319

320320
if (clazz !== undefined && clazz.type === 'class' && clazz.typesLoaded) {
321321
$log.debug(`[Nodes] Types for '${classId}' are already loaded!`);
@@ -368,7 +368,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
368368
}
369369

370370
equivalentClasses.set(classId2, cl1.id);
371-
nodes.delete(classId2);
371+
nodeMap.delete(classId2);
372372
deletedId = classId2;
373373
$log.debug(`[Nodes] Merged '${cl1.id}' and '${classId2}'.`);
374374
}
@@ -381,12 +381,12 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
381381
};
382382

383383
that.getClassNodeOrEquivalent = function (classId) {
384-
let nodeToReturn = nodes.get(classId);
384+
let nodeToReturn = nodeMap.get(classId);
385385

386386
if (nodeToReturn === undefined) {
387387
const equivalentId = equivalentClasses.get(classId);
388388
if (equivalentId !== undefined) {
389-
nodeToReturn = nodes.get(equivalentId);
389+
nodeToReturn = nodeMap.get(equivalentId);
390390
}
391391
}
392392

@@ -401,7 +401,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
401401
that.removeNodes = function (nodeArr) {
402402
if (nodeArr !== undefined && nodeArr.length > 0) {
403403
nodeArr.forEach((node) => {
404-
nodes.delete(node);
404+
nodeMap.delete(node);
405405
});
406406
}
407407
};
@@ -413,7 +413,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
413413
* @return {number} the new value of the node or -1 if node was not found
414414
*/
415415
that.incValueOfId = function (id) {
416-
const searchedItem = nodes.get(id);
416+
const searchedItem = nodeMap.get(id);
417417

418418
if (searchedItem !== undefined && searchedItem.hasOwnProperty('value')) {
419419
searchedItem.value += 1;
@@ -428,7 +428,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
428428
* @returns {boolean}
429429
*/
430430
that.isEmpty = function () {
431-
return (nodes.size === 0);
431+
return (nodeMap.size === 0);
432432
};
433433

434434
that.hasClassNodes = function () {
@@ -440,7 +440,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
440440
*/
441441
that.clearAll = function () {
442442
classUriIdMap.clear();
443-
nodes.clear();
443+
nodeMap.clear();
444444
equivalentClasses.clear();
445445
classDatatypesMap.clear();
446446
subClassSet.clear();
@@ -460,8 +460,8 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
460460
let exists = false;
461461

462462
if (childId !== undefined && parentId !== undefined) {
463-
const childNode = nodes.get(childId);
464-
const parentNode = nodes.get(parentId);
463+
const childNode = nodeMap.get(childId);
464+
const parentNode = nodeMap.get(parentId);
465465

466466
if (childNode !== undefined && parentNode !== undefined) {
467467
const combination = childId + parentId;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ld-vowl",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Extract ontology information out of arbitrary SPARQL endpoints and visualize it using a slightly adjusted form of VOWL.",
55
"author": "Marc Weise <[email protected]>",
66
"scripts": {

0 commit comments

Comments
 (0)