CDrillManager.js 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2019
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /**
  13. CDrillManager -- shared class between Query Studio and Report Viewer, which handles drill up/down and drill through
  14. */
  15. function CtxArrayPlaceHolder(){}
  16. var self = window;
  17. // CDrillManager constructor
  18. function CDrillManager(oCV)
  19. {
  20. this.m_drawDrillTargets = false;
  21. this.setCV(oCV);
  22. }
  23. CDrillManager.prototype = new CViewerHelper();
  24. CDrillManager.prototype.getSelectionController = function()
  25. {
  26. var selectionController;
  27. try
  28. {
  29. selectionController = getCognosViewerSCObjectRef(this.getCV().getId());
  30. }
  31. catch(e)
  32. {
  33. selectionController = null;
  34. }
  35. return selectionController;
  36. };
  37. CDrillManager.prototype.getSelectedObject = function()
  38. {
  39. var selectionController = this.getSelectionController();
  40. if(selectionController == null)
  41. {
  42. return null;
  43. }
  44. var SelObj = null;
  45. var selectionList = null;
  46. if (selectionController.hasSelectedChartNodes()) {
  47. selectionList = selectionController.getSelectedChartNodes();
  48. } else {
  49. selectionList = selectionController.getSelections();
  50. }
  51. if(selectionList && selectionList.length == 1) {
  52. SelObj = selectionList[0];
  53. }
  54. return SelObj;
  55. };
  56. /***************************************************************************************************
  57. COMMON METHODS BETWEEN REPORT VIEWER AND QUERY STUDIO
  58. ****************************************************************************************************/
  59. CDrillManager.prototype.canDrillUp = function()
  60. {
  61. if(this.getDrillOption('drillUp') == true && this.hasMuns()) {
  62. return true;
  63. }
  64. return false;
  65. };
  66. CDrillManager.prototype.canDrillDown = function()
  67. {
  68. if(this.getDrillOption('drillDown') == true)
  69. {
  70. return true;
  71. }
  72. return false;
  73. };
  74. CDrillManager.prototype.hasMuns = function(selectionObj)
  75. {
  76. // if no selection object is passed in, get the current selected object from the selection controller
  77. if(typeof selectionObj == "undefined") {
  78. selectionObj = this.getSelectedObject();
  79. }
  80. if(selectionObj == null) {
  81. return false;
  82. }
  83. var munArray = selectionObj.getMuns();
  84. var muns="";
  85. for(var munIdx = 0; munIdx < munArray.length && muns == ""; ++munIdx)
  86. {
  87. if(typeof munArray[munIdx][0] != "undefined") {
  88. muns += munArray[munIdx][0];
  89. }
  90. }
  91. return (muns != "");
  92. };
  93. CDrillManager.prototype.getRefQuery = function()
  94. {
  95. var refQuery = "";
  96. var selectionObj = this.getSelectedObject();
  97. if(selectionObj == null) {
  98. return "";
  99. }
  100. var refQueries = selectionObj.getRefQueries();
  101. // for area charts, having a ctx of ::1:: is valid, so look for the first non empty refQuery
  102. for (var i=0; i < refQueries.length; i++) {
  103. if (refQueries[i] != null) {
  104. for (var j=0; j < refQueries[i].length; j++) {
  105. if (refQueries[i][j] != null && refQueries[i][j] != "") {
  106. return refQueries[i][j];
  107. }
  108. }
  109. }
  110. }
  111. return refQuery;
  112. };
  113. CDrillManager.prototype.isIsolated = function()
  114. {
  115. var selectionController = this.getSelectionController();
  116. if(selectionController == null || selectionController.getDrillUpDownEnabled() == false)
  117. {
  118. return false;
  119. }
  120. var selectionObj = this.getSelectedObject();
  121. if(selectionObj == null)
  122. {
  123. return false;
  124. }
  125. if(selectionObj instanceof CSelectionChartObject && selectionController != null)
  126. {
  127. var chartArea = selectionObj.getArea();
  128. if(chartArea != null)
  129. {
  130. var isolated = chartArea.getAttribute("isolated");
  131. if(typeof isolated != "undefined" && isolated != null && isolated == "true")
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. else
  138. {
  139. var cellRef = selectionObj.getCellRef();
  140. if(typeof cellRef == "object" && cellRef != null)
  141. {
  142. var spanElement = cellRef.getElementsByTagName("span");
  143. if(spanElement != null && typeof spanElement != "undefined" && spanElement.length > 0)
  144. {
  145. var sIsolated = spanElement[0].getAttribute("isolated");
  146. if(sIsolated != null && sIsolated != "undefined" && sIsolated == "true")
  147. {
  148. return true;
  149. }
  150. }
  151. }
  152. }
  153. return false;
  154. };
  155. CDrillManager.prototype.getDrillOption = function(drillOption)
  156. {
  157. var selectionController = this.getSelectionController();
  158. if(selectionController == null || selectionController.getDrillUpDownEnabled() == false || typeof drillOption == "undefined")
  159. {
  160. return false;
  161. }
  162. var selectionObj = this.getSelectedObject();
  163. if(selectionObj == null)
  164. {
  165. return false;
  166. }
  167. if (this.isIsolated())
  168. {
  169. if (drillOption == "drillDown")
  170. {
  171. return false;
  172. }
  173. else if (drillOption == "drillUp")
  174. {
  175. return true;
  176. }
  177. }
  178. if(drillOption == "drillDown")
  179. {
  180. if(selectionObj instanceof CSelectionChartObject && selectionController != null)
  181. {
  182. var chartArea = selectionObj.getArea();
  183. if(chartArea != null)
  184. {
  185. var bIsChartTitle = chartArea.getAttribute("isChartTitle");
  186. if (typeof bIsChartTitle != "undefined" && bIsChartTitle != null && bIsChartTitle == "true")
  187. {
  188. return false;
  189. }
  190. }
  191. }
  192. }
  193. var drillOptions = selectionObj.getDrillOptions();
  194. //Normally, look at the level closest to the data to determine if you can drill up or down on a particular node or cell.
  195. //But...when the drill submenu is enabled, return true if you can drill up/down on upper levels as well...because all items are in the menu.
  196. var processAllLevels = (typeof DrillContextMenuHelper !== "undefined" && DrillContextMenuHelper.needsDrillSubMenu(this.m_oCV));
  197. for(var idx = 0; idx < drillOptions.length; ++idx)
  198. {
  199. var maxLevel=(processAllLevels) ? drillOptions[idx].length : 1;
  200. for (var level = 0; level < maxLevel; ++level) {
  201. var currentDrillOption = drillOptions[idx][level];
  202. if(currentDrillOption == "3" /*drill up and down*/)
  203. {
  204. return true;
  205. }
  206. else if(drillOption == "drillUp" && currentDrillOption == "1")
  207. {
  208. return true;
  209. }
  210. else if(drillOption == "drillDown" && currentDrillOption == "2")
  211. {
  212. return true;
  213. }
  214. }
  215. }
  216. // if the drill option flag is not present, the user cannot drill on this cell
  217. return false;
  218. };
  219. CDrillManager.prototype.canDrillThrough = function()
  220. {
  221. var selectionController = this.getSelectionController();
  222. if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  223. {
  224. return false;
  225. }
  226. return true;
  227. };
  228. /**
  229. * Returns true if we did a drill up/down action
  230. */
  231. CDrillManager.prototype.singleClickDrillEvent = function(evt, app)
  232. {
  233. var selectionController = this.getSelectionController();
  234. if (selectionController != null)
  235. {
  236. if(this.getCV().bCanUseCognosViewerSelection == true)
  237. {
  238. selectionController.pageClicked(evt);
  239. }
  240. }
  241. var node = getCrossBrowserNode(evt);;
  242. try
  243. {
  244. if(node.className && node.className.indexOf("dl") == 0)
  245. {
  246. if(this.canDrillDown())
  247. {
  248. this.singleClickDrillDown(evt, app);
  249. return true;
  250. }
  251. else if(this.canDrillUp())
  252. {
  253. this.singleClickDrillUp(evt, app);
  254. return true;
  255. }
  256. }
  257. }
  258. catch (e)
  259. {
  260. }
  261. if(app == 'RV')
  262. {
  263. return this.getDrillThroughParameters('execute', evt);
  264. }
  265. return false;
  266. };
  267. CDrillManager.prototype.singleClickDrillDown = function(evt, app /*either 'qs' or 'rv'*/)
  268. {
  269. if(app == 'QS') {
  270. this.qsDrillDown();
  271. }
  272. else {
  273. this.rvDrillDown();
  274. }
  275. };
  276. CDrillManager.prototype.singleClickDrillUp = function(evt, app /*either 'QS' or 'RV'*/)
  277. {
  278. if(app == 'QS') {
  279. this.qsDrillUp();
  280. }
  281. else {
  282. this.rvDrillUp();
  283. }
  284. };
  285. CDrillManager.prototype.getDrillParameters = function(drillType, includeMetadata, bIsSyncDrill, userSelectedDrillItem)
  286. {
  287. var drillParamsArray = [];
  288. var selectionObj = this.getSelectedObject();
  289. if(selectionObj == null) {
  290. return drillParamsArray; // return an empty array
  291. }
  292. if(typeof includeMetadata == "undefined")
  293. {
  294. includeMetadata = true;
  295. }
  296. var dataItemsArray = selectionObj.getDataItems();
  297. var munArray = selectionObj.getMuns();
  298. var lunArray = selectionObj.getDimensionalItems("lun");
  299. var hunArray = selectionObj.getDimensionalItems("hun");
  300. var drillOptions = selectionObj.getDrillOptions();
  301. if(typeof dataItemsArray == "undefined" || typeof munArray == "undefined" || typeof drillOptions == "undefined" || munArray == null || dataItemsArray == null || drillOptions == null) {
  302. return drillParamsArray; // return an empty array
  303. }
  304. if(munArray.length != dataItemsArray.length) {
  305. return drillParamsArray; // return an empty array
  306. }
  307. var num_of_items = munArray.length;
  308. for(var item_idx = 0; item_idx < num_of_items; ++item_idx) {
  309. if(dataItemsArray[item_idx].length != 0) {
  310. var iLevel=(userSelectedDrillItem) ? this.findUserSelectedDrillItem(userSelectedDrillItem, dataItemsArray[item_idx])
  311. : 0;
  312. if (iLevel<0) {
  313. continue;
  314. }
  315. if( (bIsSyncDrill === true) || this.getDrillOption(drillType))
  316. {
  317. if(munArray[item_idx][iLevel] == "" || drillParamsArray.toString().indexOf(munArray[item_idx][iLevel],0) == -1) {
  318. drillParamsArray[drillParamsArray.length] = dataItemsArray[item_idx][iLevel];
  319. drillParamsArray[drillParamsArray.length] = munArray[item_idx][iLevel];
  320. if(includeMetadata === true)
  321. {
  322. drillParamsArray[drillParamsArray.length] = lunArray[item_idx][iLevel];
  323. drillParamsArray[drillParamsArray.length] = hunArray[item_idx][iLevel];
  324. }
  325. }
  326. }
  327. }
  328. }
  329. return drillParamsArray;
  330. };
  331. /**
  332. * return the level within a list of data items where an item matching the userSelectedDrillItem was found.
  333. * return -1 if not found.
  334. */
  335. CDrillManager.prototype.findUserSelectedDrillItem = function(userSelectedDrillItem, dimDataItems) {
  336. for (var iLevel=0; iLevel<dimDataItems.length; ++iLevel) {
  337. if (userSelectedDrillItem==dimDataItems[iLevel]) {
  338. return iLevel;
  339. }
  340. }
  341. return -1; //Not found...
  342. };
  343. CDrillManager.prototype.getModelDrillThroughContext = function(XMLBuilderLocation)
  344. {
  345. var modelDrillContext="";
  346. if(this.canDrillThrough() === true)
  347. {
  348. if(typeof gUseNewSelectionContext == "undefined")
  349. {
  350. var modelPath = "";
  351. if(typeof getConfigFrame != "undefined")
  352. {
  353. modelPath = decodeURIComponent(getConfigFrame().cfgGet("PackageBase"));
  354. }
  355. else if(this.getCV().getModelPath() !== "")
  356. {
  357. modelPath = this.getCV().getModelPath();
  358. }
  359. modelDrillContext = getViewerSelectionContext(this.getSelectionController(), new CSelectionContext(modelPath));
  360. }
  361. else
  362. {
  363. var parameterValues = new CParameterValues();
  364. var selectionController = this.getSelectionController();
  365. if(selectionController) {
  366. var selectionList = selectionController.getAllSelectedObjects();
  367. for(var sel_idx = 0; sel_idx < selectionList.length; ++ sel_idx) {
  368. var selectionObj = selectionList[sel_idx];
  369. var munArray = selectionObj.getMuns();
  370. var metaDataItems = selectionObj.getMetadataItems();
  371. var useValues = selectionObj.getUseValues();
  372. for(var context_idx = 0; context_idx < metaDataItems.length; ++context_idx) {
  373. for(var idx = 0; idx < metaDataItems[context_idx].length; ++idx) {
  374. if(metaDataItems[context_idx][idx] == null || metaDataItems[context_idx][idx] == "") {
  375. continue;
  376. }
  377. var name = metaDataItems[context_idx][idx];
  378. var useValue;
  379. // if we have a mun, set it as the use value, otherwise use the useValue we have stored
  380. if(munArray[context_idx][idx] != null && munArray[context_idx][idx] != "") {
  381. useValue = munArray[context_idx][idx];
  382. }
  383. else {
  384. useValue = useValues[context_idx][idx];
  385. }
  386. // set the display value to what we have stored as the use value
  387. var displayValue = useValues[context_idx][idx];
  388. parameterValues.addSimpleParmValueItem(name, useValue, displayValue, "true");
  389. }
  390. }
  391. }
  392. }
  393. var contextElement = XMLBuilderLocation.XMLBuilderCreateXMLDocument("context");
  394. modelDrillContext = parameterValues.generateXML(XMLBuilderLocation, contextElement);
  395. }
  396. }
  397. return modelDrillContext;
  398. };
  399. /***************************************************************************************************
  400. REPORT VIEWER SPECIFIC METHODS
  401. ****************************************************************************************************/
  402. CDrillManager.prototype.rvDrillUp = function(payload)
  403. {
  404. this.getCV().executeAction("DrillUp", payload);
  405. };
  406. CDrillManager.prototype.rvDrillDown = function(payload)
  407. {
  408. this.getCV().executeAction("DrillDown", payload);
  409. };
  410. CDrillManager.prototype.rvBuildXMLDrillParameters = function(drillType, userSelectedDrillItem)
  411. {
  412. var drillParamsArray = this.getDrillParameters(drillType, true, false /*bIsSyncDrill*/, userSelectedDrillItem);
  413. if(drillParamsArray.length == 0)
  414. {
  415. // handle the error
  416. return drillParams; // TODO: drillParams ?? It does not exists here.
  417. }
  418. return this.buildDrillParametersSpecification(drillParamsArray);
  419. };
  420. CDrillManager.prototype.buildDrillParametersSpecification = function(drillParamsArray)
  421. {
  422. var drillParams = '<DrillParameters>';
  423. var idx = 0;
  424. while(idx < drillParamsArray.length) {
  425. drillParams += '<DrillGroup>';
  426. drillParams += '<DataItem>';
  427. drillParams += sXmlEncode(drillParamsArray[idx++]);
  428. drillParams += '</DataItem>';
  429. drillParams += '<MUN>';
  430. drillParams += sXmlEncode(drillParamsArray[idx++]);
  431. drillParams += '</MUN>';
  432. drillParams += '<LUN>';
  433. drillParams += sXmlEncode(drillParamsArray[idx++]);
  434. drillParams += '</LUN>';
  435. drillParams += '<HUN>';
  436. drillParams += sXmlEncode(drillParamsArray[idx++]);
  437. drillParams += '</HUN>';
  438. drillParams += '</DrillGroup>';
  439. }
  440. drillParams += '</DrillParameters>';
  441. return drillParams;
  442. };
  443. CDrillManager.prototype.getAuthoredDrillsForCurrentSelection = function()
  444. {
  445. var sResult = null;
  446. // get the report authored drills
  447. var aReportAuthoredDrills = this.getAuthoredDrillThroughTargets();
  448. if(aReportAuthoredDrills.length > 0)
  449. {
  450. var sAuthoredDrillThroughTargets = "<AuthoredDrillTargets>";
  451. for(var iIndex = 0; iIndex < aReportAuthoredDrills.length; ++iIndex)
  452. {
  453. sAuthoredDrillThroughTargets += eval('"' + aReportAuthoredDrills[iIndex] + '"');
  454. }
  455. sAuthoredDrillThroughTargets += "</AuthoredDrillTargets>";
  456. var cv = this.getCV();
  457. var authoredDrillAction = cv.getAction("AuthoredDrill");
  458. var drillTargetSpecifications = cv.getDrillTargets();
  459. if(drillTargetSpecifications.length > 0)
  460. {
  461. sResult = authoredDrillAction.getAuthoredDrillThroughContext(sAuthoredDrillThroughTargets, drillTargetSpecifications);
  462. }
  463. }
  464. return sResult;
  465. };
  466. CDrillManager.prototype.getAuthoredDrillsForGotoPage = function()
  467. {
  468. var sResult = "";
  469. var rvDrillTargetsNode = this.getAuthoredDrillsForCurrentSelection();
  470. if (rvDrillTargetsNode) {
  471. sResult = XMLBuilderSerializeNode(rvDrillTargetsNode);
  472. }
  473. return sResult;
  474. };
  475. CDrillManager.prototype.launchGoToPage = function(drillTargets, bDirectLaunch)
  476. {
  477. var selectionController = this.getSelectionController();
  478. if((selectionController != null && selectionController.getModelDrillThroughEnabled() == true) || (typeof drillTargets != "undefined" && drillTargets != null && drillTargets != ""))
  479. {
  480. // get the authored drills
  481. var sAuthoredDrills = this.getAuthoredDrillsForGotoPage();
  482. // build up the model drill context
  483. var modelDrillContext = this.getModelDrillThroughContext(self);
  484. var form = document.getElementById("drillForm");
  485. if(form != null) {
  486. document.body.removeChild(form);
  487. }
  488. form = document.createElement("form");
  489. var cvid = this.getCVId();
  490. var warpForm = document.forms["formWarpRequest" + cvid];
  491. form.setAttribute("id", "drillForm");
  492. form.setAttribute("name", "drillForm");
  493. form.setAttribute("target", warpForm.getAttribute("target"));
  494. form.setAttribute("method", "post");
  495. form.setAttribute("action", warpForm.getAttribute("action"));
  496. form.style.display = "none";
  497. document.body.appendChild(form);
  498. if(this.getCV().getModelPath() !== "")
  499. {
  500. form.appendChild(createHiddenFormField("modelPath", this.getCV().getModelPath()));
  501. }
  502. if(typeof warpForm["ui.object"] != "undefined" && warpForm["ui.object"].value != "")
  503. {
  504. form.appendChild(createFormField("drillSource", warpForm["ui.object"].value));
  505. }
  506. else if(typeof this.getCV().envParams["ui.spec"] != "undefined")
  507. {
  508. form.appendChild(createFormField("sourceSpecification", this.getCV().envParams["ui.spec"]));
  509. }
  510. if(sAuthoredDrills != "")
  511. {
  512. form.appendChild(createHiddenFormField("m", "portal/drillthrough.xts"));
  513. form.appendChild(createFormField("invokeGotoPage", "true"));
  514. form.appendChild(createFormField("m", "portal/drillthrough.xts"));
  515. form.appendChild(createFormField("modelDrillEnabled", selectionController.getModelDrillThroughEnabled()));
  516. if(typeof gUseNewSelectionContext == "undefined")
  517. {
  518. form.appendChild(createFormField("newSelectionContext", "true"));
  519. }
  520. }
  521. else
  522. {
  523. if(typeof gUseNewSelectionContext == "undefined")
  524. {
  525. form.appendChild(createHiddenFormField("m", "portal/goto2.xts"));
  526. }
  527. else
  528. {
  529. form.appendChild(createHiddenFormField("m", "portal/goto.xts"));
  530. }
  531. }
  532. form.appendChild(createHiddenFormField("b_action", "xts.run"));
  533. form.appendChild(createHiddenFormField("drillTargets", sAuthoredDrills));
  534. if(typeof gUseNewSelectionContext == "undefined")
  535. {
  536. form.appendChild(createHiddenFormField("drillContext", modelDrillContext));
  537. }
  538. else
  539. {
  540. form.appendChild(createHiddenFormField("modeledDrillthru", modelDrillContext));
  541. }
  542. form.appendChild(createHiddenFormField("errURL", "javascript:window.close();"));
  543. if(typeof bDirectLaunch != "undefined" && bDirectLaunch == true)
  544. {
  545. form.appendChild(this.createFormField("directLaunch", "true"));
  546. }
  547. var routingServerGroup = "";
  548. if(this.getCV().envParams["ui.routingServerGroup"])
  549. {
  550. routingServerGroup = this.getCV().envParams["ui.routingServerGroup"];
  551. }
  552. form.appendChild(createHiddenFormField("ui.routingServerGroup", routingServerGroup));
  553. if(this.getCV().getExecutionParameters() != "") {
  554. form.appendChild(createHiddenFormField("encExecutionParameters", this.getCV().getExecutionParameters()));
  555. }
  556. if(warpForm.lang && warpForm.lang.value != "")
  557. {
  558. form.appendChild(createHiddenFormField("lang", warpForm.lang.value));
  559. }
  560. if (!this.getCV() || !this.getCV().launchGotoPageForIWidgetMobile(drillForm)) {
  561. if (typeof this.getCV().launchGotoPage === "function") {
  562. this.getCV().launchGotoPage(form);
  563. }
  564. else {
  565. var target = "winNAT_" + ( new Date() ).getTime();
  566. var sPath = this.getCV().getWebContentRoot() + "/rv/blankDrillWin.html?cv.id=" + cvid;
  567. window.open(sPath, target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  568. form.target = target;
  569. }
  570. }
  571. }
  572. };
  573. CDrillManager.prototype.buildSearchPageXML = function(XMLBuilderLocation, pkg, model, ctxArr, defMeasArr, dataSpecification, filtArr)
  574. {
  575. var cognosSearchElement = null;
  576. if (typeof XMLBuilderLocation.XMLElement == "function")
  577. {
  578. cognosSearchElement = XMLBuilderLocation.XMLBuilderCreateXMLDocument("cognosSearch");
  579. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(cognosSearchElement.documentElement, "xmlns:cs", "http://developer.cognos.com/schemas/cs/1/");
  580. var packageElement = cognosSearchElement.createElement("package");
  581. if (typeof pkg == "string" && pkg !== "")
  582. {
  583. packageElement.appendChild(cognosSearchElement.createTextNode(pkg));
  584. }
  585. cognosSearchElement.documentElement.appendChild(packageElement);
  586. var modelElement = cognosSearchElement.createElement("model");
  587. if (typeof model == "string" && model !== "")
  588. {
  589. modelElement.appendChild(cognosSearchElement.createTextNode(model));
  590. }
  591. cognosSearchElement.documentElement.appendChild(modelElement);
  592. var selectedContextElement = cognosSearchElement.createElement("selectedContext");
  593. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:xs", "http://www.w3.org/2001/XMLSchema");
  594. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:bus", "http://developer.cognos.com/schemas/bibus/3/");
  595. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "SOAP-ENC:arrayType", "bus:parameterValue[]", "http://schemas.xmlsoap.org/soap/encoding/");
  596. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
  597. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  598. cognosSearchElement.documentElement.appendChild(selectedContextElement);
  599. for (var idxCtx in ctxArr)
  600. {
  601. var itemElement = cognosSearchElement.createElement("item");
  602. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(itemElement, "xsi:type", "bus:parameterValue", "http://www.w3.org/2001/XMLSchema-instance");
  603. var busNameElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:name", cognosSearchElement);
  604. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busNameElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  605. busNameElement.appendChild(cognosSearchElement.createTextNode(ctxArr[idxCtx].name));
  606. var busValueElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:value", cognosSearchElement);
  607. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busValueElement, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  608. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busValueElement, "SOAP-ENC:arrayType", "bus:parmValueItem[]", "http://schemas.xmlsoap.org/soap/encoding/");
  609. for (var j = 0; j < ctxArr[idxCtx].values.length; j++)
  610. {
  611. var itemChildElement = cognosSearchElement.createElement("item");
  612. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(itemChildElement, "xsi:type", "bus:simpleParmValueItem", "http://www.w3.org/2001/XMLSchema-instance");
  613. var busUseElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:use", cognosSearchElement);
  614. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busUseElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  615. busUseElement.appendChild(cognosSearchElement.createTextNode(ctxArr[idxCtx].values[j][0]));
  616. var busDisplayElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:display", cognosSearchElement);
  617. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busDisplayElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  618. var nodeValue = ctxArr[idxCtx].values[j][1] == null ? "" : ctxArr[idxCtx].values[j][1];
  619. busDisplayElement.appendChild(cognosSearchElement.createTextNode(nodeValue));
  620. itemChildElement.appendChild(busUseElement);
  621. itemChildElement.appendChild(busDisplayElement);
  622. busValueElement.appendChild(itemChildElement);
  623. }
  624. itemElement.appendChild(busNameElement);
  625. itemElement.appendChild(busValueElement);
  626. selectedContextElement.appendChild(itemElement);
  627. }
  628. var defaultMeasureElement = cognosSearchElement.createElement("defaultMeasure");
  629. cognosSearchElement.documentElement.appendChild(defaultMeasureElement);
  630. dataSpecification.buildXML(XMLBuilderLocation, cognosSearchElement, "data");
  631. var filterElement = cognosSearchElement.createElement("filter");
  632. cognosSearchElement.documentElement.appendChild(filterElement);
  633. }
  634. return cognosSearchElement;
  635. };
  636. CDrillManager.prototype.openSearchPage = function(objPath, sourceContext)
  637. {
  638. // build up the model drill context
  639. this.getModelDrillThroughContext(self);
  640. var searchForm = document.getElementById("searchPage");
  641. if(searchForm != null) {
  642. document.body.removeChild(searchForm);
  643. }
  644. searchForm = document.createElement("form");
  645. searchForm.setAttribute("id", "searchPage");
  646. searchForm.setAttribute("name", "searchPage");
  647. searchForm.setAttribute("method", "post");
  648. searchForm.setAttribute("target", searchForm.name);
  649. searchForm.setAttribute("action", this.getCV().getGateway() + "/gosearch");
  650. searchForm.style.display = "none";
  651. document.body.appendChild(searchForm);
  652. searchForm.appendChild(createHiddenFormField("csn.action", "search"));
  653. searchForm.appendChild(createHiddenFormField("csn.drill", sourceContext));
  654. var __search_win = window.open("", searchForm.name, "directories=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,top=100,left=100,height=480,width=640" );
  655. __search_win.focus();
  656. searchForm.submit();
  657. };
  658. CDrillManager.prototype.launchSearchPage = function()
  659. {
  660. var selCon = this.getSelectionController();
  661. var warpForm = document.forms["formWarpRequest" + this.getCVId()];
  662. var ctxArr = this.determineSelectionsForSearchPage(selCon);
  663. var dataSpecification = this.getSearchContextDataSpecfication(selCon);
  664. var spXML = this.buildSearchPageXML(self, warpForm.packageBase.value, this.getCV().getModelPath(), ctxArr, [], dataSpecification, []);
  665. this.openSearchPage(warpForm.packageBase.value, XMLBuilderSerializeNode(spXML));
  666. };
  667. /***************************************************************************************************
  668. QUERY STUDIO SPECIFIC METHODS
  669. ****************************************************************************************************/
  670. CDrillManager.prototype.qsDrillDown = function()
  671. {
  672. if(!this.canDrillDown()) {
  673. // throw up a a generic error page (for now)
  674. getConfigFrame().dlgGenericSelectionMessage(false);
  675. return;
  676. }
  677. // build the drill down command
  678. var drillCommand = 'DD:';
  679. this.qsSendDrillCommand(drillCommand);
  680. };
  681. CDrillManager.prototype.qsDrillUp = function()
  682. {
  683. if(!this.canDrillUp()) {
  684. // throw up a a generic error page (for now)
  685. getConfigFrame().dlgGenericSelectionMessage(false);
  686. return;
  687. }
  688. // build the drill up command
  689. var drillCommand = 'DU:';
  690. this.qsSendDrillCommand(drillCommand);
  691. };
  692. CDrillManager.prototype.qsSendDrillCommand = function(drillCommand)
  693. {
  694. var drillType;
  695. if(drillCommand == "DU:") {
  696. drillType = "drillUp";
  697. }
  698. else {
  699. drillType = "drillDown";
  700. }
  701. var drillParamsArray = this.getDrillParameters(drillType, false, false /*bIsSyncDrill*/);
  702. if(drillParamsArray.length == 0){
  703. // throw up a a generic error page (for now)
  704. getConfigFrame().dlgGenericSelectionMessage(false);
  705. return;
  706. }
  707. for(var idx = 0; idx < drillParamsArray.length; ++idx) {
  708. drillCommand += getConfigFrame().escapeParam(drillParamsArray[idx]);
  709. if(idx+1 < drillParamsArray.length) {
  710. drillCommand += ',';
  711. }
  712. }
  713. getConfigFrame().sendCmd(drillCommand, "", true);
  714. };
  715. CDrillManager.prototype.qsLaunchGoToPage = function(bDirectLaunch)
  716. {
  717. var selectionController = this.getSelectionController();
  718. if(selectionController != null && selectionController.getModelDrillThroughEnabled() == true)
  719. {
  720. // build up the model drill context
  721. var modelDrillContext = this.getModelDrillThroughContext(cf);
  722. if(modelDrillContext=="") {
  723. // throw up a a generic error page (for now)
  724. getConfigFrame().dlgGenericSelectionMessage(false);
  725. return;
  726. }
  727. var gotoForm = document.getElementById("gotoPage");
  728. if(gotoForm != null) {
  729. document.body.removeChild(gotoForm);
  730. }
  731. gotoForm = document.createElement("form");
  732. gotoForm.setAttribute("id", "gotoPage");
  733. gotoForm.setAttribute("name", "gotoPage");
  734. gotoForm.setAttribute("method", "post");
  735. gotoForm.style.display = "none";
  736. document.body.appendChild(gotoForm);
  737. var configFrame = getConfigFrame();
  738. gotoForm.appendChild(this.createFormField("objpath", decodeURIComponent(configFrame.cfgGet("PackageBase"))));
  739. if(typeof gUseNewSelectionContext == "undefined")
  740. {
  741. gotoForm.appendChild(this.createFormField("m", "portal/goto2.xts"));
  742. }
  743. else
  744. {
  745. gotoForm.appendChild(this.createFormField("m", "portal/goto.xts"));
  746. }
  747. gotoForm.appendChild(this.createFormField("b_action", "xts.run"));
  748. if(typeof gUseNewSelectionContext == "undefined")
  749. {
  750. gotoForm.appendChild(this.createFormField("drillContext", modelDrillContext));
  751. }
  752. else
  753. {
  754. gotoForm.appendChild(this.createFormField("modeledDrillthru", modelDrillContext));
  755. }
  756. if (typeof getConfigFrame().routingServerGroup != "undefined")
  757. {
  758. gotoForm.appendChild(this.createFormField("ui.routingServerGroup", getConfigFrame().routingServerGroup));
  759. }
  760. if(typeof bDirectLaunch != "undefined" && bDirectLaunch == true)
  761. {
  762. gotoForm.appendChild(this.createFormField("directLaunch", "true"));
  763. }
  764. var executionParameters = configFrame.goApplicationManager.getReportManager().getParameterManager().getExecutionParameters();
  765. if (executionParameters)
  766. {
  767. gotoForm.appendChild(this.createFormField("encExecutionParameters", executionParameters));
  768. }
  769. var target = "winNAT_" + ( new Date() ).getTime();
  770. var sPath = this.getCV().getWebContentRoot() + "/rv/blankDrillWin.html?cv.id=" + this.getCVId();
  771. window.open(sPath, target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  772. gotoForm.target = target;
  773. }
  774. };
  775. CDrillManager.prototype.qsLaunchSearchPage = function()
  776. {
  777. var cf = getConfigFrame();
  778. var selCon = goWindowManager.getSelectionController();
  779. var ctxArr = this.determineSelectionsForSearchPage(selCon);
  780. var dataSpecification = this.getSearchContextDataSpecfication(selCon);
  781. var pkgBase = decodeURIComponent(cf.cfgGet("PackageBase"));
  782. var spXML = this.buildSearchPageXML(cf, pkgBase, decodeURIComponent(cf.cfgGet("cmLastModel")), ctxArr, [], dataSpecification, []);
  783. this.openSearchPage(pkgBase, cf.XMLBuilderSerializeNode(spXML));
  784. };
  785. CDrillManager.prototype.determineSelectionsForSearchPage = function(selectionController)
  786. {
  787. var ctxArr = new CtxArrayPlaceHolder();
  788. var allSelections = selectionController.getAllSelectedObjects();
  789. for (var i = 0; i < allSelections.length; i++)
  790. {
  791. var colName = allSelections[i].getColumnName();
  792. if (!this.containsByIndiceInArray(ctxArr, colName))
  793. {
  794. ctxArr[colName] = {};
  795. ctxArr[colName].name = colName;
  796. ctxArr[colName].values = [];
  797. }
  798. var idx0 = "";
  799. var muns = allSelections[i].getMuns();
  800. if (muns != null && muns.length > 0)
  801. {
  802. idx0 = muns[0][0];
  803. }
  804. var idx1 = allSelections[i].getDisplayValues()[0];
  805. if (!(this.containsInArray(ctxArr[colName].values, 0, idx0) && this.containsInArray(ctxArr[colName].values, 1, idx1))) {
  806. ctxArr[colName].values[ctxArr[colName].values.length] = [idx0, idx1];
  807. }
  808. }
  809. return ctxArr;
  810. };
  811. CDrillManager.prototype.getSearchContextDataSpecfication = function(selectionController)
  812. {
  813. var parameterValues = new CParameterValues();
  814. var dataManager = selectionController.getCCDManager();
  815. var contextData = dataManager.m_cd;
  816. for(var ctxId in contextData)
  817. {
  818. var sUsage = dataManager.GetUsage(ctxId);
  819. if(sUsage != "2" /*2==MEASURE*/)
  820. {
  821. var sRefDataItem = dataManager.GetRDIValue(ctxId);
  822. var sUseValue = dataManager.GetDisplayValue(ctxId);
  823. parameterValues.addSimpleParmValueItem(sRefDataItem, sRefDataItem, sUseValue, "true");
  824. }
  825. }
  826. return parameterValues;
  827. };
  828. CDrillManager.prototype.containsByIndiceInArray = function(a, v)
  829. {
  830. for (var i in a)
  831. {
  832. if (i == v) {
  833. return true;
  834. }
  835. }
  836. return false;
  837. };
  838. CDrillManager.prototype.containsInArray = function(a, idx, v)
  839. {
  840. for (var i in a)
  841. {
  842. if (a[i][idx] == v) {
  843. return true;
  844. }
  845. }
  846. return false;
  847. };
  848. // temp function for now
  849. CDrillManager.prototype.createFormField = function(name, value)
  850. {
  851. var formField = document.createElement("input");
  852. formField.setAttribute("type", "hidden");
  853. formField.setAttribute("name", name);
  854. formField.setAttribute("value", value);
  855. return(formField);
  856. };
  857. /***************************************************************************************************
  858. DRILL THROUGH METHODS
  859. ****************************************************************************************************/
  860. CDrillManager.prototype.getAuthoredDrillThroughTargets = function()
  861. {
  862. var aAuthoredDrillItems = [];
  863. var selectionController = this.getSelectionController();
  864. var oHtmlItem = null;
  865. if(selectionController != null)
  866. {
  867. if(selectionController.getSelectedColumnIds().length == 1)
  868. {
  869. var selections = selectionController.getSelections();
  870. for(var selectionIndex = 0; selectionIndex < selections.length; ++selectionIndex)
  871. {
  872. var selectionObject = selections[selectionIndex];
  873. oHtmlItem = selectionObject.getCellRef();
  874. while( oHtmlItem )
  875. {
  876. if(oHtmlItem.getAttribute("dtTargets") != null)
  877. {
  878. aAuthoredDrillItems.push("<rvDrillTargets>" + oHtmlItem.getAttribute("dtTargets") + "</rvDrillTargets>");
  879. break;
  880. }
  881. else if(oHtmlItem.getAttribute("onclick") != null)
  882. {
  883. var onclickValue = oHtmlItem.getAttribute("onclick");
  884. var localFunction = null;
  885. if(onclickValue.indexOf("doSingleDrillThrough") != -1)
  886. {
  887. localFunction = onclickValue.replace("doSingleDrillThrough", "this.buildRvTargetsForSingleDrillThrough");
  888. }
  889. else if(onclickValue.indexOf("doMultipleDrillThrough") != -1)
  890. {
  891. localFunction = onclickValue.replace("doMultipleDrillThrough", "this.buildRvTargetsForMultipleDrillThrough");
  892. }
  893. if(localFunction != null)
  894. {
  895. var rvDrillTargets = eval(localFunction);
  896. if(rvDrillTargets != null)
  897. {
  898. aAuthoredDrillItems.push(rvDrillTargets);
  899. break;
  900. }
  901. }
  902. }
  903. oHtmlItem = XMLHelper_GetFirstChildElement( oHtmlItem );
  904. }
  905. }
  906. }
  907. else if(selectionController.hasSelectedChartNodes())
  908. {
  909. var chartNodes = selectionController.getSelectedChartNodes();
  910. var selectedChartNode = chartNodes[0];
  911. oHtmlItem = selectedChartNode.getArea();
  912. if(oHtmlItem.getAttribute("dtTargets") != null)
  913. {
  914. aAuthoredDrillItems.push("<rvDrillTargets>" + oHtmlItem.getAttribute("dtTargets") + "</rvDrillTargets>");
  915. }
  916. }
  917. else if (selectionController.getSelectedDrillThroughImage() != null) {
  918. var imageNode = selectionController.getSelectedDrillThroughImage();
  919. if(imageNode && imageNode.getAttribute("dtTargets") != null) {
  920. aAuthoredDrillItems.push("<rvDrillTargets>" + imageNode.getAttribute("dtTargets") + "</rvDrillTargets>");
  921. }
  922. } else if( selectionController.getSelectDrillThroughSingleton() != null) {
  923. var singletonNode = selectionController.getSelectDrillThroughSingleton();
  924. if(singletonNode && singletonNode.getAttribute("dtTargets") != null) {
  925. aAuthoredDrillItems.push("<rvDrillTargets>" + singletonNode.getAttribute("dtTargets") + "</rvDrillTargets>");
  926. }
  927. }
  928. }
  929. return aAuthoredDrillItems;
  930. };
  931. CDrillManager.prototype.getDrillThroughParameters = function(method, evt)
  932. {
  933. if(typeof method == "undefined")
  934. {
  935. method = 'query';
  936. }
  937. var aAuthoredDrillThroughTargets = [];
  938. if(typeof evt != "undefined")
  939. {
  940. var cellRef = getCrossBrowserNode(evt, true);
  941. try
  942. {
  943. while(cellRef)
  944. {
  945. if(typeof cellRef.getAttribute != "undefined" && cellRef.getAttribute("dtTargets"))
  946. {
  947. aAuthoredDrillThroughTargets.push("<rvDrillTargets>" + cellRef.getAttribute("dtTargets") + "</rvDrillTargets>");
  948. break;
  949. }
  950. cellRef = cellRef.parentNode;
  951. }
  952. }
  953. catch(e)
  954. {
  955. return false;
  956. // if an exception occurs, just eat it
  957. }
  958. }
  959. else
  960. {
  961. var oCV = this.getCV();
  962. var oDrillMgr = oCV.getDrillMgr();
  963. var selectionController = oDrillMgr.getSelectionController();
  964. if(selectionController != null)
  965. {
  966. var chartArea = null;
  967. if(selectionController.hasSelectedChartNodes())
  968. {
  969. var chartNodes = selectionController.getSelectedChartNodes();
  970. var selectedChartNode = chartNodes[0];
  971. chartArea = selectedChartNode.getArea();
  972. }
  973. if(chartArea != null)
  974. {
  975. aAuthoredDrillThroughTargets.push("<rvDrillTargets>" + chartArea.getAttribute("dtTargets") + "</rvDrillTargets>");
  976. }
  977. else
  978. {
  979. aAuthoredDrillThroughTargets = this.getAuthoredDrillThroughTargets();
  980. }
  981. }
  982. }
  983. if(aAuthoredDrillThroughTargets.length > 0)
  984. {
  985. var sAuthoredDrillThroughTargets = "<AuthoredDrillTargets>";
  986. for(var iIndex = 0; iIndex < aAuthoredDrillThroughTargets.length; ++iIndex)
  987. {
  988. sAuthoredDrillThroughTargets += eval('"' + aAuthoredDrillThroughTargets[iIndex] + '"');
  989. }
  990. sAuthoredDrillThroughTargets += "</AuthoredDrillTargets>";
  991. var authoredDrillAction = this.getCV().getAction("AuthoredDrill");
  992. if(method == "query")
  993. {
  994. authoredDrillAction.populateContextMenu(sAuthoredDrillThroughTargets);
  995. this.showOtherMenuItems();
  996. }
  997. else
  998. {
  999. if (this.getCV().envParams["cv.id"] == "AA")
  1000. {
  1001. this.getCV().m_viewerFragment.raiseAuthoredDrillClickEvent();
  1002. }
  1003. else
  1004. {
  1005. authoredDrillAction.execute(sAuthoredDrillThroughTargets);
  1006. }
  1007. }
  1008. return true;
  1009. }
  1010. else if (method == 'query')
  1011. {
  1012. this.showOtherMenuItems();
  1013. return true;
  1014. }
  1015. else
  1016. {
  1017. return false;
  1018. }
  1019. };
  1020. CDrillManager.prototype.executeAuthoredDrill = function(drillTargetsSpecification)
  1021. {
  1022. var unEncodedDrillTargetsSpecification = decodeURIComponent(drillTargetsSpecification);
  1023. var authoredDrillAction = this.getCV().getAction("AuthoredDrill");
  1024. authoredDrillAction.executeDrillTarget(unEncodedDrillTargetsSpecification);
  1025. };
  1026. CDrillManager.prototype.doesMoreExist = function(menuObj)
  1027. {
  1028. for(var i = 0; i < menuObj.getNumItems(); i++)
  1029. {
  1030. var menuItem = menuObj.get(i);
  1031. if(menuItem != null)
  1032. {
  1033. if((menuItem instanceof CMenuItem) && (menuItem.getLabel() == RV_RES.RV_MORE) && (menuItem.getAction() == this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();')) {
  1034. return true;
  1035. }
  1036. }
  1037. }
  1038. return false;
  1039. };
  1040. CDrillManager.prototype.showOtherMenuItems = function()
  1041. {
  1042. // just add the more menu item
  1043. var cv = this.getCV();
  1044. var mainWnd = cv.rvMainWnd;
  1045. var toolbarCtrl = mainWnd.getToolbarControl();
  1046. var gtButton = null;
  1047. var gtDropDownMenu = null;
  1048. if (typeof toolbarCtrl != "undefined" && toolbarCtrl != null) {
  1049. gtButton = toolbarCtrl.getItem("goto");
  1050. if (gtButton)
  1051. {
  1052. gtDropDownMenu = gtButton.getMenu();
  1053. }
  1054. }
  1055. var contextMenu = mainWnd.getContextMenu();
  1056. var sBlackList = mainWnd.getUIHide();
  1057. var gtContextMenu = null;
  1058. if (typeof contextMenu != "undefined" && contextMenu != null && contextMenu.getGoToMenuItem()) {
  1059. gtContextMenu = contextMenu.getGoToMenuItem().getMenu();
  1060. }
  1061. var searchMenuItem = null;
  1062. var selectionController = this.getSelectionController();
  1063. // there's no report authored drills, just add the more menu item
  1064. if (gtDropDownMenu != null) {
  1065. //Do not add another more menu item if the dropdown menu already has one
  1066. if(this.doesMoreExist(gtDropDownMenu) == false)
  1067. {
  1068. if(typeof gMenuSeperator != "undefined" && gtDropDownMenu.getNumItems() > 0 && (cv.bCanUseCognosViewerIndexSearch || sBlackList.indexOf(' RV_TOOLBAR_BUTTONS_GOTO_RELATED_LINKS ') == -1))
  1069. {
  1070. gtDropDownMenu.add(gMenuSeperator);
  1071. }
  1072. var moreDropDownItem = new CMenuItem(gtDropDownMenu, RV_RES.RV_MORE, this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1073. // if (cv.bCanUseCognosViewerIndexSearch) {
  1074. // searchMenuItem = new CMenuItem(gtDropDownMenu, RV_RES.RV_SEARCH, this.getCVObjectRef() + '.getDrillMgr().launchSearchPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1075. // }
  1076. if(sBlackList.indexOf(' RV_TOOLBAR_BUTTONS_GOTO_RELATED_LINKS ') != -1)
  1077. {
  1078. moreDropDownItem.hide();
  1079. }
  1080. else if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  1081. {
  1082. moreDropDownItem.disable();
  1083. }
  1084. }
  1085. }
  1086. if (gtContextMenu != null) {
  1087. if(typeof gMenuSeperator != "undefined" && gtContextMenu.getNumItems() > 0 && (cv.bCanUseCognosViewerIndexSearch || sBlackList.indexOf(' RV_CONTEXT_MENU_GOTO_RELATED_LINKS ') == -1))
  1088. {
  1089. gtContextMenu.add(gMenuSeperator);
  1090. }
  1091. var moreContextMenuItem = new CMenuItem(gtContextMenu, RV_RES.RV_MORE, this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1092. // if (cv.bCanUseCognosViewerIndexSearch) {
  1093. // searchMenuItem = new CMenuItem(gtContextMenu, RV_RES.RV_SEARCH, this.getCVObjectRef() + '.getDrillMgr().launchSearchPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1094. // }
  1095. if(sBlackList.indexOf(' RV_CONTEXT_MENU_GOTO_RELATED_LINKS ') != -1)
  1096. {
  1097. moreContextMenuItem.hide();
  1098. }
  1099. else if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  1100. {
  1101. moreContextMenuItem.disable();
  1102. }
  1103. }
  1104. if (searchMenuItem != null && selectionController != null)
  1105. {
  1106. var allSelections = selectionController.getAllSelectedObjects();
  1107. if (allSelections == null || allSelections.length === 0)
  1108. {
  1109. searchMenuItem.disable();
  1110. }
  1111. }
  1112. if (gtDropDownMenu != null) {
  1113. gtDropDownMenu.draw();
  1114. if (gtDropDownMenu.isVisible()) {
  1115. gtDropDownMenu.show();
  1116. }
  1117. }
  1118. if (gtContextMenu != null) {
  1119. gtContextMenu.draw();
  1120. if (gtContextMenu.isVisible()) {
  1121. gtContextMenu.show();
  1122. }
  1123. }
  1124. };
  1125. CDrillManager.prototype.ddc = function(evt) {
  1126. var node = getNodeFromEvent(evt);
  1127. if(node != null && node.getAttribute("ddc")!=="1") {
  1128. // adding a 'ddc' attribute to prevent processing the same node more than once.
  1129. node.setAttribute("ddc", "1");
  1130. if(node.getAttribute("dtTargets")) {
  1131. node.className = "dl " + node.className;
  1132. node.setAttribute("href", "#");
  1133. return;
  1134. }
  1135. var selectionController = this.getSelectionController();
  1136. if(selectionController != null) {
  1137. var selectedChartArea = selectionController.getSelectionObjectFactory().getSelectionChartObject(node);
  1138. if(selectedChartArea != null) {
  1139. var drillOptions = selectedChartArea.getDrillOptions();
  1140. for(var idx = 0; idx < drillOptions.length; ++idx) {
  1141. var currentDrillOption = drillOptions[idx][0];
  1142. if ((node.getAttribute("isChartTitle") === "true" && currentDrillOption == "1") || currentDrillOption == "3" || currentDrillOption == "2") {
  1143. node.className = "dl " + node.className;
  1144. node.setAttribute("href", "#");
  1145. break;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. }
  1151. };
  1152. CDrillManager.prototype.buildRvTargetsForSingleDrillThrough = function(drillThroughContext)
  1153. {
  1154. if(typeof drillThroughContext == "undefined" || drillThroughContext == null)
  1155. {
  1156. return null;
  1157. }
  1158. var drillTargets = this.getCV().getDrillTargets();
  1159. if(!drillTargets || drillTargets.length == 0)
  1160. {
  1161. return null;
  1162. }
  1163. var drillTargetRefIdx = drillThroughContext[0][0];
  1164. if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null)
  1165. {
  1166. return null;
  1167. }
  1168. var drillTargetRef = drillTargets[drillTargetRefIdx];
  1169. if(typeof drillTargetRef == "undefined" || drillTargetRef == null)
  1170. {
  1171. return null;
  1172. }
  1173. var drillTarget = "<drillTarget drillIdx=\\\"" + drillTargetRefIdx + "\\\" label=\\\"" + drillTargetRef.getLabel() + "\\\"/>";
  1174. return "<rvDrillTargets>" + drillTarget + "</rvDrillTargets>";
  1175. };
  1176. CDrillManager.prototype.buildRvTargetsForMultipleDrillThrough = function(drillThroughContext)
  1177. {
  1178. if(typeof drillThroughContext == "undefined" || drillThroughContext == null)
  1179. {
  1180. return null;
  1181. }
  1182. var drillTargets = this.getCV().getDrillTargets();
  1183. if(!drillTargets || drillTargets.length == 0)
  1184. {
  1185. return null;
  1186. }
  1187. var dtTargets = "";
  1188. for (var drillTargetIdx = 0; drillTargetIdx < drillThroughContext.length; ++drillTargetIdx)
  1189. {
  1190. var currentDrillThroughContext = drillThroughContext[drillTargetIdx];
  1191. if(currentDrillThroughContext.length < 2)
  1192. {
  1193. // there must be two or more parameters (drill idx, drill label)
  1194. continue;
  1195. }
  1196. var drillTargetRefIdx = currentDrillThroughContext[0];
  1197. if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null)
  1198. {
  1199. continue;
  1200. }
  1201. var drillTargetLabel = currentDrillThroughContext[1];
  1202. if(typeof drillTargetLabel == "undefined" || drillTargetLabel == null)
  1203. {
  1204. continue;
  1205. }
  1206. var drillTargetRef = drillTargets[drillTargetRefIdx];
  1207. if(typeof drillTargetRef == "undefined" || drillTargetRef == null)
  1208. {
  1209. continue;
  1210. }
  1211. if(drillTargetLabel === null || drillTargetLabel === "")
  1212. {
  1213. drillTargetLabel = drillTargetRef.getLabel();
  1214. }
  1215. dtTargets += "<drillTarget drillIdx=\\\"" + drillTargetRefIdx + "\\\" label=\\\"" + drillTargetLabel + "\\\"/>";
  1216. }
  1217. if(dtTargets.length > 0)
  1218. {
  1219. return "<rvDrillTargets>" + dtTargets + "</rvDrillTargets>";
  1220. }
  1221. return null;
  1222. };