123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179 |
- /****************************************************************
- ** IBM Confidential
- **
- ** OCO Source Materials
- **
- ** IBM Cognos Products: mdsrv
- **
- ** (C) Copyright IBM Corp. 2008, 2014
- **
- ** The source code for this program is not published or otherwise
- ** divested of its trade secrets, irrespective of what has been
- ** deposited with the U.S. Copyright Office.
- *****************************************************************/
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_Deck.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_TreeView.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_ListView.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/U_CookieJar.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_Dialog.js" );
- G_HAL.F_Include( WEB_CONTENT + "/common/json/json2.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/G_ResManager.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_MultiScriptRequest.js" );
- //G_HAL.F_Include( WEB_CONTENT + "hal/G_KeyboardManager.js");
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_ComboBox.js" );
- G_HAL.F_Include( WEB_CONTENT + "/hal/C_PropertySheet.js" );
- //TO DO & Ideas:
- //
- // - button: Unselect all
- //
- // - label: Number of objects selected
- // These are meant to be constants (even if JavaScript allows you to change them; you MUST NOT change them).
- var kDatabaseTypeStr = "database";
- var kCatalogTypeStr = "catalog";
- var kCubeTypeStr = "cube";
- var kInfoQueryTypeStr = "infoQuery";
- var kDimensionGroupTypeStr = "dimensionGroup";
- var kDimensionTypeStr = "dimension";
- var kMeasuresGroupTypeStr = "Measures";
- var kMeasureTypeStr = "measure";
- var asyncErrorPagePid = "importWizard_communication_error_page";
- var G_App = {};
- function ImportWizard()
- {
- this.credentials = "";
- }
- ImportWizard.prototype.setDataSourceCredentials = function(credentialString)
- {
- this.credentials = credentialString;
- urlRequestInvoker.RequestFinished();
- }
- ImportWizard.prototype.updateCredentials = function(newCredentials)
- {
- var urlPostParams = new Object();
- urlPostParams["pid"] = "updateCredentials";
- urlPostParams["current_credentials"] = this.credentials;
- urlPostParams["newcredentials_password"] = newCredentials;
- urlPostParams["error_pid"] = asyncErrorPagePid;
-
- var updateCredentialsRequestURL = GATEWAY_URL + "/metadataUIService";
-
- urlRequestInvoker.MakeAsyncRequestInIFrame( updateCredentialsRequestURL, urlPostParams );
- }
- IMPORTWIZARD = new ImportWizard();
- G_App.F_HAL_OnLoad = function()
- {
- // @todo Must pass proper locale code!
- G_ResManager.F_SetLocale( "en" );
-
- // This call is needed even if we don't pass a filename as an argument,
- // in order to load the standard HAL string resources.
- G_ResManager.F_LoadStrings( [ /*WEB_CONTENT + "/mdsrv/res/strings"*/], this );
- //Enable Accessibility for FireFox Browser only, pass false as second parameter if you don't want the focus ring in Firefox
- G_HAL.F_EnableAccessibility( G_BrowserInfo.M_bIsFirefox );
- //Enable High Contrast Mode need for FireFox only, Need testing to enable it for IE as well
- //if( G_BrowserInfo.M_bIsFirefox )
- // Need to check if the high contrast mode is enabled, waiting for HAL to expose this function or may not need it
- //G_HAL.F_EnableHighContrastMode();
- };
- G_App.initControls = function()
- {
- this.m_oDeck = new C_Deck( document.getElementById( "divDeck" ), this );
- UpdateButtonsEnableStatus( 0 /* cardIndex */ );
- this.F_ApplySkin( "corporate|portal" );
- // this.F_ApplySkin( "windows|app" );
-
- this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
- var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
- treeViewElem.setAttribute( "id", "TreeView" );
- treeViewElem.setAttribute( "showCheckboxes", "true" );
-
- // Only populate with the root node if in "create" mode!
- if (!IMPORTWIZARD.isEdit)
- {
- this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
- }
-
- this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
- g_expandTreeLevel = 0;
- var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
- useV5DataServerCheckBox.checked = IMPORTWIZARD.bUseV5DataServer;
- if (IMPORTWIZARD.bDisableClassic == "true")
- //useV5DataServerCheckBox.disabled=true;
- useV5DataServerCheckBox.style.display = "none";
-
- var ms_useV5DataServerCheckBox = document.getElementById( "ms_useV5DataServer" );
- ms_useV5DataServerCheckBox.checked = IMPORTWIZARD.bUseV5DataServer;
- PopulateLanguagesListBox();
-
- if (IMPORTWIZARD.enableTest == false)
- {
- ShowPackageRenameDlgIfNeeded();
- }
- }
- G_App.expandNode = function( node)
- {
- // testing code to expand the root node
- if (IMPORTWIZARD.enableTest == true)
- {
- //var node = g_viewNodeToExpand.selectSingleNode( "treeNode" );
- if (node != null)
- {
- G_App.m_oTreeViewCheckboxes.F_ExpandNode(node );
- G_App.m_oTreeViewCheckboxes.F_Draw();
- }
- }
- }
- function PopulateLanguagesListBox()
- {
- var getLanguagesRequestURL = GATEWAY_URL + "/metadataUIService";
- D_Progress.F_DisableCancel();
- D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"]);
-
- var getLanguagesRequestPostParams = {};
- getLanguagesRequestPostParams["pid"] = "OLAPImportWizard_Languages_pid"
- getLanguagesRequestPostParams["datasource"] = IMPORTWIZARD.dataSourceName;
- getLanguagesRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
- getLanguagesRequestPostParams["error_pid"] = asyncErrorPagePid;
- urlRequestInvoker.MakeAsyncRequestInIFrame( getLanguagesRequestURL, getLanguagesRequestPostParams );
- }
- function providerLangResultsReceived( providerLanguages )
- {
- var languagesList = providerLanguages.lang;
- var designLocaleList = document.getElementById( "designLanguage" );
- var selIndex = 0;
- for (var i = 0; i < languagesList.length; i++)
- {
- if (languagesList[i].localeId == IMPORTWIZARD.productLocale)
- selIndex = i;
- designLocaleList.options[i]=new Option(languagesList[i].localeName, languagesList[i].localeId);
- }
- designLocaleList.selectedIndex = selIndex;
-
- hideProgressIfShowing();
- //D_Progress.F_Hide();
- urlRequestInvoker.RequestFinished();
-
- // expand the root node
- //alert( "In providerLangResultsReceived( providerLanguages ).\n" );
- setTimeout( function(){
- var treeRootViewNode = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
- var node = treeRootViewNode.selectSingleNode( "treeNode" );
- G_App.expandNode(node);
- }, 700 );
- }
- function OnUseV5DataServerBtnClicked( sourceUseV5DataServerChkBox )
- {
- G_App.m_oTreeViewCheckboxes.F_Detach();
- G_App.initializeTreeViewCheckBox();
- }
-
- ImportWizard.prototype.checkDesignLocaleSelected = function(){
- var designLocaleList = document.getElementById( "designLanguage" );
-
- if (designLocaleList.selectedIndex < 0){
- return localizedStrings["MSR_SAP_designLocaleRequired"];
- }
-
- }
- G_App.initializeTreeViewCheckBox = function( )
- {
- //this.m_oTreeViewCheckboxes.F_Detach();
- this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
- var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
- treeViewElem.setAttribute( "id", "TreeView" );
- treeViewElem.setAttribute( "showCheckboxes", "true" );
- this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
- this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
-
- g_expandTreeLevel = 0;
-
- // expand the root node
- var treeRootViewNode = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
- var node = treeRootViewNode.selectSingleNode( "treeNode" );
- if (node != null)
- {
- setTimeout( function(){
- G_App.expandNode( node);
- }, 700 );
- }
- }
- function selectFirstItemInTreeControl()
- {
- var v_elSpanFirst = G_App.m_oTreeViewCheckboxes.F_GetFirstVisibleTreeItem();
- if ( v_elSpanFirst )
- {
- v_elSpanFirst.focus();
- }
- }
- G_App.F_ResManager_OnStringsLoaded = function( v_aFiles )
- {
- G_ResManager.F_LoadResources( [ WEB_CONTENT + "/mdsrv/res/EditVariablesResources.xml" ],this );
- };
- G_App.F_ResManager_OnResourcesLoaded = function( v_aFiles )
- {
- //LoadStrings is async call therefore load all the controls after G_ResManager.F_LoadStrings G_ResManager.F_LoadResources are completed. This change was done because the Treeview tries to access HAL string before it is loaded.
- this.initControls();
- }
- function retrieveImportSpec()
- {
- var getImportSpecRequestURL = GATEWAY_URL + "/metadataUIService";
-
- D_Progress.F_DisableCancel();
- D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"] );
-
-
- var getImportSpecRequestPostParams = {};
- getImportSpecRequestPostParams["pid"] = "importWizard_ImportSpec_pid";
- getImportSpecRequestPostParams["packageLocation"] = IMPORTWIZARD.packageLocation;
- getImportSpecRequestPostParams["packageName"] = IMPORTWIZARD.packageName;
- getImportSpecRequestPostParams["error_pid"] = asyncErrorPagePid;
-
- IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
- hideProgressIfShowing();
- }
- urlRequestInvoker.MakeAsyncRequestInIFrame( getImportSpecRequestURL, getImportSpecRequestPostParams );
- }
- function GenerateJSONString( obj )
- {
- var strObjJSON = "";
-
- for (var i in obj)
- {
- strObjJSON += "\t\t\"" + i + "\": ";
- strObjJSON += "\"" + obj[i] + "\",\n";
- }
-
- // The last comma must be removed, in order to have a syntactically correct JSON string.
- // Firefox doesn't care about this, but IE fails to work properly if this isn't done.
- var lastCommaIndex = strObjJSON.lastIndexOf( ',' );
-
- strObjJSON = "\t{\n" + strObjJSON.substr(0, lastCommaIndex ) + "\n\t}\n";
-
- // alert( "GenerateJSONString\n\n" + strObjJSON ); // Debugging
- return strObjJSON;
- }
- G_App.PopulateTreeView_RootNode = function( aDoc, treeViewElem )
- {
- var rootNodeElem = treeViewElem.appendChild( aDoc.createElement( "treeNode" ) );
- var nodeValueObj = {};
- nodeValueObj["type"] = kDatabaseTypeStr;
- nodeValueObj["uniqueName"] = kDatabaseTypeStr;
-
- var nodeIcon = GetIconFilePath( kDatabaseTypeStr );
- var nodeValue = GenerateJSONString( nodeValueObj );
- rootNodeElem.setAttribute( "value", nodeValue );
- rootNodeElem.setAttribute( "label", IMPORTWIZARD.dataSourceName);
- rootNodeElem.setAttribute( "smallIcon", nodeIcon );
- rootNodeElem.setAttribute( "expandedSmallIcon", nodeIcon );
- rootNodeElem.setAttribute( "expandable", "true" );
- rootNodeElem.setAttribute( "staticCheckbox", "true" );
- rootNodeElem.setAttribute( "role", "treeItem" );
- rootNodeElem.setAttribute( "tooltip", kDatabaseTypeStr );
- };
- function importSpecReceivedReceived( treeSnippet )
- {
- D_Progress.F_Hide();
- urlRequestInvoker.RequestFinished();
- G_App.m_oTreeViewCheckboxes.F_StartAsyncLoad();
- var aDoc = G_App.m_treeViewNodesDoc;
- var treeViewElem = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
- IMPORTWIZARD.dataSourceName = treeSnippet.node.Name; // In edit scenario we didn't know the ds name, so we populate it now
- PopulateTreeView( treeSnippet.node, aDoc, treeViewElem );
- G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */);
-
- selectFirstItemInTreeControl();
- }
- function SaveModifiedSettings()
- {
- var saveModifiedSettingsURL = GATEWAY_URL + "/metadataUIService";
- D_Progress.F_DisableCancel();
- D_Progress.F_Show( null, localizedStrings["MSR_SAP_Saving"]);
- var saveModifiedSettingsParams = {};
- saveModifiedSettingsParams["pid"] = "saveModifiedPackageSettings_pid";
- saveModifiedSettingsParams["searchPath"] = IMPORTWIZARD.packageLocation + "/package[@name=" + EncloseInQuotes( IMPORTWIZARD.packageName ) + "]/model";
- saveModifiedSettingsParams["property"] = "http://developer.cognos.com/ceba/constants/queryOptionEnum#mode";
-
- var ms_useV5DataServerCheckBox = document.getElementById( "ms_useV5DataServer" );
-
- if (ms_useV5DataServerCheckBox.checked)
- {
- saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#dynamic"; // XQE
- }
- else
- {
- saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#compatible"; // Legacy query stack
- }
-
- saveModifiedSettingsParams["error_pid"] = asyncErrorPagePid;
- urlRequestInvoker.MakeAsyncRequestInIFrame( saveModifiedSettingsURL, saveModifiedSettingsParams );
- }
- function OnSaveModifiedPackageSettingsRequestCompleted()
- {
- D_Progress.F_Hide();
- urlRequestInvoker.RequestFinished();
- window.location.replace( IMPORTWIZARD.backURL );
- }
- //
- // Populates the tree view based on data obtained from the server side
- // (through a JSP async call).
- // This data could be coming from either:
- // - the browse JSP (when expanding tree nodes for the first time)
- // - the import spec JSP (when editing an existing package)
- //
- function PopulateTreeView( treeViewNodeData, aDoc, treeViewElem )
- {
- var nodeLabel = treeViewNodeData.Name;
- var nodeType = treeViewNodeData.Type;
- var bIsNodeSelected = treeViewNodeData.Selected != null && treeViewNodeData.Selected != "false";
- var nodeValueObj = {};
- nodeValueObj["type"] = nodeType;
- nodeValueObj["uniqueName"] = (treeViewNodeData.uniqueName != null) ? treeViewNodeData.uniqueName : treeViewNodeData.Name;
- var nodeValue = GenerateJSONString( nodeValueObj );
- var nodeIcon = GetIconFilePath( nodeType );
- var nodeExpandedIcon = GetIconFilePath( nodeType );
- // var stateSmallIcon = "hal/images/icon_information_16x16.gif";
-
- //var bExpandable = (nodeType != kDimensionTypeStr && nodeType != kMeasureTypeStr);
- var bExpandable = (nodeType != kCubeTypeStr);
- var bHideCheckBox = (nodeType == kDimensionGroupTypeStr || nodeType == kDimensionTypeStr
- || nodeType == kMeasuresGroupTypeStr || nodeType == kMeasureTypeStr);
- //var bStaticCheckBox = (nodeType == kDatabaseTypeStr || nodeType == kCatalogTypeStr);
- var bStaticCheckBox = (nodeType != kCubeTypeStr);
- var bChecked = !bHideCheckBox && bIsNodeSelected;
- var nodeElem = treeViewElem.appendChild( aDoc.createElement( "treeNode" ) );
- nodeElem.setAttribute( "value", nodeValue );
- nodeElem.setAttribute( "label", nodeLabel );
- nodeElem.setAttribute( "smallIcon", nodeIcon );
- nodeElem.setAttribute( "expandedSmallIcon", nodeExpandedIcon );
- // nodeElem.setAttribute( "stateSmallIcon", stateSmallIcon );
- nodeElem.setAttribute( "tooltip", nodeType );
- nodeElem.setAttribute( "expandable", bExpandable ? "true" : "false" );
-
- nodeElem.setAttribute( "hideCheckbox", bHideCheckBox ? "true" : "false" );
- nodeElem.setAttribute( "staticCheckbox", bStaticCheckBox ? "true" : "false" );
- nodeElem.setAttribute( "checked", bChecked ? "true" : "false" );
-
-
-
- // testing code
- if (IMPORTWIZARD.enableTest)
- {
- if (nodeValueObj["uniqueName"] == IMPORTWIZARD.treeLevels[g_expandTreeLevel])
- {
- // remember treeViewNodeData
- g_viewNodeToExpand = nodeElem;
- }
-
- if (nodeValueObj["type"] == kCubeTypeStr)
- {
- if (nodeValueObj["uniqueName"] == IMPORTWIZARD.cubeToSelect)
- {
- nodeElem.setAttribute( "checked","true" );
- }
- }
- }
- // testing code end
-
-
-
- if (treeViewNodeData.children != null)
- {
- for (var i = 0; i < treeViewNodeData.children.length; i++)
- {
- PopulateTreeView( treeViewNodeData.children[i], aDoc, nodeElem );
- }
- }
- }
-
- /**
- * Used in edit mode, to pass to the browse JSP, the selected nodes recursively.
- */
- function ExtractSelectedTreeNodes( v_nTreeNode, nodePathEntry )
- {
- if (v_nTreeNode.childNodes != null && v_nTreeNode.childNodes.length > 0)
- {
- nodePathEntry.children = [];
-
- for (var i = 0; i < v_nTreeNode.childNodes.length; i++)
- {
- var childNodeName = v_nTreeNode.childNodes[i].getAttribute( "label" );
- var childNodeValue = v_nTreeNode.childNodes[i].getAttribute( "value" );
-
- var childNodeValueObj = eval( "(" + childNodeValue + ")" );
- var childNodeType = childNodeValueObj.type;
- var childNodeUniqueName = childNodeValueObj.uniqueName;
-
- nodePathEntry.children[i] = {};
- nodePathEntry.children[i]["uniqueName"] = childNodeUniqueName;
- nodePathEntry.children[i].Selected = "true";
- nodePathEntry.children[i].Type = childNodeType;
- nodePathEntry.children[i].Value = "false";
- nodePathEntry.children[i].Name = childNodeName;
-
- ExtractSelectedTreeNodes( v_nTreeNode.childNodes[i], nodePathEntry.children[i] );
- }
- }
- }
- var g_treeNodeBeingPopulated = null;
- var g_expandTreeLevel = 0; // used only for testing (does not expect collapsing the tree nodes)
- var g_viewNodeToExpand = null; // node to expand based on the provided drill down path
- G_App.F_TreeView_OnPopulateChildren = function( v_oTreeView, v_nTreeNode )
- {
- //
- // Disable the Finish button temporarily, to prevent 2 async calls from colliding in the same IFrame.
- //
-
- var finishButton = document.getElementById( "finishButton" );
- IMPORTWIZARD.isFinishButtonEnabled = IsButtonEnabled( finishButton );
- EnableButton( finishButton, false );// bEnable );
-
- var currentNode = v_nTreeNode;
- var nodePath = "";
-
- // The nodePath is being build back-wards
- do
- {
- var nodeName = currentNode.getAttribute( "label" );
- var nodeValue = currentNode.getAttribute( "value" );
-
- var nodeValueObj = eval( "(" + nodeValue + ")" );
- var nodeType = nodeValueObj.type;
- var nodeUniqueName = nodeValueObj.uniqueName;
-
- // if the node path is empty then we are at the beginning
- var bIsSelectedNode = (nodePath == "");
-
- var nodePathEntry = {};
- nodePathEntry.Name = nodeName;
- nodePathEntry.Type = nodeType;
- nodePathEntry.Value = "false";
-
- if (nodeType == kDatabaseTypeStr)
- {
- nodePathEntry.dbType = IMPORTWIZARD.dataSourceType; //save dbType in the ImportSpec just for FMMD to load DimImport for CQM packages
- }
- else
- {
- nodePathEntry.uniqueName = nodeUniqueName;
- }
-
- if (bIsSelectedNode)
- {
- nodePathEntry.Selected = "true";
- nodePathEntry.expansion = "true";
- ExtractSelectedTreeNodes( v_nTreeNode, nodePathEntry );
- }
-
- strNodePathEntry = JSON.stringify( nodePathEntry, null, "\t" );
-
- var nodePathEntryPostfix = (currentNode == v_nTreeNode) ? "\n" : ",\n";
- nodePath = strNodePathEntry + nodePathEntryPostfix + nodePath;
- currentNode = currentNode.parentNode;
- }
- while (currentNode != null && currentNode.tagName == "treeNode");
- nodePath = "{\"node\":[\n" + nodePath + "]}";
- g_treeNodeBeingPopulated = v_nTreeNode;
-
- var browseTreeRequestURL = GATEWAY_URL + "/metadataUIService";
- var browseTreeRequestPostParams = {};
- if (IMPORTWIZARD.enableTestNoDBConnection)
- browseTreeRequestPostParams["pid"] = "importWizard_GetTreeNodes_TEST_pid";
- else
- browseTreeRequestPostParams["pid"] = "importWizard_GetTreeNodes_pid";
- browseTreeRequestPostParams["connectionName"] = IMPORTWIZARD.dataSourceName;
- browseTreeRequestPostParams["nodePath"] = nodePath;
- browseTreeRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
- browseTreeRequestPostParams["error_pid"] = asyncErrorPagePid;
-
- var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
- browseTreeRequestPostParams["useV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false";
-
- IMPORTWIZARD.onResumeFromRecoveredErrorHandler = function()
- {
- urlRequestInvoker.RequestFinished();
-
- G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( false );// v_bSucceeded );
- g_treeNodeBeingPopulated = null;
-
- if (this.retry)
- {
- this.retry = false;
- G_App.m_oTreeViewCheckboxes.F_ExpandNode(v_nTreeNode);
- }
- };
-
- IMPORTWIZARD.onResumeFromNonRecoverableError = function()
- {
- G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( false );// v_bSucceeded );
- g_treeNodeBeingPopulated = null;
- urlRequestInvoker.RequestFinished();
- }
-
- urlRequestInvoker.MakeAsyncRequestInIFrame( browseTreeRequestURL, browseTreeRequestPostParams );
-
- return true;
- };
- G_App.F_HAL_OnUnLoad = function()
- {
- this.m_oTreeViewCheckboxes.F_Detach();
- //this.m_oListViewCheckboxes.F_Detach();
-
- if (this.m_oPropertySheet != null)
- {
- this.m_oPropertySheet.F_Detach();
- }
- };
- G_App.F_ApplySkin = function( v_sSkin )
- {
- // Build the path to the appropriate skin css file
- var v_aSkin = v_sSkin.split( "|" );
- var v_sSkinName = v_aSkin[0];
- var v_sSkinType = v_aSkin[1];
- var v_sSkinPath = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_portal_skin.css";
- var v_sSkinPath2 = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_skin.css";
-
- // Remove existing link tag to skin css
- var v_nExistingCSSNode = document.getElementById( "idHALSkinCSS" );
- if ( v_nExistingCSSNode )
- {
- v_nExistingCSSNode.parentNode.removeChild( v_nExistingCSSNode );
- }
-
- // Create and append new link tag to skin css
- var v_elHead = document.getElementsByTagName( "head" )[0];
- var v_elLinkCSS = document.createElement( "link" );
- v_elLinkCSS.id = "idHALSkinCSS";
- v_elLinkCSS.type = "text/css";
- v_elLinkCSS.rel = "stylesheet";
- v_elLinkCSS.href = v_sSkinPath;
- v_elHead.appendChild( v_elLinkCSS );
-
- var v_elLinkCSS2 = document.createElement( "link" );
- v_elLinkCSS2.id = "idHALSkinCSS";
- v_elLinkCSS2.type = "text/css";
- v_elLinkCSS2.rel = "stylesheet";
- v_elLinkCSS2.href = v_sSkinPath2;
- v_elHead.appendChild( v_elLinkCSS2 );
-
- document.body.style.backgroundColor = ( v_sSkinType == "portal" ) ? "#FFFFFF" : "";
-
- // Set skin value in cookie
- var v_dateExpires = new Date();
- v_dateExpires.setUTCFullYear( v_dateExpires.getUTCFullYear() + 1 );
- U_CookieJar.F_SetCookie( "skin", v_sSkin, v_dateExpires );
- };
- G_App.F_Deck_OnBeforeCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
- {
- };
- G_App.F_Deck_OnAfterCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
- {
- if (v_oDeck == this.m_oDeck)
- {
- var pageTitles =
- [
- localizedStrings["MSR_SAP_selectObjectsTitle"],
- localizedStrings["MSR_SAP_selectLanguagesTitle"],
- localizedStrings["MSR_SAP_generateDimensionsTitle"]
- ];
-
- // var pageTitlePostfix = (IMPORTWIZARD.isEdit) ? " <i>[Edit Package Mode]</i>" : "";
- document.getElementById( "dialogHeaderTitle" ).innerHTML = pageTitles[v_iNewCardIndex];
-
- UpdateButtonsEnableStatus( v_iNewCardIndex );
- }
- };
- G_App.F_Back = function()
- {
- this.m_oDeck.F_Back();
- };
- G_App.F_TreeView_OnNodeCheck = function( v_oTreeView, v_nTreeNode )
- {
- };
- G_App.F_TreeView_OnNodeClick = function( v_oTreeView, v_nTreeNode, v_iMouseButton )
- {
- };
- G_App.F_TreeView_OnNodeDblClick = function( v_oTreeView, v_nTreeNode )
- {
- };
- function IsButtonEnabled( button )
- {
- return (button.className == "commandButton");
- }
- // Enables the button (if bEnable is true), or disables it (if bEnable is false).
- // It preserves and restores the OnClick and OnDblClick events properly.
- function EnableButton( button, bEnable )
- {
- var prevEnabledState = IsButtonEnabled( button );
-
- if (bEnable == true /*&& button.className == "commandButtonInactiveII"*/)
- {
- button.className = "commandButton";
- button.onmouseover = function( e ) { this.className = "commandButtonOver"; };
- button.onmouseout = function( e ) { this.className = "commandButton"; };
- button.onmousedown = function( e ) { this.className = "commandButton"; };
- button.onkeypress = handle_onkeydown;
- button.children[0].tabIndex = 0;
- if (prevEnabledState == false)
- {
- if (button.onclick_enabled != null)
- {
- button.onclick = button.onclick_enabled;
- }
-
- if (button.ondblclick_enabled != null)
- {
- button.ondblclick = button.ondblclick_enabled;
- }
- }
- }
- else if (bEnable == false)
- {
- button.className = "commandButtonInactiveII";
- button.onmouseover = null;
- button.onmouseout = null;
- button.onmousedown = null;
- button.onkeypress = null;
- button.children[0].tabIndex = -1;
-
-
- // preserve the previous event handlers
- if (prevEnabledState == true)
- {
- button.onclick_enabled = button.onclick;
- button.ondblclick_enabled = button.ondblclick;
- }
-
- button.onclick = "";
- button.ondblclick = "";
- }
- }
- function UpdateButtonsEnableStatus( cardIndex )
- {
- var prevButton = document.getElementById( "prevButton" );
- var bEnablePrevButton = (cardIndex != 0);
-
- if (bEnablePrevButton)
- {
- prevButton.onclick = function( e ) { G_App.F_Back(); };
- prevButton.ondblclick = function( e ) { G_App.F_Back(); };
- }
-
- EnableButton( prevButton, bEnablePrevButton );
-
-
- var finishButton = document.getElementById( "finishButton" );
- var bEnableFinishButton = (cardIndex == G_App.m_oDeck.F_GetNumberOfCards() - 1);
-
- if (bEnableFinishButton)
- {
- finishButton.onclick = function( e ) { WizardDone(); };
- finishButton.ondblclick = function( e ) { WizardDone(); };
- EnableButton( finishButton, bEnableFinishButton );
- }
- }
- function WizardDone()
- {
- // Build the importSpec object
- var treeNodesList = G_App.m_oTreeViewCheckboxes.F_GetCheckedNodes();
-
- if (treeNodesList.length == 0)
- {
- alert( "No objects have been selected for the import.\n\nImport action cancelled.\n" );
- return;
- }
-
- var treeNodesPaths = [];
- for (var n = 0; n < treeNodesList.length; n++)
- {
- var treeNode = treeNodesList.item( n );
- treeNodesPaths[n] = GetTreeNodePath( treeNode );
- }
-
- ConsolidateTree( treeNodesPaths, 0 /* referenceNodeIndex */ );
-
- if (treeNodesPaths.length != 1)
- {
- alert( "ASSERT FAILED: The number tree objects must be 1!\n\nIt is currently: " + treeNodesPaths.length );
- }
-
- // all nodes from treeNodesPaths[0] can have zero or one child !
- var curentNode = treeNodesPaths[0].children[0];
- while (curentNode.children != null)
- {
- curentNode = curentNode.children[0];
- }
-
- var importSpec = {};
- importSpec["node"] = [];
- importSpec["node"][0] = treeNodesPaths[0];
-
- var strImportSpec = JSON.stringify( importSpec, null, "\t" );
-
- // gets the cube name
- var cubeName = curentNode.Name;
-
-
- // Build the parameters object
-
-
- var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
- var designLocaleCombo = document.getElementById("designLanguage");
- var parameters = {};
- parameters["params"] = {};
- parameters["params"]["UseV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false";
- parameters["params"]["CubeName"] = cubeName;
- parameters["params"].designLocale = designLocaleCombo.options[designLocaleCombo.selectedIndex].value;
-
- var strParameters = JSON.stringify( parameters, null, "\t" );
- var pkgInfo = {};
- pkgInfo["pkgInfo"]={};
- pkgInfo["pkgInfo"]["Name"]=IMPORTWIZARD.packageName;
- pkgInfo["pkgInfo"]["Description"]=IMPORTWIZARD.packageDescription;
- pkgInfo["pkgInfo"]["ScreenTip"]=IMPORTWIZARD.packageScreentip;
- pkgInfo["pkgInfo"]["Location"]=IMPORTWIZARD.packageLocation;
-
- var strPkgInfo = JSON.stringify( pkgInfo, null, "\t" );
-
- IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
- hideProgressIfShowing();
- }
- var importHelper = new ImportHelper(strImportSpec, strParameters, strPkgInfo);
- importHelper.runImport();
- D_Progress.F_DisableCancel();
- D_Progress.F_Show( null, localizedStrings["MSR_SAP_creatingPackage"] );
- }
- function hideProgressIfShowing()
- {
- if (D_Progress.F_IsActiveDialog())
- {
- // hide any progress that may be up
- D_Progress.F_Hide();
- }
- }
- function GetTreeNodePath( v_nTreeNode )
- {
- var currentNode = v_nTreeNode;
- var nodePathObj = {};
- var bIsLeaf = true;
-
- // The nodePath is being build back-wards
- do
- {
- var nodeLabel = currentNode.getAttribute( "label" );
- var nodeValue = currentNode.getAttribute( "value" );
-
- var nodeValueObj = eval( "(" + nodeValue + ")" );
- var nodeType = nodeValueObj.type;
- var nodeUniqueName = nodeValueObj.uniqueName;
- var nodeEntry = {};
- nodeEntry.Name = nodeLabel;
- nodeEntry.Type = nodeType;
- nodeEntry.Value = (nodeType == kDatabaseTypeStr || nodeType == kCatalogTypeStr) ? "partial" : "true";
- if (nodeType == kDatabaseTypeStr)
- {
- nodeEntry.dbType = IMPORTWIZARD.dataSourceType; //save dbType in the ImportSpec just for FMMD to load DimImport for CQM packages
- }
- else
- {
- nodeEntry.uniqueName = nodeUniqueName;
- }
-
- // if (nodePathObj != undefined)
- if (!bIsLeaf)
- {
- nodeEntry.children = [nodePathObj];
- }
-
- nodePathObj = nodeEntry;
- currentNode = currentNode.parentNode;
- bIsLeaf = false;
- }
- while (currentNode != null && currentNode.tagName == "treeNode");
- return nodePathObj;
- }
- // The first node in the array will end up containing the cosolidated tree nodes.
- function ConsolidateTree( treeNodesPaths, referenceNodeIndex )
- {
- // Consolidate the various trees (tree node paths) into a single unified tree.
- if (referenceNodeIndex < treeNodesPaths.length - 2)
- {
- ConsolidateTree( treeNodesPaths, referenceNodeIndex + 1);
- }
- // Traverse the list of nodes in reverse, to be able to remove elements on the fly.
- for (var n = treeNodesPaths.length - 1; n > (referenceNodeIndex); n--)
- {
- var firstTreeNode = treeNodesPaths[referenceNodeIndex];
- var currentTreeNode = treeNodesPaths[n];
-
- if (AreObjectsEqual( firstTreeNode, currentTreeNode, ["children"] ))
- {
- // var strTreeNodePathBEFORE = JSON.stringify( firstTreeNode, null, "\t" );
- // alert( "(BEFORE) same root node found\n\n\""
- /// + strTreeNodePathBEFORE);
- if (firstTreeNode.children == undefined || firstTreeNode.children == null)
- {
- firstTreeNode.children = currentTreeNode.children;
- }
- else
- {
- firstTreeNode.children = firstTreeNode.children.concat( currentTreeNode.children );
- }
- // node already processed; remove it from the collection.
- treeNodesPaths.splice( n, 1 );
-
- ConsolidateTree( firstTreeNode.children, 0 /* referenceNodeIndex */ );
- // var strTreeNodePathAFTER = JSON.stringify( firstTreeNode, null, "\t" );
- // alert( "(AFTER) same root node found\n\n\""
- // + strTreeNodePathAFTER);
- }
- }
- }
- G_App.F_OnCancel = function()
- {
- D_Progress.F_Hide();
- };
- function GetIconFilePath( objectType )
- {
-
- // hal/images/tv_folder.gif hal/images/tv_folder_expanded.gif
- //
- // This directory has all the images necessary:
- // C:\Program Files\cognos\c8.5.17.3_Colorado_2009-02-13\webcontent\pat\images
-
- var iconDirPath = WEB_CONTENT + "/mdsrv/importWizardUI/images/";
- //
- // This is NOT an associative array, but rather a HACK,
- // where the keys are actually elements of the object properties.
- //
- var iconMap = [];
- iconMap[kDatabaseTypeStr] = iconDirPath + "icon_data_source.gif";
- iconMap[kCatalogTypeStr] = iconDirPath + "icon_catalog.gif";
- iconMap[kCubeTypeStr] = iconDirPath + "icon_cube.gif";
- iconMap[kInfoQueryTypeStr] = iconDirPath + "icon_info_query.gif";
- iconMap[kDimensionGroupTypeStr] = iconDirPath + "icon_folder_dimensions.gif";
- iconMap[kDimensionTypeStr] = iconDirPath + "icon_dimension.gif";
- iconMap[kMeasuresGroupTypeStr] = iconDirPath + "icon_folder_measures.gif";
- iconMap[kMeasureTypeStr] = iconDirPath + "icon_measure.gif";
-
- iconMap["unknown"] = WEB_CONTENT + "/hal/images/btn_new.gif";
- var objectIconFilePath = iconMap[objectType];
-
- if (objectIconFilePath == null)
- {
- objectIconFilePath = iconMap["unknown"];
- }
- return objectIconFilePath;
- }
- function metadataTreeResultsReceived( treeSnippet )
- {
- if (g_treeNodeBeingPopulated == null)
- {
- return;
- }
-
- if (treeSnippet == null)
- {
- G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
- g_treeNodeBeingPopulated = null;
- urlRequestInvoker.RequestFinished();
- return;
- }
- g_viewNodeToExpand = null;
-
- // This function will clear only the child nodes.
- G_App.m_oTreeViewCheckboxes.F_Clear( g_treeNodeBeingPopulated );
- for (var i = 0; i < treeSnippet.node.children.length; i++)
- {
- var aDoc = G_App.m_treeViewNodesDoc;
- PopulateTreeView( treeSnippet.node.children[i], aDoc, g_treeNodeBeingPopulated );
- }
- G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
- g_treeNodeBeingPopulated = null;
- urlRequestInvoker.RequestFinished();
-
-
- //
- // Re-enable the Finish button
- //
- var finishButton = document.getElementById( "finishButton" );
- EnableButton( finishButton, IMPORTWIZARD.isFinishButtonEnabled /* bEnable */ );
-
- g_expandTreeLevel += 1;
- if (g_viewNodeToExpand != null)
- {
- setTimeout( function(){
- G_App.expandNode( g_viewNodeToExpand);
- }, 700 );
- }
- if (IMPORTWIZARD.enableTest == true)
- {
- if (g_expandTreeLevel == IMPORTWIZARD.treeLevels.length + 1)
- {
- setTimeout( function(){
- //G_App.F_Next();
- WizardDone();
- }, 700 );
- }
- }
- }
- function HandleException(jsonExceptionObj)
- {
- hideProgressIfShowing();
- var errorPageMgr = new ErrorPageManager();
-
- if (jsonExceptionObj.isQF)
- {
- document.getElementById( "main" ).style.display = "none";
- errorPageMgr.handleQF(jsonExceptionObj.faultDom, ErrorPageClosed);
- }
- else if (jsonExceptionObj.isCAM)
- {
- document.getElementById( "main" ).style.display = "none";
- errorPageMgr.handleCAM(jsonExceptionObj, ErrorPageClosed);
- }
- else
- {
- var msg = jsonExceptionObj.messageString;
- if (msg === "")
- {
- msg = localizedStrings["MSR_SAP_unknownErrorMessage"];
- }
- var stackTrace = jsonExceptionObj.stackTrace;
- stackTrace = unescape(stackTrace);
-
- document.getElementById( "main" ).style.display = "none";
- document.getElementById( "editSelection" ).style.display = "none"
-
- errorPageMgr.setupAndDisplayErrorPage(localizedStrings["MSR_SAP_errorPageTitle"], "",
- msg, stackTrace, ErrorPageClosed);
- }
- }
- function ErrorPageClosed(recovered)
- {
- document.getElementById("main").style.display = "block";
-
- // If its been recovered, then we presume that call back will occur at a later time
- if (IMPORTWIZARD.onResumeFromNonRecoverableError && !recovered){
- IMPORTWIZARD.onResumeFromNonRecoverableError();
- }
- }
- function launchFromEdit()
- {
- var selectMetadataRadioBtn = document.getElementById( "modifyMetadataSelections" );
- var editVariablesRadioBtn = document.getElementById( "editVariables" );
- var modifySettingsRadioBtn = document.getElementById( "modifySettings" );
- var editSelectionPage = document.getElementById( "editSelection" );
-
- if (selectMetadataRadioBtn.checked)
- {
- editSelectionPage.style.display = "none";
-
- var main = document.getElementById( "main" );
- main.style.display = "block";
- retrieveImportSpec();
- }
- else if (editVariablesRadioBtn.checked)
- {
- editSelectionPage.style.display = "none";
- OnShowVariables();
- }
- else if (modifySettingsRadioBtn.checked)
- {
- SaveModifiedSettings();
- }
- }
- function ImportHelper(importSpec, parameters, packageInfo)
- {
- this.m_importSpec = importSpec;
- this.m_parameters = parameters;
- this.m_packageInfo = packageInfo;
- }
- ImportHelper.prototype.runImport = function()
- {
- var importRequestURL = GATEWAY_URL + "/metadataUIService"
-
- this.m_requestId = new Date().getTime();
-
- var importRequestPostParams = {};
- if (IMPORTWIZARD.enableTestNoDBConnection)
- importRequestPostParams["pid"] = "OLAPImportWizard_Import_TEST_pid";
- else
- importRequestPostParams["pid"] = "OLAPImportWizard_Import_pid";
- importRequestPostParams["importSpec"] = this.m_importSpec;
- importRequestPostParams["parameters"] = this.m_parameters;
- importRequestPostParams["packageInfo"] = this.m_packageInfo;
- importRequestPostParams["requestId"] = this.m_requestId;
- importRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
- importRequestPostParams["error_pid"] = asyncErrorPagePid;
-
- if (IMPORTWIZARD.enableTest == true)
- {
- importRequestPostParams["enableTest"] = "true";
- }
-
- urlRequestInvoker.MakeAsyncRequestInIFrame( importRequestURL, importRequestPostParams );
- }
|