13
13
function nodesService ( $log , Properties , Prefixes , RequestConfig , Storage ) {
14
14
15
15
let classUriIdMap = new Map ( ) ;
16
- let nodes = new Map ( ) ;
16
+ let nodeMap = new Map ( ) ;
17
17
let equivalentClasses = new Map ( ) ;
18
18
19
19
const classDatatypesMap = new Map ( ) ;
@@ -33,10 +33,10 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
33
33
34
34
if ( sessionNodes !== undefined && sessionNodes !== null ) {
35
35
$log . debug ( '[Nodes] Use nodes from session or local storage!' ) ;
36
- nodes = new Map ( JSON . parse ( sessionNodes ) ) ;
36
+ nodeMap = new Map ( JSON . parse ( sessionNodes ) ) ;
37
37
38
38
// rebuild the class uri map
39
- for ( let node of nodes . values ( ) ) {
39
+ for ( let node of nodeMap . values ( ) ) {
40
40
if ( node . type === 'class' || node . type === 'disjointNode' ) {
41
41
classUriIdMap . set ( node . uri , node . id ) ;
42
42
} else if ( node . type === 'subClassProperty' ) {
@@ -56,7 +56,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
56
56
that . buildPrefixMap = function ( ) {
57
57
Prefixes . clear ( ) ;
58
58
59
- for ( let node of nodes . values ( ) ) {
59
+ for ( let node of nodeMap . values ( ) ) {
60
60
if ( node . uri !== undefined && node . uri . length > 0 &&
61
61
( node . uri !== Properties . SUBCLASS_URI && node . uri !== that . DISJOINT_NODE_URI ) ) {
62
62
let pre = node . uri . replace ( that . suffixRegEx , '' ) ;
@@ -71,7 +71,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
71
71
} ;
72
72
73
73
that . updateStorage = function ( ) {
74
- Storage . setItem ( RequestConfig . getEndpointURL ( ) + '_nodes' , JSON . stringify ( [ ...nodes ] ) ) ;
74
+ Storage . setItem ( RequestConfig . getEndpointURL ( ) + '_nodes' , JSON . stringify ( [ ...nodeMap ] ) ) ;
75
75
} ;
76
76
77
77
that . addDatatypeForClass = function ( dataTypeNode , classId ) {
@@ -88,7 +88,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
88
88
let newId = '' ;
89
89
const connTypes = classDatatypesMap . get ( classId ) ;
90
90
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 } '!` ) ;
92
92
} else {
93
93
94
94
// doesn't exist yet, so its okay to add it
@@ -98,9 +98,9 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
98
98
classDatatypesMap . set ( classId , connTypes . concat ( [ dataTypeNode . uri ] ) ) ;
99
99
}
100
100
101
- newId = dataTypeNode . type + nodes . size ;
101
+ newId = dataTypeNode . type + nodeMap . size ;
102
102
dataTypeNode . id = newId ;
103
- nodes . set ( newId , dataTypeNode ) ;
103
+ nodeMap . set ( newId , dataTypeNode ) ;
104
104
105
105
$log . debug ( `[Nodes] Add new data type node '${ dataTypeNode . uri } '.` ) ;
106
106
@@ -126,9 +126,9 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
126
126
if ( idByUri !== undefined ) {
127
127
return idByUri ;
128
128
} else {
129
- newId = newNode . type + nodes . size ;
129
+ newId = newNode . type + nodeMap . size ;
130
130
newNode . id = newId ;
131
- nodes . set ( newId , newNode ) ;
131
+ nodeMap . set ( newId , newNode ) ;
132
132
classUriIdMap . set ( newNode . uri , newId ) ;
133
133
134
134
if ( newNode . uri !== that . DISJOINT_NODE_URI ) {
@@ -152,7 +152,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
152
152
153
153
newId = combination ;
154
154
newNode . id = newId ;
155
- nodes . set ( newId , newNode ) ;
155
+ nodeMap . set ( newId , newNode ) ;
156
156
$log . debug ( `[Nodes] Add new Node '${ newNode . uri } ' with id '${ newId } '.` ) ;
157
157
} else {
158
158
$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) {
161
161
$log . error ( `[Nodes] Missing parent child info for subclass relation!` ) ;
162
162
}
163
163
} else {
164
- newId = newNode . type + nodes . size ;
164
+ newId = newNode . type + nodeMap . size ;
165
165
newNode . id = newId ;
166
- nodes . set ( newId , newNode ) ;
166
+ nodeMap . set ( newId , newNode ) ;
167
167
$log . debug ( `[Nodes] Add new Node '${ newNode . uri } '.` ) ;
168
168
}
169
169
@@ -178,7 +178,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
178
178
* @returns {Map }
179
179
*/
180
180
that . getNodes = function ( ) {
181
- return nodes ;
181
+ return nodeMap ;
182
182
} ;
183
183
184
184
/**
@@ -191,7 +191,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
191
191
let nodeToReturn = null ;
192
192
193
193
if ( idToSearch !== undefined && typeof idToSearch === 'string' ) {
194
- nodeToReturn = nodes . get ( idToSearch ) ;
194
+ nodeToReturn = nodeMap . get ( idToSearch ) ;
195
195
}
196
196
return nodeToReturn ;
197
197
} ;
@@ -205,7 +205,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
205
205
that . getInstanceCountById = function ( id ) {
206
206
let instanceCount = - 1 ;
207
207
208
- const searchedItem = nodes . get ( id ) ;
208
+ const searchedItem = nodeMap . get ( id ) ;
209
209
210
210
if ( searchedItem !== undefined && searchedItem . hasOwnProperty ( 'value' ) ) {
211
211
instanceCount = searchedItem . value ;
@@ -223,13 +223,13 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
223
223
that . getURIById = function ( id ) {
224
224
let uri = '' ;
225
225
226
- let searchedItem = nodes . get ( id ) ;
226
+ let searchedItem = nodeMap . get ( id ) ;
227
227
228
228
if ( searchedItem !== undefined && searchedItem . hasOwnProperty ( 'uri' ) ) {
229
229
uri = searchedItem . uri ;
230
230
} else {
231
231
$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 ) ;
233
233
234
234
if ( eqNode !== undefined && eqNode . uri !== undefined ) {
235
235
uri = eqNode . uri ;
@@ -248,7 +248,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
248
248
* @param {string } label - the label for the node with the given id
249
249
*/
250
250
that . insertLabel = function ( id , label ) {
251
- const searchedItem = nodes . get ( id ) ;
251
+ const searchedItem = nodeMap . get ( id ) ;
252
252
253
253
if ( searchedItem !== undefined ) {
254
254
searchedItem . name = label ;
@@ -264,7 +264,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
264
264
* @param {string } commentToAdd - the comment to add to the node with the given id
265
265
*/
266
266
that . insertComment = function ( id , commentToAdd ) {
267
- const searchedItem = nodes . get ( id ) ;
267
+ const searchedItem = nodeMap . get ( id ) ;
268
268
269
269
if ( searchedItem !== undefined ) {
270
270
searchedItem . comment = commentToAdd ;
@@ -281,7 +281,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
281
281
* @param {string } newUri
282
282
*/
283
283
that . setURI = function ( id , newUri ) {
284
- const nodeToChange = nodes . get ( id ) ;
284
+ const nodeToChange = nodeMap . get ( id ) ;
285
285
286
286
if ( nodeToChange !== undefined ) {
287
287
nodeToChange . uri = newUri ;
@@ -299,7 +299,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
299
299
that . setTypesLoaded = function ( classId ) {
300
300
if ( classId !== undefined && typeof classId === 'string' ) {
301
301
302
- const clazz = nodes . get ( classId ) ;
302
+ const clazz = nodeMap . get ( classId ) ;
303
303
304
304
if ( clazz !== undefined && clazz . type === 'class' ) {
305
305
clazz . typesLoaded = true ;
@@ -315,7 +315,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
315
315
*/
316
316
that . getTypesLoaded = function ( classId ) {
317
317
if ( classId !== undefined && typeof classId === 'string' ) {
318
- const clazz = nodes . get ( classId ) ;
318
+ const clazz = nodeMap . get ( classId ) ;
319
319
320
320
if ( clazz !== undefined && clazz . type === 'class' && clazz . typesLoaded ) {
321
321
$log . debug ( `[Nodes] Types for '${ classId } ' are already loaded!` ) ;
@@ -368,7 +368,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
368
368
}
369
369
370
370
equivalentClasses . set ( classId2 , cl1 . id ) ;
371
- nodes . delete ( classId2 ) ;
371
+ nodeMap . delete ( classId2 ) ;
372
372
deletedId = classId2 ;
373
373
$log . debug ( `[Nodes] Merged '${ cl1 . id } ' and '${ classId2 } '.` ) ;
374
374
}
@@ -381,12 +381,12 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
381
381
} ;
382
382
383
383
that . getClassNodeOrEquivalent = function ( classId ) {
384
- let nodeToReturn = nodes . get ( classId ) ;
384
+ let nodeToReturn = nodeMap . get ( classId ) ;
385
385
386
386
if ( nodeToReturn === undefined ) {
387
387
const equivalentId = equivalentClasses . get ( classId ) ;
388
388
if ( equivalentId !== undefined ) {
389
- nodeToReturn = nodes . get ( equivalentId ) ;
389
+ nodeToReturn = nodeMap . get ( equivalentId ) ;
390
390
}
391
391
}
392
392
@@ -401,7 +401,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
401
401
that . removeNodes = function ( nodeArr ) {
402
402
if ( nodeArr !== undefined && nodeArr . length > 0 ) {
403
403
nodeArr . forEach ( ( node ) => {
404
- nodes . delete ( node ) ;
404
+ nodeMap . delete ( node ) ;
405
405
} ) ;
406
406
}
407
407
} ;
@@ -413,7 +413,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
413
413
* @return {number } the new value of the node or -1 if node was not found
414
414
*/
415
415
that . incValueOfId = function ( id ) {
416
- const searchedItem = nodes . get ( id ) ;
416
+ const searchedItem = nodeMap . get ( id ) ;
417
417
418
418
if ( searchedItem !== undefined && searchedItem . hasOwnProperty ( 'value' ) ) {
419
419
searchedItem . value += 1 ;
@@ -428,7 +428,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
428
428
* @returns {boolean }
429
429
*/
430
430
that . isEmpty = function ( ) {
431
- return ( nodes . size === 0 ) ;
431
+ return ( nodeMap . size === 0 ) ;
432
432
} ;
433
433
434
434
that . hasClassNodes = function ( ) {
@@ -440,7 +440,7 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
440
440
*/
441
441
that . clearAll = function ( ) {
442
442
classUriIdMap . clear ( ) ;
443
- nodes . clear ( ) ;
443
+ nodeMap . clear ( ) ;
444
444
equivalentClasses . clear ( ) ;
445
445
classDatatypesMap . clear ( ) ;
446
446
subClassSet . clear ( ) ;
@@ -460,8 +460,8 @@ function nodesService($log, Properties, Prefixes, RequestConfig, Storage) {
460
460
let exists = false ;
461
461
462
462
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 ) ;
465
465
466
466
if ( childNode !== undefined && parentNode !== undefined ) {
467
467
const combination = childId + parentId ;
0 commit comments