From 040b8a7f4f845cdd425a32c234de38213a03ccf5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 12 Sep 2020 20:33:02 +0200 Subject: [PATCH] Data Mining --- .../FunctionLibraries/TaskFunctions.js | 58 +++++++++++++++--- .../FunctionLibraries/UiObjectsFromNodes.js | 13 ++++ DesignSpace/Workspace/Workspace.js | 23 +++++-- FloatingSpace/CircularMenuItem.js | 2 +- Utilities/NodeChildren.js | 61 +++++++++++++++++++ 5 files changed, 144 insertions(+), 13 deletions(-) create mode 100644 Utilities/NodeChildren.js diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index 8e070e9bf..6509cec62 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -6,8 +6,11 @@ function newTaskFunctions() { stopAllTasks: stopAllTasks, runAllTaskManagers: runAllTaskManagers, stopAllTaskManagers: stopAllTaskManagers, - runAllExchangeTasks: runAllExchangeTasks, - stopAllExchangeTasks: stopAllExchangeTasks + runAllExchangeDataTasks: runAllExchangeDataTasks, + stopAllExchangeDataTasks: stopAllExchangeDataTasks, + runAllExchangeTradingTasks: runAllExchangeTradingTasks, + stopAllExchangeTradingTasks: stopAllExchangeTradingTasks, + addMissingExchangeDataTasks: addMissingExchangeDataTasks } return thisObject @@ -42,8 +45,8 @@ function newTaskFunctions() { 'Output Dataset->Dataset Definition->Product Definition->' + 'Process Dependencies->' + 'Status Dependency->Status Report->Process Definition->' + - 'Data Mine Data Dependencies->Bot Data Dependencies->' + - 'Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->' + + 'Data Mine Data Dependencies->Bot Data Dependencies->' + + 'Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->Data Dependency Folder->' + 'Data Dependency->Dataset Definition->Product Definition->' + 'Record Definition->Record Property->Formula->' + 'Data Building Procedure->' + @@ -56,7 +59,7 @@ function newTaskFunctions() { 'Execution Finished Event->' + 'Execution Started Event->Execution Finished Event->Process Definition->' + 'Sensor Bot->' + - 'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' + + 'Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->Product Definition Folder->' + 'Indicator Bot->' + 'Trading Bot->' + 'Data Mine->' @@ -67,7 +70,7 @@ function newTaskFunctions() { 'Data Storage->Session Independent Data->Exchange Data Products->' + '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 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->' + @@ -215,7 +218,7 @@ function newTaskFunctions() { menu.internalClick('Stop All Tasks') } } - function runAllExchangeTasks(parent, functionLibraryProtocolNode) { + function runAllExchangeDataTasks(parent, functionLibraryProtocolNode) { for (let i = 0; i < parent.exchangeTasks.length; i++) { let node = parent.exchangeTasks[i] let menu = node.payload.uiObject.menu @@ -225,7 +228,7 @@ function newTaskFunctions() { } } - function stopAllExchangeTasks(parent, functionLibraryProtocolNode) { + function stopAllExchangeDataTasks(parent, functionLibraryProtocolNode) { for (let i = 0; i < parent.exchangeTasks.length; i++) { let node = parent.exchangeTasks[i] let menu = node.payload.uiObject.menu @@ -234,4 +237,43 @@ function newTaskFunctions() { menu.internalClick('Stop All Task Managers') } } + + function runAllExchangeTradingTasks(parent, functionLibraryProtocolNode) { + for (let i = 0; i < parent.exchangeTasks.length; i++) { + let node = parent.exchangeTasks[i] + let menu = node.payload.uiObject.menu + + menu.internalClick('Run All Task Managers') + menu.internalClick('Run All Task Managers') + } + } + + function stopAllExchangeTradingTasks(parent, functionLibraryProtocolNode) { + for (let i = 0; i < parent.exchangeTasks.length; i++) { + let node = parent.exchangeTasks[i] + let menu = node.payload.uiObject.menu + + menu.internalClick('Stop All Task Managers') + menu.internalClick('Stop All Task Managers') + } + } + + function addMissingExchangeDataTasks(node, rootNodes, functionLibraryUiObjectsFromNodes) { + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Crypto Ecosystem') { + cryptoEcosystem = rootNode + for (let j = 0; j < cryptoEcosystem.cryptoExchanges.length; j++) { + let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j] + for (let k=0; k < cryptoExchanges.exchanges.length; k++) { + let cryptoExchange = cryptoExchanges.exchanges[j] + if (isMissingChildren(node, cryptoExchange, true) === true) { + let exchangeDataTasks = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Exchange Data Tasks') + exchangeDataTasks.payload.referenceParent = cryptoExchange + } + } + } + } + } + } } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 029fca001..9f6094a2f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -26,6 +26,19 @@ function newUiObjectsFromNodes() { tasksToRun = [] sessionsToRun = [] + removeNullRootNodes() + + function removeNullRootNodes() { + for (let i = 0; i < node.rootNodes.length; i++) { + let rootNode = node.rootNodes[i] + if (rootNode === null) { + node.rootNodes.splice(i, 1) + removeNullRootNodes() + return + } + } + } + getIncludedNames() function getIncludedNames() { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 04d9d72ab..5070a8370 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -591,14 +591,29 @@ function newWorkspace() { functionLibraryTaskFunctions.stopAllTaskManagers(payload.node, functionLibraryProtocolNode) } break - case 'Run All Exchange Tasks': + case 'Run All Exchange Data Tasks': { - functionLibraryTaskFunctions.runAllExchangeTasks(payload.node, functionLibraryProtocolNode) + functionLibraryTaskFunctions.runAllExchangeDataTasks(payload.node, functionLibraryProtocolNode) } break - case 'Stop All Exchange Tasks': + case 'Stop All Exchange Data Tasks': { - functionLibraryTaskFunctions.stopAllExchangeTasks(payload.node, functionLibraryProtocolNode) + functionLibraryTaskFunctions.stopAllExchangeDataTasks(payload.node, functionLibraryProtocolNode) + } + break + case 'Run All Exchange Trading Tasks': + { + functionLibraryTaskFunctions.runAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode) + } + break + case 'Stop All Exchange Trading Tasks': + { + functionLibraryTaskFunctions.stopAllExchangeTradingTasks(payload.node, functionLibraryProtocolNode) + } + break + case 'Add Missing Exchange Data Tasks': + { + functionLibraryTaskFunctions.addMissingExchangeDataTasks(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes) } break case 'Add Missing Crypto Exchanges': diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index bf21cf958..0a632691f 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -299,7 +299,7 @@ function newCircularMenuItem() { /* The first click ask for confirmation. */ if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET) { - setStatus(thisObject.confirmationLabel, UI_COLOR.GOLDEN_ORANGE, 20, STATUS_WAITING_CONFIRMATION) + setStatus(thisObject.confirmationLabel, UI_COLOR.GOLDEN_ORANGE, 100, STATUS_WAITING_CONFIRMATION) return } /* A Click during confirmation executes the pre-defined action. */ diff --git a/Utilities/NodeChildren.js b/Utilities/NodeChildren.js new file mode 100644 index 000000000..3af5b1643 --- /dev/null +++ b/Utilities/NodeChildren.js @@ -0,0 +1,61 @@ +function isMissingChildren(startingNode, checkNode, checkReferenceParent) { + /* + This functioin scan all the children of a node and returns true or false + depending if the checkNode is a missing children. + */ + if (startingNode === undefined) { return } + if (checkNode === undefined) { return } + + let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type) + if (nodeDefinition === undefined) { 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': { + let child = startingNode[property.name] + if (checkReferenceParent !== true) { + if (child.id === checkNode.id) { + return false + } + } else { + if (child.payload !== undefined) { + if (child.payload.referenceParent !== undefined) { + if (child.payload.referenceParent.id === checkNode.id) { + return false + } + } + } + } + } + break + case 'array': { + let startingNodePropertyArray = startingNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + let arrayItem = startingNodePropertyArray[m] + if (checkReferenceParent !== true) { + if (arrayItem.id === checkNode.id) { + return false + } + } else { + if (arrayItem.payload !== undefined) { + if (arrayItem.payload.referenceParent !== undefined) { + if (arrayItem.payload.referenceParent.id === checkNode.id) { + return false + } + } + } + } + } + } + break + } + } + } + return true + } +} \ No newline at end of file