From d7aa68dd40f0712fc8d028255d18526b89f5c16b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 11 Sep 2020 13:49:09 +0200 Subject: [PATCH] Data Dependencies --- .../FunctionLibraries/DataMineFunctions.js | 61 ++++++++++++++++++- DesignSpace/Workspace/Workspace.js | 10 +++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/DataMineFunctions.js b/DesignSpace/Workspace/FunctionLibraries/DataMineFunctions.js index 68f2ba42b..13fae905b 100644 --- a/DesignSpace/Workspace/FunctionLibraries/DataMineFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/DataMineFunctions.js @@ -1,6 +1,8 @@ function newDataMineFunctions() { thisObject = { - addAllOutputDatasets: addAllOutputDatasets + addAllOutputDatasets: addAllOutputDatasets, + addAllDataDependencies: addAllDataDependencies, + addAllDataMineDataDependencies: addAllDataMineDataDependencies } return thisObject @@ -41,4 +43,61 @@ function newDataMineFunctions() { functionLibraryUiObjectsFromNodes ) } + + function addAllDataDependencies(node, functionLibraryUiObjectsFromNodes) { + + /* Validations to see if we can do this or not. */ + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + if (node.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a reference parent node to execute this action.') + return + } + if (node.payload.referenceParent.payload === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a reference parent node to execute this action.') + return + } + + /* + Next, we are going to scan through all the bots of the Data Mine referenced, and for each bot we will + create a Bots Data Dependency node. Later we will scan all the Products Definitions of each bot, and for each + Dataset of each Product we will create a Data Dependency. In case we find Product Definition Folders, we will + recreate that structure too, using in this case Data Dependency Folders. + */ + let dataMine = node.payload.referenceParent + scanBotArray(dataMine.sensorBots) + scanBotArray(dataMine.indicatorBots) + scanBotArray(dataMine.tradingBots) + + function scanBotArray(botArray) { + for (let i = 0; i < botArray.length; i++) { + let bot = botArray[i] + let botProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Data Dependencies') + botProducts.name = bot.name + + asymetricalFolderStructureCloning( + bot, + botProducts, + 'products', + 'productDefinitionFolders', + 'dataDependencyFolders', + 'Data Dependency', + 'Data Dependency Folder', + 'datasets', + functionLibraryUiObjectsFromNodes + ) + } + } + } + + function addAllDataMineDataDependencies(node, rootNodes, functionLibraryUiObjectsFromNodes) { + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + + if (rootNode.type === 'Data Mine') { + let dataMineDataDependencies = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Data Mine Data Dependencies') + dataMineDataDependencies.payload.referenceParent = rootNode + } + } + } } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 2a4adabb2..04d9d72ab 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -631,6 +631,16 @@ function newWorkspace() { functionLibraryDataStorageFunctions.addAllDataMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes) } break + case 'Add All Data Dependencies': + { + functionLibraryDataMineFunctions.addAllDataDependencies(payload.node, functionLibraryUiObjectsFromNodes) + } + break + case 'Add All Data Mine Dependencies': + { + functionLibraryDataMineFunctions.addAllDataMineDataDependencies(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes) + } + break case 'Add All Data Mine Layers': { functionLibraryChartingSpaceFunctions.addAllDataMineLayers(payload.node, functionLibraryUiObjectsFromNodes)