config.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** IBM Cognos Products: drill
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2010
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with
  10. ** IBM Corp.
  11. *****************************************************************/
  12. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  13. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  14. //
  15. // the variable "cfgValues" must have been defined in one the files including this script file.
  16. // It is done this way to ensure we have only one valid definition of "cfgValues"
  17. //
  18. var cfgValues = new Array();
  19. //
  20. // --- Configuration management functions ---
  21. //
  22. function cfgSet(n, v) { cfgValues[n] = v; }
  23. function cfgGet(n) { return cfgValues[n]; }
  24. function cfgRemove(n) { delete cfgValues[n]; }
  25. function cfgIsArray(a) {
  26. return isArray(cfgValues[a]);
  27. }
  28. function cfgPush(a, v) {
  29. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  30. addToArray(cfgValues[a], v);
  31. }
  32. function cfgAddParm(n, v) {
  33. if (!isArray(cfgValues[n]))
  34. cfgValues[n] = makeArray(cfgValues[n]);
  35. addToArray(cfgValues[n], v);
  36. }
  37. function cfgSetDefaultAt(i) {
  38. cfgSetAt("ColFormat", i, new Array("none"));
  39. cfgSetAt("IsHidden",i, false);
  40. cfgSetAt("OriginalLabels",i,"");
  41. cfgSetAt("calcOp",i,"");
  42. cfgSetAt("SummaryAgg",i,"none");
  43. cfgSetAt("DetailAgg",i,"none");
  44. cfgSetAt("RegularAgg",i,"none");
  45. cfgSetAt("sortOnRef",i,"none");
  46. cfgSetAt("promptCascadeOnRef",i,"none");
  47. cfgSetAt("promptFilterItemRef",i,"none");
  48. cfgSetAt("PromptType",i,"0");
  49. cfgSetAt("ColFilterIdx",i,new Array());
  50. cfgSetAt("ColLabels",i,"");
  51. cfgSetAt("IsFakeMeasure",i,false);
  52. cfgSetAt("IsMeasure",i,false);
  53. cfgSetAt("IsCollapsed",i,false);
  54. cfgSetAt("ColRole",i,"Ungrouped");
  55. cfgSetAt("HasSummaries",i,false);
  56. cfgSetAt("displayType",i,"");
  57. }
  58. function cfgSetColAt(i, v1, v2, v3, v4, v5, v6, v7) {
  59. cfgSetAt("QueryIDs",i,v1);
  60. cfgSetAt("ColType",i,v2);
  61. cfgSetAt("ColUsage",i,v3);
  62. cfgSetAt("ColSort",i,v4);
  63. cfgSetAt("ColSortBy",i,v5);
  64. cfgSetAt("ColIDs",i,v6);
  65. cfgSetAt("ColOldType",i,v7);
  66. }
  67. function cfgSetAt(a, i, v) {
  68. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  69. insertInArrayAt(cfgValues[a], i, v);
  70. }
  71. function cfgGetAt(a, i) {
  72. if (!cfgIsArray(a)) return null;
  73. return cfgValues[a][i];
  74. }
  75. function cfgPop(a, v) {
  76. if (!cfgIsArray(a)) return;
  77. var bRemoved=false;
  78. var size=cfgValues[a].length;
  79. for (var i=0;i<size;i++) {
  80. if (!bRemoved && cfgValues[a][i]==v) bRemoved=true;
  81. if (bRemoved && i+1<size) cfgValues[a][i]=cfgValues[a][i+1];
  82. }
  83. if (bRemoved) cfgValues[a].length=size-1;
  84. }
  85. function cfgSize(a) {
  86. if (cfgIsArray(a)) return cfgValues[a].length;
  87. return 0;
  88. }
  89. function cfgCountEntriesWithValue(a, v) {
  90. var count=0;
  91. if(cfgIsArray(a)) {
  92. var size=cfgValues[a].length;
  93. for (var i=0;i<size;i++) {
  94. if(cfgValues[a][i] == v)
  95. ++count;
  96. }
  97. }
  98. return count;
  99. }
  100. function cfgIndexOf(a, v) {
  101. if (!cfgIsArray(a)) return -1;
  102. for (var i=0; i<cfgValues[a].length; i++)
  103. if (cfgValues[a][i]==v) return i;
  104. return -1;
  105. }
  106. function cfgMakeArray(a) {
  107. return makeArray(cfgValues[a]);
  108. }
  109. //
  110. // --- Array management functions ---
  111. //
  112. function addToArray(a, v) { if (!contains(a, v)) a[a.length] = v;}
  113. function insertInArrayAt(a, i, v) { a[i] = v; }
  114. function makeArray(a) {
  115. if (a == null || typeof a == "undefined")
  116. a = new Array();
  117. else if (typeof a != "object") {
  118. var tmp = a; a = new Array(); a[0] = tmp;
  119. }
  120. return a;
  121. }
  122. function containsByIndice(a, v) {
  123. for (var i in a)
  124. if (i == v) return true;
  125. return false;
  126. }
  127. function contains(a, v) {
  128. for (var i in a)
  129. if (a[i] == v) return true;
  130. return false;
  131. }
  132. function isArray(a) {
  133. if (a != null && typeof a == "object") return true;
  134. return false;
  135. }
  136. // -----------------------------------------------------------------------------
  137. //
  138. // --- Configuration utilities functions ---
  139. //
  140. // -----------------------------------------------------------------------------
  141. function reinitConfigValues() {
  142. cfgValues = new Array();
  143. cfgSet("productLocale", "en");
  144. cfgSet("contentLocale", "en-US");
  145. cfgSet("numRows", "20");
  146. cfgSet("NewReport", false);
  147. }
  148. function loadCfgArray(type) {
  149. cfgSet("doMetadataTree",false);
  150. cfgSet("BROWSER", browserType);
  151. cfgSet("SELECT_NODE_AT", selectedNode);
  152. cfgSet("SERVER_URL", serverURL);
  153. cfgSet("SCRIPT_ENGINE", scriptEngine);
  154. cfgSet("cmLastModel", model);
  155. cfgSet("START_AT", startAt);
  156. cfgSet("RPT_SVC_PARAM", rptSvcParam);
  157. cfgSet("FALSE",false);
  158. cfgSet("TRUE",true);
  159. if (type)
  160. {
  161. cfgSet("activeTree",true);
  162. cfgSet("SELECT_TYPE",type);
  163. cfgSet("selectNamespace",false);
  164. cfgSet("selectPackage",false);
  165. /* cfgSet("selectFolder",false); */
  166. cfgSet("selectDimension",true);
  167. cfgSet("selectHierarchy",true);
  168. cfgSet("selectLevel",true);
  169. /* cfgSet("selectQItemFldr",false); */
  170. cfgSet("selectQItem",true); /* equivalents : level */
  171. cfgSet("selectMeasureFldr",false);
  172. // These are the setting that are used when we select from meta data tree either for scope or param
  173. if (type=="scope" || type=="param")
  174. {
  175. //Since we don't want the mesaure to be selected when we define the parameters we don't enable these
  176. //If in future we want to enable measure for parameters as well we have to enable these.
  177. //cfgSet("selectMeasureDimn",true);
  178. //cfgSet("selectMeasure",true);
  179. //cfgSet("rollupMeasure",true);
  180. }
  181. else
  182. {
  183. cfgSet("selectMeasureDimn",false);
  184. cfgSet("selectMeasure",false);
  185. cfgSet("rollupMeasure",false);
  186. }
  187. // These are the settings that are used when we select the scope
  188. // settings that are specific to scope should go here.
  189. if (type=="scope")
  190. {
  191. cfgSet("selectMeasureDimn",true); // To allow Measure to be selected
  192. cfgSet("selectMeasure",true); // To allow Measure to be selected
  193. cfgSet("selectHierarchyMesr",true);
  194. cfgSet("selectNamedSet",false);
  195. cfgSet("selectQSubject",true); /* equivalents : dimension; hierarchy */
  196. cfgSet("selectAttributes",false);
  197. cfgSet("selectModelFact",false);
  198. cfgSet("selectModelAttr",false);
  199. cfgSet("selectModelIdent",false);
  200. }
  201. else
  202. {
  203. cfgSet("selectHierarchyMesr",false);
  204. cfgSet("selectNamedSet",true);
  205. cfgSet("selectQSubject",false); /* equivalents : dimension; hierarchy */
  206. cfgSet("selectAttributes",true);
  207. cfgSet("selectModelFact",true);
  208. cfgSet("selectModelAttr",true);
  209. cfgSet("selectModelIdent",true);
  210. }
  211. }
  212. else
  213. {
  214. cfgSet("activeTree",false);
  215. cfgSet("selectNamespace",false);
  216. cfgSet("selectPackage",false);
  217. /* cfgSet("selectFolder",true); */
  218. cfgSet("selectMeasureDimn",false);
  219. cfgSet("selectMeasureFldr",false);
  220. cfgSet("selectHierarchyMesr",false);
  221. cfgSet("selectMeasure",false);
  222. /* cfgSet("selectDimension",true); */
  223. /* cfgSet("selectHierarchy",true); */
  224. /* cfgSet("selectLevel",true); */
  225. cfgSet("selectNamedSet",false);
  226. cfgSet("selectQSubject",false); /* equivalents : dimension; hierarchy */
  227. cfgSet("selectQItem",false); /* equivalents : level */
  228. /* cfgSet("selectQItemFldr",false); */
  229. cfgSet("selectAttributes",false);
  230. cfgSet("selectModelFact",false);
  231. cfgSet("selectModelAttr",false);
  232. cfgSet("selectModelIdent",false);
  233. }
  234. //<xsl:if test="key('env-param','debug')='true'">cf.cfgSet("__DBG__", true);</xsl:if>
  235. // cfgSet("queryLoaded",true);
  236. }