From 4239ef1a4064ace4f89bfa95048f8f2007af01cb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 1 Sep 2020 12:48:59 +0200 Subject: [PATCH] Data Mining Running Again --- ChartingSpace/PlottersManager.js | 2 +- .../FunctionLibraries/TaskFunctions.js | 5 +- Panels/Layer.js | 24 ++++----- Utilities/Branches.js | 54 ------------------- Utilities/Meshes.js | 53 ++++++++++++++++++ 5 files changed, 70 insertions(+), 68 deletions(-) create mode 100644 Utilities/Meshes.js diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index db9f03754..0a0092364 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -144,7 +144,7 @@ function newPlottersManager() { A layer can be referencing a Data Product in two different branches of the Network hiriatchy. In one of those braches we can get the Session node, at the other we Cannot. */ - let sessionReference = findNodeInNodeBranch(layer.definition, 'Session Reference') + let sessionReference = findNodeInNodeMesh(layer.definition, 'Session Reference') if (sessionReference !== undefined) { session = sessionReference.referenceParent diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index 0db5b5ed0..a6c7001f4 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -62,7 +62,10 @@ function newTaskFunctions() { let networkLightingPath = '->Network->Network Node->' + 'Data Storage->Session Independent Data->Exchange Data Products->' + - 'Single Market Data->Data Product->Product Definition->' + + 'Single Market Data->' + + 'Data Mine Products->Bot Products->' + + 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + + 'Data Product->Product Definition->' + 'Data Mining->Testing Environment->Production Environment->' + 'Exchange Tasks->Crypto Exchange->' + 'Task Manager->Task->' + diff --git a/Panels/Layer.js b/Panels/Layer.js index 5a382c213..dc6d2c20c 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -205,46 +205,46 @@ function newLayer() { } /* Here we validate that we have all the needed information */ - if (findNodeInNodeBranch(thisObject.definition, 'Data Product') === undefined) { + if (findNodeInNodeMesh(thisObject.definition, 'Data Product') === undefined) { thisObject.payload.uiObject.setErrorMessage('Data Product not Found') return } - if (findNodeInNodeBranch(thisObject.definition, 'Market') === undefined) { + if (findNodeInNodeMesh(thisObject.definition, 'Market') === undefined) { thisObject.payload.uiObject.setErrorMessage('Market not Found') return } - thisObject.productDefinition = findNodeInNodeBranch(thisObject.definition, 'Product Definition') + thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition') if (thisObject.productDefinition === undefined) { thisObject.payload.uiObject.setErrorMessage('Product Definition not Found') return } - thisObject.bot = findNodeInNodeBranch(thisObject.definition, 'Sensor Bot') + thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot') if (thisObject.bot === undefined) { - thisObject.bot = findNodeInNodeBranch(thisObject.definition, 'Indicator Bot') + thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot') } if (thisObject.bot === undefined) { - thisObject.bot = findNodeInNodeBranch(thisObject.definition, 'Trading Bot') + thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot') } if (thisObject.bot === undefined) { thisObject.payload.uiObject.setErrorMessage('Bot not Found') return } - thisObject.dataMine = findNodeInNodeBranch(thisObject.definition, 'Data Mine') + thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine') if (thisObject.dataMine === undefined) { thisObject.payload.uiObject.setErrorMessage('Data Mine not Found') return } - thisObject.exchange = findNodeInNodeBranch(thisObject.definition, 'Crypto Exchange') + thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange') if (thisObject.exchange === undefined) { thisObject.payload.uiObject.setErrorMessage('Crypto Exchange not Found') return } - thisObject.baseAsset = findNodeInNodeBranch(thisObject.definition, 'Market Base Asset') + thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset') if (thisObject.baseAsset !== undefined) { thisObject.baseAsset = thisObject.baseAsset.referenceParent } @@ -253,7 +253,7 @@ function newLayer() { return } - thisObject.quotedAsset = findNodeInNodeBranch(thisObject.definition, 'Market Quoted Asset') + thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset') if (thisObject.quotedAsset !== undefined) { thisObject.quotedAsset = thisObject.quotedAsset.referenceParent } @@ -262,13 +262,13 @@ function newLayer() { return } - thisObject.plotterModule = findNodeInNodeBranch(thisObject.definition, 'Plotter Module') + thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module') if (thisObject.plotterModule === undefined) { thisObject.payload.uiObject.setErrorMessage('Market Quoted Asset not Found') return } - thisObject.networkNode = findNodeInNodeBranch(thisObject.definition, 'Network Node') + thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node') if (thisObject.networkNode === undefined) { thisObject.payload.uiObject.setErrorMessage('Network Node not Found') return diff --git a/Utilities/Branches.js b/Utilities/Branches.js index b82686545..71123093d 100644 --- a/Utilities/Branches.js +++ b/Utilities/Branches.js @@ -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) - } - } -} \ No newline at end of file diff --git a/Utilities/Meshes.js b/Utilities/Meshes.js new file mode 100644 index 000000000..42d53bea1 --- /dev/null +++ b/Utilities/Meshes.js @@ -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) + } + } +} \ No newline at end of file