/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Viewer *| (C) Copyright IBM Corp. 2001, 2013 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ /** * RAPReportInfo encapsulates information returned from getInfo * A RAPReportInfo instance attached to the viewer object is automatically updated * for each response. */ function RAPReportInfo(reportInfo, oCV) { this.m_reportInfoJSON = reportInfo; this.m_containerInfoJSON = {}; this.m_iContainerCount = 0; this.m_bPromptPart = null; this.m_bSingleContainer = null; this.m_bDetailFilteringDisabled = null; this.m_aDrilledOnHUNs = null; this.m_bPassTrackingToBUA = null; this.m_sDisplayTypes = null; this.m_bContainsInteractiveDataContainer = null; this.m_bContainsFilters = false; this.m_bContainsSlider = false; //The referenceInfoObject is a map that supports the "isReferenced()" method. //A caller can ask reportInfo if an entity is referenced (usu. by name). this.m_referenceInfoObject = {}; this.initializeContainerInfo(); this._addNonVisibleReferences(this.m_reportInfoJSON.reportLevelProperties); this._populateHun( oCV ); } /** * initialize the reportInfo and its containers as an associative array. */ RAPReportInfo.prototype.initializeContainerInfo = function() { if(this.m_reportInfoJSON) { var reportInfoContainerArray = this.m_reportInfoJSON.containers; if (reportInfoContainerArray) { this.m_iContainerCount = reportInfoContainerArray.length; for(var containerIdx = 0; containerIdx < this.m_iContainerCount; ++containerIdx) { var containerLID=reportInfoContainerArray[containerIdx].container; this.m_containerInfoJSON[containerLID]=reportInfoContainerArray[containerIdx]; this.m_containerInfoJSON[containerLID].m_itemInfoJSON = this._initializeItemInfo(reportInfoContainerArray[containerIdx].itemInfo); this.m_containerInfoJSON[containerLID].m_drillabilityJSON = this._initializeDrillability(reportInfoContainerArray[containerIdx].drillability); this._addFilterReferences(reportInfoContainerArray[containerIdx].filter); this._addSliderReferences(reportInfoContainerArray[containerIdx].sliders); // the position of the container is used for the infoBar - keep track of it for now but should be refactored if ever // we revisit the info bar this.m_containerInfoJSON[containerLID].layoutIndex = containerIdx; if(reportInfoContainerArray[containerIdx].filter) { this.m_bContainsFilters = true; } if(reportInfoContainerArray[containerIdx].sliders) { this.m_bContainsSlider = true; } } } } }; RAPReportInfo.prototype._initializeItemInfo = function(itemInfo) { var itemInfoJSON = {}; for( var idx in itemInfo ) { itemInfoJSON[itemInfo[idx].item] = itemInfo[idx]; this.m_referenceInfoObject[itemInfo[idx].item] = true; } return itemInfoJSON; }; RAPReportInfo.prototype._initializeDrillability = function(drillability) { var drillabilityJSON = {}; for( var idx in drillability ) { drillabilityJSON[drillability[idx].item] = drillability[idx]; this.m_referenceInfoObject[drillability[idx].item] = true; } return drillabilityJSON; }; RAPReportInfo.prototype._addFilterReferences = function(filters) { //Filters.... for( var idx in filters ) { this.m_referenceInfoObject[filters[idx].item] = true; if (filters[idx].type==="contextSlice" && filters[idx].hierarchyName) { //context slices can be referenced by hierarchy name. this.m_referenceInfoObject[filters[idx].hierarchyName] = true; } } }; RAPReportInfo.prototype._addSliderReferences = function(sliders) { //Sliders... for( var idx in sliders ) { this.m_referenceInfoObject[sliders[idx].name] = true; //For sliders, its the name attribute not the item attribute. } }; RAPReportInfo.prototype._addNonVisibleReferences = function(oReportLevelProperties) { //Non-visible items... if(oReportLevelProperties && oReportLevelProperties.nonVisibleFiltersMemberItemInfo){ for(var i = 0;i 0){ var oReportLevelProperties = this.m_reportInfoJSON.reportLevelProperties; if(oReportLevelProperties){ if(oReportLevelProperties && oReportLevelProperties.nonVisibleFiltersMemberItemInfo){ for(var i = 0;i 0) ) { return filterItem; } } } } return null; }; /** * Returns the name of the slider or the item of the filter that has same HUN with the specified unique name. * * If no match is found then null is returned. * * @param uniqueName a mun, lun or hun can be passed */ RAPReportInfo.prototype.hunHasFilterOrSlider = function(uniqueName) { if (!uniqueName) { return null; } for (var lid in this.m_containerInfoJSON) { var oContainer = this.m_containerInfoJSON[lid]; if (oContainer && oContainer.filter) { var length = oContainer.filter.length; for (var i = 0; i < length; ++i) { var filterItem = oContainer.filter[i]; if (filterItem.HUN && uniqueName.indexOf(filterItem.HUN)==0) { return filterItem.item; } } } if (oContainer && oContainer.sliders) { var length = oContainer.sliders.length; for (var i = 0; i < length; ++i) { var sliderItem = oContainer.sliders[i]; if (sliderItem.hun && uniqueName.indexOf(sliderItem.hun)==0) { return sliderItem.name; } } } } return null; }; RAPReportInfo.prototype.hasSlider = function(){ return this.m_bContainsSlider; }; /** * Returns a map of sliders for this report indexed by ClientID */ RAPReportInfo.prototype.collectSliderSetFromReportInfo = function() { var reportInfoSliderIDs = {}; for (var lid in this.m_containerInfoJSON) { var sliders = this.m_containerInfoJSON[lid].sliders; if(sliders) { for(var sliderIndex = 0; sliderIndex < sliders.length; ++sliderIndex) { var sliderClientID = sliders[sliderIndex].clientId; reportInfoSliderIDs[sliderClientID] = sliders[sliderIndex]; } } } return reportInfoSliderIDs; }; /** * When the advanced server property VIEWER_CW_RAP_TIMER is set, this block of info is populated * with timing information about RAP server events that can be reported in the infobar. */ RAPReportInfo.prototype._getEventTimings = function() { return (this.m_reportInfoJSON && this.m_reportInfoJSON.reportLevelProperties && this.m_reportInfoJSON.reportLevelProperties.eventTimings) ? this.m_reportInfoJSON.reportLevelProperties.eventTimings : null; }; RAPReportInfo.prototype.destroy = function() { GUtil.destroyProperties(this); };