Removig requirement of definitions at Processs Instance

This commit is contained in:
Luis Fernando Molina committed 2019-11-21 12:00:26 +01:00
1 parent 512f6628d9
commit ad89b5b22e
3 files changed
+30 -58

No files matched your search

+6 -41
View File
@@ -140,47 +140,12 @@
let botConfig;
let processInstance = global.TASK_NODE.bot.processes[processIndex]
/* Some very basic validations that we have all the information needed. */
if (processInstance.referenceParent === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Process Instance without Reference Parent. Process Instance = " + JSON.stringify(processInstance));
global.EXIT_NODE_PROCESS()
return
}
if (processInstance.referenceParent.code.codeName === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Process Definition witn no codeName defined. Process Definition = " + JSON.stringify(processInstance.referenceParent));
global.EXIT_NODE_PROCESS()
return
}
if (processInstance.referenceParent.parentNode === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Process Definition not attached to a Bot Definition. Process Definition = " + JSON.stringify(processInstance.referenceParent));
global.EXIT_NODE_PROCESS()
return
}
if (processInstance.referenceParent.parentNode.code.codeName === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Bot Definition witn no codeName defined. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
global.EXIT_NODE_PROCESS()
return
}
if (processInstance.referenceParent.parentNode.parentNode === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Bot Definition not attached to a Team. Bot Definition = " + JSON.stringify(processInstance.referenceParent.parentNode));
global.EXIT_NODE_PROCESS()
return
}
if (processInstance.referenceParent.parentNode.parentNode.code.codeName === undefined) {
console.log(logDisplace + "Root : [INFO] start -> Team witn no codeName defined. Team = " + JSON.stringify(processInstance.referenceParent.parentNode.parentNode));
global.EXIT_NODE_PROCESS()
return
}
/* Here we will check if we need to load the configuration and code of the bot from a file or we will take that from the UI. */
if (
processInstance.referenceParent.code.framework !== undefined &&
(processInstance.referenceParent.code.framework.name === 'Multi-Period-Market' || processInstance.referenceParent.code.framework.name === 'Multi-Period-Daily')
( processInstance.referenceParent.code.framework.name === 'Multi-Period-Market' ||
processInstance.referenceParent.code.framework.name === 'Multi-Period-Daily' ||
processInstance.referenceParent.code.framework.name === 'Multi-Period')
) {
botConfig = processInstance.referenceParent.parentNode.code
botConfig.definedByUI = true
@@ -199,16 +164,16 @@
const FILE_STORAGE = require('./FileStorage.js');
let fileStorage = FILE_STORAGE.newFileStorage();
let filePath = global.TASK_NODE.bot.code.team + '/bots/' + global.TASK_NODE.bot.code.repo + '/this.bot.config.json';
let filePath = global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName + '/bots/' + global.TASK_NODE.bot.code.repo + '/this.bot.config.json';
fileStorage.getTextFile(global.TASK_NODE.bot.code.team, filePath, onFileReceived);
fileStorage.getTextFile(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName, filePath, onFileReceived);
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> err = " + JSON.stringify(err));
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> filePath = " + filePath);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> team = " + global.TASK_NODE.bot.code.team);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfigFromFile -> onInizialized -> onFileReceived -> team = " + global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName);
return;
}
+5 -1
View File
@@ -43,7 +43,11 @@
if (bot.definedByUI === true) {
/* The code of the bot is defined at the UI. No need to load a file with the code. */
callBackFunction(global.DEFAULT_OK_RESPONSE);
session.initialize(onSessionInitialized)
function onSessionInitialized(err) {
callBackFunction(err);
}
return
}
+19 -16
View File
@@ -75,13 +75,6 @@ global.EXIT_NODE_PROCESS = function exitProcess() {
for (let i = 0; i < global.TASK_NODE.bot.processes.length; i++) {
let code = global.TASK_NODE.bot.processes[i].code
/* Delete the event handler for each process. */
let key = global.TASK_NODE.bot.code.team + "-" + global.TASK_NODE.bot.code.bot + "-" + code.process
global.SYSTEM_EVENT_HANDLER.deleteEventHandler(key)
let process = global.TASK_NODE.bot.processes[i]
key = process.name + '-' + process.type + '-' + process.id
@@ -183,25 +176,35 @@ function bootLoader() {
/* Validate that the minimun amount of parameters required are defined. */
if (global.TASK_NODE.bot.code.bot === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Parameter 'bot' at the Indicator | Sensor | Trading is undefined. This process will not be executed. -> Process = " + global.TASK_NODE.bot.processes[processIndex].name);
if (global.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Process Instance without a Reference Parent. This process will not be executed. -> Process Instance = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex]));
continue
}
if (global.TASK_NODE.bot.code.team === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Parameter 'team' at the bot is undefined. This process will not be executed. -> Process = " + global.TASK_NODE.bot.processes[processIndex].name);
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Process Definition without parent Bot Definition. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].code.process === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Parameter 'process' at object Process is undefined. This process will not be executed. -> Process = " + global.TASK_NODE.bot.processes[processIndex].name);
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Bot Definition without parent Team. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
continue
}
/* Create the event handler for each process. This event handlers are where the status reports updated events are raised. */
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.code.codeName === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Process Definition without a codeName defined. -> Process Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent));
continue
}
let key = global.TASK_NODE.bot.code.team + "-" + global.TASK_NODE.bot.code.bot + "-" + code.process
global.SYSTEM_EVENT_HANDLER.createEventHandler(key)
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.code.codeName === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Bot Definition without a codeName defined. -> Bot Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode));
continue
}
if (global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.code.codeName === undefined) {
console.log("[INFO] Task Server -> server -> bootLoader -> Team without a codeName defined. -> Team Definition = " + JSON.stringify(global.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode));
continue
}
startRoot(processIndex);
}