'use strict'; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (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(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', './postProcess/QueryPostProcessHelper', './api/DataQueryExecutionAPI', './api/InternalDataQueryExecutionAPI', './api/QueryResultsAPI', './QueryResults', './DataQueryResult', '../../../widgets/livewidget/nls/StringResources', '../../dashboard/prompts/PromptsState', 'underscore'], function (APIFactory, QueryPostProcessHelper, DataQueryExecutionAPI, InternalDataQueryExecutionAPI, QueryResultsAPI, QueryResults, DataQueryResult, StringResources, PromptsState, _) { var _class, _temp; var DataQueryExecution = (_temp = _class = function () { function DataQueryExecution(params) { _classCallCheck(this, DataQueryExecution); this.MAIN = 'main'; this.content = params.content; this.dashboard = params.dashboardAPI; this.logger = this.dashboard.getGlassCoreSvc('.Logger'); this._queryProviders = {}; this._queryModifiers = {}; this._queryDefinitionProviders = {}; this._queryDefinitionModifiers = {}; this._queryPostProcessors = []; this._queryResults = null; this._rawResults = {}; this._cachedDefinitionList = null; this._requestOptions = {}; // Query key and value pair with the Key constructed from query spec and last modified time stamp, and the value // used to uniquely identify the query result data when render viz. this._queryKeyValuePair = {}; this._promptsState = new PromptsState(); } DataQueryExecution.prototype.getAPI = function getAPI(type) { if (type === 'internal') { if (!this.internalAPI) { this.internalAPI = APIFactory.createAPI(this, [DataQueryExecutionAPI, InternalDataQueryExecutionAPI]); } return this.internalAPI; } else { if (!this.api) { this.api = APIFactory.createAPI(this, [DataQueryExecutionAPI]); } return this.api; } }; DataQueryExecution.prototype.destroy = function destroy() { this.content = null; this.dashboard = null; this.logger = null; this._queryProviders = null; this._queryModifiers = null; this._queryDefinitionProviders = null; this._queryDefinitionModifiers = null; this._rawResults = null; this._cachedDefinitionList = null; this.api = null; if (this._queryResults) { this._queryResults.destroy(); this._queryResults = null; } this._promptsState.destroy(); this._promptsState = null; }; DataQueryExecution.prototype.addRequestOptions = function addRequestOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this._requestOptions = _extends({}, this._requestOptions, options); }; DataQueryExecution.prototype.removeRequestOptions = function removeRequestOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var key = void 0; for (var i = 0; i < options.length; i++) { key = options[i]; if (this._requestOptions[key]) { delete this._requestOptions[key]; } } }; DataQueryExecution.prototype.resetRequestOptions = function resetRequestOptions() { this._requestOptions = {}; }; DataQueryExecution.prototype._isValidOption = function _isValidOption(name) { return this._requestOptionWhiteList && this._requestOptionWhiteList.indexOf(name) !== -1; }; DataQueryExecution.prototype.registerQueryProvider = function registerQueryProvider(provider) { if (provider && provider.getQuerySpecList) { var type = provider.getType(); if (!this._queryProviders[type]) { this._queryProviders[type] = []; } this._queryProviders[type].push(provider); } }; DataQueryExecution.prototype.registerQueryDefinitionProvider = function registerQueryDefinitionProvider(provider) { if (!provider.getQueryDefinitionList) { throw new Error('Invalid QueryDefinitionProvider'); } var type = provider.getType(); if (!this._queryDefinitionProviders[type]) { this._queryDefinitionProviders[type] = []; } this._queryDefinitionProviders[type].push(provider); }; DataQueryExecution.prototype.getCurrentQueryResults = function getCurrentQueryResults() { var results = this._queryResults && this._queryResults.getAPI(); if (!results) { // @todo temporary solution to obtain the query results when the query // was not executed by the new DataQueryExecution var renderSequence = this.content.getFeature('RenderSequence.internal'); results = renderSequence.getCurrentRenderContext('data').getData('data'); } return results; }; DataQueryExecution.prototype.getRawResult = function getRawResult() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'data'; return this._rawResults && this._rawResults[id]; }; /** * Add a spec with max min value as min max query results to the current query results * @param {object} spec - includes data items and min max info * Note - a falsy spec will remove the existing min max query results * eg. * { * reveuneavg: { * min: 20, * max: 100, * columnId: 'revenue', * layerId: 'data' * }, * quantitysum: { * min: -100, * max: 80, * columnId: 'quantity', * layerId: 'data.region' * } * } */ DataQueryExecution.prototype.setMinMaxQueryResults = function setMinMaxQueryResults(spec) { var _this = this; if (spec) { var layersData = {}; _.each(spec, function (dataItemValue, dataItemKey) { var layerId = dataItemValue.layerId; var dataItem = { itemClass: { h: [{ u: dataItemValue.columnId, aggregate: dataItemValue.aggregate }], id: dataItemKey } }; if (layersData[layerId]) { layersData[layerId].pt.push({ v: dataItemValue.min }, { v: dataItemValue.max }); layersData[layerId].dataItems.push(dataItem, dataItem); } else { layersData[layerId] = { pt: [{ v: dataItemValue.min }, { v: dataItemValue.max }], dataItems: [dataItem, dataItem] }; } }); // creates a min max query result per layer _.each(layersData, function (data, layerId) { var mockData = { dataItems: data.dataItems, data: [{ pt: data.pt }] }; var queryResult = new DataQueryResult(mockData, _this._getVisualization().getSlots()); _this._queryResults.addResult(queryResult, layerId, QueryResultsAPI.QUERY_RESULT_TYPE.MINMAX); }); } else { // removes min max queries from all of the layers var layerIds = this._queryResults.getQueryResultIdList(); _.each(layerIds, function (layerId) { _this._queryResults.removeResult(layerId, QueryResultsAPI.QUERY_RESULT_TYPE.MINMAX); }); } return this._queryResults.getAPI(); }; DataQueryExecution.prototype.registerQueryModifier = function registerQueryModifier(modifier) { var _this2 = this; if (modifier && modifier.modifyQuerySpecList) { var type = modifier.getType(); if (!this._queryModifiers[type]) { this._queryModifiers[type] = []; } this._queryModifiers[type].push(modifier); return { remove: function remove() { return _this2._queryModifiers[type].splice(_this2._queryModifiers[type].indexOf(modifier), 1); } }; } }; DataQueryExecution.prototype.registerQueryDefinitionModifier = function registerQueryDefinitionModifier(modifier) { var _this3 = this; if (!modifier.modifyQueryDefinitionList) { throw new Error('Invalid QueryDefinitionModifier'); } var type = modifier.getType(); if (!this._queryDefinitionModifiers[type]) { this._queryDefinitionModifiers[type] = []; } this._queryDefinitionModifiers[type].push(modifier); return { remove: function remove() { return _this3._queryDefinitionModifiers[type].splice(_this3._queryDefinitionModifiers[type].indexOf(modifier), 1); } }; }; DataQueryExecution.prototype.registerQueryPostProcessor = function registerQueryPostProcessor(postProcessor) { var _this4 = this; if (postProcessor) { this._queryPostProcessors.push(postProcessor); return { remove: function remove() { return _this4._queryPostProcessors.splice(_this4._queryPostProcessors.indexOf(postProcessor), 1); } }; } }; DataQueryExecution.prototype.executeQueries = function executeQueries() { var _this5 = this; var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.MAIN; if (this._skipDataQuery()) { return this._buildEmptyData(); } return this._getQueryDefinitionList(type).then(function (queryDefinitions) { // Once the definition list is consumed for query execution // make sure to clear the definition cache _this5._setDefinitionListCache(); //Favour using QueryService2 and its constructs if they support this query _this5._currentV2Specs = null; if (queryDefinitions && queryDefinitions.length) { return _this5._executeQueries(queryDefinitions).then(function (resultList) { _this5.resetRequestOptions(); _this5._resetPromptState(); return resultList; }); } //Otherwise fall back to original QueryService var querySpecList = _this5._getQuerySpecList(type); if (querySpecList) { return _this5._doExecute(querySpecList, type).then(function (resultList) { _this5.resetRequestOptions(); _this5._resetPromptState(); return resultList; }); } else { return Promise.reject(); } }); }; DataQueryExecution.prototype._resetPromptState = function _resetPromptState() { if (this._promptsState.hasInProgressPrompts()) { this._promptsState.reset(); } else { // Clean saved prompts this._getVisualization().getSavedPrompts().reset(); } }; DataQueryExecution.prototype._getQuerySpecList = function _getQuerySpecList() { var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.MAIN; var queryProviderList = this._queryProviders[type]; var queryModifierList = this._queryModifiers[type]; if (queryProviderList && queryProviderList.length > 0) { var querySpecList = []; for (var j = 0; j < queryProviderList.length; j++) { var provider = queryProviderList[j]; var specList = provider.getQuerySpecList(); for (var k = 0; k < specList.length; k++) { var specEntry = specList[k]; querySpecList.push(specEntry); } } if (queryModifierList && queryModifierList.length > 0) { for (var i = 0; i < queryModifierList.length; i++) { var modifier = queryModifierList[i]; querySpecList = modifier.modifyQuerySpecList(querySpecList); } } return querySpecList; } else { this.logger.error('Required query queryProvider is not registered'); } }; DataQueryExecution.prototype._getQueryDefinitionList = function _getQueryDefinitionList(type) { var _this6 = this; // use the cached list if available var cachedList = this._getDefinitionListCache(); if (cachedList) { return Promise.resolve(cachedList); } var allProviders = this._queryDefinitionProviders[type] || []; var providers = allProviders.filter(function (provider) { return provider.supports(_this6.content); }); if (providers.length) { var modifiers = this._queryDefinitionModifiers[type] || []; return Promise.all(providers.map(function (provider) { return provider.getQueryDefinitionList(); })).then(function (definitionLists) { var definitionList = _.flatten(definitionLists); modifiers.forEach(function (modifier) { return definitionList = modifier.modifyQueryDefinitionList(definitionList); }); return _this6._setDefinitionListCache(definitionList); }); } return Promise.resolve(null); }; DataQueryExecution.prototype._setDefinitionListCache = function _setDefinitionListCache() { var definitionList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; this._cachedDefinitionList = definitionList; return this._cachedDefinitionList; }; DataQueryExecution.prototype._getDefinitionListCache = function _getDefinitionListCache() { return this._cachedDefinitionList; }; DataQueryExecution.prototype._doExecute = function _doExecute(queryList, providerType) { var _this7 = this; var slots = this._getVisualization().getSlots(); var internalQueryService = this.dashboard.getFeature('QueryService.internal'); this.currentSpecList = []; var requestOptions = this._getRequestOptions(); for (var i = 0; i < queryList.length; i++) { var query = queryList[i]; this.currentSpecList.push(JSON.stringify(query.spec)); query.result = internalQueryService.executeQuery(query.dataSourceId, query.spec, this.constructor.name, requestOptions); } var resultPromises = _.pluck(queryList, 'result'); return Promise.all(resultPromises).then(function (rawResultList) { // save the raw result _this7._rawResults = {}; _this7._buildQueryTag(queryList, rawResultList); var queryResults = new QueryResults(_this7._queryKeyValuePair.value); if (providerType === _this7.MAIN) { // cache the main query results _this7._queryResults = queryResults; } var _loop = function _loop(index) { var rawResult = rawResultList[index]; var queryId = queryList[index].id; var queryType = queryList[index].type; // Should be able to just pass mapped data items, but due to DSS defect 274285, temporarily pass slots to build result. var resultInstance = new DataQueryResult(rawResult.data, slots); if ((providerType === _this7.MAIN || providerType === 'detail') && queryType === QueryResultsAPI.QUERY_RESULT_TYPE.MAIN) { if (providerType === _this7.MAIN) { // Make the query spec and raw response available as properties in the query result data object resultInstance.setPropertyValue('QuerySpec.internal', JSON.stringify(queryList[index].spec)); // Ideally we should access the raw data from the ajax response as raw string, // but currentlt we don't have access to it because we query using modelling which we should mve away from resultInstance.setPropertyValue('RawData.internal', JSON.stringify(rawResult.data)); resultInstance.setPropertyValue('RequestTime.internal', rawResult.requestTime || null); if (rawResult.data.meta && rawResult.data.meta.messages) { _this7._setQueryFeedbackResult(rawResult.data.meta.messages, resultInstance); } // Keep the raw data _this7._rawResults[queryId] = rawResult.data; } var queryDefinition = { getId: function getId() { return queryId; } }; // Post process query result data _this7._postProcess(rawResult.data, queryDefinition); } queryResults.addResult(resultInstance, queryId, queryType); }; for (var index = 0; index < rawResultList.length; index++) { _loop(index); } return queryResults.getAPI(); }).catch(function (jqXHR) { var dataSource = _this7._getVisualization().getDataSource(); return _this7._handleQueryError({ dataSource: dataSource, error: jqXHR }).then(function (promptInfoList) { if (promptInfoList && promptInfoList.length) { // Rerun queries after resolve the prompts queryList.forEach(function (query) { query.spec.parameterValues = promptInfoList; }); return _this7._doExecute(queryList, providerType); } }); }); }; DataQueryExecution.prototype._setQueryFeedbackResult = function _setQueryFeedbackResult(messages, resultInstance) { for (var i = 0; i < messages.length; i++) { var message = void 0; message = messages[i]; var queryLanguagePropName = void 0; if (message[DataQueryExecution.QUERY_LANGUAGE_PROP_NAMES.QUERY_LANGUAGE]) { queryLanguagePropName = DataQueryExecution.QUERY_LANGUAGE_PROP_NAMES.QUERY_LANGUAGE; } else if (message[DataQueryExecution.QUERY_LANGUAGE_PROP_NAMES.TYPE]) { queryLanguagePropName = DataQueryExecution.QUERY_LANGUAGE_PROP_NAMES.TYPE; } else { return; } var queryLanguage = message[queryLanguagePropName]; if (DataQueryExecution.COGNOS_QUERY_LANGUAGE.indexOf(queryLanguage) !== -1) { resultInstance.setPropertyValue('QueryFeedback.cognosSQL', message.message); } else if (DataQueryExecution.NATIVE_QUERY_LANGUAGE.indexOf(queryLanguage) !== -1) { resultInstance.setPropertyValue('QueryFeedback.nativeSQL', message.message); } else if (DataQueryExecution.MDX_QUERY_LANGUAGE.indexOf(queryLanguage) !== -1) { resultInstance.setPropertyValue('QueryFeedback.MDX', message.message); } } }; DataQueryExecution.prototype._getRequestOptions = function _getRequestOptions() { return this._requestOptions; }; DataQueryExecution.prototype._handleQueryError = function _handleQueryError(_ref) { var _this8 = this; var dataSource = _ref.dataSource, error = _ref.error; var prompts = this.dashboard.getFeature('Prompts'); var isPromptFault = prompts.isPromptFault(error); var promptSpecList = isPromptFault && prompts.getPromptSpecList(error); if (isPromptFault && !this._promptsState.hasInValidState(promptSpecList)) { this._promptsState.updatePromptsState(promptSpecList); return prompts.openPromptView(promptSpecList, this._getVisualization()).then(function (responseList) { return _this8._resolvePromptValues(responseList); }).catch(function (error) { return Promise.reject(error); }); } else { // TODO: We should eventually use 'getName' when it's implemented (it will be synchronous) // instead of using 'getLocalizedName' (which is async) return dataSource.getLocalizedName().then(function (name) { return Promise.reject(_this8._queryFailed(name, error)); }).catch(function (error) { return Promise.reject(error); }); } }; DataQueryExecution.prototype._executeQueries = function _executeQueries(definitions) { var _this9 = this; var queryService = this.dashboard.getFeature('QueryService2'); var query = queryService.createQuery(definitions); query.registerFaultHandler(this._handleQueryError.bind(this)); query.registerPostProcessor(this._postProcess.bind(this)); // Use this object to cache query results prior to post-processing and saving with the result. var rawDataInternalByQueryId = {}; query.registerSaveRawDataHandler(function (rawDataResult, queryId) { //Save an object that contains the queryfeedback metadata (if any) and the raw result to save to the RawData.internal property. //NOTE: Its important to save string (or cloned) raw results here since post-processors can modify the output. rawDataInternalByQueryId[queryId] = { meta: rawDataResult.meta, result: JSON.stringify(rawDataResult) }; }); this._currentV2Specs = JSON.stringify(query.getSpecList()); var requestOptions = this._getRequestOptions(); return query.execute(undefined, requestOptions).then(function (queryResultList) { _this9._buildQueryDefinitionTag(query, queryResultList); var queryResults = new QueryResults(_this9._queryKeyValuePair.value, query.getWarningList()); queryResultList.forEach(function (queryResult, index) { var queryDefinition = definitions[index]; var queryId = queryDefinition.getId(); var queryType = queryDefinition.getType(); var rawResult = rawDataInternalByQueryId[queryId]; queryResult.setPropertyValue('QuerySpec.internal', _this9._currentV2Specs); if (rawResult) { queryResult.setPropertyValue('RawData.internal', rawResult.result); if (rawResult.meta && rawResult.meta.messages) { _this9._setQueryFeedbackResult(rawResult.meta.messages, queryResult); } } queryResults.addResult(queryResult, queryId, queryType); }); return queryResults.getAPI(); }); }; DataQueryExecution.prototype._skipDataQuery = function _skipDataQuery() { var definition = this._getVisualization().getDefinition(); return !!definition.getProperty('noDataQuery'); }; DataQueryExecution.prototype._buildEmptyData = function _buildEmptyData() { var slots = this._getVisualization().getSlots(); var mappedInfo = slots.getMappingInfoList(); var dataItemList = _.pluck(mappedInfo, 'dataItem'); var emptyData = { dataItems: _.map(dataItemList, function (dataItem) { var emptyDataItem = { itemClass: { h: [{ u: dataItem.getColumnId(), d: dataItem.getLabel() }], id: dataItem.getId() } }; // ordinal dataitems requires an aggregation // while categorical dataitems requires an empty items array var aggregate = dataItem.getAggregation(); if (!dataItem.hasDefaultAggregation() && aggregate) { emptyDataItem.itemClass.h[0].aggregate = aggregate; } else { emptyDataItem.items = []; } return emptyDataItem; }), data: [] }; var queryResult = new DataQueryResult(emptyData, slots); var queryResults = new QueryResults(); queryResults.addResult(queryResult); return Promise.resolve(queryResults.getAPI()); }; DataQueryExecution.prototype._resolvePromptValues = function _resolvePromptValues(responseList) { var aPromptInfo = []; var queryProperties = ['name', 'values', 'dataType', 'capabilities', 'modelFilterItem']; _.each(responseList, function (promptResponse) { var promptResult = _.pick(promptResponse, queryProperties); aPromptInfo.push(promptResult); }); this._resetSavedPrompts(aPromptInfo); // Prepare query spec values based on prompt dataType var promptValueSpecs = JSON.parse(JSON.stringify(aPromptInfo)); _.each(promptValueSpecs, function (promptInfo) { // MUN based dataType expect a useValue while all other types expect a displayValue for a parameter. if (!promptInfo.capabilities.optional) { // Check whether saved old spec // TODO may need upgrade for saved spec. var oldSpec = promptInfo.values[0].u; var valueType = void 0; if (oldSpec) { valueType = promptInfo.dataType === 'memberUniqueName' || promptInfo.dataType === 'hierarchyUniqueName' ? 'u' : 'd'; } else { valueType = promptInfo.dataType === 'memberUniqueName' || promptInfo.dataType === 'hierarchyUniqueName' ? 'value' : 'label'; } promptInfo.values = _.pluck(promptInfo.values, valueType); } }); return promptValueSpecs; }; DataQueryExecution.prototype._resetSavedPrompts = function _resetSavedPrompts(currPromptSpecs) { var savedPrompts = this._getVisualization().getSavedPrompts(); var newSpecs = null; if (currPromptSpecs && currPromptSpecs.length) { newSpecs = {}; currPromptSpecs.forEach(function (currPromptSpec) { newSpecs[currPromptSpec.name] = currPromptSpec; }); } // Reset to null if prompts are all deleted or reset with new values. savedPrompts.reset(newSpecs); }; DataQueryExecution.prototype._postProcess = function _postProcess(rawDataResult) { var queryDefinition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; // In the future, to preserve the order of the post processors, a possible way is to define an array of // other post processor dependencies while register to query execution. this._invokeRegisteredPostProcessors(rawDataResult); QueryPostProcessHelper.postProcessMeasuresAsSeries(rawDataResult, this._getVisualization(), queryDefinition); //There are only 2 values for suppression 'rowsAndColumns' or 'none' var suppressionEnabled = this.content.getPropertyValue('suppression') !== 'none'; QueryPostProcessHelper.postProcessMultiEdgeMeasures(rawDataResult, queryDefinition, suppressionEnabled); QueryPostProcessHelper.postProcessAggregatedSort(rawDataResult, this._getVisualization()); QueryPostProcessHelper.postProcessCustomSort(rawDataResult, this._getVisualization()); QueryPostProcessHelper.postProcessOlapProperties(rawDataResult, this._getVisualization()); }; DataQueryExecution.prototype._invokeRegisteredPostProcessors = function _invokeRegisteredPostProcessors(rawDataResult) { this._queryPostProcessors.forEach(function (processor) { return processor.process(rawDataResult); }); }; DataQueryExecution.prototype._buildGenericQueryTag = function _buildGenericQueryTag(specList, resultList) { var fullKey = ''; var INIT_TAG_ID = 100; var isLiveData = false; specList.forEach(function (spec, index) { if (spec) { fullKey = fullKey.concat(JSON.stringify(spec)); } var result = resultList[index]; if (result.ETag) { fullKey = fullKey.concat(result.ETag); } else { isLiveData = true; } }); if (_.isEmpty(this._queryKeyValuePair)) { this._queryKeyValuePair.key = fullKey; this._queryKeyValuePair.value = INIT_TAG_ID; } else if (this._queryKeyValuePair.key !== fullKey || isLiveData) { // Update the key value pair this._queryKeyValuePair.key = fullKey; this._queryKeyValuePair.value++; } }; DataQueryExecution.prototype._buildQueryTag = function _buildQueryTag(queryList, resultList) { this._buildGenericQueryTag(queryList.map(function (_ref2) { var spec = _ref2.spec; return spec; }), resultList); }; DataQueryExecution.prototype._buildQueryDefinitionTag = function _buildQueryDefinitionTag(query, resultList) { this._buildGenericQueryTag(query.getSpecList(), resultList); }; DataQueryExecution.prototype._queryFailed = function _queryFailed(sourceName, failure) { var hasUnavailableMetadataColumns = false; if (failure.message === 'promptingIsDisabled') { // this failure will be handled in Explore return failure; } var msg = 'dwErrorRunningQuery'; var code = void 0; if (failure.reason === 'staleRequest') { msg = 'dwErrorStaleRequest'; } else if (failure.reason === 'geoQueryFail') { msg = 'dwErrorGeoData'; } else if (failure.reason === 'cancelPromptSignon') { msg = 'dwPromptSignonCancelWarning'; } else if (failure.reason === 'unSupportedPromptType') { msg = failure.reason; } else if (failure.responseJSON && failure.responseJSON.errors) { var oErr = failure.responseJSON.errors[0]; code = oErr && oErr.code; if (code === 'DSS-GEN-0002') { hasUnavailableMetadataColumns = true; } else if (code === 'DSS-GEN-0001') { msg = StringResources.get('errorSourceNotFound', { sourceName: sourceName }); } else if (code === 'XQE-PLN-0226') { msg = StringResources.get('errorActionNotSupported', { sourceName: sourceName }); } else if (code === 'XQE-PLN-0214') { msg = StringResources.get('errorMeasureNotSupportedOnMultiEdges'); } else if (code === 'XQE-MDX-0020') { msg = StringResources.get('errorExceedAllowableValue'); } else if (oErr && oErr.message) { msg = oErr.message; } } if (failure.reason !== 'staleRequest') { var state = this.content.getFeature('state.internal'); state.setError(Object.assign(new Error(), { msg: msg, code: code })); } var param = { 'datasetName': sourceName }; return Object.assign(new Error(), { msg: msg, param: param, hasUnavailableMetadataColumns: hasUnavailableMetadataColumns, errorInfo: failure }); }; DataQueryExecution.prototype.queryChanged = function queryChanged() { // complete mapping is required for a complete query // attempt to create the definition list without a complete mapping // will result the definition cache to become stale if (!this._getVisualization().getSlots().isMappingComplete()) { return Promise.resolve(false); } return this._queryChanged(); }; DataQueryExecution.prototype._queryChanged = function _queryChanged() { var _this10 = this; // this._getQueryDefinitionList always returns a promise (even for v1) return this._getQueryDefinitionList(this.MAIN).then(function (queryDefinitions) { var queryChanged = false; if (queryDefinitions && queryDefinitions.length) { var queryService = _this10.dashboard.getFeature('QueryService2'); var query = queryService.createQuery(queryDefinitions, 'v2'); var querySpec = query && query.getSpecList(); queryChanged = JSON.stringify(querySpec) !== _this10._currentV2Specs; if (!queryChanged) { _this10._setDefinitionListCache(); } } else { //Otherwise fall back to original QueryService var querySpecList = _this10._getQuerySpecList(); if (!querySpecList) { // Should not happen _this10.logger.error('Could not build query spec'); } if (!_this10._queryResults) { queryChanged = true; } else { queryChanged = _.some(_this10.currentSpecList, function (currentSpec, idx) { var querySpec = querySpecList[idx] && querySpecList[idx].spec; return JSON.stringify(querySpec) !== currentSpec; }); } } return queryChanged; }); }; DataQueryExecution.prototype._getVisualization = function _getVisualization() { if (!this._visualization) { this._visualization = this.content.getFeature('Visualization.internal'); } return this._visualization; }; return DataQueryExecution; }(), _class.QUERY_LANGUAGE_PROP_NAMES = { TYPE: 'type', QUERY_LANGUAGE: 'queryLanguage' }, _class.COGNOS_QUERY_LANGUAGE = ['cognosSQL'], _class.NATIVE_QUERY_LANGUAGE = ['SQL', 'nativeSQL'], _class.MDX_QUERY_LANGUAGE = ['MDX'], _temp); return DataQueryExecution; }); //# sourceMappingURL=DataQueryExecution.js.map