'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: BI Dashboard *| (C) Copyright IBM Corp. 2019, 2020 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define([], function () { 'use strict'; /** * This post processor handles 'null suppression disabled'. * It is dependent on PostProcessMultiEdgeMeasures for multi-measure use cases so it has been chained after it. * * When null suppression is disabled, all edge items are returned in the DSS response (they are not when suppression is on) * BUT the pt array has no more cells than it would if suppression were on. * * This post processor generates null datapoints to fill those gaps so that rows/columns of null values * will be displayed. * * The post processor does not handle all shapes but supports all forms of crosstabs. * 2 or 3 edge responses (where one edge is a measure) **/ return function () { /** * @Constructor * @param {Object} queryResultDataPoints - a map of multiEdgeData * @param {Object} queryResultData - the query result data */ function PostProcessMultiEdgeShowNulls(_ref) { var queryResultDataPoints = _ref.queryResultDataPoints, queryResultData = _ref.queryResultData; _classCallCheck(this, PostProcessMultiEdgeShowNulls); this.multiEdgeData = queryResultDataPoints; this._queryResultData = queryResultData; //Pre-compute the index and size of each non-measure edge. var edges = this._queryResultData.edges; this.firstEdgeSize = queryResultDataPoints.getFirstEdgeSize(edges); //If there's 3 edges, the second nonMeasure edge will be firstEdge + 1 (usually just 1) this.secondEdgeSize = this.multiEdgeData.getSecondEdgeSize(edges); //Was the data clipped before we started?, if so, make sure it is marked as clipped at the end. var data = this._queryResultData.data; var clipMarkerIdx = data && data.length - 1; this.clipMarker = clipMarkerIdx > 0 && data[clipMarkerIdx] && data[clipMarkerIdx].hasNext ? data[clipMarkerIdx] : null; //In the query, we requested 3000 suppressed cells from DSS but if we simply process all of the data, //we could end up with thousands or tens of thousands more once nulls are inserted. //TODO: RTC297388 For now, just stop processing at a hard coded limit af 3000 cells // We should use some variation of _getQuerySpecLimit() in QueryProvider BOTH here and // on the query side but we need to think about this because now our request // includes the summaries and its difficult to know how much to bump up the limit. this._CELL_OUTPUT_LIMIT = 3000; } /** * Apply the users overrides for a multi-edge result. If this is not a multi-edge result, * this post processor is a no-op. * @return {QueryResultData} */ PostProcessMultiEdgeShowNulls.prototype._processData = function _processData() { if (this._queryResultData.edges && this._queryResultData.edges.length > 1) { //Suppress nulls off handling. var edgeCount = this._queryResultData.edges.length; if (edgeCount === 2) { this._showNulls_2Edges(); } else if (edgeCount === 3) { this._showNulls_3Edges(); } else { throw new Error('only 2 and 3 edge responses are supported for zero suppression disabled'); } if (this.clipMarker) { //If the data was clipped before, its still clipped after. this._queryResultData.data.push(this.clipMarker); } } //For V1 or single edge V2, this postProcessor is a no-op. return this._queryResultData; }; //Show nulls in a 2 edge visualization (eg a crosstab with rows and measures) by //creating a complete array of points which include the data and null values where there is no data. PostProcessMultiEdgeShowNulls.prototype._showNulls_2Edges = function _showNulls_2Edges() { var output = []; this._addFirstEdgeCellsToOutput(output); this._queryResultData.data = output; return this._queryResultData; }; //Show nulls in a 3 edge visualization (eg a crosstab with columns, rows and measures) by //creating a complete rectangle of points which include the data and null values where there is no data. PostProcessMultiEdgeShowNulls.prototype._showNulls_3Edges = function _showNulls_3Edges() { var output = []; var cellIdx = 0; for (var ptSecondEdgeId = 0; ptSecondEdgeId < this.secondEdgeSize; ++ptSecondEdgeId) { cellIdx = this._addFirstEdgeCellsToOutput(output, cellIdx, ptSecondEdgeId); if (output.length >= this._CELL_OUTPUT_LIMIT) { break; } } this._queryResultData.data = output; return this._queryResultData; }; PostProcessMultiEdgeShowNulls.prototype._addFirstEdgeCellsToOutput = function _addFirstEdgeCellsToOutput(output) { var cellIdx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var ptSecondEdgeId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; //Add cells for each item in the first edge with 'gaps filled in' for (var ptFirstEdgeId = 0; ptFirstEdgeId < this.firstEdgeSize; ++ptFirstEdgeId) { output.push(this.multiEdgeData.getPtByEdgeIds(ptFirstEdgeId, ptSecondEdgeId)); if (output.length >= this._CELL_OUTPUT_LIMIT) { this._addClipMarker(output); break; } } return cellIdx; }; PostProcessMultiEdgeShowNulls.prototype._addClipMarker = function _addClipMarker(output) { //When the data is sparse, we could easily generate many more cells than the suppressed version. //We need to clip it (and mark that its clipped). output.push({ hasNext: true }); }; return PostProcessMultiEdgeShowNulls; }(); }); //# sourceMappingURL=PostProcessMultiEdgeShowNulls.js.map