/**************************************************************** ** IBM Confidential ** ** OCO Source Materials ** ** IBM Cognos Products: mdsrv ** ** (C) Copyright IBM Corp. 2008, 2017 ** ** 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 mapCubeAliasLanguages; //map { cubeuniqueName, map { dimensionUniqueName, map { alias table / list(of selected languages) } } } var cubeNodeList; // keeps the tree nodes of the selected cubes. We need the tree nodes to be able to compute the path to the cube browsing the parents. var mapCubeDimTables; // map { cubeuniqueName, treeSnippet} ( keeps selected dimensions per cube )( used to cash the dim tables per cube to improve the performance ) 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.prototype.checkNext = function() { var currentCard = G_App.m_oDeck.F_GetIndex(); switch (currentCard) { case 0: { var msg = this.checkImportSelectionRestraints(); if (msg && msg != null) { return msg; } msg = this.checkDesignLocaleSelected(); if (msg && msg != null){ return msg; } break; } case 1: break; case 2: break; case 3: break; } return null; } ImportWizard.prototype.checkDesignLocaleSelected = function(){ var designLocaleList = document.getElementById( "designLanguage" ); if (designLocaleList.selectedIndex < 0){ return localizedStrings["MSR_SAP_designLocaleRequired"]; } } ImportWizard.prototype.checkImportSelectionRestraints = function() { var treeNodesList = G_App.m_oTreeViewCheckboxes.F_GetCheckedNodes(); if (treeNodesList.length == 0) { return localizedStrings["MSR_SAP_mustImportAtLeastOneItem"]; } return null; } 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" ); //treeViewElem.setAttribute( "multiSelect", "false" ); // 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"; // Cubes var aDoc3 = U_XML.F_CreateDocument(); var listViewElemCubes = aDoc3.appendChild( aDoc3.createElement( 'listView' ) ); listViewElemCubes.setAttribute( "id", "CubesListView" ); listViewElemCubes.setAttribute( "showCheckboxes", "false" ); listViewElemCubes.setAttribute( "multiSelect", "false" ); listViewElemCubes.appendChild( aDoc3.createElement( "listItems" ) ); this.m_oListViewCubes = new C_ListView( document.getElementById( "divListViewCubes" ), listViewElemCubes, this ); // Dimensions var aDocDimensions = U_XML.F_CreateDocument(); var listViewElemDimensions = aDocDimensions.appendChild( aDocDimensions.createElement( 'listView' ) ); listViewElemDimensions.setAttribute( "id", "DimensionsListView" ); listViewElemDimensions.setAttribute( "showCheckboxes", "false" ); listViewElemDimensions.setAttribute( "multiSelect", "false" ); listViewElemDimensions.appendChild( aDocDimensions.createElement( "listItems" ) ); this.m_oListViewDimensions = new C_ListView( document.getElementById( "divListViewDimensions" ), listViewElemDimensions, this ); // Alias Tables var aDocAliasTables = U_XML.F_CreateDocument(); var listViewElemAliasTables = aDocAliasTables.appendChild( aDocAliasTables.createElement( 'listView' ) ); listViewElemAliasTables.setAttribute( "id", "AliasTablesListView" ); listViewElemAliasTables.setAttribute( "showCheckboxes", "false" ); listViewElemAliasTables.setAttribute( "multiSelect", "false" ); listViewElemAliasTables.appendChild( aDocAliasTables.createElement( "listItems" ) ); this.m_oListViewAliasTables = new C_ListView( document.getElementById( "divListViewAliasTables" ), listViewElemAliasTables, this ); // Locales per alias per dimension var aDoc2 = U_XML.F_CreateDocument(); var listViewElem = aDoc2.appendChild( aDoc2.createElement( 'listView' ) ); listViewElem.setAttribute( "id", "LanguagesListView" ); listViewElem.setAttribute( "view", "checkbox" ); listViewElem.setAttribute( "showCheckboxes", "true" ); listViewElem.appendChild( aDoc2.createElement( "listItems" ) ); this.m_oListViewCheckboxes = new C_ListView( document.getElementById( "divListViewCheckboxes" ), listViewElem, this ); // pre-populate the language list box PopulateLanguagesListBox(); // TODO: Delete this code, and implement smart picking // if (supportedLanguagesTable.length > 0) // { // var designLanguageEditBox = document.getElementById( "designLanguage" ); // designLanguageEditBox.value = supportedLanguagesTable[0][1]; // picking the deisng locale from the list of CCL loclaes deosn't make sense, even FMUI this behaviour was questionable, but FMUI // was stuck because the design locale was already set, we are creating a model from scratch, so the design locale should be one of the provider // languages // certainly picking the first ccl language doesn't make sense, if anything we should take the content locale, and do a best match against the // available language locales // for the sake of getting this working in the integration, I'm just not doing anything here at all, the user will need to pick from the list // The code that sends down the CCL language list in the JSP should be deleted, and instead the jsp should send down the content locale so we can do a // best match // } if (IMPORTWIZARD.enableTest == false) { ShowPackageRenameDlgIfNeeded(); } // expand the root node // var treeRootViewNode = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode(); // var node = treeRootViewNode.selectSingleNode( "treeNode" ); // G_App.expandNode(node); } 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(); } } } G_App.initializeTreeViewCheckBox = function( ) { 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 ); // delete the maps mapCubeAliasLanguages = new Object(); mapCubeDimTables = new Object(); 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 ); } } G_App.F_ListView_OnCheckboxClick = function( v_oListView, v_nListItem, v_iMouseButton ) { if (v_oListView == G_App.m_oListViewCheckboxes) { var checkedItemsOrig = G_App.m_oListViewCheckboxes.F_GetCheckedListItems(); var checkedItems = new Array(); for (var n = 0; n < checkedItemsOrig.length; n++) { //alert("3"); //tanko test var lang = checkedItemsOrig[n]; var langCode = lang.getAttribute( "value" ); //var langName = lang.getAttribute( "label" ); checkedItems[n] = langCode; } // cube var cubeName = getSelectedCubeUniqueName(); if (cubeName != null) { // dimension var dimNode = G_App.m_oListViewDimensions.F_GetSelectedListItem(); if (dimNode != null) { var dimName = dimNode.getAttribute("label"); // alias table var aliasNode = G_App.m_oListViewAliasTables.F_GetSelectedListItem(); if (aliasNode != null) { var aliasName = aliasNode.getAttribute("label"); var mapDimMapLang = mapCubeAliasLanguages[cubeName]; if (mapDimMapLang == null) { mapDimMapLang = new Object(); mapCubeAliasLanguages[cubeName] = mapDimMapLang; } // var mapAliasMapLang = mapCubeAliasLanguages[cubeName]; var mapAliasMapLang = mapDimMapLang[dimName]; if (mapAliasMapLang == null) { mapAliasMapLang = new Object(); mapDimMapLang[dimName] = mapAliasMapLang; } // check to see if the languge has been already used. if (G_App.checkLangIsUsed(mapAliasMapLang, checkedItems) == false) // check to see if the languge has been already used. Unchecks the language. Returns "true" or "false" { v_nListItem.setAttribute("checked", "false"); // G_App.m_oListViewCheckboxes.F_Draw(); return; } mapAliasMapLang[aliasName] = checkedItems; // list of languages } } } } } // check to see if the languge has been already used. // Unchecks the language. // Returns true or false G_App.checkLangIsUsed = function(mapAliasMapLang, checkedItems) { var aliasNode = G_App.m_oListViewAliasTables.F_GetSelectedListItem(); if (aliasNode != null) { var aliasNameSelected = aliasNode.getAttribute("label"); for (var aliasName in mapAliasMapLang) { if (aliasNameSelected != aliasName) { var checkedItemsPerAlias = mapAliasMapLang[aliasName]; for (var n = 0; n < checkedItemsPerAlias.length; n++) { var langCode = checkedItemsPerAlias[n]; for (var k = 0; k < checkedItems.length; k++) { var code = checkedItems[k]; if (code == langCode) { // error message // like // The selected language has been used in table - "ActoCust[Week][Coach]" var message = localizedStrings["MSR_ESB_tooManyLanguages"].replace("{0}", aliasName); if (message){ alert(message); } return false; } } } } } } return true; } G_App.F_ListView_OnItemClick = function( v_oListView, v_nListItem, v_iMouseButton ) { if (v_oListView == G_App.m_oListViewCubes) { G_App.RepopulateDimTablesListView(); } if (v_oListView == G_App.m_oListViewDimensions) { var cubeName = getSelectedCubeUniqueName(); var treeSnippet = mapCubeDimTables[cubeName]; G_App.PopulateAliasTablesListView(treeSnippet); } else if (v_oListView == G_App.m_oListViewAliasTables) { G_App.RepopulateLanguagesListView(); } } G_App.RepopulateDimTablesListView = function() { var cubeNode = G_App.m_oListViewCubes.F_GetSelectedListItem(); var cubeName = getSelectedCubeUniqueName(); // see if we have already populated it var treeSnippet = mapCubeDimTables[cubeName]; // map { cubeuniqueName, treeSnippet} ( keeps selected dimensions per cube ) if (treeSnippet == null) { var selValue = cubeNode.getAttribute( "value" ); for (var k = 0; k < cubeNodeList.length; k++) { var currentNode = cubeNodeList[k]; var nodeValue = currentNode.getAttribute( "value" ); if (selValue == nodeValue) { PopulateDimensionsListBox( currentNode ); break; } } } else { metadataDimensionListResultsReceived( treeSnippet ); } } // Sets the checked languages in the language list box accordingly with the selected alias table // The values are kept in the map mapAliasLanguages G_App.RepopulateLanguagesListView = function() { // mapCubeAliasLanguages; //map { cubeuniqueName, map { dimensionUniqueName, map { alias table / list(of selected languages) } } } // Clear all check boxes G_App.m_oListViewCheckboxes.F_UncheckAll(); var cubeName = getSelectedCubeUniqueName(); if (cubeName != null) { var dimNode = G_App.m_oListViewDimensions.F_GetSelectedListItem(); var dimName = getSelectedDimUniqueName(); if (dimName != null) { var mapDimAliasLangs = mapCubeAliasLanguages[cubeName]; if (mapDimAliasLangs != null) { var mapAliasLangs = mapDimAliasLangs[dimName]; if (mapAliasLangs != null) { var aliasNode = G_App.m_oListViewAliasTables.F_GetSelectedListItem(); if (aliasNode != null) { var aliasName = aliasNode.getAttribute("label"); var listLang = mapAliasLangs[aliasName]; // list of languages if (listLang != null) { var langItems = G_App.m_oListViewCheckboxes.F_GetListItems(); for (var n = 0; n < langItems.length; n++) { var lang = langItems[n]; var langCode = lang.getAttribute( "value" ); var langName = lang.getAttribute( "label" ); // see if it has been checked for ( var k = 0; k < listLang.length; k++ ) { var item = listLang[k]; if (langCode == item) { lang.setAttribute("checked", "true"); break; } } } } } } } } } G_App.m_oListViewCheckboxes.F_Draw(); } function OnUseV5DataServerBtnClicked( sourceUseV5DataServerChkBox ) { G_App.m_oTreeViewCheckboxes.F_Detach(); G_App.initializeTreeViewCheckBox(); } 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 ); }; var bIsLanguagesListPopulated = false; function getSelectedCubeUniqueName() { var cubeNode = G_App.m_oListViewCubes.F_GetSelectedListItem(); if (cubeNode == null) return null; var nodeValue = cubeNode.getAttribute( "value" ); var childNodeValueObj = eval( "(" + nodeValue + ")" ); return childNodeValueObj.uniqueName; } function getSelectedDimUniqueName() { var dimNode = G_App.m_oListViewDimensions.F_GetSelectedListItem(); if (dimNode == null) return null; return dimNode.getAttribute( "label" ); } 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 ); } G_App.PopulateLanguagesListView = function(languagesList) { var designLocaleList = document.getElementById( "designLanguage" ); var selIndex = 0; for (var i = 0; i < languagesList.length; i++) { var newListItemNode = this.m_oListViewCheckboxes.F_AppendNewListItem(); newListItemNode.setAttribute( "value", languagesList[i].localeId ); newListItemNode.setAttribute( "label", languagesList[i].localeName ); newListItemNode.setAttribute( "staticCheckbox", "false" ); newListItemNode.setAttribute( "checked", "false" ); if (languagesList[i].localeId == IMPORTWIZARD.productLocale) selIndex = i; designLocaleList.options[i]=new Option(languagesList[i].localeName, languagesList[i].localeId); } designLocaleList.selectedIndex = selIndex; bIsLanguagesListPopulated = true; hideProgressIfShowing(); }; function providerLangResultsReceived( providerLanguages ) { G_App.PopulateLanguagesListView( providerLanguages.lang ); G_App.m_oListViewCheckboxes.F_Draw(); //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 ); // // For accessibility Set the focus on the first item of the check box // var v_nFirstListItem = G_App.m_oListViewCheckboxes.F_GetFirstSelectableItem(); // if ( v_nFirstListItem ) // { // var vaFocus = document.getElementById( v_nFirstListItem.getAttribute( "htmlId" ) ); // if( vaFocus ) // vaFocus.focus(); // } } 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( "expandable", "true" ); nodeElem.setAttribute( "hideCheckbox", bHideCheckBox ? "true" : "false" ); nodeElem.setAttribute( "staticCheckbox", bStaticCheckBox ? "true" : "false" ); //nodeElem.setAttribute( "staticCheckbox", "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 var g_dimNum = 0; // currently selected dimension number (zero based) in test mode var g_aliasNum = 0; // currently selected alias table number (zero based) in test mode G_App.F_TreeView_OnPopulateChildren = function( v_oTreeView, v_nTreeNode ) { // // Disable the Next & Finish buttons temporarily, to prevent 2 async calls from colliding in the same IFrame. // var nextButton = document.getElementById( "nextButton" ); EnableButton( nextButton, false /* bEnable */ ); 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; // either TM or TMR nodePathEntry.isSystem = "false"; } 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"] ]; document.getElementById( "dialogHeaderTitle" ).innerHTML = pageTitles[v_iNewCardIndex]; UpdateButtonsEnableStatus( v_iNewCardIndex ); if (v_iNewCardIndex == 1 /* languages card index */ ) { if (bIsLanguagesListPopulated == false) { PopulateLanguagesListBox(); } // populate the list box with the dimensions (id="divListViewDimensions") from the selected cube // Get the selected tree node var treeNodesList = G_App.m_oTreeViewCheckboxes.F_GetCheckedNodes(); // update the maps //var mapCubeAliasLanguages; //map { cubeuniqueName, map { dimensionUniqueName, map { alias table / list(of selected languages) } } } //var mapCubeDimTables; // map { cubeuniqueName, treeSnippet} ( keeps selected dimensions per cube )( used to cash the dim tables per cube to improve the performance ) // with the newly selected cubes // delete the unselected cubes (the rest will be preserved) var cubeNamesToDelete = []; for (var cubeName in mapCubeDimTables) { // search the new list to see if the cube has been deleted var found = false; for (var n = 0; n < treeNodesList.length; n++) { var treeNode = treeNodesList.item( n ); var nodeValue = treeNode.getAttribute( "value" ); var nodeValueObj = eval( "(" + nodeValue + ")" ); var nodeUniqueName = nodeValueObj.uniqueName; if (nodeUniqueName == cubeName) { found = true; break; } } if (found == false) { cubeNamesToDelete.push(cubeName); } } for (var k = 0; k < cubeNamesToDelete.length; k++) { var cube = cubeNamesToDelete[k]; delete mapCubeDimTables[cube]; if (mapCubeAliasLanguages[cube] != null) { delete mapCubeAliasLanguages[cube]; } } PopulateCubes( treeNodesList ); } else if(v_iNewCardIndex == 2 ) { //For Accessibility put the focus on the first control of the page var focusElement = document.getElementById( "radioShortName"); if( focusElement ) { focusElement.focus(); } } } }; G_App.F_Next = function() { var msg = IMPORTWIZARD.checkNext(); if (msg){ alert(msg); } else{ var currentCard = G_App.m_oDeck.F_GetIndex(); switch (currentCard) { case 0: { if (mapCubeDimTables == null) mapCubeDimTables = new Object(); if (mapCubeAliasLanguages == null) mapCubeAliasLanguages = new Object(); break; } case 1: break; case 2: break; case 3: break; } this.m_oDeck.F_Next(); } }; function PopulateCubes( treeNodesList ) { // // Disable the Next & Finish buttons temporarily, to prevent 2 async calls from colliding in the same IFrame. // cubeNodeList = treeNodesList; // keeps the tree nodes of the selected cubes. We need the tree nodes to be able to compute the path to the cube browsing the parents. G_App.m_oListViewCubes.F_Clear(); var nextButton = document.getElementById( "nextButton" ); EnableButton( nextButton, false /* bEnable */ ); var finishButton = document.getElementById( "finishButton" ); EnableButton( finishButton, true /* bEnable */ ); if (D_Progress.F_IsActiveDialog() == false) { D_Progress.F_DisableCancel(); D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"]); } for (var i = 0; i < treeNodesList.length; i++) { var cube = treeNodesList[i]; var nodeName = cube.getAttribute( "label" ); var nodeValue = cube.getAttribute( "value" ); var childNodeValueObj = eval( "(" + nodeValue + ")" ); var childNodeType = childNodeValueObj.type; var childNodeUniqueName = childNodeValueObj.uniqueName; var newListItemNode = G_App.m_oListViewCubes.F_AppendNewListItem(); newListItemNode.setAttribute( "value", nodeValue ); newListItemNode.setAttribute( "label", nodeName ); } G_App.selectFirstListBoxItem(G_App.m_oListViewCubes); G_App.m_oListViewCubes.F_Draw(); // populate dimensions for the first cube in the list var firstCube = treeNodesList[0]; PopulateDimensionsListBox( firstCube ); hideProgressIfShowing(); } function PopulateDimensionsListBox( v_nTreeNode ) { // // Disable the Next & Finish buttons temporarily, to prevent 2 async calls from colliding in the same IFrame. // var nextButton = document.getElementById( "nextButton" ); EnableButton( nextButton, false /* bEnable */ ); var finishButton = document.getElementById( "finishButton" ); IMPORTWIZARD.isFinishButtonEnabled = IsButtonEnabled( finishButton ); EnableButton( finishButton, false /* bEnable */ ); if (D_Progress.F_IsActiveDialog() == false) { D_Progress.F_DisableCancel(); D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"]); } 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; // either TM or TMR nodePathEntry.isSystem = "false"; } 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"] = "OLAPImportWizard_GetDimensionsList_TEST_pid"; else browseTreeRequestPostParams["pid"] = "OLAPImportWizard_GetDimensionsList_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.MakeAsyncRequestInIFrame2( browseTreeRequestURL, browseTreeRequestPostParams ); } G_App.F_Back = function() { this.m_oDeck.F_Back(); }; // // When a node is checked/unchecked, update the check status of the parent nodes. // 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 nextButton = document.getElementById( "nextButton" ); var bEnableNextButton = (cardIndex != G_App.m_oDeck.F_GetNumberOfCards() - 1); if (bEnableNextButton) { nextButton.onclick = function( e ) { G_App.F_Next(); }; nextButton.ondblclick = function( e ) { G_App.F_Next(); }; } EnableButton( nextButton, bEnableNextButton ); 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 UpdateImportSpecLang() { // for each cube from mapCubeAliasTables for (var cubeName in mapCubeDimTables) { var treeSnippet = mapCubeDimTables[cubeName]; var mapDimAliasLangs = mapCubeAliasLanguages[cubeName]; //map { cubeuniqueName, map { dimensionUniqueName, map { alias table / list(of selected languages) } } } if (mapDimAliasLangs != null) { for (var dimName in mapDimAliasLangs) { var mapAliasLangs = mapDimAliasLangs[dimName]; for (var i = 0; i < treeSnippet.node.children.length; i++) { treeViewDim = treeSnippet.node.children[i]; if (treeViewDim.children != null) { for (var k = 0; k < treeViewDim.children.length; k++) { var treeViewAlis = treeViewDim.children[k]; var aliasName = treeViewAlis.Name; var nodeType = treeViewAlis.Type; if (nodeType == "aliasTable") { var checkedItemsPerAlias = mapAliasLangs[aliasName]; if (checkedItemsPerAlias != null) { for (var n = 0; n < checkedItemsPerAlias.length; n++) { var langCode = checkedItemsPerAlias[n]; var nodeEntry = {}; nodeEntry.Name = aliasName; nodeEntry.Type = "aliasTableLang"; nodeEntry.uniqueName = langCode; // add the new entry to the dimension treeViewDim.children.push(nodeEntry); } } } } } } } } } } function associateCubesWithAliases(treeNodesPaths) { // browse to the leaf (cube) for (var i = 0; i < treeNodesPaths.length; i++) { var curentNode = treeNodesPaths[i].children; if (curentNode != null) { associateCubesWithAliases(curentNode); } else { // here treeNodesPaths is a cube var cube = mapCubeDimTables[treeNodesPaths[i].Name]; if (cube != null) { treeNodesPaths[i].children = cube.node.children; } } } } function WizardDone() { UpdateImportSpecLang(); // 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 ); } associateCubesWithAliases(treeNodesPaths); var importSpec = {}; importSpec["node"] = []; importSpec["node"][0] = treeNodesPaths[0]; var strImportSpec = JSON.stringify( importSpec, null, "\t" ); // var enhanceModelForSAPCheckBox = document.getElementById( "enhanceModelForSAP" ); var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" ); var designLocaleCombo = document.getElementById("designLanguage"); var parameters = {}; parameters["params"] = {}; // parameters["params"]["ObjectName"] = objectName; // parameters["params"]["ObjectLayout"] = enhanceModelForSAPCheckBox.checked ? "true" : "false"; parameters["params"]["UseV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false"; // parameters["params"].languages = selectedLanguagesCodes; 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; // either TM or TMR nodeEntry.isSystem = "false"; } else { nodeEntry.uniqueName = nodeUniqueName; } 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"] )) { 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 */ ); } } } 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 Next and Finish buttons // var nextButton = document.getElementById( "nextButton" ); EnableButton( nextButton, true /* bEnable */ ); 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(); }, 700 ); } } } function metadataDimensionListResultsReceived( treeSnippet ) { var childNodeUniqueName = getSelectedCubeUniqueName(); if (childNodeUniqueName != null) { mapCubeDimTables[childNodeUniqueName] = JSON.parse(JSON.stringify(treeSnippet)); // map { cubeListNode, treeSnippet} ( used to cash the alias tables per cube to improve the performance ) } G_App.PopulateDimensionsListView(treeSnippet); hideProgressIfShowing(); urlRequestInvoker.RequestFinished(); G_App.m_oListViewDimensions.F_Draw(); G_App.selectFirstListBoxItem(G_App.m_oListViewDimensions); G_App.m_oListViewDimensions.F_Draw(); if (IMPORTWIZARD.enableTest == false) { G_App.PopulateAliasTablesListView(treeSnippet); } if (IMPORTWIZARD.enableTest == true) { // in test mode, select all dimensions that are sent as http parameters for (var dim in IMPORTWIZARD.dimAlias) { G_App.m_oListViewDimensions.F_DeselectAll(); var strDim = new String(dim); g_dimNum = strDim.substr(1); G_App.selectListBoxItem(G_App.m_oListViewDimensions, g_dimNum); G_App.m_oListViewDimensions.F_Draw(); G_App.PopulateAliasTablesListView(treeSnippet); } // Finish // no requests in the previous code, so goto to finish WizardDone(); } // For accessibility Set the focus on the first item of the check box var v_nFirstListItem = G_App.m_oListViewDimensions.F_GetFirstSelectableItem(); if ( v_nFirstListItem ) { var vaFocus = document.getElementById( v_nFirstListItem.getAttribute( "htmlId" ) ); if( vaFocus ) vaFocus.focus(); } G_App.m_oListViewDimensions.F_Draw(); var finishButton = document.getElementById( "finishButton" ); EnableButton( finishButton, IMPORTWIZARD.isFinishButtonEnabled /* bEnable */ ); } G_App.PopulateDimensionsListView = function(treeSnippet) { G_App.m_oListViewDimensions.F_Clear(); // clear the alias tables list box for (var i = 0; i < treeSnippet.node.children.length; i++) { treeViewNodeData = treeSnippet.node.children[i] var nodeLabel = treeViewNodeData.Name; var nodeType = treeViewNodeData.Type; var newListItemNode = this.m_oListViewDimensions.F_AppendNewListItem(); newListItemNode.setAttribute( "value", nodeType ); newListItemNode.setAttribute( "label", nodeLabel ); } }; G_App.PopulateAliasTablesListView = function(treeSnippet) { if (treeSnippet == null) return; // first get the selected dimension from the dimension view list var listNode = G_App.m_oListViewDimensions.F_GetSelectedListItem(); if (listNode != null) { var bAliasTableListPopulates = "false"; G_App.m_oListViewAliasTables.F_Clear(); // clear the alias tables list box var nodeName = listNode.getAttribute( "label" ); var nodeValue = listNode.getAttribute( "value" ); for (var i = 0; i < treeSnippet.node.children.length; i++) { var treeViewNodeData = treeSnippet.node.children[i] var nodeLabel = treeViewNodeData.Name; var nodeType = treeViewNodeData.Type; if (nodeLabel == nodeName) { if (treeViewNodeData.children != null) { for (var k = 0; k < treeViewNodeData.children.length; k++) { var aliasTable = treeViewNodeData.children[k]; var sliasTableName = aliasTable.Name; var sliasTableType = aliasTable.Type; var newListItemNode = this.m_oListViewAliasTables.F_AppendNewListItem(); newListItemNode.setAttribute( "label", sliasTableName ); newListItemNode.setAttribute( "value", sliasTableType ); } bAliasTableListPopulates = "true"; } break; } } // enable languages list box if if (bAliasTableListPopulates == "true") { G_App.dissableLanguageBox("false"); G_App.m_oListViewCheckboxes.F_Draw(); // select the first alias table G_App.selectFirstListBoxItem(G_App.m_oListViewAliasTables); // populate the languages list box for the selected (first) alias table G_App.RepopulateLanguagesListView(); // select the first language list box item // first unselect all because this is multi-selection list box G_App.m_oListViewCheckboxes.F_DeselectAll(); G_App.selectFirstListBoxItem(G_App.m_oListViewCheckboxes); G_App.m_oListViewCheckboxes.F_Draw(); if (IMPORTWIZARD.enableTest == true) { var dim = "d" + g_dimNum; var mapAliasMapLang = IMPORTWIZARD.dimAlias[dim]; for (var alias in mapAliasMapLang) { G_App.m_oListViewAliasTables.F_DeselectAll(); var strAlias = new String(alias); g_aliasNum = strAlias.substr(1); G_App.selectListBoxItem(G_App.m_oListViewAliasTables, g_aliasNum); G_App.m_oListViewAliasTables.F_Draw(); // populate the languages list box for the selected (first) alias table G_App.RepopulateLanguagesListView(); var langs = mapAliasMapLang[alias]; for (var lang in langs) { // "lang" is the name of the language to select var nodeListLangs = G_App.m_oListViewCheckboxes.F_GetListItems(); var numberOfLangs = nodeListLangs.length; for ( var i = 0; i < numberOfLangs; i++ ) { var la = nodeListLangs.item( i ); langName = la.getAttribute("label"); if (langName == lang) { la.setAttribute("checked", "true"); G_App.F_ListView_OnCheckboxClick( G_App.m_oListViewCheckboxes, la, null ); break; } } G_App.m_oListViewCheckboxes.F_Draw(); } G_App.m_oListViewCheckboxes.F_Draw(); } } } else { // no alias tables // Clear all check boxes G_App.m_oListViewCheckboxes.F_UncheckAll(); G_App.m_oListViewCheckboxes.F_DeselectAll(); G_App.m_oListViewCheckboxes.F_Draw(); G_App.dissableLanguageBox("true"); G_App.m_oListViewCheckboxes.F_Draw(); } G_App.m_oListViewAliasTables.F_Draw(); } }; // The argument is "true" or "false" G_App.dissableLanguageBox = function(bEnable) { var nl = G_App.m_oListViewCheckboxes.F_GetListItems(); for ( var i = 0; i < nl.length; i++ ) { var v_nListItem = nl.item( i ); v_nListItem.setAttribute( "staticCheckbox", bEnable ); } } // G_App.selectFirstListBoxItem = function(listBoxView) { var v_nlListItems = listBoxView.F_GetListViewNode().selectNodes( "listItems/listItem" ); if (v_nlListItems != null && v_nlListItems.length > 0) { var v_nListItem = v_nlListItems.item( 0 ); v_nListItem.setAttribute( "selected", "true" ); } } // select a given item from the listbox view // itemNumber = integer (zero based) G_App.selectListBoxItem = function(listBoxView, itemNumber) { var v_nlListItems = listBoxView.F_GetListViewNode().selectNodes( "listItems/listItem" ); if (v_nlListItems != null && v_nlListItems.length > 0) { if (itemNumber < v_nlListItems.length) { var v_nListItem = v_nlListItems.item( itemNumber ); v_nListItem.setAttribute( "selected", "true" ); } } } 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 ); }