G_QanApp.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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_QanApp = {};
  8. G_QanApp.M_oParameters = {};
  9. G_QanApp.m_doc = document;
  10. G_QanApp.F_Init = function()
  11. {
  12. if( window.top != window )
  13. this.m_doc.gReportRunParameters = window.top.gReportRunParameters;
  14. this.M_oParameters = this.m_doc.gReportRunParameters;
  15. if( !this.M_oParameters )
  16. this.M_oParameters = [];
  17. this.f_parseQueryString( this.M_oParameters );
  18. this.f_setWindowTitle();
  19. this.m_sReport = this.M_oParameters["ui.spec"];
  20. G_BusServer.F_SetCafContextId(this.M_oParameters["ui.cafcontextid"]);
  21. G_QanApp.f_setGatewayURL();
  22. // Get CAFContextID if it's not passed
  23. if (this.M_oParameters["ui.cafcontextid"] == null)
  24. {
  25. var xhReq = new G_QanApp.F_GetXMLHttpRequest();
  26. xhReq.open("GET", G_QanApp.f_getGatewayURL() + "/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/close.xts&ui.compid=rs", false);
  27. xhReq.send(null);
  28. var serverResponse = xhReq.responseText;
  29. var CAFContextIDIndex = serverResponse.indexOf("var cafContextId =");
  30. var CAFContextID = serverResponse.substr(CAFContextIDIndex + 20, 124);
  31. G_BusServer.F_SetCafContextId(CAFContextID);
  32. }
  33. var v_sRoutingServerGroup = this.M_oParameters["routingServerGroup"];
  34. if ( v_sRoutingServerGroup )
  35. {
  36. G_BusServer.F_SetRoutingServerGroup(v_sRoutingServerGroup);
  37. }
  38. G_QanApp.m_logDocs = [];
  39. G_QanApp.m_executionTrees = [];
  40. G_QanApp.m_executionTreeViews = [];
  41. G_QanApp.m_logBoxViews = [];
  42. G_QanApp.f_setupResources();
  43. };
  44. G_QanApp.F_SetDefaultState = function()
  45. {
  46. if( this.m_sReport )
  47. G_QanApp.F_GetLogging();
  48. else
  49. G_QanApp.F_GetReportSpecification();
  50. }
  51. G_QanApp.F_OnLoad = function()
  52. {
  53. };
  54. G_QanApp.f_setupResources = function()
  55. {
  56. G_ResManager.F_SetLocale( "en" );
  57. var v_bUseCache = true;
  58. G_ResManager.F_LoadResources( [ "../cchl/res/cchl_resources.xml" ], null, v_bUseCache );
  59. G_ResManager.F_LoadStrings( [ "../cchl/res/cchl_strings", "res/qan_strings" ], null, v_bUseCache );
  60. };
  61. G_QanApp.f_setWindowTitle = function()
  62. {
  63. var v_sReportName = (this.M_oParameters)? this.M_oParameters["reportName"]: null;
  64. if( v_sReportName )
  65. document.title = v_sReportName + " - Query Analyzer";
  66. else
  67. document.title = "Query Analyzer";
  68. }
  69. G_QanApp.f_setGatewayURL = function( v_sURL )
  70. {
  71. if ( v_sURL )
  72. {
  73. G_CCHL.M_sGatewayURL = v_sURL;
  74. }
  75. else
  76. {
  77. var v_sGateway = this.M_oParameters["gateway"];
  78. G_CCHL.M_sGatewayURL = v_sGateway ? v_sGateway : this.F_GetWebcontentURL() + "/cgi-bin/cognos.cgi";
  79. }
  80. };
  81. G_QanApp.F_GetWebcontentURL = function()
  82. {
  83. if (this.m_sWebcontentURL)
  84. {
  85. return this.m_sWebcontentURL;
  86. }
  87. if (this.m_doc.domain)
  88. {
  89. var v_sURL = this.m_doc.location.href;
  90. // Compensate for URLs that didn't encode slashes
  91. var v_iQuestionMark = v_sURL.indexOf( "?" );
  92. if ( v_iQuestionMark > 0 )
  93. {
  94. v_sURL = v_sURL.substring( 0, v_iQuestionMark );
  95. }
  96. var v_iSlash = v_sURL.lastIndexOf("/");
  97. if (v_iSlash > 0)
  98. {
  99. v_sURL = v_sURL.substring(0, v_iSlash);
  100. v_iSlash = v_sURL.lastIndexOf("/");
  101. if (v_iSlash > 0)
  102. {
  103. v_sURL = v_sURL.substring(0, v_iSlash);
  104. this.m_sWebcontentURL = v_sURL;
  105. return v_sURL;
  106. }
  107. }
  108. }
  109. // we should never get here
  110. this.m_sWebcontentURL = "";
  111. return this.m_sWebcontentURL;
  112. };
  113. G_QanApp.f_parseQueryString = function( o )
  114. {
  115. var v_sQueryString = this.m_doc.location.search;
  116. if ( v_sQueryString )
  117. {
  118. v_sQueryString = v_sQueryString.substr( 1 );
  119. var v_aNameValue = v_sQueryString.split( "&" );
  120. for ( var i = 0; i < v_aNameValue.length; ++i )
  121. {
  122. var v_sNameValue = decodeURIComponent( v_aNameValue[i].replace( /\+/g, " " ) );
  123. var v_iEqualsPos = v_sNameValue.indexOf( "=" );
  124. if ( v_iEqualsPos != -1 )
  125. {
  126. o[v_sNameValue.substring( 0, v_iEqualsPos )] = v_sNameValue.substr( v_iEqualsPos + 1 );
  127. }
  128. }
  129. }
  130. };
  131. G_QanApp.f_getReport = function()
  132. {
  133. return this.m_sReport;
  134. }
  135. G_QanApp.f_setReport = function(m_sReportSpec)
  136. {
  137. this.m_sReport = m_sReportSpec;
  138. }
  139. G_QanApp.F_GetExecutionPlan = function()
  140. {
  141. G_QanReportValidator.F_Validate( this.f_getReport() );
  142. }
  143. G_QanApp.F_GetLogging = function()
  144. {
  145. G_QanReportValidator.F_ValidateForLogging( this.f_getReport() );
  146. }
  147. G_QanApp.F_AddLogDoc = function( vLogDoc )
  148. {
  149. G_QanApp.m_logDocs.push( vLogDoc );
  150. vLogDoc.F_SetId( G_QanApp.m_logDocs.length - 1 );
  151. vLogDoc.F_Init();
  152. return G_QanApp.m_logDocs.length - 1;
  153. }
  154. G_QanApp.F_GetLogDoc = function( iLog )
  155. {
  156. return G_QanApp.m_logDocs[iLog];
  157. }
  158. G_QanApp.F_CreateExecutionTrees = function()
  159. {
  160. if( G_QanApp.m_executionTrees.length > 0 )
  161. return;
  162. if (G_QanApp.m_logDocs.length <= 0)
  163. {
  164. var v_oExecPlan = new C_QanExecPlan( null );
  165. G_QanApp.m_executionTrees.push( v_oExecPlan );
  166. v_oExecPlan.F_Init();
  167. }
  168. for( var i = 0; i < G_QanApp.m_logDocs.length; ++i )
  169. {
  170. var v_oExecPlan = new C_QanExecPlan( G_QanApp.m_logDocs[i] );
  171. G_QanApp.m_executionTrees.push( v_oExecPlan );
  172. v_oExecPlan.F_Init();
  173. }
  174. }
  175. G_QanApp.F_GetExecutionTree = function( iLog )
  176. {
  177. return this.m_executionTrees[iLog];
  178. }
  179. G_QanApp.F_GetLoggingView = function()
  180. {
  181. return document.getElementById("idLoggingView").contentWindow;
  182. }
  183. G_QanApp.F_GetElementInLoggingView = function( sId )
  184. {
  185. return G_QanApp.F_GetLoggingView().document.getElementById( sId );
  186. }
  187. G_QanApp.F_GetLogBoxView = function( iLog )
  188. {
  189. if( !G_QanApp.m_logBoxViews[iLog] )
  190. {
  191. G_QanApp.m_logBoxViews[iLog] = new C_QanLog_BoxView( iLog );
  192. G_QanApp.m_logBoxViews[iLog].F_Init();
  193. }
  194. return G_QanApp.m_logBoxViews[iLog];
  195. }
  196. G_QanApp.f_getExecutionTreeContainer = function( iLog )
  197. {
  198. return G_QanApp.F_GetLogBoxView(iLog).F_GetExecutionTreeContainer();
  199. }
  200. G_QanApp.F_GetExecutionTreesView = function()
  201. {
  202. if( G_QanApp.m_executionTreeViews.length > 0 )
  203. return;
  204. G_QanApp.F_CreateExecutionTrees();
  205. for( var i = 0; i < G_QanApp.m_executionTrees.length; ++i )
  206. {
  207. G_QanApp.F_GetLogBoxView(i);
  208. }
  209. }
  210. G_QanApp.F_ShowExecutionTrees = function()
  211. {
  212. G_QanApp.F_GetExecutionTreesView();
  213. }
  214. G_QanApp.F_ShowPresentation = function( v_sPresentationType, v_divLogItemContainer )
  215. {
  216. var v_sILog = v_divLogItemContainer.id.replace( /log_/, "" );
  217. G_QanApp.F_GetLogBoxView(v_sILog).F_GetView( v_sPresentationType );
  218. }
  219. G_QanApp.F_GetXslDoc = function()
  220. {
  221. return this.m_xslDoc;
  222. }
  223. G_QanApp.F_SetXslDoc = function(v_xslDoc)
  224. {
  225. this.m_xslDoc = v_xslDoc;
  226. }
  227. G_QanApp.F_OpenPreferencies = function()
  228. {
  229. }
  230. G_QanApp.F_GetSQLAnalyzer = function()
  231. {
  232. G_QanDBQuery.F_Init( document.getElementById("idQanApp_Body") );
  233. G_QanDBQuery.F_Show();
  234. }
  235. G_QanApp.F_GetReportSpecification = function()
  236. {
  237. G_QanReportRequestor.F_RequestReport( this.M_oParameters["ReportPath"] );
  238. }
  239. G_QanApp.f_getGatewayURL = function()
  240. {
  241. return G_CCHL.M_sGatewayURL;
  242. }
  243. G_QanApp.F_GetXMLHttpRequest = function()
  244. {
  245. if (window.XMLHttpRequest)
  246. return new window.XMLHttpRequest;
  247. else
  248. {
  249. try {
  250. return new ActiveXObject("MSXML2.XMLHTTP.3.0");
  251. }
  252. catch(ex) {
  253. return null;
  254. }
  255. }
  256. }