RemoveAllDataFilterAction.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2013
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /**
  13. * Removes all the dynamic filters (slider) from the report spec. This is for use with
  14. * save new report in Cognos Connection. No state information should be updated with this
  15. * call.
  16. * @returns
  17. */
  18. function RemoveAllDataFilterAction()
  19. {
  20. this.m_sAction = "UpdateDataFilter";
  21. };
  22. RemoveAllDataFilterAction.prototype.setCognosViewer = function( oCV ){
  23. this.m_oCV = oCV;
  24. };
  25. RemoveAllDataFilterAction.prototype.getCognosViewer = function( oCV ){
  26. return this.m_oCV;
  27. };
  28. /**
  29. * requestParms = { callback : { method : xxxx},
  30. * { object : yyyy}
  31. * }
  32. */
  33. RemoveAllDataFilterAction.prototype.setRequestParms= function( requestParms ){
  34. if( !requestParms || !requestParms.callback){ return;}
  35. this.m_callbackMethod = requestParms.callback.method;
  36. this.m_callbackObject = requestParms.callback.object;
  37. };
  38. RemoveAllDataFilterAction.prototype.createJSONDispatcherEntry = function( requestType )
  39. {
  40. var oReq = new JSONDispatcherEntry(this.getCognosViewer());
  41. oReq.addFormField("ui.action", requestType);
  42. //add action context
  43. var actionContext = this.addActionContext();
  44. oReq.addFormField("cv.actionContext", actionContext);
  45. if (window.gViewerLogger)
  46. {
  47. window.gViewerLogger.log('Action context', actionContext, "xml");
  48. }
  49. if(typeof this.m_oCV.envParams["ui.spec"] != "undefined")
  50. {
  51. oReq.addFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  52. }
  53. oReq.addFormField("bux", 'true');
  54. return oReq;
  55. };
  56. RemoveAllDataFilterAction.prototype.addActionContext = function(){
  57. var actionContext = "<reportActions";
  58. var inlineValues = "";
  59. actionContext += " run=\"false\"";
  60. actionContext += ">";
  61. actionContext += "<reportAction name=\"" + this.m_sAction + "\">";
  62. var actionParms = "{ \"removeAll\" :\"true\"}";
  63. actionContext += xml_encode(actionParms);
  64. actionContext += "</reportAction>";
  65. actionContext += "</reportActions>";
  66. return actionContext;
  67. };
  68. RemoveAllDataFilterAction.prototype.executeCallback = function(reportSpec) {
  69. var callbackFunc = GUtil.generateCallback(this.m_callbackMethod, [reportSpec], this.m_callbackObject);
  70. callbackFunc();
  71. };
  72. RemoveAllDataFilterAction.prototype.handleServerResponse = function( serverResponse ) {
  73. if( serverResponse && serverResponse.getJSONResponseObject() ){
  74. this.executeCallback( serverResponse.getJSONResponseObject().reportSpec);
  75. }
  76. };
  77. RemoveAllDataFilterAction.prototype.execute = function() {
  78. var oCV = this.getCognosViewer();
  79. if( !oCV.getRAPReportInfo().hasSlider() ){
  80. this.executeCallback(oCV.envParams["ui.spec"]);
  81. } else {
  82. var cognosViewerRequest = this.createJSONDispatcherEntry( "modifyReport" );
  83. cognosViewerRequest.setCallbacks({"complete":{"object":this, "method":this.handleServerResponse}});
  84. oCV.dispatchRequest(cognosViewerRequest);
  85. }
  86. };