'use strict'; 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 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['underscore', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', './api/QueryResultsAPI'], function (_, APIFactory, QueryResultsAPI) { var DATA = 'data'; var QueryResults = function () { function QueryResults(resultTag, warnings) { _classCallCheck(this, QueryResults); this._oQueryResults = {}; this._resultTag = resultTag; this._warnings = warnings; } QueryResults.prototype.destroy = function destroy() { _.each(this._oQueryResults, function (results) { _.each(results, function (result) { result.destroy && result.destroy(); }); }); }; QueryResults.prototype.getAPI = function getAPI() { if (!this.queryResultsAPI) { this.queryResultsAPI = APIFactory.createAPI(this, [QueryResultsAPI]); } return this.queryResultsAPI; }; QueryResults.prototype.addResult = function addResult(queryResult) { var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DATA; var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryResultsAPI.QUERY_RESULT_TYPE.MAIN; if (!this._oQueryResults[id]) { this._oQueryResults[id] = {}; } this._oQueryResults[id][type] = queryResult; }; QueryResults.prototype.getResult = function getResult() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DATA; var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : QueryResultsAPI.QUERY_RESULT_TYPE.MAIN; var result = this._oQueryResults[id] && this._oQueryResults[id][type]; return result && result.getAPI ? result.getAPI() : result; }; QueryResults.prototype.removeResult = function removeResult() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DATA; var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : QueryResultsAPI.QUERY_RESULT_TYPE.MAIN; if (this._oQueryResults[id] && this._oQueryResults[id][type]) { delete this._oQueryResults[id][type]; } }; QueryResults.prototype.getQueryResultIdList = function getQueryResultIdList() { return this._oQueryResults && Object.keys(this._oQueryResults); }; QueryResults.prototype.getCacheValidateTag = function getCacheValidateTag() { return this._resultTag; }; QueryResults.prototype.getWarningList = function getWarningList() { return this._warnings || []; }; return QueryResults; }(); return QueryResults; }); //# sourceMappingURL=QueryResults.js.map