'use strict'; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['@waca/dashboard-common/js/core/APIFactory', '@waca/dashboard-livewidget/js/features/dashboard/queryService/api/QueryResultAPI', './ResultItem', '@waca/dashboard-livewidget/js/widgets/livewidget/query/QueryResultData'], function (APIFactory, QueryResultAPI, ResultItem, QueryResultData) { var QueryResultDataImpl = function (_QueryResultData) { _inherits(QueryResultDataImpl, _QueryResultData); function QueryResultDataImpl(queryResultObj) { _classCallCheck(this, QueryResultDataImpl); var _this = _possibleConstructorReturn(this, _QueryResultData.call(this, queryResultObj)); _this.getResultItemList = _this.getResultDataItems.bind(_this); _this.getDataPointValueList = _this.getDatapoints.bind(_this); _this.getRowCount = _this.getDatapointCount.bind(_this); _this.properties = {}; return _this; } QueryResultDataImpl.prototype.getPropertyValue = function getPropertyValue(name) { return this.properties[name]; }; QueryResultDataImpl.prototype.setPropertyValue = function setPropertyValue(name, value) { if (typeof name !== 'string') { throw new Error('Name must be a string'); } if (value !== null && typeof value !== 'string') { throw new Error('Value must be a string'); } this.properties[name] = value; }; QueryResultDataImpl.prototype.getAPI = function getAPI() { if (!this.queryResultAPI) { this.queryResultAPI = APIFactory.createAPI(this, [QueryResultAPI]); } return this.queryResultAPI; }; QueryResultDataImpl.prototype._generateDataItemArray = function _generateDataItemArray() { var _this2 = this; this._aQueryResultDataItems = []; if (this._resultData && this._resultData.dataItems && this._resultData.dataItems.length > 0) { this._resultData.dataItems.forEach(function (dataItem) { if (_this2._isValidDataItem(dataItem)) { _this2._aQueryResultDataItems.push(new ResultItem(dataItem).getAPI()); } }); } }; QueryResultDataImpl.prototype.getResultItem = function getResultItem(resultDataItemID) { return this.getResultItemList().find(function (resultDataItemAPI) { return resultDataItemID === resultDataItemAPI.getId(); }); }; //TODO: delete value.v when when all consumers are ready to new qeury APIs QueryResultDataImpl.prototype.getValue = function getValue(rowIndex, resultDataItemIndex) { var value = undefined; var dataPointValueList = this.getDataPointValueList(); var dataPoint = dataPointValueList && dataPointValueList[rowIndex]; if (dataPoint) { value = dataPoint.pt[resultDataItemIndex]; if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && (value.v !== undefined || value.value !== undefined)) { // result is a value of a measure column if (value.value === undefined) { value.value = value.v; } } else { // value is the row index of resultItemList var resultItemList = this.getResultItemList(); value = resultItemList && resultItemList[resultDataItemIndex].getValue(value); } } return value; }; QueryResultDataImpl.prototype.getValueIndex = function getValueIndex(rowIndex, resultDataItemIndex) { //Similar to getValue for categoricals except that it returns the index in the 'edge' where the tuple value is found. var value = undefined; var dataPointValueList = this.getDataPointValueList(); var dataPoint = dataPointValueList && dataPointValueList[rowIndex]; if (dataPoint) { value = dataPoint.pt[resultDataItemIndex]; if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { throw new Error('getValueIndex is only supported for categorical items.'); } } return value; }; return QueryResultDataImpl; }(QueryResultData); return QueryResultDataImpl; }); //# sourceMappingURL=QueryResultData.js.map