G_QanReportValidator.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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_QanReportValidator = {};
  8. G_QanReportValidator.m_sSeverity = "information";
  9. G_QanReportValidator.F_Validate = function( v_nReport )
  10. {
  11. var v_sReport2Validate =
  12. v_nReport.replace( /\<queries\>/, "<queries><!--info:ExecutionPlan-->" );
  13. this.m_oRequest = new C_ValidationRequest(this, v_sReport2Validate, this.m_sSeverity);
  14. D_Progress.F_SendRequest( this.m_oRequest, null, "VALIDATING" );
  15. };
  16. G_QanReportValidator.F_ValidateForLogging = function( v_nReport )
  17. {
  18. var v_sReport2Log =
  19. v_nReport.replace( /\<queries\>/, "<queries><!--info:QFSLog-->" );
  20. this.m_oRequest = new C_QanValidationRequest(this, v_sReport2Log, this.m_sSeverity);
  21. D_Progress.F_SendRequest( this.m_oRequest, null, "VALIDATING" );
  22. };
  23. G_QanReportValidator.F_Abort = function()
  24. {
  25. if ( this.m_oRequest )
  26. {
  27. this.m_oRequest.F_Abort();
  28. }
  29. };
  30. G_QanReportValidator.F_Request_OnComplete = function(v_oRequest)
  31. {
  32. delete this.m_oRequest;
  33. var v_oError = v_oRequest.F_GetError();
  34. if (v_oError)
  35. {
  36. alert( "Validation request return an error" );
  37. return;
  38. }
  39. this.m_nDefects = v_oRequest.F_GetDefects();
  40. var v_nValidateResponse = v_oRequest.F_GetQueryInfo();
  41. var v_nProperty;
  42. var v_nlQFSLogging =
  43. v_nValidateResponse.selectNodes(".//property[@name='QFSLog']");
  44. if( v_nlQFSLogging.length != 0 )
  45. {
  46. v_nProperty = v_nlQFSLogging;
  47. v_sItemName = "QFSLog";
  48. }
  49. else
  50. {
  51. if (this.m_nDefects.xml != null)
  52. {
  53. var v_xmlDoc = U_XML.F_LoadString( D_XmlError, this.m_nDefects.xml, false, true );
  54. var v_message =
  55. v_xmlDoc.selectSingleNode("./defects/queryProblems/message");
  56. if (v_message != null)
  57. var v_msgTitle = v_message.getAttribute("title");
  58. if (v_msgTitle != "XQE Message")
  59. {
  60. v_message = v_xmlDoc.selectSingleNode("./defects/layoutProblems/messages/message");
  61. if (v_message != null)
  62. var v_msgTitle = v_message.getAttribute("title");
  63. alert(v_msgTitle);
  64. return;
  65. }
  66. }
  67. var v_nlQFSExecPlan =
  68. v_nValidateResponse.selectNodes(".//property[@name='QFExecutionPlan']");
  69. v_nProperty = v_nlQFSLogging;
  70. v_sItemName = "XQE";
  71. }
  72. G_QanReportValidator.F_GetQFSFeedbackProperty( v_nProperty, v_sItemName );
  73. };
  74. G_QanReportValidator.F_GetQFSLogging = function( v_nQFSLogProperty )
  75. {
  76. this.f_showQFSFeedbackItem(v_oRequest, "ExecutionPlan");
  77. }
  78. G_QanReportValidator.F_GetQFSFeedbackProperty = function( v_nQFSFeedbackProperties, v_sItemName )
  79. {
  80. var v_nQFSProperty = v_nQFSFeedbackProperties;
  81. var v_oFileRequest =
  82. new C_MultiFileRequest( new C_RequestListenerRedirect( this, "f_showQFSFeedbackItem" ),
  83. [ "QFLogFormatting.xsl" ] );
  84. v_oFileRequest.nQFSProperty = v_nQFSProperty;
  85. v_oFileRequest.sItemName = v_sItemName;
  86. D_Progress.F_SendRequest( v_oFileRequest, null, "Loading", 30 );
  87. };
  88. G_QanReportValidator.f_loadQFSFeedbackItems = function(v_oRequest)
  89. {
  90. var nQFSProperty = v_oRequest.nQFSProperty;
  91. var v_sItemName = v_oRequest.sItemName;
  92. {
  93. var v_asXML = [];
  94. v_asXML[0] = "<QFSFeedbackList>";
  95. if (nQFSProperty.length == 0)
  96. {
  97. var v_oLogDoc = new C_QanLogDoc( '<?xml version="1.0" encoding="utf-8"?><XQELog name="Query1.0" />' );
  98. var v_iLogId = G_QanApp.F_AddLogDoc( v_oLogDoc );
  99. var v_sQueryNames = "Query1.0";
  100. v_asXML.push( "<QFSFeedbackItem type=\"QFSLog\" logId=\"" + v_iLogId + "\" queryNames=\""+ v_sQueryNames +"\">" );
  101. v_asXML.push( "</QFSFeedbackItem>" );
  102. }
  103. for( var iQuery = 0; iQuery < nQFSProperty.length; ++iQuery )
  104. {
  105. var v_nQFSPropertyItem = nQFSProperty.item(iQuery);
  106. if( v_sItemName == "ExecutionPlan" )
  107. {
  108. v_asXML.push( "<QFSFeedbackItem type=\"ExecutionPlan\">" );
  109. v_asXML.push( v_nQFSPropertyItem.childNodes[0].xml );
  110. }
  111. else
  112. {
  113. var v_oLogDoc = new C_QanLogDoc( v_nQFSPropertyItem.childNodes[0].text )
  114. var v_iLogId = G_QanApp.F_AddLogDoc( v_oLogDoc );
  115. var v_sQueryNames = v_oLogDoc.F_GetRootQRDNames();
  116. v_asXML.push( "<QFSFeedbackItem type=\"QFSLog\" logId=\"" + v_iLogId + "\" queryNames=\""+ v_sQueryNames +"\">" );
  117. }
  118. v_asXML.push( "</QFSFeedbackItem>" );
  119. }
  120. v_asXML.push( "</QFSFeedbackList>" );
  121. v_docXML = U_XML.F_LoadString( D_XmlError, v_asXML.join("\n\r") );
  122. if ( !v_docXML || !v_docXML.documentElement )
  123. return;
  124. }
  125. return v_docXML;
  126. }
  127. G_QanReportValidator.f_showQFSFeedbackItem = function(v_oRequest)
  128. {
  129. var v_sText = v_oRequest.F_GetFileContents()[ "QFLogFormatting.xsl" ];
  130. var v_docXSL = U_XML.F_LoadString( D_XmlError, v_sText );
  131. if ( !v_docXSL || !v_docXSL.documentElement )
  132. return;
  133. G_QanApp.F_SetXslDoc( v_docXSL );
  134. v_docXML = G_QanReportValidator.f_loadQFSFeedbackItems(v_oRequest);
  135. var v_frame = document.createElement( "iframe" );
  136. v_frame.name = "idLoggingView";
  137. v_frame.id = "idLoggingView";
  138. v_frame.width = "100%";
  139. v_frame.height = "100%";
  140. document.body.insertBefore( v_frame, document.body.firstChild );
  141. var v_oWin = v_frame.contentWindow;
  142. var v_sPlanHTML = v_docXML.transformNode( v_docXSL );
  143. var v_sEntryFunctionCall;
  144. if( v_sItemName == "ExecutionPlan" )
  145. v_sEntryFunctionCall = "openExecutionPlan( document.body )";
  146. else
  147. v_sEntryFunctionCall = "showExecutionTree( document.body )";
  148. v_sPlanHTML = v_sPlanHTML.replace( /\<BODY/, "<BODY client=\"CRN\" onload='loadANDapplyPreferences(document); " + v_sEntryFunctionCall + ";' " );
  149. v_sPlanHTML = v_sPlanHTML.replace( /\<script type="text\/javascript" src="[^\>]*\\\.\.\\templates\\qfw\\/g, "<script type=\"text/javascript\" src=\"" );
  150. v_sPlanHTML = v_sPlanHTML.replace( /\<link href="[^\>]*\\\.\.\\webcontent\\qfw\\/g, "<link href=\"" );
  151. v_oWin.document.write( v_sPlanHTML );
  152. v_oWin.document.close();
  153. v_oWin.document.title = "Validation Details";
  154. };
  155. G_QanReportValidator.F_ClearErrors = function()
  156. {
  157. delete this.m_nDefect;
  158. delete this.m_aValidationProblems;
  159. };
  160. G_QanReportValidator.f_showValidationErrors = function()
  161. {
  162. if ( !this.m_aValidationProblems )
  163. {
  164. return;
  165. }
  166. if ( this.m_aValidationProblems.length > 0 )
  167. {
  168. alert( "Report has validation errors" );
  169. return;
  170. }
  171. alert( "Report is valid" );
  172. };
  173. // ********************************************************************************************************
  174. // QAN Validation Request: introduced to work around the obfuscation issue of C_BusRequest
  175. //
  176. function C_QanValidationRequest( v_oListener, v_sSpec, v_sSeverityOption, v_bInteractiveDataOption )
  177. {
  178. this.m_bQIsPrompting = false;
  179. this.m_sQPromptReport = "";
  180. this.m_oQListener = v_oListener;
  181. this.m_bQServerPrompting = true;
  182. this.m_aQNamespaces = [];
  183. this.F_QAddNamespace( C_QanValidationRequest.k_sBIBusNamespaceDecl );
  184. this.F_QAddNamespace( C_QanValidationRequest.k_sBIBusRNSNamespaceDecl );
  185. this.F_ConstructBaseClass( v_oListener, v_sSpec, v_sSeverityOption, v_bInteractiveDataOption );
  186. };
  187. C_QanValidationRequest.k_sBIBusNamespace = "http://developer.cognos.com/schemas/bibus/3";
  188. C_QanValidationRequest.k_sBIBusNamespaceDecl = "xmlns:bus='" + C_QanValidationRequest.k_sBIBusNamespace + "/'";
  189. C_QanValidationRequest.k_sBIBusRNSNamespaceDecl = "xmlns:rns1='http://developer.cognos.com/schemas/reportService/1'";
  190. C_QanValidationRequest.F_Extends( C_ValidationRequest );
  191. C_QanValidationRequest.prototype.F_SetNoServerPrompting = function()
  192. {
  193. this.m_bQServerPrompting = false;
  194. };
  195. C_QanValidationRequest.prototype.F_QAddNamespace = function( v_sNamespace )
  196. {
  197. this.m_aQNamespaces.push( v_sNamespace );
  198. };
  199. C_QanValidationRequest.prototype.F_IsReadyToProcess=function()
  200. {
  201. if(!C_QanValidationRequest.superClass.F_IsReadyToProcess.call(this))
  202. {return false;}
  203. var v_sResponseText = this.F_GetResponseText();
  204. var v_docResponse = U_XML.F_LoadString( null, v_sResponseText, false, true );
  205. this.m_docQResponse = v_docResponse;
  206. 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( " " ) );
  207. if (this.m_bQServerPrompting && this.m_oQListener && G_BusServer.F_RequiresServerPrompting(v_docResponse))
  208. {
  209. this.m_bQIsPrompting = true;
  210. if (G_BusServer.F_DoPrompting(this, v_docResponse, this.m_sQPromptReport))
  211. {
  212. // Depending on what happens after prompting, either the request will be completed (failed)
  213. // or it will be re-executed
  214. delete this.m_docQResponse;
  215. return false;
  216. }
  217. this.m_bQIsPrompting = false;
  218. this.F_SetNewErrorRes( "IDS_CCHL_INITIATE_SERVERPROMTING_FAILED" );
  219. return true;
  220. }
  221. return true;
  222. }