diff --git a/src/plugins/kibi_core/lib/query_engine.js b/src/plugins/kibi_core/lib/query_engine.js index 3042cd54c..1f0877e69 100644 --- a/src/plugins/kibi_core/lib/query_engine.js +++ b/src/plugins/kibi_core/lib/query_engine.js @@ -346,7 +346,8 @@ QueryEngine.prototype._loadScripts = function () { 'select-by-edge-count', 'show-nodes-count-by-type', 'replace-investment-nodes', - 'shortest-path' + 'shortest-path', + 'expand-by-relation' ]; self.log.info('Loading scripts'); diff --git a/src/plugins/kibi_core/lib/scripts/expand-by-relation.json b/src/plugins/kibi_core/lib/scripts/expand-by-relation.json new file mode 100644 index 000000000..8acfe7994 --- /dev/null +++ b/src/plugins/kibi_core/lib/scripts/expand-by-relation.json @@ -0,0 +1,9 @@ +{ + "title": "Expand by relation", + "description": "Expands the selected nodes using the selected relations", + "st_scriptSource": "function beforeAll(graphModel, graphSelection) {\n const relations = _getKibiRelations();\n \n let relevantNodes = [];\n if(graphSelection.length === 0) {\n _.each(graphModel.nodes, function(node) {\n relevantNodes.push(node.id);\n });\n } else {\n relevantNodes = graphSelection;\n }\n \n let relevantRel = {};\n _.each(relations, function(relation) {\n _.each(relevantNodes, function (nodeId) {\n var from = new RegExp(relation.indices[0].indexPatternId);\n var to = new RegExp(relation.indices[1].indexPatternId);\n\n let nodeIndex = nodeId.substring(0, nodeId.indexOf('/'));\n if (from.test(nodeIndex) || to.test(nodeIndex)) {\n if(!relevantRel[relation.id]) {\n relevantRel[relation.id] = relation;\n }\n }\n });\n });\n \n console.log(relevantRel);\n let html = '