importWizardLinkedNode.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. /****************************************************************
  2. ** IBM Confidential
  3. **
  4. ** OCO Source Materials
  5. **
  6. ** IBM Cognos Products: mdsrv
  7. **
  8. ** (C) Copyright IBM Corp. 2008, 2014
  9. **
  10. ** The source code for this program is not published or otherwise
  11. ** divested of its trade secrets, irrespective of what has been
  12. ** deposited with the U.S. Copyright Office.
  13. *****************************************************************/
  14. G_HAL.F_Include( WEB_CONTENT + "/hal/C_Deck.js" );
  15. G_HAL.F_Include( WEB_CONTENT + "/hal/C_TreeView.js" );
  16. G_HAL.F_Include( WEB_CONTENT + "/hal/C_ListView.js" );
  17. G_HAL.F_Include( WEB_CONTENT + "/hal/U_CookieJar.js" );
  18. G_HAL.F_Include( WEB_CONTENT + "/hal/C_Dialog.js" );
  19. G_HAL.F_Include( WEB_CONTENT + "/common/json/json2.js" );
  20. G_HAL.F_Include( WEB_CONTENT + "/hal/G_ResManager.js" );
  21. G_HAL.F_Include( WEB_CONTENT + "/hal/C_MultiScriptRequest.js" );
  22. G_HAL.F_Include( WEB_CONTENT + "/hal/C_ComboBox.js" );
  23. G_HAL.F_Include( WEB_CONTENT + "/hal/C_PropertySheet.js" );
  24. //TO DO & Ideas:
  25. //
  26. // - button: Unselect all
  27. //
  28. // - label: Number of objects selected
  29. // These are meant to be constants (even if JavaScript allows you to change them; you MUST NOT change them).
  30. var kDatabaseTypeStr = "database";
  31. var asyncErrorPagePid = "importWizard_communication_error_page";
  32. var G_App = {};
  33. function ImportWizard()
  34. {
  35. this.credentials = "";
  36. }
  37. ImportWizard.prototype.setDataSourceCredentials = function(credentialString)
  38. {
  39. this.credentials = credentialString;
  40. urlRequestInvoker.RequestFinished();
  41. }
  42. ImportWizard.prototype.updateCredentials = function(newCredentials)
  43. {
  44. var urlPostParams = new Object();
  45. urlPostParams["pid"] = "updateCredentials";
  46. urlPostParams["current_credentials"] = this.credentials;
  47. urlPostParams["newcredentials_password"] = newCredentials;
  48. urlPostParams["error_pid"] = asyncErrorPagePid;
  49. var updateCredentialsRequestURL = GATEWAY_URL + "/metadataUIService";
  50. urlRequestInvoker.MakeAsyncRequestInIFrame( updateCredentialsRequestURL, urlPostParams );
  51. }
  52. IMPORTWIZARD = new ImportWizard();
  53. G_App.F_HAL_OnLoad = function()
  54. {
  55. // @todo Must pass proper locale code!
  56. G_ResManager.F_SetLocale( "en" );
  57. // This call is needed even if we don't pass a filename as an argument,
  58. // in order to load the standard HAL string resources.
  59. G_ResManager.F_LoadStrings( [ /*WEB_CONTENT + "/mdsrv/res/strings"*/], this );
  60. //Enable Accessibility for FireFox Browser only, pass false as second parameter if you don't want the focus ring in Firefox
  61. G_HAL.F_EnableAccessibility( G_BrowserInfo.M_bIsFirefox );
  62. //Enable High Contrast Mode need for FireFox only, Need testing to enable it for IE as well
  63. //if( G_BrowserInfo.M_bIsFirefox )
  64. // Need to check if the high contrast mode is enabled, waiting for HAL to expose this function or may not need it
  65. //G_HAL.F_EnableHighContrastMode();
  66. };
  67. G_App.initControls = function()
  68. {
  69. this.m_oDeck = new C_Deck( document.getElementById( "divDeck" ), this );
  70. UpdateButtonsEnableStatus( 0 /* cardIndex */ );
  71. this.F_ApplySkin( "corporate|portal" );
  72. // this.F_ApplySkin( "windows|app" );
  73. this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
  74. var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
  75. treeViewElem.setAttribute( "id", "TreeView" );
  76. treeViewElem.setAttribute( "showCheckboxes", "true" );
  77. // Only populate with the root node if in "create" mode!
  78. if (!IMPORTWIZARD.isEdit)
  79. {
  80. this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
  81. }
  82. this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
  83. g_expandTreeLevel = 0;
  84. var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
  85. useV5DataServerCheckBox.checked = true;// IMPORTWIZARD.bUseV5DataServer;
  86. if (IMPORTWIZARD.bDisableClassic == "true")
  87. //useV5DataServerCheckBox.disabled=true;
  88. useV5DataServerCheckBox.style.display = "none";
  89. PopulateLanguagesListBox();
  90. if (IMPORTWIZARD.enableTest == false)
  91. {
  92. ShowPackageRenameDlgIfNeeded();
  93. }
  94. }
  95. G_App.expandNode = function( node)
  96. {
  97. // testing code to expand the root node
  98. if (IMPORTWIZARD.enableTest == true)
  99. {
  100. //var node = g_viewNodeToExpand.selectSingleNode( "treeNode" );
  101. if (node != null)
  102. {
  103. G_App.m_oTreeViewCheckboxes.F_ExpandNode(node );
  104. G_App.m_oTreeViewCheckboxes.F_Draw();
  105. }
  106. }
  107. }
  108. function PopulateLanguagesListBox()
  109. {
  110. var getLanguagesRequestURL = GATEWAY_URL + "/metadataUIService";
  111. D_Progress.F_DisableCancel();
  112. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"]);
  113. var getLanguagesRequestPostParams = {};
  114. getLanguagesRequestPostParams["pid"] = "OLAPImportWizard_Languages_pid"
  115. getLanguagesRequestPostParams["datasource"] = IMPORTWIZARD.dataSourceName;
  116. getLanguagesRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
  117. getLanguagesRequestPostParams["error_pid"] = asyncErrorPagePid;
  118. urlRequestInvoker.MakeAsyncRequestInIFrame( getLanguagesRequestURL, getLanguagesRequestPostParams );
  119. }
  120. function providerLangResultsReceived( providerLanguages )
  121. {
  122. var languagesList = providerLanguages.lang;
  123. var designLocaleList = document.getElementById( "designLanguage" );
  124. var selIndex = 0;
  125. for (var i = 0; i < languagesList.length; i++)
  126. {
  127. if (languagesList[i].localeId == IMPORTWIZARD.productLocale)
  128. selIndex = i;
  129. designLocaleList.options[i]=new Option(languagesList[i].localeName, languagesList[i].localeId);
  130. }
  131. designLocaleList.selectedIndex = selIndex;
  132. hideProgressIfShowing();
  133. //D_Progress.F_Hide();
  134. urlRequestInvoker.RequestFinished();
  135. // expand the root node
  136. //alert( "In providerLangResultsReceived( providerLanguages ).\n" );
  137. setTimeout( function(){
  138. var treeRootViewNode = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
  139. var node = treeRootViewNode.selectSingleNode( "treeNode" );
  140. G_App.expandNode(node);
  141. }, 700 );
  142. }
  143. function OnUseV5DataServerBtnClicked( sourceUseV5DataServerChkBox )
  144. {
  145. }
  146. ImportWizard.prototype.checkDesignLocaleSelected = function(){
  147. var designLocaleList = document.getElementById( "designLanguage" );
  148. if (designLocaleList.selectedIndex < 0){
  149. return localizedStrings["MSR_SAP_designLocaleRequired"];
  150. }
  151. }
  152. G_App.initializeTreeViewCheckBox = function( )
  153. {
  154. //this.m_oTreeViewCheckboxes.F_Detach();
  155. this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
  156. var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
  157. treeViewElem.setAttribute( "id", "TreeView" );
  158. treeViewElem.setAttribute( "showCheckboxes", "true" );
  159. this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
  160. this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
  161. g_expandTreeLevel = 0;
  162. // expand the root node
  163. var treeRootViewNode = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
  164. var node = treeRootViewNode.selectSingleNode( "treeNode" );
  165. if (node != null)
  166. {
  167. setTimeout( function(){
  168. G_App.expandNode( node);
  169. }, 700 );
  170. }
  171. }
  172. function selectFirstItemInTreeControl()
  173. {
  174. var v_elSpanFirst = G_App.m_oTreeViewCheckboxes.F_GetFirstVisibleTreeItem();
  175. if ( v_elSpanFirst )
  176. {
  177. v_elSpanFirst.focus();
  178. }
  179. }
  180. G_App.F_ResManager_OnStringsLoaded = function( v_aFiles )
  181. {
  182. G_ResManager.F_LoadResources( [ WEB_CONTENT + "/mdsrv/res/EditVariablesResources.xml" ],this );
  183. };
  184. G_App.F_ResManager_OnResourcesLoaded = function( v_aFiles )
  185. {
  186. //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.
  187. this.initControls();
  188. }
  189. function retrieveImportSpec()
  190. {
  191. var getImportSpecRequestURL = GATEWAY_URL + "/metadataUIService";
  192. D_Progress.F_DisableCancel();
  193. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"] );
  194. var getImportSpecRequestPostParams = {};
  195. getImportSpecRequestPostParams["pid"] = "importWizard_ImportSpec_pid";
  196. getImportSpecRequestPostParams["packageLocation"] = IMPORTWIZARD.packageLocation;
  197. getImportSpecRequestPostParams["packageName"] = IMPORTWIZARD.packageName;
  198. getImportSpecRequestPostParams["error_pid"] = asyncErrorPagePid;
  199. IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
  200. hideProgressIfShowing();
  201. }
  202. urlRequestInvoker.MakeAsyncRequestInIFrame( getImportSpecRequestURL, getImportSpecRequestPostParams );
  203. }
  204. function GenerateJSONString( obj )
  205. {
  206. var strObjJSON = "";
  207. for (var i in obj)
  208. {
  209. strObjJSON += "\t\t\"" + i + "\": ";
  210. strObjJSON += "\"" + obj[i] + "\",\n";
  211. }
  212. // The last comma must be removed, in order to have a syntactically correct JSON string.
  213. // Firefox doesn't care about this, but IE fails to work properly if this isn't done.
  214. var lastCommaIndex = strObjJSON.lastIndexOf( ',' );
  215. strObjJSON = "\t{\n" + strObjJSON.substr(0, lastCommaIndex ) + "\n\t}\n";
  216. // alert( "GenerateJSONString\n\n" + strObjJSON ); // Debugging
  217. return strObjJSON;
  218. }
  219. G_App.PopulateTreeView_RootNode = function( aDoc, treeViewElem )
  220. {
  221. var rootNodeElem = treeViewElem.appendChild( aDoc.createElement( "treeNode" ) );
  222. var nodeValueObj = {};
  223. nodeValueObj["type"] = kDatabaseTypeStr;
  224. nodeValueObj["uniqueName"] = kDatabaseTypeStr;
  225. var nodeValue = GenerateJSONString( nodeValueObj );
  226. rootNodeElem.setAttribute( "value", nodeValue );
  227. rootNodeElem.setAttribute( "label", IMPORTWIZARD.dataSourceName);
  228. rootNodeElem.setAttribute( "expandable", "true" );
  229. rootNodeElem.setAttribute( "staticCheckbox", "true" );
  230. rootNodeElem.setAttribute( "role", "treeItem" );
  231. rootNodeElem.setAttribute( "tooltip", kDatabaseTypeStr );
  232. };
  233. function importSpecReceivedReceived( treeSnippet )
  234. {
  235. D_Progress.F_Hide();
  236. urlRequestInvoker.RequestFinished();
  237. G_App.m_oTreeViewCheckboxes.F_StartAsyncLoad();
  238. var aDoc = G_App.m_treeViewNodesDoc;
  239. var treeViewElem = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
  240. IMPORTWIZARD.dataSourceName = treeSnippet.node.Name; // In edit scenario we didn't know the ds name, so we populate it now
  241. PopulateTreeView( treeSnippet.node, aDoc, treeViewElem );
  242. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */);
  243. selectFirstItemInTreeControl();
  244. }
  245. function SaveModifiedSettings()
  246. {
  247. var saveModifiedSettingsURL = GATEWAY_URL + "/metadataUIService";
  248. D_Progress.F_DisableCancel();
  249. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Saving"]);
  250. var saveModifiedSettingsParams = {};
  251. saveModifiedSettingsParams["pid"] = "saveModifiedPackageSettings_pid";
  252. saveModifiedSettingsParams["searchPath"] = IMPORTWIZARD.packageLocation + "/package[@name=" + EncloseInQuotes( IMPORTWIZARD.packageName ) + "]/model";
  253. saveModifiedSettingsParams["property"] = "http://developer.cognos.com/ceba/constants/queryOptionEnum#mode";
  254. var ms_useV5DataServerCheckBox = document.getElementById( "ms_useV5DataServer" );
  255. if (ms_useV5DataServerCheckBox.checked)
  256. {
  257. saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#dynamic"; // XQE
  258. }
  259. else
  260. {
  261. saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#compatible"; // Legacy query stack
  262. }
  263. saveModifiedSettingsParams["error_pid"] = asyncErrorPagePid;
  264. urlRequestInvoker.MakeAsyncRequestInIFrame( saveModifiedSettingsURL, saveModifiedSettingsParams );
  265. }
  266. function OnSaveModifiedPackageSettingsRequestCompleted()
  267. {
  268. D_Progress.F_Hide();
  269. urlRequestInvoker.RequestFinished();
  270. window.location.replace( IMPORTWIZARD.backURL );
  271. }
  272. //
  273. // Populates the tree view based on data obtained from the server side
  274. // (through a JSP async call).
  275. // This data could be coming from either:
  276. // - the browse JSP (when expanding tree nodes for the first time)
  277. // - the import spec JSP (when editing an existing package)
  278. //
  279. function PopulateTreeView( treeViewNodeData, aDoc, treeViewElem )
  280. {
  281. }
  282. /**
  283. * Used in edit mode, to pass to the browse JSP, the selected nodes recursively.
  284. */
  285. function ExtractSelectedTreeNodes( v_nTreeNode, nodePathEntry )
  286. {
  287. }
  288. var g_treeNodeBeingPopulated = null;
  289. var g_expandTreeLevel = 0; // used only for testing (does not expect collapsing the tree nodes)
  290. var g_viewNodeToExpand = null; // node to expand based on the provided drill down path
  291. G_App.F_TreeView_OnPopulateChildren = function( v_oTreeView, v_nTreeNode )
  292. {
  293. return true;
  294. };
  295. G_App.F_HAL_OnUnLoad = function()
  296. {
  297. this.m_oTreeViewCheckboxes.F_Detach();
  298. if (this.m_oPropertySheet != null)
  299. {
  300. this.m_oPropertySheet.F_Detach();
  301. }
  302. };
  303. G_App.F_ApplySkin = function( v_sSkin )
  304. {
  305. // Build the path to the appropriate skin css file
  306. var v_aSkin = v_sSkin.split( "|" );
  307. var v_sSkinName = v_aSkin[0];
  308. var v_sSkinType = v_aSkin[1];
  309. var v_sSkinPath = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_portal_skin.css";
  310. var v_sSkinPath2 = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_skin.css";
  311. // Remove existing link tag to skin css
  312. var v_nExistingCSSNode = document.getElementById( "idHALSkinCSS" );
  313. if ( v_nExistingCSSNode )
  314. {
  315. v_nExistingCSSNode.parentNode.removeChild( v_nExistingCSSNode );
  316. }
  317. // Create and append new link tag to skin css
  318. var v_elHead = document.getElementsByTagName( "head" )[0];
  319. var v_elLinkCSS = document.createElement( "link" );
  320. v_elLinkCSS.id = "idHALSkinCSS";
  321. v_elLinkCSS.type = "text/css";
  322. v_elLinkCSS.rel = "stylesheet";
  323. v_elLinkCSS.href = v_sSkinPath;
  324. v_elHead.appendChild( v_elLinkCSS );
  325. var v_elLinkCSS2 = document.createElement( "link" );
  326. v_elLinkCSS2.id = "idHALSkinCSS";
  327. v_elLinkCSS2.type = "text/css";
  328. v_elLinkCSS2.rel = "stylesheet";
  329. v_elLinkCSS2.href = v_sSkinPath2;
  330. v_elHead.appendChild( v_elLinkCSS2 );
  331. document.body.style.backgroundColor = ( v_sSkinType == "portal" ) ? "#FFFFFF" : "";
  332. // Set skin value in cookie
  333. var v_dateExpires = new Date();
  334. v_dateExpires.setUTCFullYear( v_dateExpires.getUTCFullYear() + 1 );
  335. U_CookieJar.F_SetCookie( "skin", v_sSkin, v_dateExpires );
  336. };
  337. G_App.F_Deck_OnBeforeCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
  338. {
  339. };
  340. G_App.F_Deck_OnAfterCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
  341. {
  342. if (v_oDeck == this.m_oDeck)
  343. {
  344. var pageTitles =
  345. [
  346. localizedStrings["MSR_SAP_selectObjectsTitle"],
  347. localizedStrings["MSR_SAP_selectLanguagesTitle"],
  348. localizedStrings["MSR_SAP_generateDimensionsTitle"]
  349. ];
  350. // var pageTitlePostfix = (IMPORTWIZARD.isEdit) ? " &nbsp; <i>[Edit Package Mode]</i>" : "";
  351. document.getElementById( "dialogHeaderTitle" ).innerHTML = pageTitles[v_iNewCardIndex];
  352. UpdateButtonsEnableStatus( v_iNewCardIndex );
  353. }
  354. };
  355. G_App.F_Back = function()
  356. {
  357. this.m_oDeck.F_Back();
  358. };
  359. G_App.F_TreeView_OnNodeCheck = function( v_oTreeView, v_nTreeNode )
  360. {
  361. };
  362. G_App.F_TreeView_OnNodeClick = function( v_oTreeView, v_nTreeNode, v_iMouseButton )
  363. {
  364. };
  365. G_App.F_TreeView_OnNodeDblClick = function( v_oTreeView, v_nTreeNode )
  366. {
  367. };
  368. function IsButtonEnabled( button )
  369. {
  370. return (button.className == "commandButton");
  371. }
  372. // Enables the button (if bEnable is true), or disables it (if bEnable is false).
  373. // It preserves and restores the OnClick and OnDblClick events properly.
  374. function EnableButton( button, bEnable )
  375. {
  376. var prevEnabledState = IsButtonEnabled( button );
  377. if (bEnable == true /*&& button.className == "commandButtonInactiveII"*/)
  378. {
  379. button.className = "commandButton";
  380. button.onmouseover = function( e ) { this.className = "commandButtonOver"; };
  381. button.onmouseout = function( e ) { this.className = "commandButton"; };
  382. button.onmousedown = function( e ) { this.className = "commandButton"; };
  383. button.onkeypress = handle_onkeydown;
  384. button.children[0].tabIndex = 0;
  385. if (prevEnabledState == false)
  386. {
  387. if (button.onclick_enabled != null)
  388. {
  389. button.onclick = button.onclick_enabled;
  390. }
  391. if (button.ondblclick_enabled != null)
  392. {
  393. button.ondblclick = button.ondblclick_enabled;
  394. }
  395. }
  396. }
  397. else if (bEnable == false)
  398. {
  399. button.className = "commandButtonInactiveII";
  400. button.onmouseover = null;
  401. button.onmouseout = null;
  402. button.onmousedown = null;
  403. button.onkeypress = null;
  404. button.children[0].tabIndex = -1;
  405. // preserve the previous event handlers
  406. if (prevEnabledState == true)
  407. {
  408. button.onclick_enabled = button.onclick;
  409. button.ondblclick_enabled = button.ondblclick;
  410. }
  411. button.onclick = "";
  412. button.ondblclick = "";
  413. }
  414. }
  415. function UpdateButtonsEnableStatus( cardIndex )
  416. {
  417. var prevButton = document.getElementById( "prevButton" );
  418. var bEnablePrevButton = (cardIndex != 0);
  419. if (bEnablePrevButton)
  420. {
  421. prevButton.onclick = function( e ) { G_App.F_Back(); };
  422. prevButton.ondblclick = function( e ) { G_App.F_Back(); };
  423. }
  424. EnableButton( prevButton, bEnablePrevButton );
  425. var finishButton = document.getElementById( "finishButton" );
  426. var bEnableFinishButton = (cardIndex == G_App.m_oDeck.F_GetNumberOfCards() - 1);
  427. if (bEnableFinishButton)
  428. {
  429. finishButton.onclick = function( e ) { WizardDone(); };
  430. finishButton.ondblclick = function( e ) { WizardDone(); };
  431. EnableButton( finishButton, bEnableFinishButton );
  432. }
  433. }
  434. function WizardDone()
  435. {
  436. var importSpec = {};
  437. importSpec["node"] = {};
  438. importSpec["node"]["Name"] = IMPORTWIZARD.dataSourceName;
  439. importSpec["node"]["Type"] = "database";
  440. importSpec["node"]["Value"] = "true";
  441. importSpec["node"]["dbType"] = IMPORTWIZARD.dataSourceType;
  442. var strImportSpec = JSON.stringify( importSpec, null, "\t" );
  443. // Build the parameters object
  444. var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
  445. var designLocaleCombo = document.getElementById("designLanguage");
  446. var parameters = {};
  447. parameters["params"] = {};
  448. parameters["params"]["UseV5DataServer"] = "true";
  449. parameters["params"].designLocale = designLocaleCombo.options[designLocaleCombo.selectedIndex].value;
  450. var strParameters = JSON.stringify( parameters, null, "\t" );
  451. var pkgInfo = {};
  452. pkgInfo["pkgInfo"]={};
  453. pkgInfo["pkgInfo"]["Name"]=IMPORTWIZARD.packageName;
  454. pkgInfo["pkgInfo"]["Description"]=IMPORTWIZARD.packageDescription;
  455. pkgInfo["pkgInfo"]["ScreenTip"]=IMPORTWIZARD.packageScreentip;
  456. pkgInfo["pkgInfo"]["Location"]=IMPORTWIZARD.packageLocation;
  457. var strPkgInfo = JSON.stringify( pkgInfo, null, "\t" );
  458. IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
  459. hideProgressIfShowing();
  460. }
  461. var importHelper = new ImportHelper(strImportSpec, strParameters, strPkgInfo);
  462. importHelper.runImport();
  463. D_Progress.F_DisableCancel();
  464. D_Progress.F_Show( null, localizedStrings["MSR_SAP_creatingPackage"] );
  465. }
  466. function hideProgressIfShowing()
  467. {
  468. if (D_Progress.F_IsActiveDialog())
  469. {
  470. // hide any progress that may be up
  471. D_Progress.F_Hide();
  472. }
  473. }
  474. function GetTreeNodePath( v_nTreeNode )
  475. {
  476. var currentNode = v_nTreeNode;
  477. var nodePathObj = {};
  478. var bIsLeaf = true;
  479. // The nodePath is being build back-wards
  480. do
  481. {
  482. var nodeLabel = currentNode.getAttribute( "label" );
  483. var nodeValue = currentNode.getAttribute( "value" );
  484. var nodeValueObj = eval( "(" + nodeValue + ")" );
  485. var nodeType = nodeValueObj.type;
  486. var nodeUniqueName = nodeValueObj.uniqueName;
  487. var nodeEntry = {};
  488. nodeEntry.Name = nodeLabel;
  489. nodeEntry.Type = nodeType;
  490. nodeEntry.Value = (nodeType == kDatabaseTypeStr || nodeType == kCatalogTypeStr) ? "partial" : "true";
  491. if (nodeType == kDatabaseTypeStr)
  492. {
  493. nodeEntry.dbType = "M12"; //save dbType in the ImportSpec just for FMMD to load DimImport for CQM packages
  494. }
  495. else
  496. {
  497. nodeEntry.uniqueName = nodeUniqueName;
  498. }
  499. // if (nodePathObj != undefined)
  500. if (!bIsLeaf)
  501. {
  502. nodeEntry.children = [nodePathObj];
  503. }
  504. nodePathObj = nodeEntry;
  505. currentNode = currentNode.parentNode;
  506. bIsLeaf = false;
  507. }
  508. while (currentNode != null && currentNode.tagName == "treeNode");
  509. return nodePathObj;
  510. }
  511. // The first node in the array will end up containing the cosolidated tree nodes.
  512. function ConsolidateTree( treeNodesPaths, referenceNodeIndex )
  513. {
  514. }
  515. G_App.F_OnCancel = function()
  516. {
  517. D_Progress.F_Hide();
  518. };
  519. function GetIconFilePath( objectType )
  520. {
  521. return null;
  522. }
  523. function metadataTreeResultsReceived( treeSnippet )
  524. {
  525. if (g_treeNodeBeingPopulated == null)
  526. {
  527. return;
  528. }
  529. if (treeSnippet == null)
  530. {
  531. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
  532. g_treeNodeBeingPopulated = null;
  533. urlRequestInvoker.RequestFinished();
  534. return;
  535. }
  536. g_viewNodeToExpand = null;
  537. // This function will clear only the child nodes.
  538. G_App.m_oTreeViewCheckboxes.F_Clear( g_treeNodeBeingPopulated );
  539. for (var i = 0; i < treeSnippet.node.children.length; i++)
  540. {
  541. var aDoc = G_App.m_treeViewNodesDoc;
  542. //PopulateTreeView( treeSnippet.node.children[i], aDoc, g_treeNodeBeingPopulated );
  543. }
  544. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
  545. g_treeNodeBeingPopulated = null;
  546. urlRequestInvoker.RequestFinished();
  547. //
  548. // Re-enable the Finish button
  549. //
  550. var finishButton = document.getElementById( "finishButton" );
  551. EnableButton( finishButton, IMPORTWIZARD.isFinishButtonEnabled /* bEnable */ );
  552. g_expandTreeLevel += 1;
  553. if (g_viewNodeToExpand != null)
  554. {
  555. //setTimeout( function(){
  556. //G_App.expandNode( g_viewNodeToExpand);
  557. //}, 700 );
  558. }
  559. if (IMPORTWIZARD.enableTest == true)
  560. {
  561. if (g_expandTreeLevel == IMPORTWIZARD.treeLevels.length + 1)
  562. {
  563. setTimeout( function(){
  564. //G_App.F_Next();
  565. WizardDone();
  566. }, 700 );
  567. }
  568. }
  569. }
  570. function HandleException(jsonExceptionObj)
  571. {
  572. hideProgressIfShowing();
  573. var errorPageMgr = new ErrorPageManager();
  574. if (jsonExceptionObj.isQF)
  575. {
  576. document.getElementById( "main" ).style.display = "none";
  577. errorPageMgr.handleQF(jsonExceptionObj.faultDom, ErrorPageClosed);
  578. }
  579. else if (jsonExceptionObj.isCAM)
  580. {
  581. document.getElementById( "main" ).style.display = "none";
  582. errorPageMgr.handleCAM(jsonExceptionObj, ErrorPageClosed);
  583. }
  584. else
  585. {
  586. var msg = jsonExceptionObj.messageString;
  587. if (msg === "")
  588. {
  589. msg = localizedStrings["MSR_SAP_unknownErrorMessage"];
  590. }
  591. var stackTrace = jsonExceptionObj.stackTrace;
  592. stackTrace = unescape(stackTrace);
  593. document.getElementById( "main" ).style.display = "none";
  594. document.getElementById( "editSelection" ).style.display = "none"
  595. errorPageMgr.setupAndDisplayErrorPage(localizedStrings["MSR_SAP_errorPageTitle"], "",
  596. msg, stackTrace, ErrorPageClosed);
  597. }
  598. }
  599. function ErrorPageClosed(recovered)
  600. {
  601. document.getElementById("main").style.display = "block";
  602. // If its been recovered, then we presume that call back will occur at a later time
  603. if (IMPORTWIZARD.onResumeFromNonRecoverableError && !recovered){
  604. IMPORTWIZARD.onResumeFromNonRecoverableError();
  605. }
  606. }
  607. function launchFromEdit()
  608. {
  609. var selectMetadataRadioBtn = document.getElementById( "modifyMetadataSelections" );
  610. var editVariablesRadioBtn = document.getElementById( "editVariables" );
  611. var modifySettingsRadioBtn = document.getElementById( "modifySettings" );
  612. var editSelectionPage = document.getElementById( "editSelection" );
  613. if (selectMetadataRadioBtn.checked)
  614. {
  615. editSelectionPage.style.display = "none";
  616. var main = document.getElementById( "main" );
  617. main.style.display = "block";
  618. retrieveImportSpec();
  619. }
  620. else if (editVariablesRadioBtn.checked)
  621. {
  622. editSelectionPage.style.display = "none";
  623. OnShowVariables();
  624. }
  625. else if (modifySettingsRadioBtn.checked)
  626. {
  627. SaveModifiedSettings();
  628. }
  629. }
  630. function ImportHelper(importSpec, parameters, packageInfo)
  631. {
  632. this.m_importSpec = importSpec;
  633. this.m_parameters = parameters;
  634. this.m_packageInfo = packageInfo;
  635. }
  636. ImportHelper.prototype.runImport = function()
  637. {
  638. var importRequestURL = GATEWAY_URL + "/metadataUIService"
  639. this.m_requestId = new Date().getTime();
  640. var importRequestPostParams = {};
  641. if (IMPORTWIZARD.enableTestNoDBConnection)
  642. importRequestPostParams["pid"] = "OLAPImportWizard_Import_TEST_pid";
  643. else
  644. importRequestPostParams["pid"] = "LinkedNodeImportWizard_Import_pid";
  645. importRequestPostParams["importSpec"] = this.m_importSpec;
  646. importRequestPostParams["parameters"] = this.m_parameters;
  647. importRequestPostParams["packageInfo"] = this.m_packageInfo;
  648. importRequestPostParams["requestId"] = this.m_requestId;
  649. importRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
  650. importRequestPostParams["error_pid"] = asyncErrorPagePid;
  651. if (IMPORTWIZARD.enableTest == true)
  652. {
  653. importRequestPostParams["enableTest"] = "true";
  654. }
  655. urlRequestInvoker.MakeAsyncRequestInIFrame( importRequestURL, importRequestPostParams );
  656. }