'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2018 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * * VisModelManager * The VisModelManager object manages model-oriented information * and utilities for a visualization. * * The VisModelManager owns VisDataSlots and VisProperties that the renderer pieces render, * interactivity modifies and save persists. * * It also has utilities to ease access for Visualization items to data-oriented actions * (like querying/filtering). */ define(['../../../../lib/@waca/core-client/js/core-client/ui/core/Class'], function (Class) { 'use strict'; var VisModelManagerWrappedAPI = null; // class declaration VisModelManagerWrappedAPI = Class.extend({ isMappingEmpty: function isMappingEmpty() { return this.mappingAPI.isMappingEmpty(); }, /** * @param id - the id of the slot to return the API for. * @returns a SlotAPI by its id for either a mapped or unmapped slot. * If no matching slotAPI exists for this id, it will return null. */ getDataSlotById: function getDataSlotById(id) { return this.mappingAPI.getSlotAPIs({ includeUnmappedSlots: true, ids: [id] })[0] || null; }, /** * @param dataItemAPIOrUniqueId - a dataItemAPI or a dataItemUniqueId * @returns a structure containing the slotAPI, the index in the slot where the item occurs and the dataItemAPI. */ getDataItemSlotAndIndex: function getDataItemSlotAndIndex(dataItemAPIOrUniqueId) { return this.mappingAPI.getDataItemSlotAndIndex(dataItemAPIOrUniqueId); }, /** * underscore-like filter function that applies to slots and items. * @param callback(dataItemAPI, slotAPI, indexInSlot) - add item location information to the filtered set when this function returns true. * @param slotAPI (optional) - restrict the filter to the supplied slot. * @returns An array of itemLocations that match the filter callback (dataItemAPI, slotAPI, indexInSlot) */ filterSlotDataItems: function filterSlotDataItems(callback, optionalSlotAPI) { return this.mappingAPI.filterSlotDataItems(callback, optionalSlotAPI); }, /** * @returns Label by mapping */ getLabelByMapping: function getLabelByMapping(mapping) { return mapping.type !== 'attribute' || mapping.getSlotType() !== 'ordinal' ? mapping.getLabel() : this.getDataSlotById(mapping.slotId).getLabel(); }, /** * @param options - options which control which slotAPI's to return. * if 'includeUnmappedSlots' is specified, all slots are returned for the definition * otherwise, only mapped slots are returned. * @returns slotAPI's for the slots in this visualization customized by options. */ getDataSlots: function getDataSlots(options) { return this.mappingAPI.getSlotAPIs(options || {}); }, getLayers: function getLayers() { return this.mappingAPI.getLayers(); }, getDefaultLayer: function getDefaultLayer() { /*TODO:For R9 release,We assume default layer is the first dataset from viz definition. A viz definition always have at least one dataSet if defined */ return this.getDefinition().datasets[0]; }, isDataItemMapped: function isDataItemMapped(dataItemUniqueId) { if (!dataItemUniqueId) { return false; } var dataItemAPIs = this.mappingAPI.getDataItemAPIs(); var numberOfDataItems = dataItemAPIs.length; for (var i = 0; i < numberOfDataItems; i++) { if (dataItemAPIs[i].getUniqueId() === dataItemUniqueId) { return true; } } return false; } }); return VisModelManagerWrappedAPI; }); //# sourceMappingURL=VisModelManagerWrappedAPI.js.map