123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2017, 2019
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- /**
- * This Class encapsulates raw query result data returned from DSS and provides its accessors and iterators
- **/
- define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../../lib/@waca/dashboard-common/dist/query/FacetDataObject', 'underscore'], function (BaseClass, FacetData, _) {
- 'use strict';
- var SingleQueryResult = BaseClass.extend({
- _facetData: null, /*QueryResultData Object*/
- _queryThreshHold: 3000,
- _attachedPayload: null,
- _dataViewId: null,
- init: function init(dataViewId, queryResultData, queryThreshold, attachedPayload, queryResultAPI) {
- this._queryThreshHold = queryThreshold;
- this._facetData = queryResultData;
- this._attachedPayload = attachedPayload;
- this._dataViewId = dataViewId;
- this.data = queryResultData; //TODO: Remove this in Endor
- this._queryResultAPI = queryResultAPI;
- },
- getFacetData: function getFacetData() {
- return this._facetData;
- },
- getQueryThreshhold: function getQueryThreshhold() {
- return this._queryThreshHold;
- },
- getTopBottomMappings: function getTopBottomMappings() {
- return this._attachedPayload ? this._attachedPayload.topBottomMappings : {};
- },
- setTopBottomMappings: function setTopBottomMappings(topBottomMappings) {
- this._attachedPayload = this._attachedPayload || {};
- this._attachedPayload.topBottomMappings = topBottomMappings;
- },
- getAttachedPayload: function getAttachedPayload() {
- return this._attachedPayload;
- },
- getHasMoreData: function getHasMoreData() {
- return this._facetDdata ? this._faectData.hasMoreData() : false;
- },
- getDataViewId: function getDataViewId() {
- return this._dataViewId;
- },
- // TODO temporarily provide an API to get the new QueryResultAPI
- getQueryResult: function getQueryResult() {
- return this._queryResultAPI;
- }
- });
- var QueryResultObject = BaseClass.extend({
- _renderContext: null,
- hasMoreData: false,
- queryThreshold: Number.MAX_VALUE,
- init: function init(renderContext) {
- this._aQueryResults = [];
- this._renderContext = renderContext;
- },
- addQueryResultObject: function addQueryResultObject(dataViewId, queryResultData, queryThreshold, attachedPayload, queryResultAPI) {
- this._aQueryResults.push(new SingleQueryResult(dataViewId, queryResultData, queryThreshold, attachedPayload, queryResultAPI));
- // summarize the clipping information among multiple query results
- this.hasMoreData = this.hasMoreData || queryResultData.hasMoreData();
- this.queryThreshold = Math.min(this.queryThreshold, queryThreshold);
- },
- getQueryResultByDataViewId: function getQueryResultByDataViewId(dataViewId) {
- return _.find(this._aQueryResults, function (entry) {
- return entry.getDataViewId() === dataViewId;
- });
- },
- getQueryResultByIndex: function getQueryResultByIndex(index) {
- return this._aQueryResults[index];
- },
- getDefaultQueryResult: function getDefaultQueryResult() {
- return this._aQueryResults[0];
- },
- getQueryResults: function getQueryResults() {
- return this._aQueryResults;
- },
- getRenderContext: function getRenderContext() {
- return this._renderContext;
- },
- /**
- * set top bottom mapping from top bottom spec
- * @param {Object} topBottomSpec
- * @param {int} index - optional. default to 0 if not set
- * eg. { Quantityavg: {
- * max: xx,
- * min: xx
- * }, {
- * UnitCostsum: {
- * max: xx,
- * min: xx }
- * } }
- */
- setTopBottomMappings: function setTopBottomMappings(topBottomSpec, index) {
- var topBottomMapping = {};
- _.each(topBottomSpec, function (value, key) {
- var facetDataItemMax = new FacetData({ u: value.max });
- var facetDataItemMin = new FacetData({ u: value.min });
- topBottomMapping[key] = {
- bottomResult: facetDataItemMin,
- topResult: facetDataItemMax
- };
- });
- var queryResult = this.getQueryResultByIndex(index || 0);
- queryResult.setTopBottomMappings(topBottomMapping);
- }
- });
- return QueryResultObject;
- });
- //# sourceMappingURL=QueryResultObject.js.map
|