123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- /****************************************************************************************************************************
- Licensed Materials - Property of IBM
- BI and PM: QFW
- © Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *****************************************************************************************************************************/
- var G_QanApp = {};
- G_QanApp.M_oParameters = {};
- G_QanApp.m_doc = document;
- G_QanApp.F_Init = function()
- {
- if( window.top != window )
- this.m_doc.gReportRunParameters = window.top.gReportRunParameters;
-
- this.M_oParameters = this.m_doc.gReportRunParameters;
- if( !this.M_oParameters )
- this.M_oParameters = [];
-
- this.f_parseQueryString( this.M_oParameters );
-
- this.f_setWindowTitle();
- this.m_sReport = this.M_oParameters["ui.spec"];
-
- G_BusServer.F_SetCafContextId(this.M_oParameters["ui.cafcontextid"]);
- G_QanApp.f_setGatewayURL();
- // Get CAFContextID if it's not passed
- if (this.M_oParameters["ui.cafcontextid"] == null)
- {
- var xhReq = new G_QanApp.F_GetXMLHttpRequest();
-
- xhReq.open("GET", G_QanApp.f_getGatewayURL() + "/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/close.xts&ui.compid=rs", false);
-
- xhReq.send(null);
-
- var serverResponse = xhReq.responseText;
-
-
- var CAFContextIDIndex = serverResponse.indexOf("var cafContextId =");
-
- var CAFContextID = serverResponse.substr(CAFContextIDIndex + 20, 124);
-
- G_BusServer.F_SetCafContextId(CAFContextID);
-
- }
-
-
- var v_sRoutingServerGroup = this.M_oParameters["routingServerGroup"];
- if ( v_sRoutingServerGroup )
- {
- G_BusServer.F_SetRoutingServerGroup(v_sRoutingServerGroup);
- }
-
- G_QanApp.m_logDocs = [];
- G_QanApp.m_executionTrees = [];
- G_QanApp.m_executionTreeViews = [];
- G_QanApp.m_logBoxViews = [];
- G_QanApp.f_setupResources();
- };
- G_QanApp.F_SetDefaultState = function()
- {
- if( this.m_sReport )
- G_QanApp.F_GetLogging();
- else
- G_QanApp.F_GetReportSpecification();
- }
- G_QanApp.F_OnLoad = function()
- {
- };
- G_QanApp.f_setupResources = function()
- {
- G_ResManager.F_SetLocale( "en" );
- var v_bUseCache = true;
- G_ResManager.F_LoadResources( [ "../cchl/res/cchl_resources.xml" ], null, v_bUseCache );
- G_ResManager.F_LoadStrings( [ "../cchl/res/cchl_strings", "res/qan_strings" ], null, v_bUseCache );
- };
- G_QanApp.f_setWindowTitle = function()
- {
- var v_sReportName = (this.M_oParameters)? this.M_oParameters["reportName"]: null;
- if( v_sReportName )
- document.title = v_sReportName + " - Query Analyzer";
- else
- document.title = "Query Analyzer";
- }
- G_QanApp.f_setGatewayURL = function( v_sURL )
- {
- if ( v_sURL )
- {
- G_CCHL.M_sGatewayURL = v_sURL;
- }
- else
- {
- var v_sGateway = this.M_oParameters["gateway"];
- G_CCHL.M_sGatewayURL = v_sGateway ? v_sGateway : this.F_GetWebcontentURL() + "/cgi-bin/cognos.cgi";
- }
- };
- G_QanApp.F_GetWebcontentURL = function()
- {
- if (this.m_sWebcontentURL)
- {
- return this.m_sWebcontentURL;
- }
- if (this.m_doc.domain)
- {
- var v_sURL = this.m_doc.location.href;
- // Compensate for URLs that didn't encode slashes
- var v_iQuestionMark = v_sURL.indexOf( "?" );
- if ( v_iQuestionMark > 0 )
- {
- v_sURL = v_sURL.substring( 0, v_iQuestionMark );
- }
- var v_iSlash = v_sURL.lastIndexOf("/");
- if (v_iSlash > 0)
- {
- v_sURL = v_sURL.substring(0, v_iSlash);
- v_iSlash = v_sURL.lastIndexOf("/");
- if (v_iSlash > 0)
- {
- v_sURL = v_sURL.substring(0, v_iSlash);
- this.m_sWebcontentURL = v_sURL;
- return v_sURL;
- }
- }
- }
- // we should never get here
- this.m_sWebcontentURL = "";
- return this.m_sWebcontentURL;
- };
- G_QanApp.f_parseQueryString = function( o )
- {
- var v_sQueryString = this.m_doc.location.search;
-
- if ( v_sQueryString )
- {
- v_sQueryString = v_sQueryString.substr( 1 );
- var v_aNameValue = v_sQueryString.split( "&" );
- for ( var i = 0; i < v_aNameValue.length; ++i )
- {
- var v_sNameValue = decodeURIComponent( v_aNameValue[i].replace( /\+/g, " " ) );
- var v_iEqualsPos = v_sNameValue.indexOf( "=" );
- if ( v_iEqualsPos != -1 )
- {
- o[v_sNameValue.substring( 0, v_iEqualsPos )] = v_sNameValue.substr( v_iEqualsPos + 1 );
- }
- }
- }
- };
- G_QanApp.f_getReport = function()
- {
- return this.m_sReport;
- }
- G_QanApp.f_setReport = function(m_sReportSpec)
- {
- this.m_sReport = m_sReportSpec;
- }
- G_QanApp.F_GetExecutionPlan = function()
- {
- G_QanReportValidator.F_Validate( this.f_getReport() );
- }
- G_QanApp.F_GetLogging = function()
- {
- G_QanReportValidator.F_ValidateForLogging( this.f_getReport() );
- }
- G_QanApp.F_AddLogDoc = function( vLogDoc )
- {
- G_QanApp.m_logDocs.push( vLogDoc );
- vLogDoc.F_SetId( G_QanApp.m_logDocs.length - 1 );
- vLogDoc.F_Init();
-
- return G_QanApp.m_logDocs.length - 1;
- }
- G_QanApp.F_GetLogDoc = function( iLog )
- {
- return G_QanApp.m_logDocs[iLog];
- }
- G_QanApp.F_CreateExecutionTrees = function()
- {
- if( G_QanApp.m_executionTrees.length > 0 )
- return;
-
- if (G_QanApp.m_logDocs.length <= 0)
- {
- var v_oExecPlan = new C_QanExecPlan( null );
- G_QanApp.m_executionTrees.push( v_oExecPlan );
- v_oExecPlan.F_Init();
- }
-
- for( var i = 0; i < G_QanApp.m_logDocs.length; ++i )
- {
- var v_oExecPlan = new C_QanExecPlan( G_QanApp.m_logDocs[i] );
- G_QanApp.m_executionTrees.push( v_oExecPlan );
- v_oExecPlan.F_Init();
- }
- }
- G_QanApp.F_GetExecutionTree = function( iLog )
- {
- return this.m_executionTrees[iLog];
- }
- G_QanApp.F_GetLoggingView = function()
- {
- return document.getElementById("idLoggingView").contentWindow;
- }
- G_QanApp.F_GetElementInLoggingView = function( sId )
- {
- return G_QanApp.F_GetLoggingView().document.getElementById( sId );
- }
- G_QanApp.F_GetLogBoxView = function( iLog )
- {
- if( !G_QanApp.m_logBoxViews[iLog] )
- {
- G_QanApp.m_logBoxViews[iLog] = new C_QanLog_BoxView( iLog );
- G_QanApp.m_logBoxViews[iLog].F_Init();
- }
-
- return G_QanApp.m_logBoxViews[iLog];
- }
- G_QanApp.f_getExecutionTreeContainer = function( iLog )
- {
- return G_QanApp.F_GetLogBoxView(iLog).F_GetExecutionTreeContainer();
- }
- G_QanApp.F_GetExecutionTreesView = function()
- {
- if( G_QanApp.m_executionTreeViews.length > 0 )
- return;
- G_QanApp.F_CreateExecutionTrees();
- for( var i = 0; i < G_QanApp.m_executionTrees.length; ++i )
- {
- G_QanApp.F_GetLogBoxView(i);
- }
- }
- G_QanApp.F_ShowExecutionTrees = function()
- {
- G_QanApp.F_GetExecutionTreesView();
- }
- G_QanApp.F_ShowPresentation = function( v_sPresentationType, v_divLogItemContainer )
- {
- var v_sILog = v_divLogItemContainer.id.replace( /log_/, "" );
- G_QanApp.F_GetLogBoxView(v_sILog).F_GetView( v_sPresentationType );
- }
- G_QanApp.F_GetXslDoc = function()
- {
- return this.m_xslDoc;
- }
- G_QanApp.F_SetXslDoc = function(v_xslDoc)
- {
- this.m_xslDoc = v_xslDoc;
- }
- G_QanApp.F_OpenPreferencies = function()
- {
-
- }
- G_QanApp.F_GetSQLAnalyzer = function()
- {
- G_QanDBQuery.F_Init( document.getElementById("idQanApp_Body") );
- G_QanDBQuery.F_Show();
- }
- G_QanApp.F_GetReportSpecification = function()
- {
- G_QanReportRequestor.F_RequestReport( this.M_oParameters["ReportPath"] );
- }
- G_QanApp.f_getGatewayURL = function()
- {
- return G_CCHL.M_sGatewayURL;
- }
- G_QanApp.F_GetXMLHttpRequest = function()
- {
- if (window.XMLHttpRequest)
- return new window.XMLHttpRequest;
- else
- {
- try {
- return new ActiveXObject("MSXML2.XMLHTTP.3.0");
- }
- catch(ex) {
- return null;
- }
- }
- }
|