From 39443539fc5518810a008eed79d75bb553fa0aa7 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Sat, 23 Oct 2021 02:41:01 +0300 Subject: [PATCH 1/7] install product in available trading mines --- .../Schemas/App-Schema/product-definition.json | 11 +++++++++++ .../Foundations/UI/Function-Libraries/ActionSwitch.js | 5 +++++ Projects/ProjectsSchema.json | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/Projects/Foundations/Schemas/App-Schema/product-definition.json b/Projects/Foundations/Schemas/App-Schema/product-definition.json index 4efc22367..ccb455e73 100644 --- a/Projects/Foundations/Schemas/App-Schema/product-definition.json +++ b/Projects/Foundations/Schemas/App-Schema/product-definition.json @@ -9,6 +9,17 @@ "dontShowAtFullscreen": true, "actionFunction": "uiObject.configEditor.activate" }, + { + "action": "Install Product", + "label": "Install Product", + "askConfirmation": true, + "confirmationLabel": "Confirm to Proceed", + "workDoneLabel": "Done", + "relatedUiObject": "Product Definition", + "actionFunction": "payload.executeAction", + "relatedUiObjectProject": "Foundations" + }, + { "action": "Add UI Object", "disableIfPropertyIsDefined": true, diff --git a/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js b/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js index 2bff88d79..bf8f2f205 100644 --- a/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js +++ b/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js @@ -446,6 +446,11 @@ function newFoundationsActionSwitch() { UI.projects.foundations.spaces.floatingSpace.moveFloatingObject(action.node.payload.position) } break + case 'Install Product': + { + UI.projects.foundations.functionLibraries.productFunctions.installProduct(action.node, action.rootNodes) + } + break default: { console.log("[WARN] Action sent to Foundations Action Switch does not belong here. Verify at the App Schema file of the node that triggered this action that the actionProject is pointing to the right project. -> Action = " + action.name + " -> Action Node Name = " + action.node.name) diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index c1d5710cf..69f7e03c6 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -371,6 +371,11 @@ "propertyName": "cryptoEcosystemFunctions", "functionName": "newFoundationsFunctionLibraryCryptoEcosystemFunctions" }, + { + "name": "Product Functions", + "propertyName": "productFunctions", + "functionName": "newFoundationsFunctionLibraryProductFunctions" + }, { "name": "Data Storage Functions", "propertyName": "dataStorageFunctions", From 01bc9ccba29f8e033ddbb275ff6276185f34c847 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Sat, 23 Oct 2021 21:59:25 +0300 Subject: [PATCH 2/7] install product into trading mine --- .../UI/Function-Libraries/ProductFunctions.js | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Projects/Foundations/UI/Function-Libraries/ProductFunctions.js diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js new file mode 100644 index 000000000..2dfe66979 --- /dev/null +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -0,0 +1,81 @@ +function newFoundationsFunctionLibraryProductFunctions() { + let thisObject = { + installProduct: installProduct, + + } + + return thisObject + + function installProduct( + node, + rootNodes + ) { + + let product = node + let productIndicatorBot = product.payload.parentNode + let productDataMineParent = productIndicatorBot.payload.parentNode + + + + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Trading Mine') { + installInTradingMine(rootNode) + } + } + + function installInTradingMine(tradingMine) { + + for (let j = 0; j < tradingMine.tradingBots.length; j++) { + let tradingBotNode = tradingMine.tradingBots[j] + installInTradingBotNode(tradingBotNode) + } + + function installInTradingBotNode(tradingBot) { + + for (let k = 0; k < tradingBot.processes.length; k++) { + let process = tradingBot.processes[k] + installInProcessDefinitionDependencies(process) + } + + function installInProcessDefinitionDependencies(process) { + + /** + * In case the data mine is not referenced at all, we must add it + */ + + let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(process.processDependencies, 'Data Mine Data Dependencies', productDataMineParent) + + let botDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, true, true, false, false) + + /** + * If Bot Data Dependency exists add Data Dependencies + * Otherwise create the Bot Data Dependency and add Data Dependencies to newly created Bot Data Dependency + */ + if (botDataDependencies !== undefined) { + addAllDataDependencies(botDataDependencies) + } else { + dataMineDependency.payload.uiObject.menu.internalClick('Add UI Object') + /** + * Find newly created bot data dependency and change his name to match Indicat Bot name + */ + let newBotDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, 'New Bot Data Dependencies', true, true, false, false) + newBotDataDependencies.name = productIndicatorBot.name + addAllDataDependencies(newBotDataDependencies) + } + + + function addAllDataDependencies(botDataDependencies) { + for (let l = 0; l < product.datasets.length; l++) { + let dataset = product.datasets[l] + UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botDataDependencies, 'Data Dependency', dataset) + } + } + + } + } + + } + + } +} \ No newline at end of file From 180a0ff84e558f5131889579ed69453546914178 Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Mon, 25 Oct 2021 02:32:33 +0300 Subject: [PATCH 3/7] refactor trading mine and data mine install; added data task install --- .../UI/Function-Libraries/ProductFunctions.js | 193 +++++++++++++++--- 1 file changed, 170 insertions(+), 23 deletions(-) diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js index 2dfe66979..e9e314603 100644 --- a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -6,6 +6,13 @@ function newFoundationsFunctionLibraryProductFunctions() { return thisObject + /** + * + * This function will install the product into : + * Available Trading Mines as process dependency for the trading bot + * Previously installed Markets + */ + function installProduct( node, rootNodes @@ -15,30 +22,171 @@ function newFoundationsFunctionLibraryProductFunctions() { let productIndicatorBot = product.payload.parentNode let productDataMineParent = productIndicatorBot.payload.parentNode + node.payload.uiObject.setInfoMessage('This product is being installed. This might take a couple of seconds. Please hold on while we connect all the dots for you. ') + setTimeout(startInstalling, 500) - for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode.type === 'Trading Mine') { - installInTradingMine(rootNode) + function startInstalling() { + + for (let i = 0; i < rootNodes.length; i++) { + + let rootNode = rootNodes[i] + + if (rootNode.type === 'Trading Mine') { + installInTradingMine(rootNode) + } else if (rootNode.type === 'LAN Network') { + installInNetworkNodes(rootNode) + } } + + function installInNetworkNodes(lanNetwork) { + + for (let j = 0; j < lanNetwork.lanNetworkNodes.length; j++) { + let lanNetworkNode = lanNetwork.lanNetworkNodes[j] + installInDataMinesData(lanNetworkNode) + installInDataTasks(lanNetworkNode) + } + + + /** + * + * We will add data mine tasks of the product only to existing Market Data Tasks + * If no Market Data Tasks are available, product task will not be installed into this branch + * Market Data can be installed by using Install Market Script. + */ + function installInDataTasks(lanNetworkNode) { + let dataTasks = UI.projects.visualScripting.utilities.branches.findInBranch(lanNetworkNode, 'Data Tasks', product, true) + + // Install in each existing Project Data Task + for (let j = 0; j < dataTasks.projectDataTasks.length; j++) { + let projectDataTask = dataTasks.projectDataTasks[j] + + // Install in each existing Exchange + for (let k = 0; k < projectDataTask.exchangeDataTasks.length; k++) { + let exchangeDataTask = projectDataTask.exchangeDataTasks[k] + + // Install in each existing Market Data + for (let l = 0; l < exchangeDataTask.marketDataTasks.length; l++) { + let marketDataTask = exchangeDataTask.marketDataTasks[l] + + // If Data Mine is not installed we are going to create it, otherwise we use the existing one + let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(marketDataTask, 'Data Mine Tasks', productDataMineParent) + + if (dataMineDependency.taskManagers.length > 0) { + //We will add the task and indicator bot into first task manager we find + let task = findOrCreateTask(dataMineDependency.taskManagers[0]) + let indicatorBot = findOrCreateIndicatorBot(task) + + findOrCreateIndicatorProcessInstance(indicatorBot) + } else { + //Let's create a new task manager as none exists + let newTaskManager = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Task Manager') + newTaskManager.name = productDataMineParent.name + + let task = findOrCreateTask(newTaskManager) + let indicatorBot = findOrCreateIndicatorBot(task) + + findOrCreateIndicatorProcessInstance(indicatorBot) + + } + + } + } + } + + + function findOrCreateTask(taskManager) { + let task = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(taskManager, undefined, productIndicatorBot.name, false, true, false, false) + if (task === undefined) { + let newTask = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(taskManager, 'Task') + newTask.name = productIndicatorBot.name + + return newTask + } + return task; + } + + function findOrCreateIndicatorBot(task) { + let botInstance = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(task, 'Indicator Bot Instance', undefined, false, true, false, false) + if (botInstance === undefined) { + let newBotInstance = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(task, 'Indicator Bot Instance') + newBotInstance.name = productIndicatorBot.name + + return newBotInstance + } + return botInstance + } + + function findOrCreateIndicatorProcessInstance(indicatorBot) { + for (m = 0; m < productIndicatorBot.processes.length; m++) { + let processDefinition = productIndicatorBot.processes[m] + UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(indicatorBot, 'Indicator Process Instance', processDefinition) + } + } + + + + } + + /** + * + * We will add Data Product to Market Data Products only if there is at least one Exchange and Market installed + * We will not create the entire hierarchy for the Exchange as this is a job for Install Market script + * + */ + function installInDataMinesData(lanNetworkNode) { + + let dataMinesData = UI.projects.visualScripting.utilities.branches.findInBranch(lanNetworkNode, 'Data Mines Data', product, true) + + + for (let j = 0; j < dataMinesData.projectDataProducts.length; j++) { + let projectDataProduct = dataMinesData.projectDataProducts[j] + + for (let k = 0; k < projectDataProduct.exchangeDataProducts.length; k++) { + let exchangeDataProduct = projectDataProduct.exchangeDataProducts[k] + + for (let l = 0; l < exchangeDataProduct.marketDataProducts.length; l++) { + let marketDataProduct = exchangeDataProduct.marketDataProducts[l] + + let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(marketDataProduct, 'Data Mine Products', productDataMineParent) + let botProductDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, false, true, false, false) + + /** + * If Bot Product Dependency exists add Data Product + * Otherwise create the Bot Product Dependency and addData Product to newly created Bot Product Dependency + */ + if (botProductDependencies !== undefined) { + addDataProduct(botProductDependencies) + } else { + let newBotProductDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Bot Products') + newBotProductDependencies.name = productIndicatorBot.name + addDataProduct(newBotProductDependencies) + } + + function addDataProduct(botProductDependencies) { + UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botProductDependencies, 'Data Product', product) + } + } + + } + } + + + } + + } + } + + function installInTradingMine(tradingMine) { for (let j = 0; j < tradingMine.tradingBots.length; j++) { let tradingBotNode = tradingMine.tradingBots[j] - installInTradingBotNode(tradingBotNode) - } - function installInTradingBotNode(tradingBot) { - - for (let k = 0; k < tradingBot.processes.length; k++) { - let process = tradingBot.processes[k] - installInProcessDefinitionDependencies(process) - } - - function installInProcessDefinitionDependencies(process) { + for (let k = 0; k < tradingBotNode.processes.length; k++) { + let process = tradingBotNode.processes[k] /** * In case the data mine is not referenced at all, we must add it @@ -46,7 +194,7 @@ function newFoundationsFunctionLibraryProductFunctions() { let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(process.processDependencies, 'Data Mine Data Dependencies', productDataMineParent) - let botDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, true, true, false, false) + let botDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, false, true, false, false) /** * If Bot Data Dependency exists add Data Dependencies @@ -55,11 +203,7 @@ function newFoundationsFunctionLibraryProductFunctions() { if (botDataDependencies !== undefined) { addAllDataDependencies(botDataDependencies) } else { - dataMineDependency.payload.uiObject.menu.internalClick('Add UI Object') - /** - * Find newly created bot data dependency and change his name to match Indicat Bot name - */ - let newBotDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, 'New Bot Data Dependencies', true, true, false, false) + let newBotDataDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Bot Data Dependencies') newBotDataDependencies.name = productIndicatorBot.name addAllDataDependencies(newBotDataDependencies) } @@ -71,11 +215,14 @@ function newFoundationsFunctionLibraryProductFunctions() { UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botDataDependencies, 'Data Dependency', dataset) } } - } } - } + } } -} \ No newline at end of file + +} + + + From af35bf32e09c9941b696e2e569bbaafb4e0fd8cf Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Mon, 25 Oct 2021 02:40:04 +0300 Subject: [PATCH 4/7] identified charting space in workspace --- .../UI/Function-Libraries/ProductFunctions.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js index e9e314603..69dd65f47 100644 --- a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -36,6 +36,8 @@ function newFoundationsFunctionLibraryProductFunctions() { installInTradingMine(rootNode) } else if (rootNode.type === 'LAN Network') { installInNetworkNodes(rootNode) + } else if (rootNode.type === 'Charting Space') { + installInChartingSpace(rootNode) } } @@ -220,6 +222,24 @@ function newFoundationsFunctionLibraryProductFunctions() { } + + function installInChartingSpace(chartingSpace) { + + for (let j = 0; j < chartingSpace.projectDashboards.length; j++) { + let projectDashboard = chartingSpace.projectDashboards[j] + + for (k = 0; k < projectDashboard.dashboards.length; k++) { + let dashboard = projectDashboard.dashboards[k] + + for (l = 0; l < dashboard.timeMachines.length; l++) { + timeMachine = dashboard.timeMachines[l] + + + } + } + } + + } } } From f142fec0c1173c9b50d52b8339d63010a0ff5ffd Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Mon, 25 Oct 2021 21:55:05 +0300 Subject: [PATCH 5/7] install product in charting space --- .../UI/Function-Libraries/ProductFunctions.js | 94 ++++++++++++++----- 1 file changed, 73 insertions(+), 21 deletions(-) diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js index 69dd65f47..3ce174ff8 100644 --- a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -7,10 +7,12 @@ function newFoundationsFunctionLibraryProductFunctions() { return thisObject /** - * - * This function will install the product into : + * + * This function will install the product in : * Available Trading Mines as process dependency for the trading bot * Previously installed Markets + * Data Tasks for all markets + * Charting Space for all dashboards */ function installProduct( @@ -21,6 +23,8 @@ function newFoundationsFunctionLibraryProductFunctions() { let product = node let productIndicatorBot = product.payload.parentNode let productDataMineParent = productIndicatorBot.payload.parentNode + let dataMineProduct + let dataProduct node.payload.uiObject.setInfoMessage('This product is being installed. This might take a couple of seconds. Please hold on while we connect all the dots for you. ') @@ -37,6 +41,7 @@ function newFoundationsFunctionLibraryProductFunctions() { } else if (rootNode.type === 'LAN Network') { installInNetworkNodes(rootNode) } else if (rootNode.type === 'Charting Space') { + // Installing in charting space can be done only after we make sure the Data products are installed installInChartingSpace(rootNode) } } @@ -51,7 +56,7 @@ function newFoundationsFunctionLibraryProductFunctions() { /** - * + * * We will add data mine tasks of the product only to existing Market Data Tasks * If no Market Data Tasks are available, product task will not be installed into this branch * Market Data can be installed by using Install Market Script. @@ -126,15 +131,13 @@ function newFoundationsFunctionLibraryProductFunctions() { } } - - } /** - * - * We will add Data Product to Market Data Products only if there is at least one Exchange and Market installed + * + * We will add Data Product to Market Data Products only if there is at least one Exchange and Market installed * We will not create the entire hierarchy for the Exchange as this is a job for Install Market script - * + * */ function installInDataMinesData(lanNetworkNode) { @@ -150,30 +153,29 @@ function newFoundationsFunctionLibraryProductFunctions() { for (let l = 0; l < exchangeDataProduct.marketDataProducts.length; l++) { let marketDataProduct = exchangeDataProduct.marketDataProducts[l] - let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(marketDataProduct, 'Data Mine Products', productDataMineParent) - let botProductDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, false, true, false, false) + dataMineProduct = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(marketDataProduct, 'Data Mine Products', productDataMineParent) + let botProductDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineProduct, undefined, productIndicatorBot.name, false, true, false, false) /** - * If Bot Product Dependency exists add Data Product - * Otherwise create the Bot Product Dependency and addData Product to newly created Bot Product Dependency - */ + * If Bot Product Dependency exists add Data Product + * Otherwise create the Bot Product Dependency and addData Product to newly created Bot Product Dependency + */ if (botProductDependencies !== undefined) { addDataProduct(botProductDependencies) } else { - let newBotProductDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Bot Products') + let newBotProductDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineProduct, 'Bot Products') newBotProductDependencies.name = productIndicatorBot.name addDataProduct(newBotProductDependencies) } function addDataProduct(botProductDependencies) { - UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botProductDependencies, 'Data Product', product) + dataProduct = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botProductDependencies, 'Data Product', product) } } } } - } } @@ -181,7 +183,6 @@ function newFoundationsFunctionLibraryProductFunctions() { } - function installInTradingMine(tradingMine) { for (let j = 0; j < tradingMine.tradingBots.length; j++) { @@ -228,13 +229,64 @@ function newFoundationsFunctionLibraryProductFunctions() { for (let j = 0; j < chartingSpace.projectDashboards.length; j++) { let projectDashboard = chartingSpace.projectDashboards[j] - for (k = 0; k < projectDashboard.dashboards.length; k++) { + for (let k = 0; k < projectDashboard.dashboards.length; k++) { let dashboard = projectDashboard.dashboards[k] - for (l = 0; l < dashboard.timeMachines.length; l++) { - timeMachine = dashboard.timeMachines[l] + for (let l = 0; l < dashboard.timeMachines.length; l++) { + let timeMachine = dashboard.timeMachines[l] - + if (timeMachine.timelineCharts.length > 0) { + let existingTimelineChartUpdated = false + /** + * We first search the existing timeline charts for a Layer Manager children that references our product data mine parent, to reuse it + * If none found we will create a new timeline chart with all branches + */ + for (let m = 0; m < timeMachine.timelineCharts.length; m++) { + let currentTimelineChart = timeMachine.timelineCharts[m] + + let referencedLayerManager = UI.projects.visualScripting.utilities.nodeChildren.findChildReferencingThisNode(currentTimelineChart, dataMineProduct) + console.log(referencedLayerManager) + if (referencedLayerManager !== undefined) { + // We have found a timeline chart that references our product data mine, let's check if our product is installed, otherwise we install it + + let botLayer = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(referencedLayerManager, undefined, productIndicatorBot.name, false, true, false, false) + + if (botLayer === undefined) { + let newBotLayer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(referencedLayerManager, 'Bot Layers') + newBotLayer.name = productIndicatorBot.name + botLayer = newBotLayer + } + + UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botLayer, 'Layer', dataProduct) + existingTimelineChartUpdated = true + } + + } + // None of the existing timeline charts are referencing our data mine, so let's create it + if (existingTimelineChartUpdated === false) { + createTimelineChartWithAllBranches(timeMachine) + } + } else { + //No timeline chart exists at all, so let's create one for our data mine + createTimelineChartWithAllBranches(timeMachine) + } + + function createTimelineChartWithAllBranches(timeMachine) { + let newTimelineChart = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart') + newTimelineChart.name = productDataMineParent.name + + console.log(dataMineProduct) + let layerManager = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(newTimelineChart, 'Layer Manager') + UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(layerManager, dataMineProduct) + + + let botLayer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(layerManager, 'Bot Layers') + botLayer.name = productIndicatorBot.name + + let layer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(botLayer, 'Layer') + UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(layer, dataProduct) + + } } } } From 6b1b973eccc29349d9a2ea8353586a35239c5c8a Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Tue, 26 Oct 2021 15:22:01 +0300 Subject: [PATCH 6/7] refactored the way the installing procedure is being executed; refactored function names to be more relevant; added install in charting space logic; added save trading mine plugin logic --- .../UI/Function-Libraries/ProductFunctions.js | 243 ++++++++++-------- 1 file changed, 142 insertions(+), 101 deletions(-) diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js index 3ce174ff8..5192beef7 100644 --- a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -33,19 +33,28 @@ function newFoundationsFunctionLibraryProductFunctions() { function startInstalling() { for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode.type === 'Trading Mine') { installInTradingMine(rootNode) - } else if (rootNode.type === 'LAN Network') { + } + } + + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'LAN Network') { installInNetworkNodes(rootNode) - } else if (rootNode.type === 'Charting Space') { - // Installing in charting space can be done only after we make sure the Data products are installed + } + } + + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Charting Space') { installInChartingSpace(rootNode) } } + node.payload.uiObject.setInfoMessage('Product installation is complete.') + function installInNetworkNodes(lanNetwork) { for (let j = 0; j < lanNetwork.lanNetworkNodes.length; j++) { @@ -59,7 +68,7 @@ function newFoundationsFunctionLibraryProductFunctions() { * * We will add data mine tasks of the product only to existing Market Data Tasks * If no Market Data Tasks are available, product task will not be installed into this branch - * Market Data can be installed by using Install Market Script. + * Market Data can be installed by using Install Market script. */ function installInDataTasks(lanNetworkNode) { let dataTasks = UI.projects.visualScripting.utilities.branches.findInBranch(lanNetworkNode, 'Data Tasks', product, true) @@ -81,19 +90,19 @@ function newFoundationsFunctionLibraryProductFunctions() { if (dataMineDependency.taskManagers.length > 0) { //We will add the task and indicator bot into first task manager we find - let task = findOrCreateTask(dataMineDependency.taskManagers[0]) - let indicatorBot = findOrCreateIndicatorBot(task) + let task = ceateTaskIfNotPresent(dataMineDependency.taskManagers[0]) + let indicatorBot = createIndicatorBotIfNotPresent(task) - findOrCreateIndicatorProcessInstance(indicatorBot) + createIndicatorProcessInstanceIfNotPresent(indicatorBot) } else { //Let's create a new task manager as none exists let newTaskManager = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Task Manager') newTaskManager.name = productDataMineParent.name - let task = findOrCreateTask(newTaskManager) - let indicatorBot = findOrCreateIndicatorBot(task) + let task = ceateTaskIfNotPresent(newTaskManager) + let indicatorBot = createIndicatorBotIfNotPresent(task) - findOrCreateIndicatorProcessInstance(indicatorBot) + createIndicatorProcessInstanceIfNotPresent(indicatorBot) } @@ -102,7 +111,7 @@ function newFoundationsFunctionLibraryProductFunctions() { } - function findOrCreateTask(taskManager) { + function ceateTaskIfNotPresent(taskManager) { let task = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(taskManager, undefined, productIndicatorBot.name, false, true, false, false) if (task === undefined) { let newTask = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(taskManager, 'Task') @@ -113,7 +122,7 @@ function newFoundationsFunctionLibraryProductFunctions() { return task; } - function findOrCreateIndicatorBot(task) { + function createIndicatorBotIfNotPresent(task) { let botInstance = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(task, 'Indicator Bot Instance', undefined, false, true, false, false) if (botInstance === undefined) { let newBotInstance = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(task, 'Indicator Bot Instance') @@ -124,8 +133,8 @@ function newFoundationsFunctionLibraryProductFunctions() { return botInstance } - function findOrCreateIndicatorProcessInstance(indicatorBot) { - for (m = 0; m < productIndicatorBot.processes.length; m++) { + function createIndicatorProcessInstanceIfNotPresent(indicatorBot) { + for (let m = 0; m < productIndicatorBot.processes.length; m++) { let processDefinition = productIndicatorBot.processes[m] UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(indicatorBot, 'Indicator Process Instance', processDefinition) } @@ -161,14 +170,14 @@ function newFoundationsFunctionLibraryProductFunctions() { * Otherwise create the Bot Product Dependency and addData Product to newly created Bot Product Dependency */ if (botProductDependencies !== undefined) { - addDataProduct(botProductDependencies) + createDataProductIfNotPresent(botProductDependencies) } else { let newBotProductDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineProduct, 'Bot Products') newBotProductDependencies.name = productIndicatorBot.name - addDataProduct(newBotProductDependencies) + createDataProductIfNotPresent(newBotProductDependencies) } - function addDataProduct(botProductDependencies) { + function createDataProductIfNotPresent(botProductDependencies) { dataProduct = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botProductDependencies, 'Data Product', product) } } @@ -180,118 +189,150 @@ function newFoundationsFunctionLibraryProductFunctions() { } - } + function installInTradingMine(tradingMine) { + let savePlugin = false + for (let j = 0; j < tradingMine.tradingBots.length; j++) { + let tradingBotNode = tradingMine.tradingBots[j] + + for (let k = 0; k < tradingBotNode.processes.length; k++) { + let process = tradingBotNode.processes[k] + + /** + * In case the data mine is not referenced at all, we must add it + */ + + let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(process.processDependencies, 'Data Mine Data Dependencies', productDataMineParent) + + let botDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, false, true, false, false) + + /** + * If Bot Data Dependency exists add Data Dependencies + * Otherwise create the Bot Data Dependency and add Data Dependencies to newly created Bot Data + */ + if (botDataDependencies !== undefined) { + addAllDataDependenciesIfNotExists(botDataDependencies) + } else { + let newBotDataDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Bot Data Dependencies') + newBotDataDependencies.name = productIndicatorBot.name + addAllDataDependenciesIfNotExists(newBotDataDependencies) + } - function installInTradingMine(tradingMine) { + function addAllDataDependenciesIfNotExists(botDataDependencies) { + for (let l = 0; l < product.datasets.length; l++) { + let dataset = product.datasets[l] - for (let j = 0; j < tradingMine.tradingBots.length; j++) { - let tradingBotNode = tradingMine.tradingBots[j] - - for (let k = 0; k < tradingBotNode.processes.length; k++) { - let process = tradingBotNode.processes[k] - - /** - * In case the data mine is not referenced at all, we must add it - */ - - let dataMineDependency = UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(process.processDependencies, 'Data Mine Data Dependencies', productDataMineParent) - - let botDataDependencies = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(dataMineDependency, undefined, productIndicatorBot.name, false, true, false, false) - - /** - * If Bot Data Dependency exists add Data Dependencies - * Otherwise create the Bot Data Dependency and add Data Dependencies to newly created Bot Data Dependency - */ - if (botDataDependencies !== undefined) { - addAllDataDependencies(botDataDependencies) - } else { - let newBotDataDependencies = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(dataMineDependency, 'Bot Data Dependencies') - newBotDataDependencies.name = productIndicatorBot.name - addAllDataDependencies(newBotDataDependencies) - } - - - function addAllDataDependencies(botDataDependencies) { - for (let l = 0; l < product.datasets.length; l++) { - let dataset = product.datasets[l] - UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botDataDependencies, 'Data Dependency', dataset) + // Explicit check is needed so we know if we have to save the plugin or not + if (UI.projects.visualScripting.utilities.nodeChildren.isMissingChildrenById(botDataDependencies, dataset, true) === true) { + savePlugin = true + let dataDependency = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(botDataDependencies, 'Data Dependency') + UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(dataDependency, dataset) + } + } } } } + /** + * There is no reason to save the plugin if no modifications have been made to the hierarchy + * We will save the plugin only if we get to the point were we have to add the data dependencies + * + */ + if (savePlugin) { + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode.type === 'Plugins') { + let tradingMinePlugin = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(rootNode, 'Plugin Trading Mines', undefined, false, true, false, false) + + for (let j = 0; j < tradingMinePlugin.pluginFiles.length; j++) { + pluginFile = tradingMinePlugin.pluginFiles[j] + + UI.projects.communityPlugins.functionLibraries.pluginsFunctions.savePlugin(pluginFile) + } + } + } + + } + } + /** + * This function will install the product into existing Charting Space + * It is mandatory to have at least a dashboard which contains at least one time machine + * + */ + function installInChartingSpace(chartingSpace) { - } + for (let j = 0; j < chartingSpace.projectDashboards.length; j++) { + let projectDashboard = chartingSpace.projectDashboards[j] - function installInChartingSpace(chartingSpace) { + for (let k = 0; k < projectDashboard.dashboards.length; k++) { + let dashboard = projectDashboard.dashboards[k] - for (let j = 0; j < chartingSpace.projectDashboards.length; j++) { - let projectDashboard = chartingSpace.projectDashboards[j] + for (let l = 0; l < dashboard.timeMachines.length; l++) { + let timeMachine = dashboard.timeMachines[l] - for (let k = 0; k < projectDashboard.dashboards.length; k++) { - let dashboard = projectDashboard.dashboards[k] + if (timeMachine.timelineCharts.length > 0) { + let existingTimelineChartUpdated = false + /** + * We first search the existing timeline charts for a Layer Manager children that references our product data mine parent, to reuse it + * If none found we will create a new timeline chart with all branches + */ + for (let m = 0; m < timeMachine.timelineCharts.length; m++) { + let currentTimelineChart = timeMachine.timelineCharts[m] - for (let l = 0; l < dashboard.timeMachines.length; l++) { - let timeMachine = dashboard.timeMachines[l] - - if (timeMachine.timelineCharts.length > 0) { - let existingTimelineChartUpdated = false - /** - * We first search the existing timeline charts for a Layer Manager children that references our product data mine parent, to reuse it - * If none found we will create a new timeline chart with all branches - */ - for (let m = 0; m < timeMachine.timelineCharts.length; m++) { - let currentTimelineChart = timeMachine.timelineCharts[m] - - let referencedLayerManager = UI.projects.visualScripting.utilities.nodeChildren.findChildReferencingThisNode(currentTimelineChart, dataMineProduct) - console.log(referencedLayerManager) - if (referencedLayerManager !== undefined) { - // We have found a timeline chart that references our product data mine, let's check if our product is installed, otherwise we install it - - let botLayer = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(referencedLayerManager, undefined, productIndicatorBot.name, false, true, false, false) - - if (botLayer === undefined) { - let newBotLayer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(referencedLayerManager, 'Bot Layers') - newBotLayer.name = productIndicatorBot.name - botLayer = newBotLayer + let referencedLayerManager = UI.projects.visualScripting.utilities.nodeChildren.findChildReferencingThisNode(currentTimelineChart, dataMineProduct) + if (referencedLayerManager !== undefined) { + // We have found a timeline chart that references our product data mine, let's check if our product is installed, otherwise we install it + let botLayer = createBotLayerIfNotPresent(referencedLayerManager) + createLayerIfNotPresent(botLayer) + existingTimelineChartUpdated = true } - UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botLayer, 'Layer', dataProduct) - existingTimelineChartUpdated = true } - - } - // None of the existing timeline charts are referencing our data mine, so let's create it - if (existingTimelineChartUpdated === false) { + // None of the existing timeline charts are referencing our data mine, so let's create it + if (existingTimelineChartUpdated === false) { + createTimelineChartWithAllBranches(timeMachine) + } + } else { + //No timeline chart exists at all, so let's create one for our data mine createTimelineChartWithAllBranches(timeMachine) } - } else { - //No timeline chart exists at all, so let's create one for our data mine - createTimelineChartWithAllBranches(timeMachine) - } - function createTimelineChartWithAllBranches(timeMachine) { - let newTimelineChart = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart') - newTimelineChart.name = productDataMineParent.name + function createTimelineChartWithAllBranches(timeMachine) { + let newTimelineChart = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(timeMachine, 'Timeline Chart') + newTimelineChart.name = productDataMineParent.name - console.log(dataMineProduct) - let layerManager = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(newTimelineChart, 'Layer Manager') - UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(layerManager, dataMineProduct) + let layerManager = newTimelineChart.layerManager + UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(layerManager, dataMineProduct) + let botLayer = createBotLayerIfNotPresent(layerManager) + createLayerIfNotPresent(botLayer) - let botLayer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(layerManager, 'Bot Layers') - botLayer.name = productIndicatorBot.name + } - let layer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(botLayer, 'Layer') - UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(layer, dataProduct) + function createBotLayerIfNotPresent(layerManager) { + let botLayer = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(layerManager, undefined, productIndicatorBot.name, false, true, false, false) + if (botLayer === undefined) { + let newBotLayer = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(layerManager, 'Bot Layers') + newBotLayer.name = productIndicatorBot.name + return newBotLayer + } + return botLayer + } + + function createLayerIfNotPresent(botLayer) { + UI.projects.visualScripting.utilities.nodeChildren.findOrCreateChildWithReference(botLayer, 'Layer', dataProduct) + } } } } + } } + + } } From 6a3e7bea73abb1cf9e92328b22372975246d6d9d Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Tue, 26 Oct 2021 15:52:50 +0300 Subject: [PATCH 7/7] global variable 'pluginFile' --- Projects/Foundations/UI/Function-Libraries/ProductFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js index 5192beef7..a5a34fd60 100644 --- a/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/ProductFunctions.js @@ -244,7 +244,7 @@ function newFoundationsFunctionLibraryProductFunctions() { let tradingMinePlugin = UI.projects.visualScripting.utilities.meshes.findNodeInNodeMesh(rootNode, 'Plugin Trading Mines', undefined, false, true, false, false) for (let j = 0; j < tradingMinePlugin.pluginFiles.length; j++) { - pluginFile = tradingMinePlugin.pluginFiles[j] + let pluginFile = tradingMinePlugin.pluginFiles[j] UI.projects.communityPlugins.functionLibraries.pluginsFunctions.savePlugin(pluginFile) }