123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- '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 Business Analytics (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(['underscore', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', './api/QueryDefinitionAPI', './QueryDataItemSet'], function (_, APIFactory, QueryDefinitionAPI, QueryDataItemSet) {
- var reducer = function reducer(accumulator, currentValue) {
- accumulator[currentValue.columnId] = currentValue;
- return accumulator;
- };
- var QueryDefinition = function () {
- function QueryDefinition(_ref) {
- var id = _ref.id,
- type = _ref.type;
- _classCallCheck(this, QueryDefinition);
- this.id = id;
- this.type = type;
- this.dataSource = null;
- this.dataItemSets = [];
- this.filters = [];
- this.summariesEnabled = true; //Summaries are enabled by default.
- this.queryHints = [];
- this.expandEnabled = true;
- this.suppressionEnabled = true; //suppression is enabled by default.
- this.supportsNonContextualTopBottom = true; //Non contextual top bottom is supported by default.
- this.properties = {};
- }
- QueryDefinition.prototype.getId = function getId() {
- return this.id;
- };
- QueryDefinition.prototype.getType = function getType() {
- return this.type;
- };
- QueryDefinition.prototype.getAPI = function getAPI() {
- if (!this.api) {
- this.api = APIFactory.createAPI(this, [QueryDefinitionAPI]);
- }
- return this.api;
- };
- QueryDefinition.prototype.setDataSource = function setDataSource(source) {
- this.dataSource = source;
- };
- QueryDefinition.prototype.getDataSource = function getDataSource() {
- return this.dataSource;
- };
- QueryDefinition.prototype.setSummariesEnabled = function setSummariesEnabled(flag) {
- this.summariesEnabled = flag;
- };
- QueryDefinition.prototype.getSummariesEnabled = function getSummariesEnabled() {
- return this.summariesEnabled;
- };
- QueryDefinition.prototype.setSuppressionEnabled = function setSuppressionEnabled(flag) {
- this.suppressionEnabled = flag;
- };
- QueryDefinition.prototype.getSuppressionEnabled = function getSuppressionEnabled() {
- return this.suppressionEnabled;
- };
- QueryDefinition.prototype.createDataItemSet = function createDataItemSet(dataItems) {
- var dataItemSet = new QueryDataItemSet();
- dataItemSet.addDataItemList(dataItems);
- this.dataItemSets.push(dataItemSet);
- return dataItemSet.getAPI();
- };
- QueryDefinition.prototype.getDataItemSetList = function getDataItemSetList() {
- return this.dataItemSets.slice();
- };
- QueryDefinition.prototype.getAllDataItemsList = function getAllDataItemsList() {
- return _.flatten(this.dataItemSets.map(function (dataItemSet) {
- return dataItemSet.getAllDataItemsList();
- }));
- };
- QueryDefinition.prototype.addFilters = function addFilters(filters) {
- var _filters;
- (_filters = this.filters).push.apply(_filters, filters);
- };
- QueryDefinition.prototype.removeFilters = function removeFilters() {
- var _this = this;
- var filtersToRemove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- if (filtersToRemove.length > 0) {
- var removeFiltersMap = filtersToRemove.reduce(reducer, {});
- var currentFilters = this.filters.reduce(reducer, {});
- var currentKeys = Object.keys(currentFilters);
- this.filters.length = 0;
- currentKeys.forEach(function (key) {
- if (!removeFiltersMap[key]) {
- _this.filters.push(currentFilters[key]);
- }
- });
- }
- };
- QueryDefinition.prototype.getFilters = function getFilters() {
- return this.filters;
- };
- QueryDefinition.prototype.addQueryHint = function addQueryHint(queryHint) {
- this.queryHints.push(queryHint);
- };
- QueryDefinition.prototype.getQueryHints = function getQueryHints() {
- return this.queryHints;
- };
- QueryDefinition.prototype.setExpandEnabled = function setExpandEnabled(flag) {
- this.expandEnabled = flag;
- };
- QueryDefinition.prototype.getExpandEnabled = function getExpandEnabled() {
- return this.expandEnabled;
- };
- QueryDefinition.prototype.setSupportsNonContextualTopBottom = function setSupportsNonContextualTopBottom(flag) {
- this.supportsNonContextualTopBottom = flag;
- };
- QueryDefinition.prototype.getSupportsNonContextualTopBottom = function getSupportsNonContextualTopBottom() {
- return this.supportsNonContextualTopBottom;
- };
- QueryDefinition.prototype.getPropertyValue = function getPropertyValue(name) {
- return this.properties[name];
- };
- QueryDefinition.prototype.setPropertyValue = function setPropertyValue(name, value) {
- if (name) {
- if (value === undefined) {
- delete this.properties[name];
- } else {
- this.properties[name] = value;
- }
- }
- };
- return QueryDefinition;
- }();
- return QueryDefinition;
- });
- //# sourceMappingURL=QueryDefinition.js.map
|