diff --git a/src/common/viz/FigureExtractor.js b/src/common/viz/FigureExtractor.js index 88da807d0..5e76bccc2 100644 --- a/src/common/viz/FigureExtractor.js +++ b/src/common/viz/FigureExtractor.js @@ -1,9 +1,6 @@ -/*globals define, _*/ +/* globals define */ define(['./Utils'], function (Utils) { - const FigureExtractor = function (client) { - this._client = client; - this._metaNodesMap = this._initializeMetaNodesMap(); - }; + const BASE_METADATA_TYPE = 'Metadata'; const EXTRACTORS = { GRAPH: 'Graph', SUBGRAPH: 'SubGraph', @@ -14,29 +11,30 @@ define(['./Utils'], function (Utils) { SCATTER_POINTS: 'ScatterPoints' }; - FigureExtractor.prototype._initializeMetaNodesMap = function () { - const metaNodes = this._client.getAllMetaNodes(); - const idsAndTypes = metaNodes.map(node => [node.getId(), node.getAttribute('name')]); - return _.object(idsAndTypes); + const ensureCanExtract = function(metaType) { + if(!Object.values(EXTRACTORS).includes(metaType)) { + throw new Error(`Node of type ${metaType} is not supported yet.`); + } }; + const FigureExtractor = function (client) { + this._client = client; + }; + + FigureExtractor.prototype.constructor = FigureExtractor; + FigureExtractor.prototype.extract = function(node) { const extractorFn = this.getMetaType(node); - if (!Object.values(EXTRACTORS).includes(extractorFn)){ - throw new Error(`Node of type ${extractorFn} is not supported yet.`); - } else { - return this[extractorFn](node); - } + ensureCanExtract(extractorFn); + return this[extractorFn](node); }; FigureExtractor.prototype.extractChildrenOfType = function(node, metaType) { - const children = node.getChildrenIds().map(id => this._client.getNode(id)); + const children = this.getMetadataChildrenIds(node).map(id => this._client.getNode(id)); return children.filter(node => this.getMetaType(node) === metaType) .map(child => this.extract(child)); }; - FigureExtractor.prototype.constructor = FigureExtractor; - FigureExtractor.prototype[EXTRACTORS.GRAPH] = function(node) { const id = node.getId(), execId = this.getExecutionId(node); @@ -50,18 +48,19 @@ define(['./Utils'], function (Utils) { title: node.getAttribute('title'), }; - let childrenIds = node.getChildrenIds(); + let childrenIds = this.getMetadataChildrenIds(node); + let childNode, childNodeFn; desc.subGraphs = childrenIds.map((childId) => { childNode = this._client.getNode(childId); childNodeFn = this.getMetaType(childNode); + ensureCanExtract(childNodeFn); return this[childNodeFn](childNode); }); desc.subGraphs.sort(this.compareSubgraphIDs); return desc; }; - FigureExtractor.prototype[EXTRACTORS.SUBGRAPH] = function(node){ const id = node.getId(), graphId = node.getParentId(), @@ -180,6 +179,20 @@ define(['./Utils'], function (Utils) { } }; + FigureExtractor.prototype.getMetadataChildrenIds = function (node) { + const allMetaNodes = this._client.getAllMetaNodes(); + const metadataBaseNode = allMetaNodes + .find(node => node.getAttribute('name') === BASE_METADATA_TYPE); + + if(metadataBaseNode) { + return node.getChildrenIds().filter(id => { + return this._client.isTypeOf(id, metadataBaseNode.getId()); + }); + } else { + return []; + } + }; + FigureExtractor.prototype.getGraphNode = function(node) { return this._getContainmentParentNodeAt(node, 'Graph'); }; @@ -197,7 +210,7 @@ define(['./Utils'], function (Utils) { FigureExtractor.prototype.getMetaType = function (node) { const metaTypeId = node.getMetaTypeId(); - return this._metaNodesMap[metaTypeId]; + return this._client.getNode(metaTypeId).getAttribute('name'); }; const extractPointsArray = function (pair) { diff --git a/src/seeds/devProject/devProject.webgmex b/src/seeds/devProject/devProject.webgmex index 8ffc334e6..3b4d65a3d 100644 Binary files a/src/seeds/devProject/devProject.webgmex and b/src/seeds/devProject/devProject.webgmex differ diff --git a/src/seeds/pipeline/pipeline.webgmex b/src/seeds/pipeline/pipeline.webgmex index 46c7525c3..610698c33 100644 Binary files a/src/seeds/pipeline/pipeline.webgmex and b/src/seeds/pipeline/pipeline.webgmex differ diff --git a/src/seeds/pipeline/releases.jsonl b/src/seeds/pipeline/releases.jsonl index 5011f29b8..6e493be8f 100644 --- a/src/seeds/pipeline/releases.jsonl +++ b/src/seeds/pipeline/releases.jsonl @@ -1,2 +1,4 @@ {"version":"0.20.0","changelog":"Add provenance info to Data nodes"} {"version":"0.21.0","changelog":"Add provenance to metadata (via WithProvenance mixin)"} +{"version":"0.21.1","changelog":"Update Inheritance of Subgraph, Line, Images, ScatterPoints etc.. nodes"} +