importWizard.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** IBM Cognos Products: mdsrv
  5. **
  6. ** (C) Copyright IBM Corp. 2008, 2016
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *****************************************************************/
  10. G_HAL.F_Include( WEB_CONTENT + "/hal/C_Deck.js" );
  11. G_HAL.F_Include( WEB_CONTENT + "/hal/C_TreeView.js" );
  12. G_HAL.F_Include( WEB_CONTENT + "/hal/C_ListView.js" );
  13. G_HAL.F_Include( WEB_CONTENT + "/hal/U_CookieJar.js" );
  14. G_HAL.F_Include( WEB_CONTENT + "/hal/C_Dialog.js" );
  15. G_HAL.F_Include( WEB_CONTENT + "/common/json/json2.js" );
  16. G_HAL.F_Include( WEB_CONTENT + "/hal/G_ResManager.js" );
  17. G_HAL.F_Include( WEB_CONTENT + "/hal/C_MultiScriptRequest.js" );
  18. //G_HAL.F_Include( WEB_CONTENT + "hal/G_KeyboardManager.js");
  19. G_HAL.F_Include( WEB_CONTENT + "/hal/C_ComboBox.js" );
  20. G_HAL.F_Include( WEB_CONTENT + "/hal/C_PropertySheet.js" );
  21. //TO DO & Ideas:
  22. //
  23. // - button: Unselect all
  24. //
  25. // - label: Number of objects selected
  26. // These are meant to be constants (even if JavaScript allows you to change them; you MUST NOT change them).
  27. var kDatabaseTypeStr = "database";
  28. var kCatalogTypeStr = "catalog";
  29. var kCubeTypeStr = "cube";
  30. var kInfoQueryTypeStr = "infoQuery";
  31. var kDimensionGroupTypeStr = "dimensionGroup";
  32. var kDimensionTypeStr = "dimension";
  33. var kMeasuresGroupTypeStr = "Measures";
  34. var kMeasureTypeStr = "measure";
  35. var asyncErrorPagePid = "importWizard_communication_error_page";
  36. var G_App = {};
  37. function ImportWizard()
  38. {
  39. this.credentials = "";
  40. }
  41. ImportWizard.prototype.setDataSourceCredentials = function(credentialString)
  42. {
  43. this.credentials = credentialString;
  44. urlRequestInvoker.RequestFinished();
  45. }
  46. ImportWizard.prototype.updateCredentials = function(newCredentials)
  47. {
  48. var urlPostParams = new Object();
  49. urlPostParams["pid"] = "updateCredentials";
  50. urlPostParams["current_credentials"] = this.credentials;
  51. urlPostParams["newcredentials_password"] = newCredentials;
  52. urlPostParams["error_pid"] = asyncErrorPagePid;
  53. var updateCredentialsRequestURL = GATEWAY_URL + "/metadataUIService";
  54. urlRequestInvoker.MakeAsyncRequestInIFrame( updateCredentialsRequestURL, urlPostParams );
  55. }
  56. ImportWizard.prototype.checkNext = function()
  57. {
  58. var currentCard = G_App.m_oDeck.F_GetIndex();
  59. switch (currentCard)
  60. {
  61. case 0:
  62. {
  63. var msg = this.checkImportSelectionRestraints();
  64. if (msg && msg != null)
  65. {
  66. return msg;
  67. }
  68. break;
  69. }
  70. case 1:
  71. var msg = this.checkDesignLocaleSelected();
  72. if (msg && msg != null){
  73. return msg;
  74. }
  75. break;
  76. case 2:
  77. break;
  78. case 3:
  79. break;
  80. }
  81. return null;
  82. }
  83. ImportWizard.prototype.checkDesignLocaleSelected = function(){
  84. var designLocaleList = document.getElementById( "designLanguage" );
  85. if (designLocaleList.selectedIndex < 0){
  86. return localizedStrings["MSR_SAP_designLocaleRequired"];
  87. }
  88. }
  89. ImportWizard.prototype.checkImportSelectionRestraints = function()
  90. {
  91. var treeNodesList = G_App.m_oTreeViewCheckboxes.F_GetCheckedNodes();
  92. var numCubes = 0;
  93. var numInfoQueries = 0;
  94. for (var n = 0; n < treeNodesList.length; n++)
  95. {
  96. var currentNode = treeNodesList.item(n);
  97. var nodeValue = currentNode.getAttribute( "value" );
  98. var nodeValueObj = eval( "(" + nodeValue + ")" );
  99. if (nodeValueObj.type == kCubeTypeStr)
  100. {
  101. numCubes++;
  102. }
  103. else if (nodeValueObj.type == kInfoQueryTypeStr)
  104. {
  105. numInfoQueries++;
  106. }
  107. if (numCubes > this.maxCubes)
  108. {
  109. return localizedStrings["MSR_SAP_tooManyCubes"].replace("{0}", this.maxCubes);
  110. }
  111. if (numInfoQueries > this.maxInfoQueries)
  112. {
  113. return localizedStrings["MSR_SAP_tooManyInfoQueries"].replace("{0}", this.maxInfoQueries);
  114. }
  115. }
  116. if (treeNodesList.length == 0)
  117. {
  118. return localizedStrings["MSR_SAP_mustImportAtLeastOneItem"];
  119. }
  120. return null;
  121. }
  122. IMPORTWIZARD = new ImportWizard();
  123. G_App.F_HAL_OnLoad = function()
  124. {
  125. // @todo Must pass proper locale code!
  126. G_ResManager.F_SetLocale( "en" );
  127. // This call is needed even if we don't pass a filename as an argument,
  128. // in order to load the standard HAL string resources.
  129. G_ResManager.F_LoadStrings( [ /*WEB_CONTENT + "/mdsrv/res/strings"*/], this );
  130. //Enable Accessibility for FireFox Browser only, pass false as second parameter if you don't want the focus ring in Firefox
  131. G_HAL.F_EnableAccessibility( G_BrowserInfo.M_bIsFirefox );
  132. //Enable High Contrast Mode need for FireFox only, Need testing to enable it for IE as well
  133. //if( G_BrowserInfo.M_bIsFirefox )
  134. // Need to check if the high contrast mode is enabled, waiting for HAL to expose this function or may not need it
  135. //G_HAL.F_EnableHighContrastMode();
  136. };
  137. var useV5DataServerCheckBox = null;
  138. G_App.initControls = function()
  139. {
  140. this.m_oDeck = new C_Deck( document.getElementById( "divDeck" ), this );
  141. UpdateButtonsEnableStatus( 0 /* cardIndex */ );
  142. var obj = document.getElementById( "radioShortName" );
  143. obj.checked = true;
  144. this.F_ApplySkin( "corporate|portal" );
  145. // this.F_ApplySkin( "windows|app" );
  146. this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
  147. var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
  148. treeViewElem.setAttribute( "id", "TreeView" );
  149. treeViewElem.setAttribute( "showCheckboxes", "true" );
  150. // Only populate with the root node if in "create" mode!
  151. if (!IMPORTWIZARD.isEdit)
  152. {
  153. this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
  154. }
  155. // var v_nTreeNode = treeViewElem.selectSingleNode( ".//treeNode[@label='Node A1']" );
  156. // v_nTreeNode.setAttribute( "checked", "true" );
  157. // var v_nTreeNode = treeViewElem.selectSingleNode( ".//treeNode[@label='Node A2']" );
  158. // v_nTreeNode.setAttribute( "staticCheckbox", "true" );
  159. this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
  160. var dualStructuresCheckBox = document.getElementById( "cbSAPBWDualStructuresSupport" );
  161. dualStructuresCheckBox.checked = "true";
  162. useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
  163. useV5DataServerCheckBox.checked = IMPORTWIZARD.bUseV5DataServer;
  164. if (IMPORTWIZARD.bDisableClassic == "true")
  165. //useV5DataServerCheckBox.disabled=true;
  166. useV5DataServerCheckBox.style.display = "none";
  167. var aDoc2 = U_XML.F_CreateDocument();
  168. var listViewElem = aDoc2.appendChild( aDoc2.createElement( 'listView' ) );
  169. listViewElem.setAttribute( "id", "LanguagesListView" );
  170. listViewElem.setAttribute( "showCheckboxes", "true" );
  171. listViewElem.appendChild( aDoc2.createElement( "listItems" ) );
  172. this.m_oListViewCheckboxes = new C_ListView( document.getElementById( "divListViewCheckboxes" ), listViewElem, this );
  173. // TODO: Delete this code, and implement smart picking
  174. // if (supportedLanguagesTable.length > 0)
  175. // {
  176. // var designLanguageEditBox = document.getElementById( "designLanguage" );
  177. // designLanguageEditBox.value = supportedLanguagesTable[0][1];
  178. // picking the deisng locale from the list of CCL loclaes deosn't make sense, even FMUI this behaviour was questionable, but FMUI
  179. // 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
  180. // languages
  181. // 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
  182. // available language locales
  183. // 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
  184. // 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
  185. // best match
  186. // }
  187. ShowPackageRenameDlgIfNeeded();
  188. // For accessibility In edit choice page set the default focus to editvariables
  189. if (IMPORTWIZARD.isEdit)
  190. {
  191. var vfocusElement = document.getElementById("editVariables");
  192. if( vfocusElement )
  193. {
  194. vfocusElement.focus();
  195. }
  196. }
  197. }
  198. G_App.initializeTreeViewCheckBox = function( )
  199. {
  200. this.m_treeViewNodesDoc = U_XML.F_CreateDocument();
  201. var treeViewElem = this.m_treeViewNodesDoc.appendChild( this.m_treeViewNodesDoc.createElement( 'treeView' ) );
  202. treeViewElem.setAttribute( "id", "TreeView" );
  203. treeViewElem.setAttribute( "showCheckboxes", "true" );
  204. this.PopulateTreeView_RootNode( this.m_treeViewNodesDoc, treeViewElem );
  205. this.m_oTreeViewCheckboxes = new C_TreeView( document.getElementById( "divTreeViewCheckboxes" ), treeViewElem, this );
  206. // delete the maps
  207. mapCubeAliasLanguages = new Object();
  208. mapCubeDimTables = new Object();
  209. }
  210. function selectFirstItemInTreeControl()
  211. {
  212. //var v_nTreeView = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
  213. //var v_elSpanFirst = v_nTreeView.F_GetFirstVisibleTreeItem();
  214. var v_elSpanFirst = G_App.m_oTreeViewCheckboxes.F_GetFirstVisibleTreeItem();
  215. if ( v_elSpanFirst )
  216. {
  217. v_elSpanFirst.focus();
  218. }
  219. }
  220. G_App.F_ResManager_OnStringsLoaded = function( v_aFiles )
  221. {
  222. G_ResManager.F_LoadResources( [ WEB_CONTENT + "/mdsrv/res/EditVariablesResources.xml" ],this );
  223. };
  224. G_App.F_ResManager_OnResourcesLoaded = function( v_aFiles )
  225. {
  226. //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.
  227. this.initControls();
  228. }
  229. function retrieveImportSpec()
  230. {
  231. var getImportSpecRequestURL = GATEWAY_URL + "/metadataUIService";
  232. D_Progress.F_DisableCancel();
  233. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"] );
  234. var getImportSpecRequestPostParams = {};
  235. getImportSpecRequestPostParams["pid"] = "importWizard_ImportSpec_pid";
  236. getImportSpecRequestPostParams["packageLocation"] = IMPORTWIZARD.packageLocation;
  237. getImportSpecRequestPostParams["packageName"] = IMPORTWIZARD.packageName;
  238. getImportSpecRequestPostParams["error_pid"] = asyncErrorPagePid;
  239. IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
  240. hideProgressIfShowing();
  241. }
  242. urlRequestInvoker.MakeAsyncRequestInIFrame( getImportSpecRequestURL, getImportSpecRequestPostParams );
  243. }
  244. function GenerateJSONString( obj )
  245. {
  246. var strObjJSON = "";
  247. for (var i in obj)
  248. {
  249. strObjJSON += "\t\t\"" + i + "\": ";
  250. strObjJSON += "\"" + obj[i] + "\",\n";
  251. }
  252. // The last comma must be removed, in order to have a syntactically correct JSON string.
  253. // Firefox doesn't care about this, but IE fails to work properly if this isn't done.
  254. var lastCommaIndex = strObjJSON.lastIndexOf( ',' );
  255. strObjJSON = "\t{\n" + strObjJSON.substr(0, lastCommaIndex ) + "\n\t}\n";
  256. // alert( "GenerateJSONString\n\n" + strObjJSON ); // Debugging
  257. return strObjJSON;
  258. }
  259. G_App.PopulateTreeView_RootNode = function( aDoc, treeViewElem )
  260. {
  261. var rootNodeElem = treeViewElem.appendChild( aDoc.createElement( "treeNode" ) );
  262. var nodeValueObj = {};
  263. nodeValueObj["type"] = kDatabaseTypeStr;
  264. nodeValueObj["uniqueName"] = kDatabaseTypeStr;
  265. var nodeIcon = GetIconFilePath( kDatabaseTypeStr );
  266. var nodeValue = GenerateJSONString( nodeValueObj );
  267. rootNodeElem.setAttribute( "value", nodeValue );
  268. rootNodeElem.setAttribute( "label", IMPORTWIZARD.dataSourceName);
  269. rootNodeElem.setAttribute( "smallIcon", nodeIcon );
  270. rootNodeElem.setAttribute( "expandedSmallIcon", nodeIcon );
  271. rootNodeElem.setAttribute( "expandable", "true" );
  272. rootNodeElem.setAttribute( "staticCheckbox", "true" );
  273. rootNodeElem.setAttribute( "role", "treeItem" );
  274. rootNodeElem.setAttribute( "tooltip", kDatabaseTypeStr );
  275. };
  276. var bIsLanguagesListPopulated = false;
  277. function PopulateLanguagesListBox()
  278. {
  279. var getLanguagesRequestURL = GATEWAY_URL + "/metadataUIService";
  280. D_Progress.F_DisableCancel();
  281. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Loading"]);
  282. var getLanguagesRequestPostParams = {};
  283. getLanguagesRequestPostParams["pid"] = "importWizard_Languages_pid"
  284. getLanguagesRequestPostParams["datasource"] = IMPORTWIZARD.dataSourceName;
  285. getLanguagesRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
  286. getLanguagesRequestPostParams["useV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false";
  287. getLanguagesRequestPostParams["error_pid"] = asyncErrorPagePid;
  288. urlRequestInvoker.MakeAsyncRequestInIFrame( getLanguagesRequestURL, getLanguagesRequestPostParams );
  289. }
  290. G_App.PopulateLanguagesListView = function(languagesList)
  291. {
  292. var designLocaleList = document.getElementById( "designLanguage" );
  293. for (var i = 0; i < languagesList.length; i++)
  294. {
  295. var newListItemNode = this.m_oListViewCheckboxes.F_AppendNewListItem();
  296. newListItemNode.setAttribute( "value", languagesList[i].localeId );
  297. newListItemNode.setAttribute( "label", languagesList[i].localeName );
  298. newListItemNode.setAttribute( "staticCheckbox", "false" );
  299. newListItemNode.setAttribute( "checked", "false" );
  300. designLocaleList.options[i]=new Option(languagesList[i].localeName, languagesList[i].localeId);
  301. }
  302. bIsLanguagesListPopulated = true;
  303. };
  304. function OnUseV5DataServerBtnClicked( sourceUseV5DataServerChkBox )
  305. {
  306. G_App.m_oTreeViewCheckboxes.F_Detach();
  307. G_App.initializeTreeViewCheckBox();
  308. }
  309. function providerLangResultsReceived( providerLanguages )
  310. {
  311. G_App.PopulateLanguagesListView( providerLanguages.lang );
  312. G_App.m_oListViewCheckboxes.F_Draw();
  313. D_Progress.F_Hide();
  314. urlRequestInvoker.RequestFinished();
  315. // For accessibility Set the focus on the first item of the check box
  316. var v_nFirstListItem = G_App.m_oListViewCheckboxes.F_GetFirstSelectableItem();
  317. if ( v_nFirstListItem )
  318. {
  319. var vaFocus = document.getElementById( v_nFirstListItem.getAttribute( "htmlId" ) );
  320. if( vaFocus )
  321. vaFocus.focus();
  322. }
  323. }
  324. function importSpecReceivedReceived( treeSnippet )
  325. {
  326. D_Progress.F_Hide();
  327. urlRequestInvoker.RequestFinished();
  328. G_App.m_oTreeViewCheckboxes.F_StartAsyncLoad();
  329. var aDoc = G_App.m_treeViewNodesDoc;
  330. var treeViewElem = G_App.m_oTreeViewCheckboxes.F_GetTreeViewNode();
  331. IMPORTWIZARD.dataSourceName = treeSnippet.node.Name; // In edit scenario we didn't know the ds name, so we populate it now
  332. PopulateTreeView( treeSnippet.node, aDoc, treeViewElem );
  333. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */);
  334. selectFirstItemInTreeControl();
  335. }
  336. function SaveModifiedSettings()
  337. {
  338. var saveModifiedSettingsURL = GATEWAY_URL + "/metadataUIService";
  339. D_Progress.F_DisableCancel();
  340. D_Progress.F_Show( null, localizedStrings["MSR_SAP_Saving"]);
  341. var saveModifiedSettingsParams = {};
  342. saveModifiedSettingsParams["pid"] = "saveModifiedPackageSettings_pid";
  343. saveModifiedSettingsParams["searchPath"] = IMPORTWIZARD.packageLocation + "/package[@name=" + EncloseInQuotes( IMPORTWIZARD.packageName ) + "]/model";
  344. saveModifiedSettingsParams["property"] = "http://developer.cognos.com/ceba/constants/queryOptionEnum#mode";
  345. //var useV5DataServerCheckBox = document.getElementById( "ms_useV5DataServer" );
  346. if (useV5DataServerCheckBox.checked)
  347. {
  348. saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#dynamic"; // XQE
  349. }
  350. else
  351. {
  352. saveModifiedSettingsParams["value"] = "http://developer.cognos.com/ceba/constants/queryModeEnum#compatible"; // Legacy query stack
  353. }
  354. saveModifiedSettingsParams["error_pid"] = asyncErrorPagePid;
  355. urlRequestInvoker.MakeAsyncRequestInIFrame( saveModifiedSettingsURL, saveModifiedSettingsParams );
  356. }
  357. function OnSaveModifiedPackageSettingsRequestCompleted()
  358. {
  359. D_Progress.F_Hide();
  360. urlRequestInvoker.RequestFinished();
  361. window.location.replace( IMPORTWIZARD.backURL );
  362. }
  363. //
  364. // Populates the tree view based on data obtained from the server side
  365. // (through a JSP async call).
  366. // This data could be coming from either:
  367. // - the browse JSP (when expanding tree nodes for the first time)
  368. // - the import spec JSP (when editing an existing package)
  369. //
  370. function PopulateTreeView( treeViewNodeData, aDoc, treeViewElem )
  371. {
  372. var nodeLabel = treeViewNodeData.Name;
  373. var nodeType = treeViewNodeData.Type;
  374. var bIsNodeSelected = treeViewNodeData.Selected != null && treeViewNodeData.Selected != "false";
  375. var nodeValueObj = {};
  376. nodeValueObj["type"] = nodeType;
  377. nodeValueObj["uniqueName"] = (treeViewNodeData.uniqueName != null) ? treeViewNodeData.uniqueName : treeViewNodeData.Name;
  378. var nodeValue = GenerateJSONString( nodeValueObj );
  379. var nodeIcon = GetIconFilePath( nodeType );
  380. var nodeExpandedIcon = GetIconFilePath( nodeType );
  381. // var stateSmallIcon = "hal/images/icon_information_16x16.gif";
  382. var bExpandable = (nodeType != kDimensionTypeStr && nodeType != kMeasureTypeStr);
  383. var bHideCheckBox = (nodeType == kDimensionGroupTypeStr || nodeType == kDimensionTypeStr
  384. || nodeType == kMeasuresGroupTypeStr || nodeType == kMeasureTypeStr);
  385. var bStaticCheckBox = (nodeType == kDatabaseTypeStr || nodeType == kCatalogTypeStr);
  386. var bChecked = !bHideCheckBox && bIsNodeSelected;
  387. var nodeElem = treeViewElem.appendChild( aDoc.createElement( "treeNode" ) );
  388. nodeElem.setAttribute( "value", nodeValue );
  389. nodeElem.setAttribute( "label", nodeLabel );
  390. nodeElem.setAttribute( "smallIcon", nodeIcon );
  391. nodeElem.setAttribute( "expandedSmallIcon", nodeExpandedIcon );
  392. // nodeElem.setAttribute( "stateSmallIcon", stateSmallIcon );
  393. nodeElem.setAttribute( "tooltip", nodeType );
  394. nodeElem.setAttribute( "expandable", bExpandable ? "true" : "false" );
  395. nodeElem.setAttribute( "hideCheckbox", bHideCheckBox ? "true" : "false" );
  396. nodeElem.setAttribute( "staticCheckbox", bStaticCheckBox ? "true" : "false" );
  397. nodeElem.setAttribute( "checked", bChecked ? "true" : "false" );
  398. if (treeViewNodeData.children != null)
  399. {
  400. for (var i = 0; i < treeViewNodeData.children.length; i++)
  401. {
  402. PopulateTreeView( treeViewNodeData.children[i], aDoc, nodeElem );
  403. }
  404. }
  405. }
  406. /**
  407. * Used in edit mode, to pass to the browse JSP, the selected nodes recursively.
  408. */
  409. function ExtractSelectedTreeNodes( v_nTreeNode, nodePathEntry )
  410. {
  411. if (v_nTreeNode.childNodes != null && v_nTreeNode.childNodes.length > 0)
  412. {
  413. nodePathEntry.children = [];
  414. for (var i = 0; i < v_nTreeNode.childNodes.length; i++)
  415. {
  416. var childNodeName = v_nTreeNode.childNodes[i].getAttribute( "label" );
  417. var childNodeValue = v_nTreeNode.childNodes[i].getAttribute( "value" );
  418. var childNodeValueObj = eval( "(" + childNodeValue + ")" );
  419. var childNodeType = childNodeValueObj.type;
  420. var childNodeUniqueName = childNodeValueObj.uniqueName;
  421. nodePathEntry.children[i] = {};
  422. nodePathEntry.children[i]["uniqueName"] = childNodeUniqueName;
  423. nodePathEntry.children[i].Selected = "true";
  424. nodePathEntry.children[i].Type = childNodeType;
  425. nodePathEntry.children[i].Value = "false";
  426. nodePathEntry.children[i].Name = childNodeName;
  427. ExtractSelectedTreeNodes( v_nTreeNode.childNodes[i], nodePathEntry.children[i] );
  428. }
  429. }
  430. }
  431. var g_treeNodeBeingPopulated = null;
  432. G_App.F_TreeView_OnPopulateChildren = function( v_oTreeView, v_nTreeNode )
  433. {
  434. //
  435. // Disable the Next & Finish buttons temporarily, to prevent 2 async calls from colliding in the same IFrame.
  436. //
  437. var nextButton = document.getElementById( "nextButton" );
  438. EnableButton( nextButton, false /* bEnable */ );
  439. var finishButton = document.getElementById( "finishButton" );
  440. IMPORTWIZARD.isFinishButtonEnabled = IsButtonEnabled( finishButton );
  441. EnableButton( finishButton, false /* bEnable */ );
  442. var currentNode = v_nTreeNode;
  443. var nodePath = "";
  444. // The nodePath is being build back-wards
  445. do
  446. {
  447. var nodeName = currentNode.getAttribute( "label" );
  448. var nodeValue = currentNode.getAttribute( "value" );
  449. var nodeValueObj = eval( "(" + nodeValue + ")" );
  450. var nodeType = nodeValueObj.type;
  451. var nodeUniqueName = nodeValueObj.uniqueName;
  452. // if the node path is empty then we are at the beginning
  453. var bIsSelectedNode = (nodePath == "");
  454. var nodePathEntry = {};
  455. nodePathEntry.Name = nodeName;
  456. nodePathEntry.Type = nodeType;
  457. nodePathEntry.Value = "false";
  458. if (nodeType == kDatabaseTypeStr)
  459. {
  460. nodePathEntry.dbType = "BW";
  461. var dualStructuresCheckBox = document.getElementById( "cbSAPBWDualStructuresSupport" );
  462. nodePathEntry.dualStructures = dualStructuresCheckBox.checked ? "true" : "false";
  463. nodePathEntry.isSystem = "false";
  464. }
  465. else
  466. {
  467. nodePathEntry.uniqueName = nodeUniqueName;
  468. }
  469. if (bIsSelectedNode)
  470. {
  471. nodePathEntry.Selected = "true";
  472. nodePathEntry.expansion = "true";
  473. ExtractSelectedTreeNodes( v_nTreeNode, nodePathEntry );
  474. }
  475. strNodePathEntry = JSON.stringify( nodePathEntry, null, "\t" );
  476. var nodePathEntryPostfix = (currentNode == v_nTreeNode) ? "\n" : ",\n";
  477. nodePath = strNodePathEntry + nodePathEntryPostfix + nodePath;
  478. currentNode = currentNode.parentNode;
  479. }
  480. while (currentNode != null && currentNode.tagName == "treeNode");
  481. nodePath = "{\"node\":[\n" + nodePath + "]}";
  482. g_treeNodeBeingPopulated = v_nTreeNode;
  483. var browseTreeRequestURL = GATEWAY_URL + "/metadataUIService";
  484. var browseTreeRequestPostParams = {};
  485. browseTreeRequestPostParams["pid"] = "importWizard_GetTreeNodes_pid";
  486. browseTreeRequestPostParams["connectionName"] = IMPORTWIZARD.dataSourceName;
  487. browseTreeRequestPostParams["nodePath"] = nodePath;
  488. browseTreeRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
  489. browseTreeRequestPostParams["error_pid"] = asyncErrorPagePid;
  490. browseTreeRequestPostParams["useV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false";
  491. IMPORTWIZARD.onResumeFromRecoveredErrorHandler = function()
  492. {
  493. urlRequestInvoker.RequestFinished();
  494. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( false /* v_bSucceeded */ );
  495. g_treeNodeBeingPopulated = null;
  496. if (this.retry)
  497. {
  498. this.retry = false;
  499. G_App.m_oTreeViewCheckboxes.F_ExpandNode(v_nTreeNode);
  500. }
  501. };
  502. IMPORTWIZARD.onResumeFromNonRecoverableError = function()
  503. {
  504. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( false /* v_bSucceeded */ );
  505. g_treeNodeBeingPopulated = null;
  506. urlRequestInvoker.RequestFinished();
  507. }
  508. urlRequestInvoker.MakeAsyncRequestInIFrame( browseTreeRequestURL, browseTreeRequestPostParams );
  509. // WHAT IS THIS USEFULL FOR ????
  510. // if ( v_nTreeNode.firstChild || ( v_nTreeNode.getAttribute( "hasFetchedChildren" ) == "true" ) )
  511. // {
  512. // return;
  513. // }
  514. //
  515. // v_nTreeNode.setAttribute( "hasFetchedChildren", "true" );
  516. //
  517. // var v_bIsSearch = ( v_nTreeNode.getAttribute( "isSearchNode" ) == "true" );
  518. // var v_sSearchPath = v_nTreeNode.getAttribute( "searchPath" );
  519. // if ( v_nTreeNode.getAttribute( "isSearchNode" ) != "true" )
  520. // {
  521. // v_sSearchPath += "/*";
  522. // }
  523. // this.m_oRequest = G_ContentManager.F_CreateCMRequest( this, v_sSearchPath );
  524. // this.m_oRequest.F_Send();
  525. // this.m_nCurrentNode = v_nTreeNode;
  526. return true;
  527. };
  528. G_App.F_HAL_OnUnLoad = function()
  529. {
  530. this.m_oTreeViewCheckboxes.F_Detach();
  531. this.m_oListViewCheckboxes.F_Detach();
  532. if (this.m_oPropertySheet != null)
  533. {
  534. this.m_oPropertySheet.F_Detach();
  535. }
  536. };
  537. G_App.F_ApplySkin = function( v_sSkin )
  538. {
  539. // Build the path to the appropriate skin css file
  540. var v_aSkin = v_sSkin.split( "|" );
  541. var v_sSkinName = v_aSkin[0];
  542. var v_sSkinType = v_aSkin[1];
  543. var v_sSkinPath = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_portal_skin.css";
  544. var v_sSkinPath2 = WEB_CONTENT + "/skins/" + v_sSkinName + "/hal/hal_skin.css";
  545. // Remove existing link tag to skin css
  546. var v_nExistingCSSNode = document.getElementById( "idHALSkinCSS" );
  547. if ( v_nExistingCSSNode )
  548. {
  549. v_nExistingCSSNode.parentNode.removeChild( v_nExistingCSSNode );
  550. }
  551. // Create and append new link tag to skin css
  552. var v_elHead = document.getElementsByTagName( "head" )[0];
  553. var v_elLinkCSS = document.createElement( "link" );
  554. v_elLinkCSS.id = "idHALSkinCSS";
  555. v_elLinkCSS.type = "text/css";
  556. v_elLinkCSS.rel = "stylesheet";
  557. v_elLinkCSS.href = v_sSkinPath;
  558. v_elHead.appendChild( v_elLinkCSS );
  559. var v_elLinkCSS2 = document.createElement( "link" );
  560. v_elLinkCSS2.id = "idHALSkinCSS";
  561. v_elLinkCSS2.type = "text/css";
  562. v_elLinkCSS2.rel = "stylesheet";
  563. v_elLinkCSS2.href = v_sSkinPath2;
  564. v_elHead.appendChild( v_elLinkCSS2 );
  565. document.body.style.backgroundColor = ( v_sSkinType == "portal" ) ? "#FFFFFF" : "";
  566. // Set skin value in cookie
  567. var v_dateExpires = new Date();
  568. v_dateExpires.setUTCFullYear( v_dateExpires.getUTCFullYear() + 1 );
  569. U_CookieJar.F_SetCookie( "skin", v_sSkin, v_dateExpires );
  570. };
  571. G_App.F_Deck_OnBeforeCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
  572. {
  573. };
  574. G_App.F_Deck_OnAfterCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
  575. {
  576. if (v_oDeck == this.m_oDeck)
  577. {
  578. var pageTitles =
  579. [
  580. localizedStrings["MSR_SAP_selectObjectsTitle"],
  581. localizedStrings["MSR_SAP_selectLanguagesTitle"],
  582. localizedStrings["MSR_SAP_generateDimensionsTitle"]
  583. ];
  584. // var pageTitlePostfix = (IMPORTWIZARD.isEdit) ? " &nbsp; <i>[Edit Package Mode]</i>" : "";
  585. document.getElementById( "dialogHeaderTitle" ).innerHTML = pageTitles[v_iNewCardIndex];
  586. UpdateButtonsEnableStatus( v_iNewCardIndex );
  587. if (v_iNewCardIndex == 1 /* languages card index */ && bIsLanguagesListPopulated == false)
  588. {
  589. PopulateLanguagesListBox();
  590. }
  591. else if(v_iNewCardIndex == 2 )
  592. {
  593. //For Accessibility put the focus on the first control of the page
  594. var focusElement = document.getElementById( "radioShortName");
  595. if( focusElement )
  596. {
  597. focusElement.focus();
  598. }
  599. }
  600. }
  601. };
  602. G_App.F_Next = function()
  603. {
  604. var msg = IMPORTWIZARD.checkNext();
  605. if (msg){
  606. alert(msg);
  607. }
  608. else{
  609. this.m_oDeck.F_Next();
  610. }
  611. };
  612. G_App.F_Back = function()
  613. {
  614. this.m_oDeck.F_Back();
  615. };
  616. //
  617. // When a node is checked/unchecked, update the check status of the parent nodes.
  618. //
  619. G_App.F_TreeView_OnNodeCheck = function( v_oTreeView, v_nTreeNode )
  620. {
  621. var currentNode = v_nTreeNode;
  622. while (currentNode.parentNode != null && currentNode.parentNode.tagName == "treeNode")
  623. {
  624. var parentNode = currentNode.parentNode;
  625. var bIsNodeCheckedPrevState = (currentNode.getAttribute( "checked" ) == "true");
  626. // The new state of the check box.
  627. var bIsNodeChecked = !bIsNodeCheckedPrevState;
  628. var bIsParentNodeChecked = (parentNode.getAttribute( "checked" ) == "true");
  629. // The call to F_GetCheckedChildrenNodes doesn't include the current "node check" operation!
  630. var numOfCheckedNodes = G_App.m_oTreeViewCheckboxes.F_GetCheckedChildrenNodes( parentNode ).length;
  631. // The node that triggered the event is not yet included in the F_GetCheckedChildrenNodes result!
  632. if (currentNode == v_nTreeNode)
  633. {
  634. numOfCheckedNodes += bIsNodeChecked ? +1 : -1;
  635. }
  636. parentNode.setAttribute( "checked", numOfCheckedNodes > 0 ? "true" : "false" );
  637. G_App.m_oTreeViewCheckboxes.F_UpdateNode( parentNode );
  638. currentNode = parentNode;
  639. }
  640. };
  641. G_App.F_TreeView_OnNodeClick = function( v_oTreeView, v_nTreeNode, v_iMouseButton )
  642. {
  643. };
  644. G_App.F_TreeView_OnNodeDblClick = function( v_oTreeView, v_nTreeNode )
  645. {
  646. };
  647. function IsButtonEnabled( button )
  648. {
  649. return (button.className == "commandButton");
  650. }
  651. // Enables the button (if bEnable is true), or disables it (if bEnable is false).
  652. // It preserves and restores the OnClick and OnDblClick events properly.
  653. function EnableButton( button, bEnable )
  654. {
  655. var prevEnabledState = IsButtonEnabled( button );
  656. if (bEnable == true /*&& button.className == "commandButtonInactiveII"*/)
  657. {
  658. button.className = "commandButton";
  659. button.onmouseover = function( e ) { this.className = "commandButtonOver"; };
  660. button.onmouseout = function( e ) { this.className = "commandButton"; };
  661. button.onmousedown = function( e ) { this.className = "commandButton"; };
  662. button.onkeypress = handle_onkeydown;
  663. button.children[0].tabIndex = 0;
  664. if (prevEnabledState == false)
  665. {
  666. if (button.onclick_enabled != null)
  667. {
  668. button.onclick = button.onclick_enabled;
  669. }
  670. if (button.ondblclick_enabled != null)
  671. {
  672. button.ondblclick = button.ondblclick_enabled;
  673. }
  674. }
  675. }
  676. else if (bEnable == false)
  677. {
  678. button.className = "commandButtonInactiveII";
  679. button.onmouseover = null;
  680. button.onmouseout = null;
  681. button.onmousedown = null;
  682. button.onkeypress = null;
  683. button.children[0].tabIndex = -1;
  684. // preserve the previous event handlers
  685. if (prevEnabledState == true)
  686. {
  687. button.onclick_enabled = button.onclick;
  688. button.ondblclick_enabled = button.ondblclick;
  689. }
  690. button.onclick = "";
  691. button.ondblclick = "";
  692. }
  693. }
  694. function UpdateButtonsEnableStatus( cardIndex )
  695. {
  696. var prevButton = document.getElementById( "prevButton" );
  697. var bEnablePrevButton = (cardIndex != 0);
  698. if (bEnablePrevButton)
  699. {
  700. prevButton.onclick = function( e ) { G_App.F_Back(); };
  701. prevButton.ondblclick = function( e ) { G_App.F_Back(); };
  702. }
  703. EnableButton( prevButton, bEnablePrevButton );
  704. var nextButton = document.getElementById( "nextButton" );
  705. var bEnableNextButton = (cardIndex != G_App.m_oDeck.F_GetNumberOfCards() - 1);
  706. if (bEnableNextButton)
  707. {
  708. nextButton.onclick = function( e ) { G_App.F_Next(); };
  709. nextButton.ondblclick = function( e ) { G_App.F_Next(); };
  710. }
  711. EnableButton( nextButton, bEnableNextButton );
  712. var finishButton = document.getElementById( "finishButton" );
  713. var bEnableFinishButton = (cardIndex == G_App.m_oDeck.F_GetNumberOfCards() - 1);
  714. if (bEnableFinishButton)
  715. {
  716. finishButton.onclick = function( e ) { WizardDone(); };
  717. finishButton.ondblclick = function( e ) { WizardDone(); };
  718. EnableButton( finishButton, bEnableFinishButton );
  719. }
  720. }
  721. function WizardDone()
  722. {
  723. // Build the importSpec object
  724. var treeNodesList = G_App.m_oTreeViewCheckboxes.F_GetCheckedNodes();
  725. if (treeNodesList.length == 0)
  726. {
  727. alert( "No objects have been selected for the import.\n\nImport action cancelled.\n" );
  728. return;
  729. }
  730. var treeNodesPaths = [];
  731. for (var n = 0; n < treeNodesList.length; n++)
  732. {
  733. var treeNode = treeNodesList.item( n );
  734. treeNodesPaths[n] = GetTreeNodePath( treeNode );
  735. // var nodeName = treeNode.getAttribute( "label" );
  736. // var nodeValue = treeNode.getAttribute( "value" );
  737. //
  738. // var nodeValueObj = eval( "(" + nodeValue + ")" );
  739. // var nodeType = nodeValueObj.type;
  740. // var nodeUniqueName = nodeValueObj.uniqueName;
  741. // alert( nodeName + " " + nodeValue );
  742. }
  743. ConsolidateTree( treeNodesPaths, 0 /* referenceNodeIndex */ );
  744. if (treeNodesPaths.length != 1)
  745. {
  746. alert( "ASSERT FAILED: The number tree objects must be 1!\n\nIt is currently: " + treeNodesPaths.length );
  747. }
  748. var importSpec = {};
  749. importSpec["node"] = [];
  750. importSpec["node"][0] = treeNodesPaths[0];
  751. var strImportSpec = JSON.stringify( importSpec, null, "\t" );
  752. // Build the parameters object
  753. var nodeList = G_App.m_oListViewCheckboxes.F_GetCheckedListItems();
  754. var selectedLanguages = [];
  755. var selectedLanguagesCodes = [];
  756. for (var i = 0; i < nodeList.length; i++)
  757. {
  758. var listItem = nodeList.item( i );
  759. var langCode = listItem.getAttribute( "value" );
  760. var langName = listItem.getAttribute( "label" );
  761. selectedLanguages.push( langName );
  762. selectedLanguagesCodes.push( langCode );
  763. }
  764. var shortNameRadioBtn = document.getElementById( "radioShortName" );
  765. var longNameRadioBtn = document.getElementById( "radioLongName" );
  766. var technicalNameRadioBtn = document.getElementById( "radioTechnicalName" );
  767. var objectName = shortNameRadioBtn.value;
  768. if (longNameRadioBtn.checked)
  769. {
  770. objectName = longNameRadioBtn.value;
  771. }
  772. else if (technicalNameRadioBtn.checked)
  773. {
  774. objectName = technicalNameRadioBtn.value;
  775. }
  776. var enhanceModelForSAPCheckBox = document.getElementById( "enhanceModelForSAP" );
  777. var useV5DataServerCheckBox = document.getElementById( "useV5DataServer" );
  778. var designLocaleCombo = document.getElementById("designLanguage");
  779. var parameters = {};
  780. parameters["params"] = {};
  781. parameters["params"]["ObjectName"] = objectName;
  782. parameters["params"]["ObjectLayout"] = enhanceModelForSAPCheckBox.checked ? "true" : "false";
  783. parameters["params"]["UseV5DataServer"] = useV5DataServerCheckBox.checked ? "true" : "false";
  784. parameters["params"].languages = selectedLanguagesCodes;
  785. parameters["params"].designLocale = designLocaleCombo.options[designLocaleCombo.selectedIndex].value;
  786. var strParameters = JSON.stringify( parameters, null, "\t" );
  787. var pkgInfo = {};
  788. pkgInfo["pkgInfo"]={};
  789. pkgInfo["pkgInfo"]["Name"]=IMPORTWIZARD.packageName;
  790. pkgInfo["pkgInfo"]["Description"]=IMPORTWIZARD.packageDescription;
  791. pkgInfo["pkgInfo"]["ScreenTip"]=IMPORTWIZARD.packageScreentip;
  792. pkgInfo["pkgInfo"]["Location"]=IMPORTWIZARD.packageLocation;
  793. var strPkgInfo = JSON.stringify( pkgInfo, null, "\t" );
  794. IMPORTWIZARD.onResumeFromNonRecoverableError = function(){
  795. hideProgressIfShowing();
  796. }
  797. var importHelper = new ImportHelper(strImportSpec, strParameters, strPkgInfo);
  798. importHelper.runImport();
  799. D_Progress.F_DisableCancel();
  800. D_Progress.F_Show( null, localizedStrings["MSR_SAP_creatingPackage"] );
  801. }
  802. function hideProgressIfShowing()
  803. {
  804. if (D_Progress.F_IsActiveDialog())
  805. {
  806. // hide any progress that may be up
  807. D_Progress.F_Hide();
  808. }
  809. }
  810. function GetTreeNodePath( v_nTreeNode )
  811. {
  812. var currentNode = v_nTreeNode;
  813. var nodePathObj = {};
  814. var bIsLeaf = true;
  815. // The nodePath is being build back-wards
  816. do
  817. {
  818. var nodeLabel = currentNode.getAttribute( "label" );
  819. var nodeValue = currentNode.getAttribute( "value" );
  820. var nodeValueObj = eval( "(" + nodeValue + ")" );
  821. var nodeType = nodeValueObj.type;
  822. var nodeUniqueName = nodeValueObj.uniqueName;
  823. var nodeEntry = {};
  824. nodeEntry.Name = nodeLabel;
  825. nodeEntry.Type = nodeType;
  826. nodeEntry.Value = (nodeType == kDatabaseTypeStr || nodeType == kCatalogTypeStr) ? "partial" : "true";
  827. if (nodeType == kDatabaseTypeStr)
  828. {
  829. nodeEntry.dbType = "BW";
  830. var dualStructuresCheckBox = document.getElementById( "cbSAPBWDualStructuresSupport" );
  831. nodeEntry.dualStructures = dualStructuresCheckBox.checked ? "true" : "false";
  832. nodeEntry.isSystem = "false";
  833. }
  834. else
  835. {
  836. nodeEntry.uniqueName = nodeUniqueName;
  837. }
  838. // if (nodePathObj != undefined)
  839. if (!bIsLeaf)
  840. {
  841. nodeEntry.children = [nodePathObj];
  842. }
  843. nodePathObj = nodeEntry;
  844. currentNode = currentNode.parentNode;
  845. bIsLeaf = false;
  846. }
  847. while (currentNode != null && currentNode.tagName == "treeNode");
  848. return nodePathObj;
  849. }
  850. // The first node in the array will end up containing the cosolidated tree nodes.
  851. function ConsolidateTree( treeNodesPaths, referenceNodeIndex )
  852. {
  853. // Consolidate the various trees (tree node paths) into a single unified tree.
  854. if (referenceNodeIndex < treeNodesPaths.length - 2)
  855. {
  856. ConsolidateTree( treeNodesPaths, referenceNodeIndex + 1);
  857. }
  858. // Traverse the list of nodes in reverse, to be able to remove elements on the fly.
  859. for (var n = treeNodesPaths.length - 1; n > (referenceNodeIndex); n--)
  860. {
  861. var firstTreeNode = treeNodesPaths[referenceNodeIndex];
  862. var currentTreeNode = treeNodesPaths[n];
  863. if (AreObjectsEqual( firstTreeNode, currentTreeNode, ["children"] ))
  864. {
  865. // var strTreeNodePathBEFORE = JSON.stringify( firstTreeNode, null, "\t" );
  866. // alert( "(BEFORE) same root node found\n\n\""
  867. /// + strTreeNodePathBEFORE);
  868. if (firstTreeNode.children == undefined || firstTreeNode.children == null)
  869. {
  870. firstTreeNode.children = currentTreeNode.children;
  871. }
  872. else
  873. {
  874. firstTreeNode.children = firstTreeNode.children.concat( currentTreeNode.children );
  875. }
  876. // node already processed; remove it from the collection.
  877. treeNodesPaths.splice( n, 1 );
  878. ConsolidateTree( firstTreeNode.children, 0 /* referenceNodeIndex */ );
  879. // var strTreeNodePathAFTER = JSON.stringify( firstTreeNode, null, "\t" );
  880. // alert( "(AFTER) same root node found\n\n\""
  881. // + strTreeNodePathAFTER);
  882. }
  883. }
  884. }
  885. G_App.F_OnCancel = function()
  886. {
  887. D_Progress.F_Hide();
  888. };
  889. function GetIconFilePath( objectType )
  890. {
  891. // hal/images/tv_folder.gif hal/images/tv_folder_expanded.gif
  892. //
  893. // This directory has all the images necessary:
  894. // C:\Program Files\cognos\c8.5.17.3_Colorado_2009-02-13\webcontent\pat\images
  895. var iconDirPath = WEB_CONTENT + "/mdsrv/importWizardUI/images/";
  896. //
  897. // This is NOT an associative array, but rather a HACK,
  898. // where the keys are actually elements of the object properties.
  899. //
  900. var iconMap = [];
  901. iconMap[kDatabaseTypeStr] = iconDirPath + "icon_data_source.gif";
  902. iconMap[kCatalogTypeStr] = iconDirPath + "icon_catalog.gif";
  903. iconMap[kCubeTypeStr] = iconDirPath + "icon_cube.gif";
  904. iconMap[kInfoQueryTypeStr] = iconDirPath + "icon_info_query.gif";
  905. iconMap[kDimensionGroupTypeStr] = iconDirPath + "icon_folder_dimensions.gif";
  906. iconMap[kDimensionTypeStr] = iconDirPath + "icon_dimension.gif";
  907. iconMap[kMeasuresGroupTypeStr] = iconDirPath + "icon_folder_measures.gif";
  908. iconMap[kMeasureTypeStr] = iconDirPath + "icon_measure.gif";
  909. iconMap["unknown"] = WEB_CONTENT + "/hal/images/btn_new.gif";
  910. var objectIconFilePath = iconMap[objectType];
  911. if (objectIconFilePath == null)
  912. {
  913. objectIconFilePath = iconMap["unknown"];
  914. }
  915. return objectIconFilePath;
  916. }
  917. function metadataTreeResultsReceived( treeSnippet )
  918. {
  919. if (g_treeNodeBeingPopulated == null)
  920. {
  921. return;
  922. }
  923. if (treeSnippet == null)
  924. {
  925. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
  926. g_treeNodeBeingPopulated = null;
  927. urlRequestInvoker.RequestFinished();
  928. return;
  929. }
  930. // This function will clear only the child nodes.
  931. G_App.m_oTreeViewCheckboxes.F_Clear( g_treeNodeBeingPopulated );
  932. for (var i = 0; i < treeSnippet.node.children.length; i++)
  933. {
  934. var aDoc = G_App.m_treeViewNodesDoc;
  935. PopulateTreeView( treeSnippet.node.children[i], aDoc, g_treeNodeBeingPopulated );
  936. }
  937. G_App.m_oTreeViewCheckboxes.F_EndAsyncLoad( true /* v_bSucceeded */ );
  938. g_treeNodeBeingPopulated = null;
  939. urlRequestInvoker.RequestFinished();
  940. //
  941. // Re-enable the Next and Finish buttons
  942. //
  943. var nextButton = document.getElementById( "nextButton" );
  944. EnableButton( nextButton, true /* bEnable */ );
  945. var finishButton = document.getElementById( "finishButton" );
  946. EnableButton( finishButton, IMPORTWIZARD.isFinishButtonEnabled /* bEnable */ );
  947. }
  948. function HandleException(jsonExceptionObj)
  949. {
  950. hideProgressIfShowing();
  951. var errorPageMgr = new ErrorPageManager();
  952. if (jsonExceptionObj.isQF)
  953. {
  954. document.getElementById( "main" ).style.display = "none";
  955. errorPageMgr.handleQF(jsonExceptionObj.faultDom, ErrorPageClosed);
  956. }
  957. else if (jsonExceptionObj.isCAM)
  958. {
  959. document.getElementById( "main" ).style.display = "none";
  960. errorPageMgr.handleCAM(jsonExceptionObj, ErrorPageClosed);
  961. }
  962. else
  963. {
  964. var msg = jsonExceptionObj.messageString;
  965. if (msg === "")
  966. {
  967. msg = localizedStrings["MSR_SAP_unknownErrorMessage"];
  968. }
  969. var stackTrace = jsonExceptionObj.stackTrace;
  970. stackTrace = unescape(stackTrace);
  971. document.getElementById( "main" ).style.display = "none";
  972. document.getElementById( "editSelection" ).style.display = "none"
  973. errorPageMgr.setupAndDisplayErrorPage(localizedStrings["MSR_SAP_errorPageTitle"], "",
  974. msg, stackTrace, ErrorPageClosed);
  975. }
  976. }
  977. function ErrorPageClosed(recovered)
  978. {
  979. document.getElementById("main").style.display = "block";
  980. // If its been recovered, then we presume that call back will occur at a later time
  981. if (IMPORTWIZARD.onResumeFromNonRecoverableError && !recovered){
  982. IMPORTWIZARD.onResumeFromNonRecoverableError();
  983. }
  984. }
  985. function launchFromEdit()
  986. {
  987. var selectMetadataRadioBtn = document.getElementById( "modifyMetadataSelections" );
  988. var editVariablesRadioBtn = document.getElementById( "editVariables" );
  989. var modifySettingsRadioBtn = document.getElementById( "modifySettings" );
  990. var editSelectionPage = document.getElementById( "editSelection" );
  991. if (selectMetadataRadioBtn.checked)
  992. {
  993. editSelectionPage.style.display = "none";
  994. var main = document.getElementById( "main" );
  995. main.style.display = "block";
  996. retrieveImportSpec();
  997. }
  998. else if (editVariablesRadioBtn.checked)
  999. {
  1000. editSelectionPage.style.display = "none";
  1001. OnShowVariables();
  1002. }
  1003. else if (modifySettingsRadioBtn.checked)
  1004. {
  1005. SaveModifiedSettings();
  1006. }
  1007. }
  1008. function ImportHelper(importSpec, parameters, packageInfo)
  1009. {
  1010. this.m_importSpec = importSpec;
  1011. this.m_parameters = parameters;
  1012. this.m_packageInfo = packageInfo;
  1013. }
  1014. ImportHelper.prototype.runImport = function()
  1015. {
  1016. var importRequestURL = GATEWAY_URL + "/metadataUIService"
  1017. this.m_requestId = new Date().getTime();
  1018. var importRequestPostParams = {};
  1019. importRequestPostParams["pid"] = "importWizard_Import_pid";
  1020. importRequestPostParams["importSpec"] = this.m_importSpec;
  1021. importRequestPostParams["parameters"] = this.m_parameters;
  1022. importRequestPostParams["packageInfo"] = this.m_packageInfo;
  1023. importRequestPostParams["requestId"] = this.m_requestId;
  1024. importRequestPostParams["dataSourceCredentials"] = IMPORTWIZARD.credentials;
  1025. importRequestPostParams["error_pid"] = asyncErrorPagePid;
  1026. urlRequestInvoker.MakeAsyncRequestInIFrame( importRequestURL, importRequestPostParams );
  1027. }