123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- '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 Business Analytics (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(['./VIPRDecoratable', './VIPRDataPointIterator', './VIPRCatDataItem', './VIPRContDataItem', './VIPRCatContDataItem', '../../../apiHelpers/SlotAPIHelper'], function (VIPRDecoratable, VIPRDataPointIterator, VIPRCatDataItem, VIPRContDataItem, VIPRCatContDataItem, SlotAPIHelper) {
- // We should ignore any dataItem that is not part of the vipr slots
- // Adding a tooltip slot caused an error in the constructor
- var VIPRDataSet = function (_VIPRDecoratable) {
- _inherits(VIPRDataSet, _VIPRDecoratable);
- function VIPRDataSet(datasetId, queryResult, slots, context, content) {
- _classCallCheck(this, VIPRDataSet);
- var _this = _possibleConstructorReturn(this, _VIPRDecoratable.call(this));
- _this.id = datasetId;
- _this.queryResult = queryResult;
- _this.slots = slots;
- _this.context = context;
- _this.context.queryResult = queryResult;
- _this.context.dataset = _this;
- _this.viprDataPoints = {};
- // Need to preload dataItems to handle empty result.
- _this.dataItems = [];
- var resultDataItems = queryResult.getResultItemList();
- var numberOfDataItems = resultDataItems ? resultDataItems.length : 0;
- for (var index = 0; index < numberOfDataItems; index++) {
- var resultDataItem = resultDataItems[index];
- // properly resolve the slot by looking for the dataitem in the slots.
- // CADBLOC-1504: SparkLine View for KPI is a line chart we built on fly, the temp dataItem id for it couldn't be used to find a slot, in this scenario, we find slot based on index
- var slot = _this._getSlot(resultDataItem) || _this.slots[index];
- var slotDef = slot && slot.getDefinition();
- var slotDataItems = slot && slot.getDataItemList();
- if (slotDataItems && slotDataItems.length) {
- // @todo check for multi measure case?
- var type = slotDataItems[0].getType(); // sample the type with the first dataitem
- var VIPRDataItem = type === 'attribute' ? VIPRCatDataItem : VIPRContDataItem;
- var latLongSubTypes = ['latitude', 'longitude'];
- if (latLongSubTypes.indexOf(slotDef.getSubType()) > -1) {
- VIPRDataItem = VIPRCatContDataItem;
- }
- _this.context.index = {
- dataitem: _this.slots.indexOf(slot)
- };
- _this.dataItems[index] = new VIPRDataItem(resultDataItem, _this.context, content);
- }
- }
- return _this;
- }
- VIPRDataSet.prototype._getSlot = function _getSlot(resultDataItem) {
- var slot = this.slots.find(function (slot) {
- if (SlotAPIHelper.isMultiMeasuresValueSlot(slot) && resultDataItem.getDataItemList()[0].getId() === SlotAPIHelper.MULTI_MEASURES_VALUE) {
- return true;
- }
- var foundDataItem = slot.getDataItemList().find(function (dataItem) {
- return dataItem.getId() === resultDataItem.getDataItemList()[0].getId();
- });
- return foundDataItem;
- });
- return slot;
- };
- VIPRDataSet.prototype.getId = function getId() {
- return this.id;
- };
- // implement IDataSet
- VIPRDataSet.prototype.getDataItem = function getDataItem(index) {
- return index < this.dataItems.length ? this.dataItems[index] : null;
- };
- VIPRDataSet.prototype.getDataItemCount = function getDataItemCount() {
- return this.dataItems.length;
- };
- VIPRDataSet.prototype.getDataPointIterator = function getDataPointIterator() {
- return new VIPRDataPointIterator(this, this.context);
- };
- return VIPRDataSet;
- }(VIPRDecoratable);
- return VIPRDataSet;
- });
- //# sourceMappingURL=VIPRDataSet.js.map
|