'use strict'; 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. 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../dashboard/queryService/ResultItem', '../../dashboard/queryService/QueryResultColumn', '../../../widgets/livewidget/nls/StringResources', 'underscore', '../../../apiHelpers/SlotAPIHelper'], function (ResultItem, QueryResultColumn, StringResources, _, SlotAPIHelper) { var DataQueryResultItem = function (_ResultItem) { _inherits(DataQueryResultItem, _ResultItem); function DataQueryResultItem(dataItemObject, slots) { _classCallCheck(this, DataQueryResultItem); var _this = _possibleConstructorReturn(this, _ResultItem.call(this, dataItemObject)); _this._slots = slots; _this.getRowCount = _this.getTupleCount.bind(_this); return _this; } DataQueryResultItem.prototype.getDataItemList = function getDataItemList() { if (!this._dataItemList) { this._dataItemList = []; var id = this.getTupleHeaderId(); var dataItemInfo = this._slots.getMappingInfo(id); if (!dataItemInfo) { var _dataItemList; // Could be a slot with nested data items in result item, otherwise skip var slot = this._slots.getSlot(id); var dataItemList = slot && slot.getDataItemList(); if (dataItemList && this.isMultiMeasureValue(dataItemList)) { // TODO Temporary solution for multiMeasureValue data item. dataItemList = [new QueryResultColumn({ u: SlotAPIHelper.MULTI_MEASURES_VALUE, d: StringResources.get('ValuesCaption') }).getAPI()]; } if (!dataItemList) { // Handle data item generated internally, such as contextual grid to get data with columns referenced by tab filters var columnHeaders = this.getTupleHeaders()[0]; dataItemList = columnHeaders && _.map(columnHeaders, function (columnHeader) { return new QueryResultColumn(columnHeader).getAPI(); }); } (_dataItemList = this._dataItemList).push.apply(_dataItemList, dataItemList); } else { this._dataItemList.push(dataItemInfo.dataItem); } } return this._dataItemList; }; DataQueryResultItem.prototype.isMultiMeasureValue = function isMultiMeasureValue(dataItemList) { if (dataItemList.length < 2) { return false; } var list = _.filter(dataItemList, function (dataItem) { return dataItem.getType() === 'fact'; }); return list.length > 1; }; return DataQueryResultItem; }(ResultItem); return DataQueryResultItem; }); //# sourceMappingURL=DataQueryResultItem.js.map