Session Reference

This commit is contained in:
Luis Fernando Molina committed 2020-09-13 19:30:53 +02:00
1 parent 91582d1715
commit c7bc3ea93b
7 files changed
+95 -39

No files matched your search

+1 -1
View File
@@ -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 = findNodeInNodeMesh(layer.definition, 'Session Reference')
let sessionReference = findNodeInNodeMesh(layer.definition, 'Session Reference', false, true, true, true)
if (sessionReference !== undefined) {
session = sessionReference.referenceParent
@@ -1,7 +1,8 @@
function newDataStorageFunctions() {
thisObject = {
addAllDataProducts: addAllDataProducts,
addAllDataMineProducts: addAllDataMineProducts
addAllDataMineProducts: addAllDataMineProducts,
addMissingSessionReferences: addMissingSessionReferences
}
return thisObject
@@ -55,11 +56,36 @@ function newDataStorageFunctions() {
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
}
}
}
function addMissingSessionReferences(node, rootNodes, functionLibraryUiObjectsFromNodes) {
let networkNode = findNodeInNodeMesh(node, 'Network Node', true, false, true, false)
if (networkNode === undefined) {return}
let backtestingSessionsArray = nodeBranchToArray(networkNode, 'Backtesting Session')
let fordwardTestingSessionsArray = nodeBranchToArray(networkNode, 'Fordward Testing Session')
let paperTradingSessionsArray = nodeBranchToArray(networkNode, 'Paper Trading Session')
let liveTradingSessionsArray = nodeBranchToArray(networkNode, 'Live Trading Session')
addMissingSession(backtestingSessionsArray)
addMissingSession(fordwardTestingSessionsArray)
addMissingSession(paperTradingSessionsArray)
addMissingSession(liveTradingSessionsArray)
function addMissingSession(sessionsArray) {
for (let i = 0; i < sessionsArray.length; i++) {
let session = sessionsArray[i]
if (isMissingChildren(node, session, true) === true) {
let sessionReference = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Session Reference')
sessionReference.payload.referenceParent = session
}
}
}
}
}
+5
View File
@@ -716,6 +716,11 @@ function newWorkspace() {
functionLibraryDataStorageFunctions.addAllDataMineProducts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add Missing Session References':
{
functionLibraryDataStorageFunctions.addMissingSessionReferences(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
}
break
case 'Add All Data Dependencies':
{
functionLibraryDataMineFunctions.addAllDataDependencies(payload.node, functionLibraryUiObjectsFromNodes)
+13 -13
View File
@@ -205,49 +205,49 @@ function newLayer() {
}
/* Here we validate that we have all the needed information */
if (findNodeInNodeMesh(thisObject.definition, 'Data Product') === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Data Product', false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Product not Found')
return
}
if (findNodeInNodeMesh(thisObject.definition, 'Market') === undefined) {
if (findNodeInNodeMesh(thisObject.definition, 'Market', false, true, true, true) === undefined) {
thisObject.payload.uiObject.setErrorMessage('Market not Found')
return
}
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition')
thisObject.productDefinition = findNodeInNodeMesh(thisObject.definition, 'Product Definition', false, true, true, true)
if (thisObject.productDefinition === undefined) {
thisObject.payload.uiObject.setErrorMessage('Product Definition not Found')
return
}
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Sensor Bot', false, true, true, true)
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Indicator Bot', false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot')
thisObject.bot = findNodeInNodeMesh(thisObject.definition, 'Trading Bot', false, true, true, true)
}
if (thisObject.bot === undefined) {
thisObject.payload.uiObject.setErrorMessage('Bot not Found')
return
}
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine')
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Data Mine', false, true, true, true)
if (thisObject.dataMine === undefined) {
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Trading Mine')
thisObject.dataMine = findNodeInNodeMesh(thisObject.definition, 'Trading Mine', false, true, true, true)
if (thisObject.dataMine === undefined) {
thisObject.payload.uiObject.setErrorMessage('Data Mine or Trading Mine not Found')
return
}
}
thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange')
thisObject.exchange = findNodeInNodeMesh(thisObject.definition, 'Crypto Exchange', false, true, true, true)
if (thisObject.exchange === undefined) {
thisObject.payload.uiObject.setErrorMessage('Crypto Exchange not Found')
return
}
thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset')
thisObject.baseAsset = findNodeInNodeMesh(thisObject.definition, 'Market Base Asset', false, true, true, true)
if (thisObject.baseAsset !== undefined) {
thisObject.baseAsset = thisObject.baseAsset.referenceParent
}
@@ -256,7 +256,7 @@ function newLayer() {
return
}
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset')
thisObject.quotedAsset = findNodeInNodeMesh(thisObject.definition, 'Market Quoted Asset', false, true, true, true)
if (thisObject.quotedAsset !== undefined) {
thisObject.quotedAsset = thisObject.quotedAsset.referenceParent
}
@@ -265,13 +265,13 @@ function newLayer() {
return
}
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module')
thisObject.plotterModule = findNodeInNodeMesh(thisObject.definition, 'Plotter Module', false, true, true, true)
if (thisObject.plotterModule === undefined) {
thisObject.payload.uiObject.setErrorMessage('Market Quoted Asset not Found')
return
}
thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node')
thisObject.networkNode = findNodeInNodeMesh(thisObject.definition, 'Network Node', false, true, true, true)
if (thisObject.networkNode === undefined) {
thisObject.payload.uiObject.setErrorMessage('Network Node not Found')
return
+4
View File
@@ -3,11 +3,15 @@ function nodeBranchToArray(node, nodeType) {
This function scans a node branch for a certain node type and
return an array of with all the nodes of that type found.
*/
if (node === undefined) { return }
if (nodeType === undefined) { return }
let resultArray = []
scanNodeBranch(node, nodeType)
return resultArray
function scanNodeBranch(startingNode) {
if (startingNode === undefined) {return}
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
if (nodeDefinition === undefined) { return }
+4 -3
View File
@@ -1,8 +1,9 @@
/*
This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it.
*/
function getHiriarchyMap(rootNode) {
/*
This function scans a node hiriatchy recursively and creates a Map by Id of all the nodes of it.
*/
let hiriatchyMap = new Map()
evalNode(rootNode)
return hiriatchyMap
+40 -20
View File
@@ -1,10 +1,10 @@
function findNodeInNodeMesh(node, nodeType) {
function findNodeInNodeMesh(node, nodeType, connectedViaPayload, findInChildren, findInParents, findInReferenceParents) {
/*
This function scans a node mesh for a certain node type and
returns the first instance found.
*/
let nodeFound
scanNodeMesh(node, nodeType)
scanNodeMesh(node)
return nodeFound
function scanNodeMesh(startingNode) {
@@ -20,34 +20,54 @@ function findNodeInNodeMesh(node, nodeType) {
}
/* We scan through this node children */
if (nodeDefinition.properties !== undefined) {
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
if (findInChildren === true) {
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])
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
}
break
}
}
}
}
/* We scan parents nodes. */
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode)
if (findInParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.parentNode !== undefined) {
scanNodeMesh(startingNode.payload.parentNode)
}
} else {
if (startingNode.parentNode !== undefined) {
scanNodeMesh(startingNode.parentNode)
}
}
}
/* We scan reference parents too. */
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent)
if (findInReferenceParents === true) {
if (connectedViaPayload === true) {
if (startingNode.payload.referenceParent !== undefined) {
scanNodeMesh(startingNode.payload.referenceParent)
}
} else {
if (startingNode.referenceParent !== undefined) {
scanNodeMesh(startingNode.referenceParent)
}
}
}
}
}