ModuleAPI.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /*
  4. *+------------------------------------------------------------------------+
  5. *| Licensed Materials - Property of IBM
  6. *| IBM Cognos Products: Dashboard
  7. *| (C) Copyright IBM Corp. 2017, 2020
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or disclosure
  10. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *+----------------------------------------------met--------------------------+
  12. */
  13. define(['./modelmanagers/ShapingModelManager', '../utils/ShapingUIUtils'], function (ShapingModelManager, ShapingUIUtils) {
  14. 'use strict';
  15. /**
  16. * INTENT: ModuleAPI provides a UI-Oriented interface to the moser module
  17. * It hides the implementation of the underlying model.
  18. */
  19. var ShapingModelAPI =
  20. /**
  21. * Contructor
  22. * @param {Object} options.dashboardApi The dashboard API
  23. * @param {Object} options.sourceModel The source model
  24. */
  25. function ShapingModelAPI(options) {
  26. var _this = this;
  27. _classCallCheck(this, ShapingModelAPI);
  28. var shapingModelManager = new ShapingModelManager(options);
  29. var shapingModel = options.sourceModel.get('shaping');
  30. var sourceModelManager = options.sourceModelManager;
  31. var sourcesCollectionManager = sourceModelManager.sourcesCollectionManager;
  32. // event APIs
  33. this.on = shapingModel.on.bind(shapingModel);
  34. this.off = shapingModel.off.bind(shapingModel);
  35. // Temp hack until all our UIs are moved to live-widget. We don't want dashbboard to have a direct
  36. // depency on live-widget classes.
  37. this.getShapingUIUtils = function () {
  38. return ShapingUIUtils;
  39. };
  40. // DEFINE THE API....
  41. this.load = shapingModelManager.load.bind(shapingModelManager);
  42. this.queryData = shapingModelManager.queryData.bind(shapingModelManager);
  43. this.queryPredictData = shapingModelManager.queryPredictData.bind(shapingModelManager);
  44. this.querySmartsExploreRelationshipData = shapingModelManager.querySmartsExploreRelationshipData.bind(shapingModelManager);
  45. this.getModuleId = shapingModelManager.getModuleId.bind(shapingModelManager);
  46. this.getShapingHelper = shapingModelManager.getShapingHelper.bind(shapingModelManager);
  47. this.addCalculation = shapingModelManager.addCalculation.bind(shapingModelManager);
  48. this.getMetadataColumn = shapingModelManager.getMetadataColumn.bind(shapingModelManager);
  49. this.getMetadataColumns = shapingModelManager.getMetadataColumns.bind(shapingModelManager);
  50. this.getMoserObject = shapingModelManager.getMoserObject.bind(shapingModelManager);
  51. this.addToUndoStack = shapingModelManager.addToUndoStack.bind(shapingModelManager);
  52. this.getDrillGroups = shapingModelManager.getDrillGroups.bind(shapingModelManager);
  53. this.getDrillGroupsForColumn = shapingModelManager.getDrillGroupsForColumn.bind(shapingModelManager);
  54. this.relink = shapingModelManager.relink.bind(shapingModelManager);
  55. this.reloadMetadata = shapingModelManager.reloadMetadata.bind(shapingModelManager);
  56. this.tablesHaveJointRelationship = shapingModelManager.tablesHaveJointRelationship.bind(shapingModelManager);
  57. this.getTableNames = shapingModelManager.getTableNames.bind(shapingModelManager);
  58. this.getLocalizedName = shapingModelManager.getLocalizedName.bind(shapingModelManager);
  59. this.ensureTemporaryModule = shapingModelManager.ensureTemporaryModule.bind(shapingModelManager);
  60. this.getShapingId = shapingModel.getShapingId.bind(shapingModel);
  61. this.getEmbeddedModuleId = shapingModel.get.bind(shapingModel, 'embeddedModuleId');
  62. this.getState = sourceModelManager.getState.bind(sourceModelManager);
  63. this.getSourceId = options.sourceModel.get.bind(options.sourceModel, 'id');
  64. this.getSourceName = options.sourceModel.get.bind(options.sourceModel, 'name');
  65. this.getAssetId = options.sourceModel.get.bind(options.sourceModel, 'assetId');
  66. this.isOlapPackage = options.sourceModel.getIsOlapPackage.bind(options.sourceModel);
  67. this.getSourceType = options.sourceModel.get.bind(options.sourceModel, 'type');
  68. this.getLastModified = sourceModelManager.getLastModified.bind(options.sourceModel);
  69. this.setLastModified = sourceModelManager.setLastModified.bind(options.sourceModel);
  70. this.getSourceIdsFromAssetId = sourcesCollectionManager && sourcesCollectionManager.getSourceIdsFromAssetId.bind(sourcesCollectionManager);
  71. this.addWADerivedAttribute = shapingModelManager.addWADerivedAttribute.bind(shapingModelManager);
  72. this.getTemporarySessionModuleJSON = shapingModelManager.getTemporarySessionModuleJSON.bind(shapingModelManager);
  73. this.copyPartialMoserModuleJSON = shapingModelManager.copyPartialMoserModuleJSON.bind(shapingModelManager);
  74. this.saveTemporaryModule = shapingModelManager.saveTemporaryModule.bind(shapingModelManager);
  75. this.clearTemporaryModule = shapingModelManager.clearTemporaryModule.bind(shapingModelManager);
  76. this.whenTemporaryModuleReady = shapingModelManager.whenTemporaryModuleReady.bind(shapingModelManager);
  77. this.getMetadataSubsetIds = shapingModelManager.getMetadataSubsetIds.bind(shapingModelManager);
  78. this.isMultiSheetUploadedFile = function () {
  79. return _this.getSourceType() === 'uploadedFile' && _this.getTableNames().length > 1;
  80. };
  81. };
  82. return ShapingModelAPI;
  83. });
  84. //# sourceMappingURL=ModuleAPI.js.map