DataItemAPI.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2018, 2021
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * @interface DataItemAPI
  10. * @classdesc API class that is used to work with data items.
  11. * @example slots.getDataItem(<dataItemId>)
  12. * @example slots.getDataItemList()[<index>]
  13. * @example slots.getMappingInfoList()[<index>].dataItem
  14. */
  15. define([], function () {
  16. var DataItemAPI = function () {
  17. function DataItemAPI() {
  18. _classCallCheck(this, DataItemAPI);
  19. }
  20. /**
  21. * @description Returns the unique ID that identifies the given data item.
  22. *
  23. * @function DataItemAPI#getId
  24. * @public
  25. *
  26. * @return {String} ID of the data item
  27. */
  28. DataItemAPI.prototype.getId = function getId() {};
  29. // setLabel is not exposed as API. It is not needed for now.
  30. // /**
  31. // * @description Set dataitem label.
  32. // *
  33. // * @function DataItemAPI#setLabel
  34. // * @private
  35. // *
  36. // * @param {String} label
  37. // */
  38. // setLabel() { }
  39. /**
  40. * @description Returns the data item label.
  41. *
  42. * @function DataItemAPI#getLabel
  43. * @public
  44. *
  45. * @return {String} Label of the data item
  46. */
  47. DataItemAPI.prototype.getLabel = function getLabel() {};
  48. /**
  49. * @description Returns the item ID that this data item references. An item ID is the metadata columnId.
  50. *
  51. * @function DataItemAPI#getColumnId
  52. * @public
  53. *
  54. * @return {String} columnId
  55. */
  56. DataItemAPI.prototype.getColumnId = function getColumnId() {};
  57. /**
  58. * @description Returns the navigation path ID associated with this data item.
  59. *
  60. * @function DataItemAPI#getNavigationPathId
  61. * @private
  62. *
  63. * @return {String} navigationPathId
  64. */
  65. DataItemAPI.prototype.getNavigationPathId = function getNavigationPathId() {};
  66. /**
  67. * @description Sets the navigation path ID associated with this data item.
  68. *
  69. * @function DataItemAPI#setNavigationPathId
  70. * @private
  71. *
  72. * @param {String} id
  73. * @param {transactionToken} [transactionToken]
  74. *
  75. */
  76. DataItemAPI.prototype.setNavigationPathId = function setNavigationPathId() {};
  77. /**
  78. * @description Returns the item data type.
  79. * @function DataItemAPI#getDataType
  80. * @public
  81. *
  82. * @return {String} dataType { 'string' | 'decimal' }
  83. */
  84. DataItemAPI.prototype.getDataType = function getDataType() {};
  85. /**
  86. * @description Returns true if the data item is a data or time type. Data or time types include: date, datetime, time, year.
  87. * @function DataItemAPI#isDateOrTimeType
  88. * @private
  89. *
  90. * @return {Boolean} isDateOrTimeType
  91. */
  92. DataItemAPI.prototype.isDateOrTimeType = function isDateOrTimeType() {};
  93. /**
  94. * @description Returns the type of the data item. The type can be either 'attribute' or 'fact'.
  95. * @function DataItemAPI#getType
  96. * @public
  97. *
  98. * @return {String} type
  99. */
  100. DataItemAPI.prototype.getType = function getType() {};
  101. /**
  102. * @description Returns the data item aggregation type.
  103. * @function DataItemAPI#getAggregation
  104. * @public
  105. *
  106. * @return {String} aggregationType is explicitly set, or has a value, otherwise the default metadata aggregation value
  107. *
  108. */
  109. DataItemAPI.prototype.getAggregation = function getAggregation() {};
  110. /**
  111. * @description Sets the data item aggregation type.
  112. * @function DataItemAPI#setAggregation
  113. * @public
  114. *
  115. * @param {aggregation} [aggregation = null]
  116. * @param {transactionToken} [transactionToken]
  117. */
  118. DataItemAPI.prototype.setAggregation = function setAggregation() /*aggregation, transactionToken*/{};
  119. /**
  120. * @description Returns true if the data item aggregation type was not explicitly set.
  121. * @function DataItemAPI#hasDefaultAggregation
  122. * @public
  123. *
  124. * @return {Boolean} hasDefaultAggregation
  125. *
  126. */
  127. DataItemAPI.prototype.hasDefaultAggregation = function hasDefaultAggregation() {};
  128. /**
  129. * @description Returns true if the data item sort type was not explicitly set.
  130. * @function DataItemAPI#hasDefaultSort
  131. * @public
  132. *
  133. * @return {Boolean} hasDefaultSort
  134. *
  135. */
  136. DataItemAPI.prototype.hasDefaultSort = function hasDefaultSort() {};
  137. /**
  138. * @description Returns true if the data item format type was not explicitly set.
  139. * @function DataItemAPI#hasDefaultFormat
  140. * @public
  141. *
  142. * @return {Boolean} hasDefaultFormat
  143. *
  144. */
  145. DataItemAPI.prototype.hasDefaultFormat = function hasDefaultFormat() {};
  146. /**
  147. * @description Returns the column metadata that is associated with this data item.
  148. *
  149. * @function DataItemAPI#getMetadataColumn
  150. * @private
  151. *
  152. * @return {MetadataColumnAPI} columnMetadata returns null if the metadata item is not available
  153. */
  154. DataItemAPI.prototype.getMetadataColumn = function getMetadataColumn() {};
  155. /**
  156. * @description Returns the data format for this data item.
  157. * @function DataItemAPI#getFormat
  158. * @public
  159. *
  160. * @param {Object} options ignoreDefaultFormatting (ignore any default formatting)
  161. * @return {FormatSpec} Format spec
  162. */
  163. DataItemAPI.prototype.getFormat = function getFormat() /* options */{};
  164. /**
  165. * @description Sets the format spec for the given data item.
  166. * @function DataItemAPI#setFormat
  167. * @public
  168. *
  169. * @param {FormatSpec} formatSpec
  170. * @param {transactionToken} transactionToken
  171. *
  172. */
  173. DataItemAPI.prototype.setFormat = function setFormat() /*formatSpec, transactionToken*/{};
  174. /**
  175. * @description Gets the effective sort spec. If a user sort is set, then it is returned. Otherwise, the default sort is returned.
  176. *
  177. * @function DataItemAPI#getSort
  178. * @public
  179. * @return {SortSpec}
  180. *
  181. * @example
  182. * {
  183. * type: String ('asc' | 'desc' | 'null'),
  184. * priority: Number,
  185. * by: String ('caption' | 'value'),
  186. * context: String (column id used for the sort context)
  187. * custom: Object (specify sort overrides)
  188. * custom.top: String[] (Use values of members to move to the top of the sorted list)
  189. * custom.enabled: Boolean (indicate if custom sort is enabled)
  190. * }
  191. *
  192. */
  193. DataItemAPI.prototype.getSort = function getSort() {};
  194. /**
  195. * @description Gets the top/bottom information that is set on the data item.
  196. * @function DataItemAPI#getTopBottom
  197. * @public
  198. * @example
  199. * {
  200. * type: String ('topcount' | 'toppercent' | 'bottomcount' | 'bottompercent'),
  201. * value: Number,
  202. * rank: boolean
  203. * context: Object (with itemId and aggregate)
  204. * }
  205. *
  206. * @return {TopBottomInfo}
  207. *
  208. */
  209. DataItemAPI.prototype.getTopBottom = function getTopBottom() {};
  210. /**
  211. * @description Sets the top/bottom information on the data item.
  212. * @function DataItemAPI#setTopBottom
  213. * @public
  214. *
  215. * @example
  216. * {
  217. * type: String ('topcount' | 'toppercent' | 'bottomcount' | 'bottompercent'),
  218. * value: Number,
  219. * rank: boolean,
  220. * context: measure (column id) can be used when the topbottom applied on the categories
  221. * }
  222. *
  223. * @param {TopBottomInfo} topBottomInfo
  224. * @param {transactionToken} transactionToken
  225. *
  226. */
  227. DataItemAPI.prototype.setTopBottom = function setTopBottom() /* topBottomInfo, transactionToken */{};
  228. /**
  229. * @description Returns true if the data item is a hierarchy and we can drill down.
  230. * @function DataItemAPI#canDrillDown
  231. * @public
  232. *
  233. * @return {Boolean} canDrillDown
  234. */
  235. DataItemAPI.prototype.canDrillDown = function canDrillDown() {};
  236. /**
  237. * @description Drill down in a data item.
  238. *
  239. * @function DataItemAPI#drillDown
  240. * @public
  241. *
  242. * @param {String} value
  243. * @param {transactionToken} transactionToken
  244. *
  245. *
  246. */
  247. DataItemAPI.prototype.drillDown = function drillDown() /* value, transactionToken */{};
  248. /**
  249. * @description Gets the drill down value (member id) if a drill down is set.
  250. *
  251. * @function DataItemAPI#getDrillDownValue
  252. * @public
  253. *
  254. * @return {String} drillDown value
  255. */
  256. DataItemAPI.prototype.getDrillDownValue = function getDrillDownValue() {};
  257. /**
  258. * @description Drill up in a data item.
  259. *
  260. * @function DataItemAPI#drillUp
  261. * @public
  262. *
  263. * @param {String} value
  264. * @param {transactionToken} transactionToken
  265. *
  266. *
  267. */
  268. DataItemAPI.prototype.drillUp = function drillUp() /* value, transactionToken */{};
  269. /**
  270. * @description Gets the drill up value (member id) if a drill up is set.
  271. *
  272. * @function DataItemAPI#getDrillDownValue
  273. * @public
  274. *
  275. * @return {String} drillUp value
  276. */
  277. DataItemAPI.prototype.getDrillUpValue = function getDrillUpValue() {};
  278. /**
  279. * @description Clears the drill up or down selection.
  280. *
  281. * @function DataItemAPI#clearDrill
  282. * @public
  283. *
  284. * @param {transactionToken} transactionToken
  285. */
  286. DataItemAPI.prototype.clearDrill = function clearDrill() {};
  287. /**
  288. * @description Enables binning in the data item.
  289. * @function DataItemAPI#setBinning
  290. * @private
  291. *
  292. * @param {BinningSpec} binningSpec - null to clear the binning
  293. * @param {transactionToken} transactionToken
  294. *
  295. */
  296. DataItemAPI.prototype.setBinning = function setBinning() /* binningSpec, transactionToken */{};
  297. /**
  298. * @description Gets the binning json object if specified for this data item.
  299. * @function DataItemAPI#getBinning
  300. * @private
  301. *
  302. * @return {BinningSpec} Returns binning spec. If there is no binning, returns undefined.
  303. */
  304. DataItemAPI.prototype.getBinning = function getBinning() {};
  305. /**
  306. * @description Returns true if the model sort type has been set.
  307. * @function DataItemAPI#hasModelSort
  308. * @private
  309. *
  310. * @return {Boolean} hasModelSort
  311. */
  312. DataItemAPI.prototype.hasModelSort = function hasModelSort() {};
  313. /**
  314. * @description Sets the type, sort-by method and priority of sort on the data item.
  315. *
  316. * @function DataItemAPI#setSort
  317. * @public
  318. * @param {SortSpec} sortSpec
  319. * @param {transactionToken} transactionToken
  320. *
  321. */
  322. DataItemAPI.prototype.setSort = function setSort() /* sortSpec, transactionToken */{};
  323. /**
  324. * @description Gets the union information that is set on the data item.
  325. * @function DataItemAPI#getUnion
  326. * @private
  327. * @return {UnionAPI}
  328. */
  329. DataItemAPI.prototype.getUnion = function getUnion() {};
  330. /**
  331. * @description Indicates if the data item is not available. Returns true if the column was deleted or hidden.
  332. * @function DataItemAPI#isUnavailable
  333. * @public
  334. * @return {Boolean}
  335. */
  336. DataItemAPI.prototype.isColumnUnavailable = function isColumnUnavailable() {};
  337. /**
  338. * @description Serialize the set of actions/parameters applied to a dataItem (eg sort or topbottom) as a JSON object array.
  339. * This function can be used to make API calls to re-apply actions to re-construct a basic dataItem with columnId from scratch
  340. * in a widgetspec-agnostic way.
  341. * @function DataItemAPI#serializeActions
  342. * @example
  343. * [{
  344. * name: 'setSort',
  345. * params: [{ type: 'desc' }]
  346. * },{
  347. * name: 'setTopBottom',
  348. * params: [{ type: 'topcount', value: '2', context: { itemId: 'Sales.Revenue' }}]
  349. * }]
  350. * @return {Object} the actions serialized as a JSON object.
  351. */
  352. DataItemAPI.prototype.serializeActions = function serializeActions() {};
  353. return DataItemAPI;
  354. }();
  355. /**
  356. * @description Enum for all supported topbottom type.
  357. * @readonly
  358. * @enum {String}
  359. * @constant
  360. * @memberOf DataItemAPI
  361. */
  362. DataItemAPI.TOPBOTTOM_TYPE = {
  363. topcount: 'topcount',
  364. toppercent: 'toppercent',
  365. bottomcount: 'bottomcount',
  366. bottompercent: 'bottompercent'
  367. };
  368. /**
  369. * @description Enum for all supported aggregation type.
  370. * @readonly
  371. * @enum {String}
  372. * @constant
  373. * @memberOf DataItemAPI
  374. */
  375. DataItemAPI.AGGREGATION_TYPE = {
  376. none: 'none',
  377. average: 'avg',
  378. automatic: 'automatic',
  379. calculated: 'calculated',
  380. count: 'count',
  381. countDistinct: 'countdistinct',
  382. maximum: 'max',
  383. median: 'median',
  384. minimum: 'min',
  385. standardDeviation: 'stddev',
  386. total: 'sum',
  387. variance: 'variance'
  388. };
  389. return DataItemAPI;
  390. });
  391. //# sourceMappingURL=DataItemAPI.js.map