Data Mining Installed
This commit is contained in:
1 parent
89f6926027
commit
e567acdd5d
6 files changed
+173
-3
No files matched your search
@@ -2,7 +2,9 @@ function newCryptoEcosystemFunctions() {
|
||||
thisObject = {
|
||||
addMissingExchanges: addMissingExchanges,
|
||||
addMissingAssets: addMissingAssets,
|
||||
addMissingMarkets: addMissingMarkets
|
||||
addMissingMarkets: addMissingMarkets,
|
||||
installMarket: installMarket,
|
||||
uninstallMarket: uninstallMarket
|
||||
}
|
||||
|
||||
return thisObject
|
||||
@@ -203,4 +205,52 @@ function newCryptoEcosystemFunctions() {
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function installMarket(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
|
||||
|
||||
let market = node
|
||||
let cryptoExchange = findNodeInNodeMesh(node, 'Crypto Exchange', undefined, true, false, true, false)
|
||||
if (cryptoExchange === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Market must be a descendant of a Crypto Exchange')
|
||||
return
|
||||
}
|
||||
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.type === 'Network') {
|
||||
installInNetwork(rootNode)
|
||||
}
|
||||
}
|
||||
|
||||
function installInNetwork(network) {
|
||||
/*
|
||||
Here we complete the missing stuff at Data Mining
|
||||
*/
|
||||
let dataMining = findInBranch(network, 'Data Mining', node, true)
|
||||
if (dataMining === undefined) { return }
|
||||
|
||||
let exchangeDataTasks = findOrCreateChildWithReference(dataMining, 'Exchange Data Tasks', cryptoExchange, functionLibraryUiObjectsFromNodes)
|
||||
exchangeDataTasks.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
let marketDataTask = findAndRecreateChildWithReference(exchangeDataTasks, 'Market Data Tasks', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
|
||||
|
||||
menuClick(marketDataTask, 'Add Missing Data Mine Tasks', true)
|
||||
menuClickOfNodeArray(marketDataTask.dataMineTasks, 'Add All Tasks', true)
|
||||
/*
|
||||
Here we complete the missing stuff at Session Independent Data
|
||||
*/
|
||||
let sessionIndependentData = findInBranch(network, 'Session Independent Data', node, true)
|
||||
if (sessionIndependentData === undefined) { return }
|
||||
|
||||
let exchangeDataProducts = findOrCreateChildWithReference(sessionIndependentData, 'Exchange Data Products', cryptoExchange, functionLibraryUiObjectsFromNodes)
|
||||
exchangeDataProducts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
let singleMarketData = findAndRecreateChildWithReference(exchangeDataProducts, 'Single Market Data', market, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
|
||||
|
||||
menuClick(singleMarketData, 'Add All Data Mine Products', true)
|
||||
menuClickOfNodeArray(singleMarketData.dataMineProducts, 'Add All Data Products', true)
|
||||
}
|
||||
}
|
||||
|
||||
function uninstallMarket(node, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -451,7 +451,8 @@ function newTaskFunctions() {
|
||||
if (node.payload.referenceParent === undefined) { return }
|
||||
|
||||
let taskManager = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Task Manager')
|
||||
taskManager.name = node.name
|
||||
taskManager.name = node.payload.referenceParent.name
|
||||
taskManager.payload.floatingObject.collapseToggle()
|
||||
|
||||
switch (node.type) {
|
||||
case 'Data Mine Tasks': {
|
||||
|
||||
@@ -700,6 +700,16 @@ function newWorkspace() {
|
||||
functionLibraryCryptoEcosystemFunctions.addMissingMarkets(payload.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning)
|
||||
}
|
||||
break
|
||||
case 'Install Market':
|
||||
{
|
||||
functionLibraryCryptoEcosystemFunctions.installMarket(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
|
||||
}
|
||||
break
|
||||
case 'Uninstall Market':
|
||||
{
|
||||
functionLibraryCryptoEcosystemFunctions.uninstallMarket(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter)
|
||||
}
|
||||
break
|
||||
case 'Add All Output Datasets':
|
||||
{
|
||||
functionLibraryDataMineFunctions.addAllOutputDatasets(payload.node, functionLibraryUiObjectsFromNodes)
|
||||
|
||||
+12
-1
@@ -43,4 +43,15 @@ function nodeBranchToArray(node, nodeType) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function findInBranch(startingNode, nodeType, errorNode, connectedViaPayload) {
|
||||
/*
|
||||
This function finds a node in a brach and reports an error if it could not be found.
|
||||
*/
|
||||
let nodeFound = findNodeInNodeMesh(startingNode, nodeType, undefined, connectedViaPayload, true, false, false)
|
||||
if (nodeFound === undefined) {
|
||||
errorNode.payload.uiObject.setErrorMessage('Could not find ' + nodeType + ' at ' + startingNode.type + ' ' + startingNode.name)
|
||||
return
|
||||
} else {
|
||||
return nodeFound
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
function menuClickOfNodeArray(nodeArray, action, confirm) {
|
||||
for (let j=0; j < nodeArray.length; j++) {
|
||||
let node = nodeArray[j]
|
||||
menuClick(node, action, confirm)
|
||||
}
|
||||
}
|
||||
|
||||
function menuClick(node, action, confirm) {
|
||||
let menu = node.payload.uiObject.menu
|
||||
menu.internalClick(action)
|
||||
if (confirm === true) {
|
||||
menu.internalClick(action)
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,88 @@ function isMissingChildren(startingNode, checkNode, checkReferenceParent) {
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
function findChildReferencingThisNode(startingNode, checkNode) {
|
||||
/*
|
||||
This functioin scan all the children of a node and returns the child
|
||||
that is referencing the checkNode.
|
||||
*/
|
||||
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 (child.payload !== undefined) {
|
||||
if (child.payload.referenceParent !== undefined) {
|
||||
if (child.payload.referenceParent.id === checkNode.id) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let startingNodePropertyArray = startingNode[property.name]
|
||||
if (startingNodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < startingNodePropertyArray.length; m++) {
|
||||
let arrayItem = startingNodePropertyArray[m]
|
||||
|
||||
if (arrayItem.payload !== undefined) {
|
||||
if (arrayItem.payload.referenceParent !== undefined) {
|
||||
if (arrayItem.payload.referenceParent.id === checkNode.id) {
|
||||
return arrayItem
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
function findOrCreateChildWithReference(startingNode, childType, referencedNode, functionLibraryUiObjectsFromNodes) {
|
||||
/*
|
||||
This function find the child node of starting node that references
|
||||
refereced node. If there is none, then it creates a child and stablish
|
||||
the referecen.
|
||||
*/
|
||||
let child
|
||||
if (isMissingChildren(startingNode, referencedNode, true) === true) {
|
||||
child = functionLibraryUiObjectsFromNodes.addUIObject(startingNode, childType)
|
||||
child.payload.referenceParent = referencedNode
|
||||
} else {
|
||||
child = findChildReferencingThisNode(startingNode, referencedNode)
|
||||
}
|
||||
return child
|
||||
}
|
||||
|
||||
function findAndRecreateChildWithReference(startingNode, childType, referencedNode, rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
|
||||
/*
|
||||
This function finds the child of the starting node that references
|
||||
the reference node and if found it deletes it. Existing or not
|
||||
it creates it again with the child type specified.
|
||||
*/
|
||||
let child
|
||||
child = findChildReferencingThisNode(startingNode, referencedNode)
|
||||
if (child !== undefined) {
|
||||
functionLibraryNodeDeleter.deleteUIObject(child, rootNodes)
|
||||
}
|
||||
child = functionLibraryUiObjectsFromNodes.addUIObject(startingNode, childType)
|
||||
child.payload.referenceParent = referencedNode
|
||||
return child
|
||||
}
|
||||
Reference in new issue
Block a user