calcNumericRank.xts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <!--
  13. Used for rank
  14. -->
  15. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/QSRVUITextPL.xml,messages/portal.xml,messages/portalRL.xml" requiredCapability="canUseQueryStudio">
  16. <xts:block id="page" type="exec" mode="output" processor="XSLT" mimeType="text/html">
  17. <!-- get the debug logic sheet -->
  18. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  19. <!-- get the new theme stuff -->
  20. <!-- apply the following logicsheets in order -->
  21. <xts:logicsheet path="qs/logicsheets/calc_theme.xsl"/>
  22. <xts:logicsheet path="logicsheets/portal.xsl"/>
  23. <xts:logicsheet path="qs/logicsheets/dialogs.xsl"/>
  24. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  25. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  26. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  27. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  28. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  29. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  30. <!-- apply the form logic -->
  31. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  32. <xsl:stylesheet version="1.0"
  33. xmlns:clcdlg="test_calculationDlg"
  34. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  35. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  36. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  37. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  38. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  39. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  40. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  41. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  42. xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/"
  43. xmlns:qsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/qs/dialog/"
  44. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  45. exclude-result-prefixes="clcdlg xsl xts lyt pf dp df cp cf dbg qsdlg xtsext">
  46. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  47. <!-- add any theme variables -->
  48. <df:variables/>
  49. <pf:variables/>
  50. <!-- start the output -->
  51. <xsl:template match="/root">
  52. <dp:page>
  53. <dp:script>
  54. <script type="text/javascript">
  55. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/layout.js</xsl:attribute>
  56. <xsl:text/>//<xsl:text/>
  57. </script>
  58. <script type="text/javascript">
  59. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CDialogManager.js</xsl:attribute>
  60. <xsl:text/>//<xsl:text/>
  61. </script>
  62. <script type="text/javascript">
  63. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CWindowManager.js</xsl:attribute>
  64. <xsl:text/>//<xsl:text/>
  65. </script>
  66. <script type="text/javascript">&lt;!--
  67. var goDialogManager = new CDialogManager();
  68. <clcdlg:jvs/>
  69. var expression = new Array();
  70. var detailAggs = new Array();
  71. var regularAggs = new Array();
  72. var calculatedExpression = new Array();
  73. var cf = getConfigFrame();
  74. var calcType = cf.dlgGlobalGetParm('xxCalcType');
  75. var calcParentIds = new Array();
  76. var calcParentLabels = new Array();
  77. var groupsInfoValid = true;
  78. function execute()
  79. {
  80. var oMQMgr = goDialogManager.getMiniQueryManager();
  81. var before_col_id = cf.dlgGlobalGetParm('xxInsBeforeColid');
  82. var calcBy = "none";
  83. var calcExpr = "generated";
  84. var calcBase = expression[document.f.repSel.options.selectedIndex];
  85. var detailAgg = detailAggs[document.f.repSel.options.selectedIndex];
  86. var cType = -1;
  87. var cUsage = -1;
  88. if (cf.dlgGlobalGetParm('xxGroupedColInfo') != null &amp;&amp; document.f.basedOn[1].checked &amp;&amp; groupsInfoValid)
  89. calcBy = document.f.repGroups.options[document.f.repGroups.options.selectedIndex].value;
  90. else
  91. calcExpr = "rank(^^^0^^^ for report prefilter)";
  92. var calculationExpression = calcExpr;
  93. var summarizationExpression = calcExpr;
  94. if (calcBy == "none")
  95. {
  96. calculationExpression = stringReplace (calculationExpression, "\\^\\^\\^" + 0 + "\\^\\^\\^", expression[document.f.repSel.options.selectedIndex]);
  97. summarizationExpression = stringReplace (summarizationExpression, "\\^\\^\\^" + 0 + "\\^\\^\\^", calculatedExpression[document.f.repSel.options.selectedIndex]);
  98. }
  99. else
  100. summarizationExpression = calculatedExpression[document.f.repSel.options.selectedIndex];
  101. // alert(calculationExpression + "\n--\n" + summarizationExpression);
  102. var calcName = getCalcName();
  103. var queryId = -1;
  104. for (var i = 0; i &lt; calcParentLabels.length; i++)
  105. {
  106. if (calcParentLabels[i] == document.f.repSel.options[document.f.repSel.options.selectedIndex].text)
  107. {
  108. queryId = i;
  109. break;
  110. }
  111. }
  112. if (queryId &lt; 0)
  113. return;
  114. //TODO - CLEANUP can the following code be replaced by below?
  115. //queryId = oMQMgr.isMeasure(calcParentIds[queryId]);
  116. for (var j = 0; j &lt; oMQMgr.getAllColumns().length; j++)
  117. {
  118. if (calcParentIds[queryId] == oMQMgr.getColumnId(j))
  119. {
  120. queryId = oMQMgr.isMeasure(j);
  121. break;
  122. }
  123. }
  124. if (queryId &lt; 0)
  125. return;
  126. else if (queryId == false)
  127. {
  128. cType = 21;
  129. cUsage = 2;
  130. }
  131. getConfigFrame().addCalcColumn(before_col_id, calculationExpression, summarizationExpression, calcName, calcBy, "rank", calcBase, -1, cType, cUsage, "none", -1, detailAgg);
  132. }
  133. function generateName(withQuotes)
  134. {
  135. var calcName = document.f.calcList.options[document.f.calcList.selectedIndex].text; // Rank
  136. var rankColumn = document.f.repSel.options[document.f.repSel.options.selectedIndex].text;
  137. if (withQuotes &amp;&amp; document.f.basedOn &amp;&amp; document.f.basedOn[1].checked &amp;&amp; groupsInfoValid)
  138. {
  139. calcName = "<xts:string id="CALCULATION_RANK_GROUP_EQUATION" encode="javascript"/>";
  140. calcName = stringReplace (calcName, "\\^1", document.f.repGroups.options[document.f.repGroups.options.selectedIndex].text);
  141. }
  142. else
  143. calcName = "<xts:string id="CALCULATION_RANK_EQUATION" encode="javascript"/>";
  144. calcName = stringReplace (calcName, "\\^0", rankColumn);
  145. return calcName;
  146. }
  147. function init()
  148. {
  149. attachMouseEvents();
  150. for (var i = 0; i &lt; cf.dlgGlobalSize('xxCalcParentIds'); i++)
  151. {
  152. var label = cf.dlgGlobalGetParmAt('xxCalcParentIds', i);
  153. calcParentIds[i] = label[0];
  154. calcParentLabels[i] = label[1];
  155. }
  156. for (var i = 0; i &lt; cf.dlgGlobalSize('xxColInfo'); i++)
  157. {
  158. var colInfo = cf.dlgGlobalGetParmAt('xxColInfo', i);
  159. expression[i] = colInfo[1];
  160. calculatedExpression[i] = colInfo[1];
  161. document.f.repSel.options[document.f.repSel.options.length] = new Option(colInfo[0], i);
  162. }
  163. for (var i = 0; i &lt; cf.dlgGlobalSize('xxAggs'); i++)
  164. {
  165. var aggs = cf.dlgGlobalGetParmAt('xxAggs', i);
  166. detailAggs[i] = aggs[0];
  167. regularAggs[i] = aggs[1];
  168. }
  169. if (cf.dlgGlobalGetParm('xxGroupedColInfo') != null)
  170. {
  171. // populate list of grouped columns menu
  172. for (var i = 0; i &lt; cf.dlgGlobalSize('xxGroupedColInfo'); i++)
  173. {
  174. var label = cf.dlgGlobalGetParmAt('xxGroupedColInfo', i);
  175. document.f.repGroups.options[document.f.repGroups.options.length] = new Option(label[0], label[1]);
  176. }
  177. document.getElementById("displayBasedOn").style.display = "inline";
  178. }
  179. var validCalcs = new Array();
  180. for (var i = 0; i &lt; cf.dlgGlobalSize('xxValidCalcItem'); i++)
  181. validCalcs[validCalcs.length] = cf.dlgGlobalGetParmAt('xxValidCalcItem', i);
  182. if (cf.dlgGlobalGetParm('xxCalcType') == 'interval')
  183. populateCalculationList(calcType, validCalcs);
  184. else
  185. populateCalculationList(calcType, validCalcs, "analytic");
  186. // select calculation
  187. document.f.calcList.selectedIndex = cf.dlgGlobalGetParm('xxCalcTypeIdx');
  188. if (cf.dlgGlobalGetParm('xxCalcType') != 'interval')
  189. document.f.calcNumberList.selectedIndex = cf.dlgGlobalGetParm('xxCalcSubTypeIdx');
  190. if (cf.dlgGlobalGetParm('xxGroupedColInfo') != null)
  191. {
  192. document.f.basedOn[0].checked = true;
  193. document.f.repGroups.disabled = true;
  194. }
  195. updateRepItemSelection();
  196. loadHint();
  197. setGlobals(calcType, false);
  198. addInsert();
  199. }
  200. function toggleRepGroupsState()
  201. {
  202. if (document.f.basedOn[0].checked)
  203. document.f.repGroups.disabled = true;
  204. else
  205. document.f.repGroups.disabled = false;
  206. }
  207. function updateRepItemSelection()
  208. {
  209. if (cf.dlgGlobalGetParm('xxGroupedColInfo') == null)
  210. {
  211. document.getElementById("displayBasedOn").style.display = "none";
  212. groupsInfoValid = false;
  213. }
  214. else
  215. {
  216. document.getElementById("displayBasedOn").style.display = "inline";
  217. groupsInfoValid = true;
  218. }
  219. onSelOperation();
  220. }
  221. //--&gt;</script>
  222. </dp:script>
  223. <form style="margin:0px" name="f" method="POST" onsubmit="execute();return false;">
  224. <table border="0" cellspacing="0" cellpadding="0" height="100%" width="100%">
  225. <tr>
  226. <td width="100%" height="0%">
  227. <!-- dialog header -->
  228. <clcdlg:basic_header/>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td width="100%" height="100%" valign="top">
  233. <lyt:layout style="2" border="no">
  234. <lyt:section>
  235. <xsl:if test="/root/env/param[@name='xxCalcType']!='interval'">
  236. <clcdlg:calculationsType/>
  237. </xsl:if>
  238. <clcdlg:calculations/>
  239. <dp:input>
  240. <dp:section1>
  241. <xts:string id="CALCULATION_REP_ITEM"/>
  242. </dp:section1>
  243. <dp:section2>
  244. <select name="repSel" size="1" style="width:260" onChange="javascript:updateRepItemSelection();"/>
  245. </dp:section2>
  246. </dp:input>
  247. <div id="displayBasedOn" style="display:none">
  248. <dp:choice title="CALCULATION_BASED_ON_LABEL">
  249. <dp:section1>
  250. <input type="radio" name="basedOn" onClick="javascript:onSelOperation();toggleRepGroupsState();"/>
  251. </dp:section1>
  252. <dp:section2>
  253. <xts:string id="CALCULATION_ALLVALUES"/>
  254. </dp:section2>
  255. <dp:section1>
  256. <input type="radio" name="basedOn" onClick="javascript:onSelOperation();toggleRepGroupsState();"/>
  257. </dp:section1>
  258. <dp:section2>
  259. <xts:string id="CALCULATION_GROUP"/>
  260. </dp:section2>
  261. <dp:section3>
  262. <select name="repGroups" size="1" style="width:260" onChange="javascript:onSelOperation();"/>
  263. </dp:section3>
  264. </dp:choice>
  265. </div>
  266. </lyt:section>
  267. <lyt:section>
  268. <clcdlg:calc_hint/>
  269. </lyt:section>
  270. </lyt:layout>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td width="100%" height="0%">
  275. <!-- Use default buttons [ OK = execute() and CANCEL = hideDialogFrame() ] -->
  276. <clcdlg:buttons/>
  277. </td>
  278. </tr>
  279. <!-- <dbg:dumpxml select="/"/> -->
  280. </table>
  281. </form>
  282. </dp:page>
  283. </xsl:template>
  284. </xsl:stylesheet>
  285. </xts:block>
  286. </xts:morphlet>