SummaryQueryProvider.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', './api/QueryProviderAPI', 'underscore'], function (APIFactory, QueryProviderAPI, _) {
  9. var SummaryQueryProvider = function () {
  10. function SummaryQueryProvider(options) {
  11. _classCallCheck(this, SummaryQueryProvider);
  12. var features = options && options.features;
  13. if (features) {
  14. this._mainProvider = features.QueryProvider;
  15. }
  16. var queryExecution = features && features.DataQueryExecution;
  17. if (queryExecution) {
  18. queryExecution.registerQueryProvider(this.getAPI());
  19. }
  20. }
  21. SummaryQueryProvider.prototype.getAPI = function getAPI() {
  22. if (!this.api) {
  23. this.api = APIFactory.createAPI(this, [QueryProviderAPI]);
  24. }
  25. return this.api;
  26. };
  27. SummaryQueryProvider.prototype.getType = function getType() {
  28. return 'summary';
  29. };
  30. SummaryQueryProvider.prototype.getQuerySpecList = function getQuerySpecList() {
  31. var querySpecList = this._mainProvider && this._mainProvider.getQuerySpecList();
  32. return _.chain(querySpecList)
  33. // Get the main query (ie. filter out minmax query)
  34. .filter(function (entry) {
  35. return entry.type === 'main';
  36. })
  37. // update the query spec type
  38. .map(function (entry) {
  39. _.extend(entry.spec, {
  40. type: 'summary'
  41. });
  42. return entry;
  43. }).value();
  44. };
  45. return SummaryQueryProvider;
  46. }();
  47. return SummaryQueryProvider;
  48. });
  49. //# sourceMappingURL=SummaryQueryProvider.js.map