G_QanReportRequestor.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /****************************************************************************************************************************
  2. Licensed Materials - Property of IBM
  3. BI and PM: QFW
  4. © Copyright IBM Corp. 2005, 2010
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. *****************************************************************************************************************************/
  7. var G_QanReportRequestor = {};
  8. G_QanReportRequestor.m_sReportSpec = "";
  9. G_QanReportRequestor.m_sSeverity = "information";
  10. G_QanReportRequestor.F_RequestReport = function( v_sPath )
  11. {
  12. this.m_sReportSpec = "";
  13. this.m_oRequest = new C_QanReportRequest(this, v_sPath);
  14. D_Progress.F_SendRequest( this.m_oRequest, null, "OBTAINING REPORT SPECIFICATION" );
  15. };
  16. G_QanReportRequestor.F_Abort = function()
  17. {
  18. if ( this.m_oRequest )
  19. {
  20. this.m_oRequest.F_Abort();
  21. }
  22. };
  23. G_QanReportRequestor.F_Request_OnComplete = function(v_oRequest)
  24. {
  25. delete this.m_oRequest;
  26. var v_oError = v_oRequest.F_GetError();
  27. if (v_oError)
  28. {
  29. alert( "Report Specification request return an error" );
  30. return;
  31. }
  32. //this.m_nDefects = v_oRequest.F_GetDefects();
  33. var v_nRequestResponse = v_oRequest.F_GetSpecificationValue();
  34. this.m_sReportSpec = v_nRequestResponse;
  35. G_QanApp.f_setReport(this.m_sReportSpec);
  36. if( this.m_sReportSpec )
  37. G_QanApp.F_GetLogging();
  38. else
  39. G_QanApp.F_GetSQLAnalyzer();
  40. };
  41. G_QanReportRequestor.F_GetQFSLogging = function( v_nQFSLogProperty )
  42. {
  43. this.f_showQFSFeedbackItem(v_oRequest, "ExecutionPlan");
  44. }
  45. G_QanReportRequestor.F_GetQFSFeedbackProperty = function( v_nQFSFeedbackProperties, v_sItemName )
  46. {
  47. var v_nQFSProperty = v_nQFSFeedbackProperties;
  48. var v_oFileRequest =
  49. new C_MultiFileRequest( new C_RequestListenerRedirect( this, "f_showQFSFeedbackItem" ),
  50. [ "QFLogFormatting.xsl" ] );
  51. v_oFileRequest.nQFSProperty = v_nQFSProperty;
  52. v_oFileRequest.sItemName = v_sItemName;
  53. D_Progress.F_SendRequest( v_oFileRequest, null, "Loading", 30 );
  54. };
  55. G_QanReportRequestor.f_loadQFSFeedbackItems = function(v_oRequest)
  56. {
  57. var nQFSProperty = v_oRequest.nQFSProperty;
  58. var v_sItemName = v_oRequest.sItemName;
  59. {
  60. var v_asXML = [];
  61. v_asXML[0] = "<QFSFeedbackList>";
  62. if (nQFSProperty.length == 0)
  63. {
  64. var v_oLogDoc = new C_QanLogDoc( '<?xml version="1.0" encoding="utf-8"?><XQELog name="Query1.0" />' );
  65. var v_iLogId = G_QanApp.F_AddLogDoc( v_oLogDoc );
  66. var v_sQueryNames = "Query1.0";
  67. v_asXML.push( "<QFSFeedbackItem type=\"QFSLog\" logId=\"" + v_iLogId + "\" queryNames=\""+ v_sQueryNames +"\">" );
  68. v_asXML.push( "</QFSFeedbackItem>" );
  69. }
  70. for( var iQuery = 0; iQuery < nQFSProperty.length; ++iQuery )
  71. {
  72. var v_nQFSPropertyItem = nQFSProperty.item(iQuery);
  73. if( v_sItemName == "ExecutionPlan" )
  74. {
  75. v_asXML.push( "<QFSFeedbackItem type=\"ExecutionPlan\">" );
  76. v_asXML.push( v_nQFSPropertyItem.childNodes[0].xml );
  77. }
  78. else
  79. {
  80. var v_oLogDoc = new C_QanLogDoc( v_nQFSPropertyItem.childNodes[0].text )
  81. var v_iLogId = G_QanApp.F_AddLogDoc( v_oLogDoc );
  82. var v_sQueryNames = v_oLogDoc.F_GetRootQRDNames();
  83. v_asXML.push( "<QFSFeedbackItem type=\"QFSLog\" logId=\"" + v_iLogId + "\" queryNames=\""+ v_sQueryNames +"\">" );
  84. }
  85. v_asXML.push( "</QFSFeedbackItem>" );
  86. }
  87. v_asXML.push( "</QFSFeedbackList>" );
  88. v_docXML = U_XML.F_LoadString( D_XmlError, v_asXML.join("\n\r") );
  89. if ( !v_docXML || !v_docXML.documentElement )
  90. return;
  91. }
  92. return v_docXML;
  93. }
  94. G_QanReportRequestor.f_showQFSFeedbackItem = function(v_oRequest)
  95. {
  96. var v_sText = v_oRequest.F_GetFileContents()[ "QFLogFormatting.xsl" ];
  97. var v_docXSL = U_XML.F_LoadString( D_XmlError, v_sText );
  98. if ( !v_docXSL || !v_docXSL.documentElement )
  99. return;
  100. G_QanApp.F_SetXslDoc( v_docXSL );
  101. v_docXML = G_QanReportRequestor.f_loadQFSFeedbackItems(v_oRequest);
  102. var v_frame = document.createElement( "iframe" );
  103. v_frame.name = "idLoggingView";
  104. v_frame.id = "idLoggingView";
  105. v_frame.width = "100%";
  106. v_frame.height = "100%";
  107. document.body.insertBefore( v_frame, document.body.firstChild );
  108. var v_oWin = v_frame.contentWindow;
  109. var v_sPlanHTML = v_docXML.transformNode( v_docXSL );
  110. var v_sEntryFunctionCall;
  111. if( v_sItemName == "ExecutionPlan" )
  112. v_sEntryFunctionCall = "openExecutionPlan( document.body )";
  113. else
  114. v_sEntryFunctionCall = "showExecutionTree( document.body )";
  115. v_sPlanHTML = v_sPlanHTML.replace( /\<BODY/, "<BODY client=\"CRN\" onload='loadANDapplyPreferences(document); " + v_sEntryFunctionCall + ";' " );
  116. v_sPlanHTML = v_sPlanHTML.replace( /\<script type="text\/javascript" src="[^\>]*\\\.\.\\templates\\qfw\\/g, "<script type=\"text/javascript\" src=\"" );
  117. v_sPlanHTML = v_sPlanHTML.replace( /\<link href="[^\>]*\\\.\.\\webcontent\\qfw\\/g, "<link href=\"" );
  118. v_oWin.document.write( v_sPlanHTML );
  119. v_oWin.document.close();
  120. v_oWin.document.title = "Validation Details";
  121. };
  122. G_QanReportRequestor.F_ClearErrors = function()
  123. {
  124. delete this.m_nDefect;
  125. delete this.m_aValidationProblems;
  126. };
  127. G_QanReportRequestor.f_showRequestErrors = function()
  128. {
  129. if ( !this.m_aRequestProblems )
  130. {
  131. return;
  132. }
  133. if ( this.m_aReuestProblems.length > 0 )
  134. {
  135. alert( "Report has request report specification errors" );
  136. return;
  137. }
  138. alert( "Report is valid" );
  139. };
  140. // ********************************************************************************************************
  141. // QAN Report Request: introduced to work around the obfuscation issue of C_BusRequest
  142. //
  143. function C_QanReportRequest( v_oListener, v_sPath)
  144. {
  145. this.m_bQIsPrompting = false;
  146. this.m_sQPromptReport = "";
  147. this.m_oQListener = v_oListener;
  148. this.m_bQServerPrompting = true;
  149. this.m_aQNamespaces = [];
  150. this.F_QAddNamespace( C_QanReportRequest.k_sBIBusNamespaceDecl );
  151. this.F_QAddNamespace( C_QanReportRequest.k_sBIBusRNSNamespaceDecl );
  152. this.F_ConstructBaseClass( v_oListener, v_sPath);
  153. };
  154. C_QanReportRequest.k_sBIBusNamespace = "http://developer.cognos.com/schemas/bibus/3";
  155. C_QanReportRequest.k_sBIBusNamespaceDecl = "xmlns:bus='" + C_QanReportRequest.k_sBIBusNamespace + "/'";
  156. C_QanReportRequest.k_sBIBusRNSNamespaceDecl = "xmlns:rns1='http://developer.cognos.com/schemas/reportService/1'";
  157. C_QanReportRequest.F_Extends( C_ReportRequest );
  158. C_QanReportRequest.prototype.F_SetNoServerPrompting = function()
  159. {
  160. this.m_bQServerPrompting = false;
  161. };
  162. C_QanReportRequest.prototype.F_QAddNamespace = function( v_sNamespace )
  163. {
  164. this.m_aQNamespaces.push( v_sNamespace );
  165. };
  166. C_QanReportRequest.prototype.F_IsReadyToProcess=function()
  167. {
  168. if(!C_QanReportRequest.superClass.F_IsReadyToProcess.call(this))
  169. {return false;}
  170. var v_sResponseText = this.F_GetResponseText();
  171. var v_docResponse = U_XML.F_LoadString( null, v_sResponseText, false, true );
  172. this.m_docQResponse = v_docResponse;
  173. this.m_docQResponse.setProperty( "SelectionNamespaces", "xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + this.m_aQNamespaces.join( " " ) );
  174. if (this.m_bQServerPrompting && this.m_oQListener && G_BusServer.F_RequiresServerPrompting(v_docResponse))
  175. {
  176. this.m_bQIsPrompting = true;
  177. if (G_BusServer.F_DoPrompting(this, v_docResponse, this.m_sQPromptReport))
  178. {
  179. // Depending on what happens after prompting, either the request will be completed (failed)
  180. // or it will be re-executed
  181. delete this.m_docQResponse;
  182. return false;
  183. }
  184. this.m_bQIsPrompting = false;
  185. this.F_SetNewErrorRes( "IDS_CCHL_INITIATE_SERVERPROMTING_FAILED" );
  186. return true;
  187. }
  188. return true;
  189. }