ResultItem.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. 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; }
  4. 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; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2019
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['@waca/dashboard-common/js/core/APIFactory', '@waca/dashboard-livewidget/js/features/dashboard/queryService/api/ResultItemAPI', '@waca/dashboard-livewidget/js/widgets/livewidget/query/QueryResultDataItem', './QueryResultColumn', 'underscore'], function (APIFactory, ResultItemAPI, QueryResultDataItem, QueryResultColumn, _) {
  11. var ResultItem = function (_QueryResultDataItem) {
  12. _inherits(ResultItem, _QueryResultDataItem);
  13. function ResultItem(dataItemObject) {
  14. _classCallCheck(this, ResultItem);
  15. var _this = _possibleConstructorReturn(this, _QueryResultDataItem.call(this, dataItemObject));
  16. _this.getRowCount = _this.getTupleCount.bind(_this);
  17. return _this;
  18. }
  19. ResultItem.prototype.getAPI = function getAPI() {
  20. if (!this.api) {
  21. this.api = APIFactory.createAPI(this, [ResultItemAPI]);
  22. }
  23. return this.api;
  24. };
  25. ResultItem.prototype.getDataItemList = function getDataItemList() {
  26. var resultColumnList = this.getTupleHeaders()[0];
  27. return _.map(resultColumnList, function (columnObj) {
  28. return new QueryResultColumn(columnObj).getAPI();
  29. });
  30. };
  31. ResultItem.prototype.getId = function getId() {
  32. return this._getTupleHeaderObjects()[0].id;
  33. };
  34. //TODO: delete memberObj.u and memberObj.d when all consumers are ready to new qeury APIs
  35. ResultItem.prototype.getValue = function getValue(rowIndex) {
  36. var tuple = this.getTuple(rowIndex);
  37. tuple.forEach(function (memberObj) {
  38. if (memberObj.value === undefined) {
  39. memberObj.value = memberObj.u;
  40. memberObj.label = memberObj.d;
  41. }
  42. });
  43. return tuple;
  44. };
  45. return ResultItem;
  46. }(QueryResultDataItem);
  47. return ResultItem;
  48. });
  49. //# sourceMappingURL=ResultItem.js.map