Folders at Data Products and Layers

This commit is contained in:
Luis Fernando Molina committed 2020-08-31 14:37:47 +02:00
1 parent 27130d6ca7
commit 327f5f826b
6 files changed
+241 -61

No files matched your search

@@ -0,0 +1,50 @@
function newChartingSpaceFunctions() {
thisObject = {
addAllDataMineLayers: addAllDataMineLayers
}
return thisObject
function addAllDataMineLayers(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
}
/*
We are going to go through the referenced branch and recreate the structure
we find there inside the layers manager. We will end up having at the end
all layers referencing the data products inside the referenced branch.
*/
let dataMine = node.payload.referenceParent
scanBotArray(dataMine.botProducts)
function scanBotArray(botArray) {
for (let i = 0; i < botArray.length; i++) {
let bot = botArray[i]
let botLayers = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Bot Layers')
botLayers.name = bot.name
asymetricalFolderStructureCloning(
bot,
botLayers,
'dataProducts',
'dataProductFolders',
'layerFolders',
'Layer',
'Layer Folder',
undefined,
functionLibraryUiObjectsFromNodes
)
}
}
}
}
@@ -1,11 +1,11 @@
function newDataMineFunctions() {
thisObject = {
addMissingOutputDatasets: addMissingOutputDatasets
addAllOutputDatasets: addAllOutputDatasets
}
return thisObject
function addMissingOutputDatasets(node, functionLibraryUiObjectsFromNodes) {
function addAllOutputDatasets(node, functionLibraryUiObjectsFromNodes) {
/* Validations to see if we can do this or not. */
if (node.payload === undefined) { return }
@@ -29,57 +29,16 @@ function newDataMineFunctions() {
Output Dataset Folder, and for each Product Definition found we will create a Output Definition
for each Dataset defined inside the Product Definition.
*/
scanForProductDefinitions(node.payload.parentNode.payload.parentNode, node)
function scanForProductDefinitions(originNode, destinationNode) {
if (originNode === undefined) { return }
if (destinationNode === undefined) { return }
/* Now we go down through all the children of the origin node, recreating at the destination node the same children structure*/
let nodeDefinition = getNodeDefinition(originNode)
if (nodeDefinition === undefined) { return }
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.name) {
case 'products': {
let originNodePropertyArray = originNode[property.name]
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originProduct = originNodePropertyArray[m]
for (let n = 0; n < originProduct.datasets.length; n++) {
let datasetDefinition = originProduct.datasets[n]
let outputDataset = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, 'Output Dataset')
outputDataset.payload.referenceParent = datasetDefinition
}
}
break
}
case 'productDefinitionFolders': {
let originNodePropertyArray = originNode[property.name]
let destinationNodePropertyArray = destinationNode['outputDatasetFolders']
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originFolder = originNodePropertyArray[m]
let found = false
let destinationFolder
for (let n = 0; n < destinationNodePropertyArray.length; n++) {
destinationFolder = destinationNodePropertyArray[n]
if (originFolder.name === destinationFolder.name) {
found = true
}
}
if (found === false) {
destinationFolder = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, 'Output Dataset Folder')
destinationFolder.name = originFolder.name
}
scanForProductDefinitions(originFolder, destinationFolder)
}
break
}
}
}
}
}
asymetricalFolderStructureCloning(
node.payload.parentNode.payload.parentNode,
node,
'products',
'productDefinitionFolders',
'outputDatasetFolders',
'Output Dataset',
'Output Dataset Folder',
'datasets',
functionLibraryUiObjectsFromNodes
)
}
}
@@ -0,0 +1,65 @@
function newDataStorageFunctions() {
thisObject = {
addAllDataProducts: addAllDataProducts,
addAllDataMineProducts: addAllDataMineProducts
}
return thisObject
function addAllDataProducts(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 Products node. Later we will scan all the Products Definitions of each bot, and for each one
we will create a Data Product. In case we find Product Definition Folders, we will recreate that structure
too, using in this case Data Product 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 Products')
botProducts.name = bot.name
asymetricalFolderStructureCloning(
bot,
botProducts,
'products',
'productDefinitionFolders',
'dataProductFolders',
'Data Product',
'Data Product Folder',
undefined,
functionLibraryUiObjectsFromNodes
)
}
}
}
function addAllDataMineProducts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
if (rootNode.type === 'Data Mine') {
let dataMineProducts = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Data Mine Products')
dataMineProducts.payload.referenceParent = rootNode
}
}
}
}
+19 -2
View File
@@ -67,6 +67,8 @@ function newWorkspace() {
let functionLibraryDependenciesFilter = newDependenciesFilter()
let functionLibraryNodePath = newNodePath()
let functionLibraryDataMineFunctions = newDataMineFunctions()
let functionLibraryDataStorageFunctions = newDataStorageFunctions()
let functionLibraryChartingSpaceFunctions = newChartingSpaceFunctions()
thisObject.nodeChildren = newNodeChildren()
@@ -613,9 +615,24 @@ function newWorkspace() {
functionLibraryCCXTFunctions.addMissingMarkets(payload.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning)
}
break
case 'Add Missing Output Datasets':
case 'Add All Output Datasets':
{
functionLibraryDataMineFunctions.addMissingOutputDatasets(payload.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning)
functionLibraryDataMineFunctions.addAllOutputDatasets(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Products':
{
functionLibraryDataStorageFunctions.addAllDataProducts(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Products':
{
functionLibraryDataStorageFunctions.addAllDataMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Mine Layers':
{
functionLibraryChartingSpaceFunctions.addAllDataMineLayers(payload.node, functionLibraryUiObjectsFromNodes)
}
break
case 'Send Webhook Test Message':
+1 -5
View File
@@ -163,9 +163,7 @@ function newLayer() {
'Exchange Markets->Crypto Exchange->' +
'Product Definition->' +
'Sensor Bot->Indicator Bot->Trading Bot->' +
'Data Mine->' +
'Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->' +
'Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->Output Dataset Folder->' +
'Data Mine->' +
'Dataset Definition->' +
'Record Definition->Record Property->Formula->' +
'Data Building Procedure->Procedure Loop->Javascript Code->Procedure Initialization->Javascript Code->' +
@@ -193,8 +191,6 @@ function newLayer() {
if (thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset === undefined) { return }
if (thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent === undefined) { return }
if (thisObject.definition.referenceParent.referenceParent === undefined) { return }
if (thisObject.definition.referenceParent.referenceParent.parentNode === undefined) { return }
if (thisObject.definition.referenceParent.referenceParent.parentNode.parentNode === undefined) { return }
if (thisObject.definition.referenceParent.parentNode.parentNode === undefined) { return }
if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode === undefined) { return }
if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode === undefined) { return }
+93
View File
@@ -0,0 +1,93 @@
function asymetricalFolderStructureCloning(
originNode,
destinationNode,
originObjectsArrayPropertyName,
originFoldersArrayPropertyName,
destinationFoldersArrayPropertyName,
clonedObjectType,
destinationFolderType,
originObjectArrayPropertyName,
functionLibraryUiObjectsFromNodes
) {
/*
This function will scan one branch of the workspace, and recreate
a similar structure in some other place, based on the parameters
sent to the function is what types of nodes are going to be mapped
into which other types.
*/
if (originNode === undefined) { return }
if (destinationNode === undefined) { return }
/* Now we go down through all the children of the origin node, recreating at the destination node the same children structure*/
let nodeDefinition = getNodeDefinition(originNode)
if (nodeDefinition === undefined) { return }
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
switch (property.name) {
case originObjectsArrayPropertyName: {
let originNodePropertyArray = originNode[property.name]
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originObject = originNodePropertyArray[m]
if (originObjectArrayPropertyName === undefined) {
/*
In this first Use Case, we are going to connect each orgin object clone
to its origin object counter part.
*/
let clonedObject = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, clonedObjectType)
clonedObject.payload.referenceParent = originObject
} else {
/*
In this second Use Case, we are going to connect an inner object that is
inside the origin object at an array. We recognize we have to do this
because we did receive this array proeprty name.
*/
let originObjectArray = originObject[originObjectArrayPropertyName]
for (let n = 0; n < originObjectArray.length; n++) {
let originObjectArrayItem = originObjectArray[n]
let clonedObject = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, clonedObjectType)
clonedObject.payload.referenceParent = originObjectArrayItem
}
}
}
break
}
case originFoldersArrayPropertyName: {
let originNodePropertyArray = originNode[property.name]
let destinationNodePropertyArray = destinationNode[destinationFoldersArrayPropertyName]
for (let m = 0; m < originNodePropertyArray.length; m++) {
let originFolder = originNodePropertyArray[m]
let found = false
let destinationFolder
for (let n = 0; n < destinationNodePropertyArray.length; n++) {
destinationFolder = destinationNodePropertyArray[n]
if (originFolder.name === destinationFolder.name) {
found = true
}
}
if (found === false) {
destinationFolder = functionLibraryUiObjectsFromNodes.addUIObject(destinationNode, destinationFolderType)
destinationFolder.name = originFolder.name
}
asymetricalFolderStructureCloning(
originFolder,
destinationFolder,
originObjectsArrayPropertyName,
originFoldersArrayPropertyName,
destinationFoldersArrayPropertyName,
clonedObjectType,
destinationFolderType,
originObjectArrayPropertyName,
functionLibraryUiObjectsFromNodes
)
}
break
}
}
}
}
}