Standarization and isMissingChildrenByType function added

This commit is contained in:
Luis Fernando Molina committed 2021-06-10 20:33:15 +02:00
1 parent 6121a6d7f9
commit cbdb422398
5 files changed
+62 -18

No files matched your search

@@ -129,7 +129,7 @@ function newFoundationsFunctionLibraryChartingSpaceFunctions() {
if (environment.id !== node.payload.referenceParent.id) { continue }
let market = UI.projects.foundations.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (market.payload.referenceParent === undefined) { continue }
if (UI.projects.foundations.utilities.children.isMissingChildren(node, session, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, session, true) === true) {
createTimeMachine(node, session, market.payload.referenceParent, networkNode, rootNodes)
}
}
@@ -320,13 +320,13 @@ function newFoundationsFunctionLibraryChartingSpaceFunctions() {
let testingTradingTasks = UI.projects.foundations.utilities.branches.findInBranch(networkNode, 'Testing Trading Tasks', node, true)
let productionTradingTasks = UI.projects.foundations.utilities.branches.findInBranch(networkNode, 'Production Trading Tasks', node, true)
if (UI.projects.foundations.utilities.children.isMissingChildren(node, testingTradingTasks, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, testingTradingTasks, true) === true) {
let dashboard = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Dashboard')
dashboard.payload.referenceParent = testingTradingTasks
dashboard.name = testingTradingTasks.type + ' ' + networkNode.name
}
if (UI.projects.foundations.utilities.children.isMissingChildren(node, productionTradingTasks, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, productionTradingTasks, true) === true) {
let dashboard = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Dashboard')
dashboard.payload.referenceParent = productionTradingTasks
dashboard.name = productionTradingTasks.type + ' ' + networkNode.name
@@ -345,7 +345,7 @@ function newFoundationsFunctionLibraryChartingSpaceFunctions() {
if (rootNode.type === project + ' Project') {
let projectDefinition = rootNode.projectDefinition
if (projectDefinition !== undefined) {
if (UI.projects.foundations.utilities.children.isMissingChildren(node, projectDefinition, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, projectDefinition, true) === true) {
let projectTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Project Dashboards', undefined, project)
projectTasks.payload.referenceParent = projectDefinition
}
@@ -478,7 +478,7 @@ function newFoundationsFunctionLibraryCryptoEcosystemFunctions() {
*/
for (let i = 0; i < learningSessionsCreatedArray.length; i++) {
let session = learningSessionsCreatedArray[i]
if (UI.projects.foundations.utilities.children.isMissingChildren(marketLearningProducts, session, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(marketLearningProducts, session, true) === true) {
UI.projects.foundations.functionLibraries.dataStorageFunctions.createSessionReference(marketLearningProducts, session, 'Learning Session Reference')
}
}
@@ -533,7 +533,7 @@ function newFoundationsFunctionLibraryCryptoEcosystemFunctions() {
*/
for (let i = 0; i < tradingSessionsCreatedArray.length; i++) {
let session = tradingSessionsCreatedArray[i]
if (UI.projects.foundations.utilities.children.isMissingChildren(marketTradingProducts, session, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(marketTradingProducts, session, true) === true) {
UI.projects.foundations.functionLibraries.dataStorageFunctions.createSessionReference(marketTradingProducts, session, 'Trading Session Reference')
}
}
@@ -123,7 +123,7 @@ function newFoundationsFunctionLibraryDataStorageFunctions() {
/* We will filter out all the sessions that does not belong to the market we are in */
let marketTradingTasks = UI.projects.foundations.utilities.meshes.findNodeInNodeMesh(session, 'Market Trading Tasks', undefined, true, false, true, false)
if (node.payload.referenceParent.id !== marketTradingTasks.payload.referenceParent.id) { continue }
if (UI.projects.foundations.utilities.children.isMissingChildren(node, session, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, session, true) === true) {
createSessionReference(node, session, 'Trading Session Reference')
}
}
@@ -146,7 +146,7 @@ function newFoundationsFunctionLibraryDataStorageFunctions() {
/* We will filter out all the sessions that does not belong to the market we are in */
let marketLearningTasks = UI.projects.foundations.utilities.meshes.findNodeInNodeMesh(session, 'Market Learning Tasks', undefined, true, false, true, false)
if (node.payload.referenceParent.id !== marketLearningTasks.payload.referenceParent.id) { continue }
if (UI.projects.foundations.utilities.children.isMissingChildren(node, session, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, session, true) === true) {
createSessionReference(node, session, 'Learning Session Reference')
}
}
@@ -177,7 +177,7 @@ function newFoundationsFunctionLibraryDataStorageFunctions() {
for (let i = 0; i < marketsArray.length; i++) {
let market = marketsArray[i]
if (UI.projects.foundations.utilities.children.isMissingChildren(node, market, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, market, true) === true) {
let marketDataProducts = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType)
marketDataProducts.payload.referenceParent = market
}
@@ -205,7 +205,7 @@ function newFoundationsFunctionLibraryDataStorageFunctions() {
let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j]
for (let k = 0; k < cryptoExchanges.exchanges.length; k++) {
let cryptoExchange = cryptoExchanges.exchanges[k]
if (UI.projects.foundations.utilities.children.isMissingChildren(node, cryptoExchange, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, cryptoExchange, true) === true) {
let exchange = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType)
exchange.payload.referenceParent = cryptoExchange
}
@@ -238,7 +238,7 @@ function newFoundationsFunctionLibraryDataStorageFunctions() {
if (rootNode.type === project + ' Project') {
let projectDefinition = rootNode.projectDefinition
if (projectDefinition !== undefined) {
if (UI.projects.foundations.utilities.children.isMissingChildren(node, projectDefinition, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, projectDefinition, true) === true) {
let projectTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType, undefined, project)
projectTasks.payload.referenceParent = projectDefinition
}
@@ -609,7 +609,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
if (rootNode.type === project + ' Project') {
let projectDefinition = rootNode.projectDefinition
if (projectDefinition !== undefined) {
if (UI.projects.foundations.utilities.children.isMissingChildren(node, projectDefinition, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, projectDefinition, true) === true) {
let projectTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType, undefined, project)
projectTasks.payload.referenceParent = projectDefinition
}
@@ -640,7 +640,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
let cryptoExchanges = cryptoEcosystem.cryptoExchanges[j]
for (let k = 0; k < cryptoExchanges.exchanges.length; k++) {
let cryptoExchange = cryptoExchanges.exchanges[k]
if (UI.projects.foundations.utilities.children.isMissingChildren(node, cryptoExchange, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, cryptoExchange, true) === true) {
let exchangeTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType)
exchangeTasks.payload.referenceParent = cryptoExchange
}
@@ -672,7 +672,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
for (let i = 0; i < markets.length; i++) {
let market = markets[i]
if (UI.projects.foundations.utilities.children.isMissingChildren(node, market, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, market, true) === true) {
let marketDataTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType)
marketDataTasks.payload.referenceParent = market
}
@@ -697,7 +697,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
if (rootNode.type === rootNodeType) {
let mine = rootNode
if (UI.projects.foundations.utilities.children.isMissingChildren(node, mine, true) === true) {
if (UI.projects.foundations.utilities.children.isMissingChildrenById(node, mine, true) === true) {
let dataMineTasks = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, newNodeType)
dataMineTasks.payload.referenceParent = mine
}
@@ -1,6 +1,7 @@
function newFoundationsUtilitiesNodeChildren() {
let thisObject = {
isMissingChildren: isMissingChildren,
isMissingChildrenById: isMissingChildrenById,
isMissingChildrenByType: isMissingChildrenByType,
findChildReferencingThisNode: findChildReferencingThisNode,
findOrCreateChildWithReference: findOrCreateChildWithReference,
findAndRecreateChildWithReference: findAndRecreateChildWithReference,
@@ -10,7 +11,7 @@ function newFoundationsUtilitiesNodeChildren() {
return thisObject
function isMissingChildren(startingNode, checkNode, checkReferenceParent) {
function isMissingChildrenById(startingNode, checkNode, checkReferenceParent) {
/*
This functioin scan all the children of a node and returns true or false
depending if the checkNode is a missing children.
@@ -116,6 +117,49 @@ function newFoundationsUtilitiesNodeChildren() {
}
}
function isMissingChildrenByType(startingNode, nodeType) {
/*
This functioin scan all the children of a node and returns true or false
depending if the node has a children with a certain type.
*/
if (startingNode === undefined) { return }
let schemaDocument = getSchemaDocument(startingNode)
if (schemaDocument === undefined) { return }
/* We scan through this node children */
if (schemaDocument.childrenNodesProperties !== undefined) {
for (let i = 0; i < schemaDocument.childrenNodesProperties.length; i++) {
let property = schemaDocument.childrenNodesProperties[i]
switch (property.type) {
case 'node': {
let child = startingNode[property.name]
if (child !== undefined) {
if (child.type === nodeType) {
return false
}
}
}
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.type === nodeType) {
return false
}
}
}
break
}
}
}
return true
}
}
function findChildReferencingThisNode(startingNode, checkNode) {
/*
This functioin scan all the children of a node and returns the child
@@ -174,7 +218,7 @@ function newFoundationsUtilitiesNodeChildren() {
the referecen.
*/
let child
if (isMissingChildren(startingNode, referencedNode, true) === true) {
if (isMissingChildrenById(startingNode, referencedNode, true) === true) {
child = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(startingNode, childType)
child.payload.referenceParent = referencedNode
} else {