SelectionContextLibraryTester.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <!--
  2. *****************************************************************
  3. ** Licensed Materials - Property of IBM
  4. **
  5. ** IBM Cognos Products: drill
  6. **
  7. ** (C) Copyright IBM Corp. 2001, 2010
  8. **
  9. ** US Government Users Restricted Rights - Use, duplication or
  10. ** disclosure restricted by GSA ADP Schedule Contract with
  11. ** IBM Corp.
  12. *****************************************************************
  13. -->
  14. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  15. <html>
  16. <head>
  17. <meta name="generator" content=
  18. "HTML Tidy for Windows (vers 1st July 2003), see www.w3.org">
  19. <title>Selection Context Library Test Page</title>
  20. <script language="javascript" src=
  21. "http://localhost/cognos8/cognoslaunch.js" type="text/javascript">
  22. </script>
  23. <script language="javascript" src=
  24. "http://localhost/cognos8/drill/utility.js" type="text/javascript">
  25. </script>
  26. <script language="javascript" src=
  27. "http://localhost/cognos8/drill/CSelectionContextBuilder.js" type=
  28. "text/javascript">
  29. </script>
  30. </head>
  31. <body>
  32. <script language="javascript" type="text/javascript">
  33. <!--
  34. //Example 1: Build a basic selection context includes selection of a single value from a single column.
  35. function BuildBasicSelection()
  36. {
  37. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  38. //Select a measure (add more by adding to the childSelections array)...??could also be built from child to parent??
  39. var oProdLine = oSelectionContext.addSelectedCell( /*dataItemName*/ "Product line",
  40. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product line]",
  41. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product line]->:[PC].[@MEMBER].[2103]",
  42. /*useValueType*/ "memberUniqueName",
  43. /*displayValue*/ "Personal Accessories");
  44. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  45. document.getElementById("fSC").value = oSelectionContext.toString();
  46. }
  47. //Example 2: Build the selection context for a nested selection including a single value from a single cell
  48. // and a "parent" as would beseen in a higher level of a nested crosstab.
  49. function BuildNestedSelection()
  50. {
  51. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  52. //Select a column....(order method type = "Mail")
  53. var oOrderMethod = oSelectionContext.addSelectedCell( /*dataItemName*/ "Order method type",
  54. /*metadataModelItem*/ "[Great_Outdoors].[Order method].[Order method].[Order method type]",
  55. /*useValue*/ "[Great_Outdoors].[Order method].[Order method].[Order method type]->:[PC].[@MEMBER].[603]",
  56. /*useValueType*/ "memberUniqueName",
  57. /*displayValue*/ "Mail");
  58. //Select a column....(product line = "Personal Accessories")
  59. var oProdLine = oOrderMethod.addDefiningCell( /*dataItemName*/ "Product line",
  60. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product line]",
  61. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product line]->:[PC].[@MEMBER].[2103]",
  62. /*useValueType*/ "memberUniqueName",
  63. /*displayValue*/ "Personal Accessories");
  64. //Give the defining cell an axis ordinal
  65. oProdLine.addProperty('ordinal', '2');
  66. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  67. document.getElementById("fSC").value = oSelectionContext.toString();
  68. }
  69. //Example 3: Build the selection context for a measure which is made up of the measure and two defining cells (one for
  70. // row and one for column AND a nested selection in the rows (product line/product type)).
  71. function BuildNestedMeasure()
  72. {
  73. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  74. //Select a measure (add more by adding to the childSelections array)...??could also be built from child to parent??
  75. var oMeasure = oSelectionContext.addSelectedCell( /*dataItemName*/ "Quantity",
  76. /*metadataModelItem*/ "[Great_Outdoors].[Measures].[Quantity]",
  77. /*useValue*/ "500",
  78. /*useValueType*/ "Decimal",
  79. /*displayValue*/ "$500.00",
  80. /*usage*/ "measure");
  81. //Select a column....(product type = "Tents")
  82. var oProdType = oMeasure.addDefiningCell( /*dataItemName*/ "Product type",
  83. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product type]",
  84. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product type]->:[PC].[@MEMBER].[102]",
  85. /*useValueType*/ "memberUniqueName",
  86. /*displayValue*/ "Personal Accessories",
  87. /*usage*/ "identifier");
  88. //Select a column....(product line = "Personal Accessories")
  89. var oProdLine = oProdType.addDefiningCell( /*dataItemName*/ "Product line",
  90. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product line]",
  91. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product line]->:[PC].[@MEMBER].[2103]",
  92. /*useValueType*/ "memberUniqueName",
  93. /*displayValue*/ "Personal Accessories",
  94. /*usage*/ "identifier");
  95. //Note: declaring a variable is only required if nesting above a cell.
  96. oMeasure.addDefiningCell( /*dataItemName*/ "Year",
  97. /*metadataModelItem*/ "[Great_Outdoors].[Time].[Time].[Year]",
  98. /*useValue*/ "[Great_Outdoors].[Time].[Time].[Year]->:[PC].[@MEMBER].[20050101-20051231]",
  99. /*useValueType*/ "memberUniqueName",
  100. /*displayValue*/ "2005",
  101. /*usage*/ "identifier");
  102. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  103. document.getElementById("fSC").value = oSelectionContext.toString();
  104. }
  105. //Example 4: Build a selection context where multiple values for the same item are selected (at the root)
  106. function BuildMultiSelectSameItemAtRoot()
  107. {
  108. //Create the Selection interface objects....IMPORTANT: Need better names for these top level interfaces!
  109. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  110. //Select a column....(product type = "Tents")
  111. var oProdType = oSelectionContext.addSelectedCell( /*dataItemName*/ "Product type",
  112. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product type]",
  113. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product type]->:[PC].[@MEMBER].[102]",
  114. /*useValueType*/ "memberUniqueName",
  115. /*displayValue*/ "Tents");
  116. //Select a column....(product line = "Packs")
  117. var oProdType2 = oSelectionContext.addSelectedCell( /*dataItemName*/ "Product type",
  118. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product type]",
  119. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product type]->:[PC].[@MEMBER].[104]",
  120. /*useValueType*/ "memberUniqueName",
  121. /*displayValue*/ "Packs");
  122. //add a special property (one that's in the schema)
  123. oProdType2.addProperty('LevelUniqueName', '[Great_Outdoors].[Products].[Products].[Product line]');
  124. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  125. document.getElementById("fSC").value = oSelectionContext.toString();
  126. }
  127. //Example 5: Build the selection context for a nested selection including a single value from a single cell
  128. // and a "parent" as would beseen in a higher level of a nested crosstab.
  129. function BuildMultiSelectTwoChildrenSameParent()
  130. {
  131. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  132. //Select a column....(product type = "Tents")
  133. var oProdTypeTents = oSelectionContext.addSelectedCell( /*dataItemName*/ "Product type",
  134. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product type]",
  135. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product type]->:[PC].[@MEMBER].[102]",
  136. /*useValueType*/ "memberUniqueName",
  137. /*displayValue*/ "Personal Accessories");
  138. //Select a column....(product line = "Packs")
  139. var oProdTypePacks = oSelectionContext.addSelectedCell( /*dataItemName*/ "Product type",
  140. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product type]",
  141. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product type]->:[PC].[@MEMBER].[104]",
  142. /*useValueType*/ "memberUniqueName",
  143. /*displayValue*/ "Packs");
  144. //Select a column....(product line = "Personal Accessories")
  145. var oProdLine = oProdTypeTents.addDefiningCell( /*dataItemName*/ "Product line",
  146. /*metadataModelItem*/ "[Great_Outdoors].[Products].[Products].[Product line]",
  147. /*useValue*/ "[Great_Outdoors].[Products].[Products].[Product line]->:[PC].[@MEMBER].[2103]",
  148. /*useValueType*/ "memberUniqueName",
  149. /*displayValue*/ "Personal Accessories");
  150. //Once added, the other addDefiningCell overload can be used
  151. oProdTypePacks.referenceDefiningCell(oProdLine);
  152. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  153. document.getElementById("fSC").value = oSelectionContext.toString();
  154. }
  155. //Example 6: Build a selection context for illustrating measure based scope.
  156. function BuildMeasureBasedScope()
  157. {
  158. var oSelectionContext = new CSelectionContext(document.getElementById("fModelPath").value); //The output selection context
  159. //Select a measure (add more by adding to the childSelections array)...??could also be built from child to parent??
  160. var oQuantity = oSelectionContext.addSelectedCell( /*dataItemName*/ "Quantity",
  161. /*metadataModelItem*/ "[Great_Outdoors].[Measures].[Quantity]",
  162. /*useValue*/ "1000",
  163. /*useValueType*/ "Decimal");
  164. //The final selection context is made up of the header, the metadata table, the cells and the strings.
  165. document.getElementById("fSC").value = oSelectionContext.toString();
  166. }
  167. //this function launches the goto page with the output from the selection context library.
  168. function LaunchGotoPage()
  169. {
  170. var sGateway = document.getElementById('fGateway').value;
  171. var sModelPath = document.getElementById('fModelPath').value;
  172. var sEncodedModelPath = sEncodedModelPath = encode64(document.getElementById('fModelPath').value);
  173. var sTool = "Goto2";
  174. var sDirectLaunch = "true";
  175. var sLang = "";
  176. var sRoutingServerGroup = "";
  177. var sEncExecutionParameters = "";
  178. var sAuthoredDrillthru = "";
  179. var sModeledDrillthru = "";
  180. var sDrillContext = document.getElementById('fSC').value;
  181. cognosLaunch('ui.gateway', sGateway,
  182. 'ui.tool', sTool,
  183. 'directLaunch', sDirectLaunch,
  184. 'lang', sLang,
  185. 'ui.routingServerGroup', sRoutingServerGroup,
  186. 'encExecutionParameters', sEncExecutionParameters,
  187. 'authoredDrillthru', sAuthoredDrillthru,
  188. 'modeledDrillthru', sModeledDrillthru,
  189. 'modelPath', sModelPath,
  190. 'drillContext', sDrillContext);
  191. }
  192. -->
  193. </script>
  194. <h1>Selection Context Library Test Page</h1>
  195. <!-- Minimum additional parameters necessary to launch the goto page -->
  196. <h2>The following are values required to launch the Go To
  197. page...</h2>
  198. <table>
  199. <tr>
  200. <td>*Name:</td>
  201. <td><input type="text" name="fGateway" value=
  202. "http://localhost/cognos8/cgi-bin/cognos.cgi" size="100"></td>
  203. </tr>
  204. <tr>
  205. <td>*Model:</td>
  206. <td><input type="text" name="fModelPath" value=
  207. "/content/package[@name='sales and marketing cube']/model[last()]"
  208. size="100"></td>
  209. </tr>
  210. <tr>
  211. <td>Action:</td>
  212. <td><input type="text" name="fAction" value="filter" size="100" id=
  213. "Text1"></td>
  214. </tr>
  215. <tr>
  216. <td colspan="2" align="right">* denotes "Required"</td>
  217. </tr>
  218. </table>
  219. <!-- Produce a selection context using the selection context library -->
  220. <h2>Produce example Selection Contexts using the Selection Context
  221. Builder Library...</h2>
  222. <table id="SelectionContextLibraryTable">
  223. <tr>
  224. <td colspan="2">=== Example 1: "Simple Selection" ====<br>
  225. OLAP Product Line = "Personal Accessories"<br>
  226. <button onclick="BuildBasicSelection()" id="Basic" type=
  227. "button">=== Example 1: "Simple Selection" ====</button></td>
  228. </tr>
  229. <tr>
  230. <td colspan="2">=== Example 2: "Single axis nested Selection
  231. ===<br>
  232. OLAP Product type = "Tents" nested under<br>
  233. OLAP Product Line = "Personal Accessories"<br>
  234. <button onclick="BuildNestedSelection()" id="Nested" type=
  235. "button">=== Example 2: "Single axis nested Selection
  236. ===</button></td>
  237. </tr>
  238. <tr>
  239. <td colspan="2">=== Example 3: Measure selection (with nested row
  240. axis) ===<br>
  241. Measure: Quantity<br>
  242. Rows: Product type = "Tents" nested under Product Line = "Personal
  243. Accessories"<br>
  244. Cols: Year = "2005"<br>
  245. <button onclick="BuildNestedMeasure()" id="Button2" type=
  246. "button">=== Example 3: Measure selection (with nested row axis)
  247. ===</button></td>
  248. </tr>
  249. <tr>
  250. <td colspan="2">=== Example 4: Multi select of same item at the
  251. root (or select) ===<br>
  252. Product type = "Tents"<br>
  253. Product type = "Packs"<br>
  254. <button onclick="BuildMultiSelectSameItemAtRoot()" id="Button1"
  255. type="button">=== Example 4: Multi select of same item at the
  256. selection root (or select) ===</button></td>
  257. </tr>
  258. <tr>
  259. <td colspan="2">=== Example 5: Multi select - two cells have the
  260. same defining cell ===<br>
  261. Product type = "Tents"<br>
  262. Product type = "Packs"<br>
  263. <button onclick="BuildMultiSelectTwoChildrenSameParent()" id=
  264. "Button4" type="button">=== Example 5: Multi select - two cells
  265. have the same defining cell ===</button></td>
  266. </tr>
  267. <tr>
  268. <td colspan="2">=== Example 6: Measure Based Scope ===<br>
  269. Quantity = "1000"<br>
  270. <button onclick="BuildMeasureBasedScope()" id="Button6" type=
  271. "button">=== Example 6: Measure Based Scope ===</button></td>
  272. </tr>
  273. <tr>
  274. <td width="74">Output<br>
  275. Selection<br>
  276. Context:</td>
  277. <td>
  278. <textarea rows="30" cols="100" name="fSC" id="fSC">
  279. </textarea></td>
  280. </tr>
  281. <tr>
  282. <td align="right" colspan="2"><b>Launch the goto page with this
  283. output selection context:<br>
  284. <button onclick="LaunchGotoPage()" id="Button3" type=
  285. "button">Launch Goto Page</button></b></td>
  286. </tr>
  287. </table>
  288. </body>
  289. </html>