rsReportToDashboardService.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Licensed Materials - Property of IBM
  3. * IBM Cognos Products: rs
  4. * (C) Copyright IBM Corp. 2018
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. *
  7. */
  8. define([
  9. 'baglass/core-client/js/core-client/ui/core/Class',
  10. 'q',
  11. 'bi/authoring/utils/V5ToDashboard'
  12. ], function(Class, Q, V5ToDashboard) {
  13. 'use strict';
  14. var rsReportToDashboardService = Class.extend({
  15. init: function(attributes) {
  16. this._glassContext = attributes.glassContext;
  17. rsReportToDashboardService.inherited('init', this, arguments);
  18. },
  19. convertReportToDashboard: function() {
  20. this.deferred = Q.defer();
  21. this._glassContext.getCoreSvc('.Clipboard').get().then(function(v_oExternalCopy) {
  22. if (v_oExternalCopy && v_oExternalCopy.type == "REPORT") {
  23. var v_nSourceReport = (new DOMParser()).parseFromString(v_oExternalCopy.spec, "text/xml").documentElement;
  24. var v_aSelectionIids = v_oExternalCopy.selectionIids;
  25. V5ToDashboard.ConvertV5toDB(v_nSourceReport, v_aSelectionIids, this._glassContext).then(function(v_oDBSpec) {
  26. this.deferred.resolve(JSON.stringify(v_oDBSpec));
  27. }.bind(this));
  28. }
  29. else
  30. {
  31. this.deferred.resolve("");
  32. }
  33. }.bind(this));
  34. return this.deferred.promise;
  35. }
  36. });
  37. return rsReportToDashboardService;
  38. });