'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(['underscore', './VIPRDecoratable', './VIPRItem'], function (_, VIPRDecoratable, VIPRItem) { // implements ITuple var VIPRTuple = function (_VIPRDecoratable) { _inherits(VIPRTuple, _VIPRDecoratable); function VIPRTuple(tuple, context, content, viprItemCache) { _classCallCheck(this, VIPRTuple); var _this = _possibleConstructorReturn(this, _VIPRDecoratable.apply(this, arguments)); _this.tuple = tuple; _this.content = content; _this.context = context; _this.datapoints = []; _this.items = []; _this.dataset = context.dataset; _this.dataItemIndex = _this.context.index.dataitem; _this.dataItemFormats = _this.context.index.dataItemFormats; _this.itemClassSetIndex = _this.context.index.itemClassSet; _this._viprItemCache = viprItemCache; return _this; } VIPRTuple.prototype.getUniqueName = function getUniqueName() { return this.getItem(0).getUniqueName(); }; VIPRTuple.prototype.getCaption = function getCaption() { return this.getItem(0).getCaption(); }; VIPRTuple.prototype.getParent = function getParent() { return this.getItem(0).getParent(); }; VIPRTuple.prototype.getItemClassSetIndex = function getItemClassSetIndex() { //Since Enodr release, a tuple could have a itemClassSetIndex property //that indicates which itemClass the current tuple is using return this.itemClassSetIndex; }; VIPRTuple.prototype._createVIPRItem = function _createVIPRItem(index, viprTuple, content) { var context = viprTuple.context; var viprItemInfo = viprTuple.tuple[index]; var key = void 0; if (viprItemInfo.d) { key = viprItemInfo.d + '->' + viprItemInfo.u; } else { key = viprItemInfo.label + '->' + viprItemInfo.value; } if (!this._viprItemCache[key]) { this._viprItemCache[key] = new VIPRItem(this.tuple[index], context, content); } this._viprItemCache[key].addTuple(viprTuple); return this._viprItemCache[key]; }; VIPRTuple.prototype.getItem = function getItem(index) { if (index < this.getItemCount() && this.items[index] === undefined) { // keep track of the tuple item index as part of the context index this.context.index.tupleitem = index; this.context.index.dataitem = this.dataItemIndex; this.context.index.dataItemFormats = this.dataItemFormats; this.context.dataset = this.dataset; this.items[index] = this._createVIPRItem(index, this, this.content); } return this.items[index]; }; VIPRTuple.prototype.getItemCount = function getItemCount() { return this.tuple ? this.tuple.length : 0; }; VIPRTuple.prototype.addDataPoint = function addDataPoint(datapoint) { if (this.datapoints.indexOf(datapoint) === -1) { this.datapoints.push(datapoint); } }; VIPRTuple.prototype.decorate = function decorate(action, value) { var _VIPRDecoratable$prot; (_VIPRDecoratable$prot = _VIPRDecoratable.prototype.decorate).call.apply(_VIPRDecoratable$prot, [this].concat(Array.prototype.slice.call(arguments))); if (this.datapoints.length > 0) { // decorate the datapoints _.each(this.datapoints, function (dp) { dp.decorate(action, value); }); } }; return VIPRTuple; }(VIPRDecoratable); return VIPRTuple; }); //# sourceMappingURL=VIPRTuple.js.map