123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2019, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['./QueryPostProcessor'], function (QueryPostProcessor) {
- /**
- * @description Property display value is used for dashboard rendering, and the corresponding member unique id is
- * used for filters or other actions. V2 query response has property display values embedded in its parent valueSet.
- * This class maps olap property display value to '.d' in identifier to make v2 query response algin with
- * current dashboard implementation so v1 and v2 queries can follow the same logic.
- *
- * @example The response identifiers with an olap property:
- * '1': {
- * 'ihId': 1,
- * 'd': 'Camping Equipment',<-corresponding member display value
- * 'u': '[Sales (analysis)].[Products].[Products].[Product line]->[Products].[991]',<-corresponding member unique id
- * 'Product line code': {<-property name
- * 'v': 991<-property display value
- * }
- * }
- *
- * After process:
- * '1': {
- * 'ihId': 1,
- * 'd': 991,
- * 'u': '[Sales (analysis)].[Products].[Products].[Product line]->[Products].[991]',<-corresponding member unique id
- * }
- **/
- return function (_QueryPostProcessor) {
- _inherits(PostProcessOlapProperties, _QueryPostProcessor);
- /**
- * @Constructor
- * @param {Object} queryResultData The raw query result data
- * @param {VisualizationAPI} visualization The {@link VisualizationAPI}
- */
- function PostProcessOlapProperties(_ref) {
- var queryResultData = _ref.queryResultData,
- visualization = _ref.visualization;
- _classCallCheck(this, PostProcessOlapProperties);
- var _this = _possibleConstructorReturn(this, _QueryPostProcessor.call(this, { queryResultData: queryResultData }));
- _this.visualization = visualization;
- _this.visDataItems = _this.visualization.getSlots().getDataItemList() || [];
- _this.edges = _this._queryResultData.edges;
- return _this;
- }
- /**
- * Apply the users overrides
- * @return {QueryResultData}
- */
- PostProcessOlapProperties.prototype._processData = function _processData() {
- // TODO Need to handle list viz post endor r5.
- if (this.edges) {
- // Build properties map from slots data items with property id as the key and the property label as the value.
- var properties = {};
- this.visDataItems.forEach(function (visDataItem) {
- var metadataColumn = visDataItem.getMetadataColumn();
- if (metadataColumn && metadataColumn.isProperty()) {
- properties[visDataItem.getId()] = metadataColumn.getLabel();
- }
- });
- var propertiesIds = Object.keys(properties);
- var propertyIdx = -1;
- if (propertiesIds.length) {
- // Build ihId and property name map from query response if query has any property projected
- var ihIdAndPropertyNameMap = {};
- this.edges.forEach(function (edge) {
- edge.itemClasses.forEach(function (itemClass) {
- itemClass.h.forEach(function (header) {
- propertyIdx = propertiesIds.indexOf(header.di);
- if (propertyIdx !== -1) {
- ihIdAndPropertyNameMap[header.ihId] = properties[propertiesIds[propertyIdx]];
- }
- });
- });
- var ihIdsOfProperties = Object.keys(ihIdAndPropertyNameMap);
- if (ihIdsOfProperties.length) {
- // Replace identifiers .d value: replace member caption with projected property value.
- ihIdsOfProperties.forEach(function (ihId) {
- //edge.identifiers might not be defined;
- edge.identifiers && Object.values(edge.identifiers).forEach(function (identifier) {
- if (identifier.ihId === parseInt(ihId)) {
- var propertyName = ihIdAndPropertyNameMap[ihId];
- if (identifier[propertyName]) {
- identifier.d = identifier[propertyName].v;
- delete identifier[propertyName];
- }
- }
- });
- });
- ihIdAndPropertyNameMap = {};
- }
- });
- }
- }
- return this._queryResultData;
- };
- return PostProcessOlapProperties;
- }(QueryPostProcessor);
- });
- //# sourceMappingURL=PostProcessOlapProperties.js.map
|