/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2011 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ /** @fileOverview Managing Prompts. @namespace cognos.Prompt */ /** @constructor @class Prompting Parameter */ cognos.Prompt.Parameter = function(sName) { this.m_aControls = []; this.m_aValues = []; this.m_sName = sName; }; /** @param {cognos.Value[]} aValues Values to add to this parameter. @return {void} */ cognos.Prompt.Parameter.prototype.addValues = function(aValues) { this.m_aValues = this.m_aValues.concat(aValues); }; /** Clear all values for this parameter. Does not update the controls associated to this parameter. @return {void} */ cognos.Prompt.Parameter.prototype.clearValues = function() { this.m_aValues = []; }; /** @private @param {cognos.Prompt.Control} oControl @return {void} */ cognos.Prompt.Parameter.prototype.f_addControl = function(oControl) { this.m_aControls.push( oControl ); }; /** Returns an array of all controls associated to this parameter. @return {cognos.Prompt.Control[]} */ cognos.Prompt.Parameter.prototype.getControls = function() { return this.m_aControls; }; /** Returns the parameter's name. @return {String} */ cognos.Prompt.Parameter.prototype.getName = function() { return this.m_sName; }; /** Returns all values for this parameter. @return {cognos.Value[]} */ cognos.Prompt.Parameter.prototype.getValues = function() { var v_aValues = this.m_aValues; var v_aControls = this.getControls(); for (var v_idx = 0; v_idx < v_aControls.length; v_idx++) { var v_oControl = v_aControls[v_idx]; if ( v_oControl.isValid() ) { v_aValues = v_aValues.concat(v_oControl.getValues()); } } return v_aValues; }; /** Returns all values for this parameter in XML form. @private @return {String} */ cognos.Prompt.Parameter.prototype.getXML = function() { var v_aXML = [""]; var v_aValues = this.getValues(); for (var v_idx = 0; v_idx < v_aValues.length; v_idx++) { v_aXML.push( cognos.Value.toXML(v_aValues[v_idx]) ); } v_aXML.push( "" ); return v_aXML.join(K_PRMT_sEMPTY); }; /** Check if this parameter is satisfied. @private @return {boolean} */ cognos.Prompt.Parameter.prototype.isValid = function() { return ( this.isRequired() && (this.getValues().length == 0) ? false : true ); }; /** Currently the required is handled by the controls. @private @return {boolean} */ cognos.Prompt.Parameter.prototype.isRequired = function() { var v_bRequired = false; for (var v_idx = 0; v_idx < this.m_aControls.length; v_idx++) { v_bRequired = (v_bRequired || this.m_aControls[v_idx].isRequired()); } return v_bRequired; };