SmartsRecommender.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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, 2020
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../impl/SmartsRecommenderFeature', './api/SmartsRecommenderAPI', './api/DeprecatedSmartsRecommenderAPI'], function (APIFactory, SmartsRecommenderFeature, SmartsRecommenderAPI, DeprecatedSmartsRecommenderAPI) {
  11. 'use strict';
  12. var VisualizationSmartsRecommender = function (_SmartsRecommenderFea) {
  13. _inherits(VisualizationSmartsRecommender, _SmartsRecommenderFea);
  14. function VisualizationSmartsRecommender(options) {
  15. _classCallCheck(this, VisualizationSmartsRecommender);
  16. var _this = _possibleConstructorReturn(this, _SmartsRecommenderFea.call(this, options));
  17. _this._api = APIFactory.createAPI(_this, [SmartsRecommenderAPI]);
  18. _this._deprecatedAPI = APIFactory.createAPI(_this, [DeprecatedSmartsRecommenderAPI]);
  19. return _this;
  20. }
  21. VisualizationSmartsRecommender.prototype.destroy = function destroy() {
  22. _SmartsRecommenderFea.prototype.destroy.call(this);
  23. this._api = null;
  24. this._deprecatedAPI = null;
  25. };
  26. VisualizationSmartsRecommender.prototype.getAPI = function getAPI(type) {
  27. if (type === 'deprecated') {
  28. return this._deprecatedAPI;
  29. }
  30. return this._api;
  31. };
  32. VisualizationSmartsRecommender.prototype.recommendAlternateContent = function recommendAlternateContent() {
  33. throw new Error('Not implemented yet');
  34. };
  35. VisualizationSmartsRecommender.prototype.recommendRelatedContent = function recommendRelatedContent() {
  36. throw new Error('Not implemented yet');
  37. };
  38. VisualizationSmartsRecommender.prototype.recommendAlternateVisualizationsAsWidgetSpecs = function recommendAlternateVisualizationsAsWidgetSpecs(dataSourceId, columnIds) {
  39. var _this2 = this;
  40. return _SmartsRecommenderFea.prototype.recommendAlternateVisualizationsFromColumnIds.call(this, dataSourceId, columnIds).then(function (recommendations) {
  41. return _this2._transformToWidgetSpecs(recommendations, dataSourceId);
  42. });
  43. };
  44. // deprecated interface -- called by explore
  45. VisualizationSmartsRecommender.prototype.recommendRelatedVisualizationsAsWidgetSpecs = function recommendRelatedVisualizationsAsWidgetSpecs(dataSourceId, columnIds, includeBestVisForTargetFields) {
  46. var _this3 = this;
  47. return _SmartsRecommenderFea.prototype.recommendRelatedVisualizationsFromColumnIds.call(this, dataSourceId, columnIds, null, includeBestVisForTargetFields).then(function (recommendations) {
  48. return _this3._transformToWidgetSpecs(recommendations, dataSourceId);
  49. });
  50. };
  51. VisualizationSmartsRecommender.prototype.transformRecommendationsToLiveWidgetSpecs = function transformRecommendationsToLiveWidgetSpecs(recommendations, sourceId) {
  52. var transformedRecommendations = this._visRecommenderDelegator.smarts._transformRecommendationResponse(sourceId, recommendations);
  53. return this._transformToWidgetSpecs(transformedRecommendations, sourceId);
  54. };
  55. VisualizationSmartsRecommender.prototype._transformToWidgetSpecs = function _transformToWidgetSpecs(recommendations, sourceId) {
  56. return this._transformWidgetRecommendationsToLiveWidgetSpecs(recommendations, {
  57. type: 'live',
  58. data: {
  59. dataViews: [{
  60. id: 'id_123',
  61. modelRef: sourceId
  62. }]
  63. }
  64. });
  65. };
  66. return VisualizationSmartsRecommender;
  67. }(SmartsRecommenderFeature);
  68. return VisualizationSmartsRecommender;
  69. });
  70. //# sourceMappingURL=SmartsRecommender.js.map