Data Mines Includes

This commit is contained in:
Luis Fernando Molina committed 2020-03-28 17:40:32 +01:00
1 parent 7ee5692d0a
commit 12568602aa
3 files changed
+83 -18

No files matched your search

@@ -19,26 +19,69 @@ function newUiObjectsFromNodes () {
tasksToRun = []
sessionsToRun = []
/* Create the workspace UI OBject and then continue with the root nodes. */
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
if (node.rootNodes !== undefined) {
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
createUiObjectFromNode(rootNode, undefined, undefined)
addIncludedNodes()
function addIncludedNodes () {
blobService = newFileStorage()
if (node.code === undefined) {
node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}'
}
let code = JSON.parse(node.code)
let includeDataMines = code.includeDataMines
let totalIncluded = 0
for (let i = 0; i < includeDataMines.length; i++) {
let dataMine = includeDataMines[i]
blobService.getBlobToText('DataMines' + '/' + dataMine, undefined, onFileReceived, true)
function onFileReceived (err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Cannot load included Data Mine ' + dataMine + '. The workspace can not be loaded.')
return
}
let includedDataMine = JSON.parse(text)
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Data Mine') {
let code = JSON.parse(rootNode.code)
if (code.name === dataMine) {
rootNodes.splice(i, 1)
}
}
}
node.rootNodes.push(includedDataMine)
totalIncluded++
if (totalIncluded === includeDataMines.length) {
addUserDefinedNodes()
}
}
}
}
tryToConnectChildrenWithReferenceParents()
function addUserDefinedNodes () {
/* Create the workspace UI OBject and then continue with the root nodes. */
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
if (node.rootNodes !== undefined) {
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
createUiObjectFromNode(rootNode, undefined, undefined)
}
}
if (replacingCurrentWorkspace === true) {
// We need to wait all tasks that were potentially running to stop
setTimeout(runTasks, 70000)
// We give a few seconds for the tasks to start
setTimeout(runSessions, 80000)
} else {
runTasks()
// We give a few seconds for the tasks to start
setTimeout(runSessions, 10000)
tryToConnectChildrenWithReferenceParents()
if (replacingCurrentWorkspace === true) {
// We need to wait all tasks that were potentially running to stop
setTimeout(runTasks, 70000)
// We give a few seconds for the tasks to start
setTimeout(runSessions, 80000)
} else {
runTasks()
// We give a few seconds for the tasks to start
setTimeout(runSessions, 10000)
}
}
}
+15 -1
View File
@@ -169,12 +169,26 @@ function newWorkspace () {
}
function stringifyWorkspace (removePersonalData) {
let code
if (thisObject.workspaceNode.code === undefined) {
thisObject.workspaceNode.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}'
}
code = JSON.parse(thisObject.workspaceNode.code)
let includeDataMines = code.includeDataMines
let stringifyReadyNodes = []
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true)
if (node) {
stringifyReadyNodes.push(node)
if (node.type !== 'Data Mine') {
stringifyReadyNodes.push(node)
} else {
code = JSON.parse(node.code)
if (includeDataMines.includes(code.codeName) === false) {
stringifyReadyNodes.push(node)
}
}
}
}
let workspace = {
+9 -1
View File
@@ -41,6 +41,9 @@ function newChartingSpace () {
const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25
initialSetup()
let isInitialized = false
return thisObject
function reset () {
@@ -87,6 +90,8 @@ function newChartingSpace () {
}
function initialize () {
if (isInitialized === true) { return }
let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes
for (let i = 0; i < rootNodes.length; i++) {
let rootNode = rootNodes[i]
@@ -96,7 +101,7 @@ function newChartingSpace () {
}
if (thisObject.payload === undefined) {
if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') }
// if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') }
return
}
@@ -111,6 +116,8 @@ function newChartingSpace () {
thisObject.viewport.initialize()
canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
isInitialized = true
}
function getContainer (point, purpose) {
@@ -263,6 +270,7 @@ function newChartingSpace () {
}
function physics () {
initialize()
thisObjectPhysics()
if (thisObject.visible !== true) { return }
if (thisObject.viewport !== undefined) {