123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Dashboard
- * (C) Copyright IBM Corp. 2018, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- */
- define(['underscore', '../../../visualizations/renderer/sequence/BaseTask', './SummaryTypes'], function (_, BaseTask, SummaryTypes) {
- 'use strict';
- /**
- * @class SummaryTask
- * Task to run the summary queries as part of the render sequence
- */
- var SummaryTask = BaseTask.extend({
- init: function init(options, moduleOptions) {
- SummaryTask.inherited('init', this, arguments);
- this.feature = moduleOptions.summaryFeature;
- this.visualization = moduleOptions.visualization;
- this.content = moduleOptions.content;
- },
- /**
- * @private
- * @function _requiresSummaryQuery
- * Check if the current data mapping requires a summary query
- * @return {boolean} true if visualization requires a summary query based on the current mapping, otherwise false
- */
- _requiresSummaryQuery: function _requiresSummaryQuery() {
- // Check the visualization property first if it requires summaries
- var v2QuerySupported = this.content.getFeature('Visualization').getType() === 'Crosstab';
- if (v2QuerySupported || this.feature.isNotSupported() || this.content.getPropertyValue('hideSummaries') === true) {
- return false;
- }
- // We assume the SummaryTask is created because
- // the visualization supports summary queries
- // question is it required to do sumbit a summary query
- return _.find(this.visualization.getSlots().getMappedSlotList(), function (slotAPI) {
- return _.find(slotAPI.getDataItemList(), function (dataItemAPI) {
- if (dataItemAPI.getType() === 'fact' && slotAPI.getDefinition().getProperty('summaryValues')) {
- return SummaryTypes.indexOf(dataItemAPI.getAggregation()) > -1;
- }
- });
- }) ? true : false;
- },
- /**
- * @public
- * @override
- * @function process
- * Process the summaries
- * @param {Object} renderContext - The render renderContext
- * @returns {Promise} - Promise which resolves when the task is finished
- */
- process: function process(renderContext) {
- var _this = this;
- if (this._isStepComplete(renderContext, this.getId())) {
- return Promise.resolve(renderContext);
- }
- if (this._requiresSummaryQuery()) {
- this._queryExecution = this._queryExecution || this.content.getFeature('DataQueryExecution');
- this._queryModifier = this._queryModifier || this.content.getFeature('SummaryQueryModifier');
- this._queryModifier.resetDataItemIdList();
- var projectionsList = this._getProjectionList();
- _.each(projectionsList, function (projections, idx) {
- _this._queryModifier.addDataItemIdList(projections);
- _this.feature.addSummaryQueryResult(idx, _this._queryExecution.executeQueries('summary'));
- });
- }
- this._completeStep(renderContext, this.getId(), arguments);
- return Promise.resolve(renderContext);
- },
- /**
- * @private
- * Assemble the query projections from category and measure unique ids.
- * @returns {string[]} An array of arrays corresponding to the summary query projection list.
- * @example
- * oQueryProjections = {
- * aCategoryUIds: [[A],[AB],[ABC],[D],[DE],[EDF],[AD],[ADE],[ADEF],[ABD],[ABDE],[ABDEF],[ABCD],[ABCDE]],
- * aOrdinalUIds: [G, H]
- * }
- * result = [
- ['A','G','H'],
- ['A','B','G','H'],
- ['A','B','C','G','H'],
- ['D','G','H'],
- ['D','E','G','H'],
- ['D','E','F','G','H'],
- ['A','D','G','H'],
- ['A','D','E','G','H'],
- ['A','D','E','F','G','H'],
- ['A','B','D','G','H'],
- ['A','B','D','E','G','H'],
- ['A','B','D','E','F','G','H'],
- ['A','B','C','D','G','H'],
- ['A','B','C','D','E','G','H'],
- ['G','H']
- ]
- */
- _getProjectionList: function _getProjectionList() {
- var oQueryProjections = this.feature && this.feature.getProjectionListObj();
- if (_.isEmpty(oQueryProjections)) {
- return [];
- }
- var aSummaryQueryProjections = _.map(oQueryProjections.aCategoryUIds, function (uIds) {
- return uIds.concat(oQueryProjections.aOrdinalUIds);
- });
- aSummaryQueryProjections.push(oQueryProjections.aOrdinalUIds); // The last query is the overall summary query.
- return aSummaryQueryProjections;
- }
- });
- return SummaryTask;
- });
- //# sourceMappingURL=SummaryTask.js.map
|