Data Mining Running Again

This commit is contained in:
Luis Fernando Molina committed 2020-09-01 12:48:59 +02:00
1 parent edc20a1a0a
commit 4239ef1a40
5 files changed
+70 -68

No files matched your search

-54
View File
@@ -36,57 +36,3 @@ function nodeBranchToArray(node, nodeType) {
}
}
}
function findNodeInNodeBranch(node, nodeType) {
/*
This function scans a node branch for a certain node type and
returns the first instance found.
*/
let nodeFound
scanNodeBranch(node, nodeType)
return nodeFound
function scanNodeBranch(startingNode) {
if (startingNode === undefined) { return }
if (nodeFound !== undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
if (startingNode.type === nodeType) {
nodeFound = startingNode
return
}
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
scanNodeBranch(startingNode[property.name])
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeBranch(startingNodePropertyArray[m])
}
}
break
}
}
}
}
/* We scan parents nodes. */
if (startingNode.parentNode !== undefined) {
scanNodeBranch(startingNode.parentNode)
}
/* We scan reference parents too. */
if (startingNode.referenceParent !== undefined) {
scanNodeBranch(startingNode.referenceParent)
}
}
}
+53
View File
@@ -0,0 +1,53 @@
function findNodeInNodeMesh(node, nodeType) {
/*
This function scans a node mesh for a certain node type and
returns the first instance found.
*/
let nodeFound
scanNodeMesh(node, nodeType)
return nodeFound
function scanNodeMesh(startingNode) {
if (startingNode === undefined) { return }
if (nodeFound !== undefined) { return }
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
if (startingNode.type === nodeType) {
nodeFound = startingNode
return
}
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.type) {
case 'node': {
scanNodeMesh(startingNode[property.name])
}
break
case 'array': {
let startingNodePropertyArray = startingNode[property.name]
if (startingNodePropertyArray !== undefined) {
for (let m = 0; m < startingNodePropertyArray.length; m++) {
scanNodeMesh(startingNodePropertyArray[m])
}
}
break
}
}
}
}
/* We scan parents nodes. */
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode)
}
/* We scan reference parents too. */
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent)
}
}
}