DetailQueryProvider.js 2.2 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. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019
  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', './api/QueryModifierAPI', 'underscore'], function (APIFactory, QueryProviderAPI, QueryModifierAPI, _) {
  9. var DetailQueryProvider = function () {
  10. function DetailQueryProvider(options) {
  11. _classCallCheck(this, DetailQueryProvider);
  12. var features = options && options.features;
  13. if (features) {
  14. this._mainProvider = features.QueryProvider;
  15. this._mainModifier = features.QueryModifier;
  16. }
  17. var queryExecution = features && features.DataQueryExecution;
  18. if (queryExecution) {
  19. queryExecution.registerQueryProvider(this.getAPI());
  20. queryExecution.registerQueryModifier(this.getAPI());
  21. }
  22. }
  23. DetailQueryProvider.prototype.getAPI = function getAPI() {
  24. if (!this.api) {
  25. this.api = APIFactory.createAPI(this, [QueryProviderAPI, QueryModifierAPI]);
  26. }
  27. return this.api;
  28. };
  29. DetailQueryProvider.prototype.getType = function getType() {
  30. return 'detail';
  31. };
  32. DetailQueryProvider.prototype.getQuerySpecList = function getQuerySpecList() {
  33. var querySpecList = this._mainProvider && this._mainProvider.getQuerySpecList();
  34. return _.chain(querySpecList)
  35. // apply details of the main query (ie. filter out minmax query)
  36. .filter(function (entry) {
  37. return entry.type === 'main';
  38. })
  39. // update the query spec type in order to request disaggregated detail result
  40. .map(function (entry) {
  41. _.extend(entry.spec, {
  42. type: 'detail'
  43. });
  44. return entry;
  45. }).value();
  46. };
  47. DetailQueryProvider.prototype.modifyQuerySpecList = function modifyQuerySpecList(specList) {
  48. return this._mainModifier && this._mainModifier.modifyQuerySpecList(specList);
  49. };
  50. return DetailQueryProvider;
  51. }();
  52. return DetailQueryProvider;
  53. });
  54. //# sourceMappingURL=DetailQueryProvider.js.map