agentTreeObjects.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2008 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. var K_sQUERYSUBJECT = "querySubject";
  11. var K_sHIERARCHY = "hierarchy";
  12. var K_sDIMENSION = "dimension";
  13. var K_sFILTER = "filter";
  14. var K_sMEASURE_FOLDER = "measureFolder";
  15. var K_sMEASUREDIMENSION = "measureDimension";
  16. var K_sHIERARCHY_FOLDER = "hierarchyFolder";
  17. var K_sQUERYITEMFOLDER = "queryItemFolder";
  18. var K_sFOLDER = "folder";
  19. var K_sNAMESPACE = "namespace";
  20. var K_sCALCULATION = "calculation";
  21. var K_sCALCULATIONCONSTANT = "calculationConstant";
  22. var K_sMEASURE = "measure";
  23. var K_sROLLUPMEASURE = "rollupMeasure";
  24. var K_sNAMEDSET = "namedSet";
  25. var K_sLEVEL = "level";
  26. var K_sQUERYITEM = "queryItem";
  27. var K_sMEMBER = "member";
  28. var K_sMEMBER_FOLDER = "memberFolder";
  29. var K_sMEMBER_SEARCH = "memberSearch";
  30. function mdQuerySubject(name, path, ref, parent, type)
  31. {
  32. this.name = name;
  33. this.ref = ref;
  34. this.path = path;
  35. this.parent = parent;
  36. this.type = type;
  37. }
  38. function mdFilter(name, path, ref, parent, type)
  39. {
  40. this.name = name;
  41. this.ref = ref;
  42. this.path = path;
  43. this.parent = parent;
  44. this.type = type;
  45. }
  46. function mdQueryItemFolder(name, path, ref, parent, type)
  47. {
  48. this.name = name;
  49. this.ref = ref;
  50. this.path = path;
  51. this.parent = parent;
  52. this.type = type;
  53. }
  54. function mdFolder(name, path, ref, parent, type)
  55. {
  56. this.name = name;
  57. this.ref = ref;
  58. this.path = path;
  59. this.parent = parent;
  60. this.type = type;
  61. }
  62. function mdCalculation(name, path, ref, datatype, usage, regularAggregate, semiAggregate, promptType, displayType, sortOnRef, promptCascadeOnRef, promptFilterItemRef, parent, type)
  63. {
  64. this.name = name;
  65. this.ref = ref;
  66. this.path = path;
  67. this.datatype = datatype;
  68. this.usage = usage;
  69. this.regularAggregate = regularAggregate;
  70. this.semiAggregate = semiAggregate;
  71. this.promptType = promptType;
  72. this.displayType = displayType;
  73. this.sortOnRef = sortOnRef;
  74. this.promptCascadeOnRef = promptCascadeOnRef;
  75. this.promptFilterItemRef = promptFilterItemRef;
  76. this.parent = parent;
  77. this.type = type;
  78. }
  79. function mdQueryItem(name, path, ref, datatype, usage, regularAggregate, semiAggregate, promptType, displayType, sortOnRef, promptCascadeOnRef, promptFilterItemRef, parent, type)
  80. {
  81. this.name = name;
  82. this.ref = ref;
  83. this.path = path;
  84. this.datatype = datatype;
  85. this.usage = usage;
  86. this.regularAggregate = regularAggregate;
  87. this.semiAggregate = semiAggregate;
  88. this.promptType = promptType;
  89. this.displayType = displayType;
  90. this.sortOnRef = sortOnRef;
  91. this.promptCascadeOnRef = promptCascadeOnRef;
  92. this.promptFilterItemRef = promptFilterItemRef;
  93. this.parent = parent;
  94. this.type = type;
  95. }
  96. function mdMember(path, ref, levelLabel, levelNumber, levelUniqueName, memberCaption, memberUniqueName, parentUniqueName, type)
  97. {
  98. this.path = path;
  99. this.ref = ref;
  100. this.levelLabel = levelLabel;
  101. this.levelNumber = levelNumber;
  102. this.levelUniqueName = levelUniqueName;
  103. this.memberCaption = memberCaption;
  104. this.memberUniqueName = memberUniqueName;
  105. this.parentUniqueName = parentUniqueName;
  106. this.type = type;
  107. // put these in to get OLAP Reports working
  108. this.name = memberCaption;
  109. this.datatype = "";
  110. this.usage = "";
  111. this.regularAggregate = "none";
  112. this.semiAggregate = "none";
  113. this.promptType = "";
  114. this.displayType = "";
  115. this.sortOnRef = "";
  116. this.promptCascadeOnRef = "";
  117. this.promptFilterItemRef = "";
  118. this.parent = "";
  119. }
  120. // we create an item - but there's nothing in there
  121. function mdSearch(path, type)
  122. {
  123. this.path = path;
  124. this.type = type;
  125. }
  126. // define all the metadata object functions
  127. var dropValueFunction = function()
  128. {
  129. return this.ref;
  130. }
  131. var replaceFunction = function()
  132. {
  133. return this;
  134. }
  135. // set this into all the prototypes
  136. mdQuerySubject.prototype.getDropValue = dropValueFunction;
  137. mdFilter.prototype.getDropValue = dropValueFunction;
  138. mdQueryItemFolder.prototype.getDropValue = dropValueFunction;
  139. mdFolder.prototype.getDropValue = dropValueFunction;
  140. mdCalculation.prototype.getDropValue = dropValueFunction;
  141. mdQueryItem.prototype.getDropValue = dropValueFunction;
  142. mdMember.prototype.getDropValue = dropValueFunction;
  143. // this is a hack - Tree assumes we're passing strings but we pass objects instead.
  144. // tree calls replace function - so we have to define a replace function for the object
  145. // we're adding.
  146. mdQuerySubject.prototype.replace = replaceFunction;
  147. mdFilter.prototype.replace = replaceFunction;
  148. mdQueryItemFolder.prototype.replace = replaceFunction;
  149. mdFolder.prototype.replace = replaceFunction;
  150. mdCalculation.prototype.replace = replaceFunction;
  151. mdQueryItem.prototype.replace = replaceFunction;
  152. mdMember.prototype.replace = replaceFunction;
  153. mdSearch.prototype.replace = replaceFunction;
  154. function fnGroup(name, qosLevel)
  155. {
  156. this.name = name;
  157. this.qosLevel = qosLevel;
  158. }
  159. fnGroup.prototype.getDropValue = function()
  160. {
  161. return this.name;
  162. }
  163. fnGroup.prototype.replace = replaceFunction;
  164. function fnFunction(dropText, name, syntax, tip, type, qosLevel)
  165. {
  166. this.dropText = dropText;
  167. this.name = name;
  168. this.syntax = syntax;
  169. this.tip = tip;
  170. this.type = type;
  171. this.qosLevel = qosLevel;
  172. }
  173. fnFunction.prototype.getDropValue = function()
  174. {
  175. var dropValue = null;
  176. if (this.dropText.localeCompare("@listSeparator") == 0) {
  177. dropValue = cf.cfgGet("META_ListSeparator");
  178. } else if (this.dropText.localeCompare("@date") == 0) {
  179. dropValue = getDateString();
  180. } else if (this.dropText.localeCompare("@dateTime") == 0) {
  181. dropValue = getDateTimeString();
  182. } else if (this.dropText.localeCompare("@time") == 0) {
  183. dropValue = getTimeString();
  184. } else {
  185. dropValue = this.dropText;
  186. }
  187. // make sure we have a drop value
  188. if (dropValue == "") {
  189. dropValue = this.name + "(";
  190. }
  191. // otherwise return the drop text
  192. return dropValue;
  193. }
  194. fnFunction.prototype.replace = replaceFunction;
  195. function getDateString()
  196. {
  197. var ret_value = "";
  198. var date = new Date();
  199. var year = date.getFullYear();
  200. var month = date.getMonth()+1;
  201. var date = date.getDate();
  202. ret_value = pad(year,4) + "-" + pad(month,2) + "-" + pad(date,2);
  203. return ret_value;
  204. }
  205. function getTimeString()
  206. {
  207. var ret_value = "";
  208. var date = new Date();
  209. var hours = date.getHours();
  210. var minutes = date.getMinutes();
  211. var seconds = date.getSeconds();
  212. var millis = date.getMilliseconds();
  213. ret_value = pad(hours,2) + ":" + pad(minutes,2) + ":" +
  214. pad(seconds,2) + "." + pad(millis,3);
  215. return ret_value;
  216. }
  217. function getDateTimeString()
  218. {
  219. return getDateString() + " " + getTimeString();
  220. }
  221. function pad(val, size)
  222. {
  223. var ret_value = "";
  224. var val_str = new String("" + val);
  225. for (var i = 0; i < size-val_str.length; ++i) {
  226. ret_value += "0";
  227. }
  228. ret_value += val_str;
  229. // return it
  230. return ret_value;
  231. }
  232. function aiDataItem(name, ref, regularAggregate, displayType)
  233. {
  234. this.name = name;
  235. this.ref = ref;
  236. this.regularAggregate = regularAggregate;
  237. this.displayType = displayType;
  238. this.bIsIndicator = false;
  239. this.indicatorPath = "../ags/images/tree/qualifier_key.gif";
  240. }
  241. function aiCalculation(name, path, ref, datatype, usage, regularAggregate, semiAggregate, promptType, displayType, sortOnRef, promptCascadeOnRef, promptFilterItemRef)
  242. {
  243. this.name = name;
  244. this.ref = ref;
  245. this.path = path;
  246. this.datatype = datatype;
  247. this.usage = usage;
  248. this.regularAggregate = regularAggregate;
  249. this.semiAggregate = semiAggregate;
  250. this.promptType = promptType;
  251. this.displayType = displayType;
  252. this.sortOnRef = sortOnRef;
  253. this.promptCascadeOnRef = promptCascadeOnRef;
  254. this.promptFilterItemRef = promptFilterItemRef;
  255. }
  256. function aiParameter(name, acceptRange)
  257. {
  258. this.name = name;
  259. this.acceptRange = acceptRange;
  260. }
  261. function aiHistory(name)
  262. {
  263. this.name = name;
  264. }
  265. var calcDropValueFunction = function()
  266. {
  267. // want to drop the name
  268. return "[" + this.name + "]";
  269. }
  270. var paramDropValueFunction = function()
  271. {
  272. // want to drop the name again
  273. return "?" + this.name + "?";
  274. }
  275. var historyDropValueFunction = function()
  276. {
  277. // want to drop the name again
  278. return "\\[" + this.name + "\\]";
  279. }
  280. var dataItemValueFunction = function()
  281. {
  282. // want just the name
  283. var copyName = this.name;
  284. // the ']' characters shold be escaped, using another ']'
  285. // for the report server to understand them
  286. copyName = copyName.replace(/]/g, "]]");
  287. return "[" + copyName + "]";
  288. }
  289. // define the dropValue functions
  290. aiDataItem.prototype.getDropValue = dataItemValueFunction;
  291. aiCalculation.prototype.getDropValue = calcDropValueFunction;
  292. aiParameter.prototype.getDropValue = paramDropValueFunction;
  293. aiHistory.prototype.getDropValue = historyDropValueFunction;
  294. aiDataItem.prototype.isIndicator = function () {return this.bIsIndicator;}
  295. aiDataItem.prototype.getIndicator = function () {return this.indicatorPath;}
  296. aiDataItem.prototype.replace = replaceFunction;
  297. aiCalculation.prototype.replace = replaceFunction;
  298. aiParameter.prototype.replace = replaceFunction;
  299. aiHistory.prototype.replace = replaceFunction;