/* * This class is responsible for maintaining the parameters collection for a report. */ ReportParameters = new Class.create; ReportParameters.prototype = { initialize: function(parent) { this.parameters = new Array(); this.length = 0; this.parent = parent; this.refreshData = false; this.parameterNameToUpdate = ''; this.originalXmlNode = null; this.hasUserInteractiveParameters = false; this.hasParametersThatNeedInput = false; }, ajaxUpdate: function(request) { DiagContext.traceVerbose('ReportParameters: ajaxUpdate'); var elem = request.responseXML.getElementsByTagName('Parameters'); if (elem != null && elem.length > 0) { this.parameterNameToUpdate = ''; this.setParametersFromXml(elem[0]); } this.parent.controller.updateParameterPanel(this); }, parameterExistsInCollection: function(parameterName) { var parameterExists = false; for(var i=0;i 0) { this._getValues(values[0], parameter); } defaultValues = parameterNode.getElementsByTagName('DefaultValues'); if (defaultValues.length > 0) { this._getDefaultValues(defaultValues[0], parameter); } validValues = parameterNode.getElementsByTagName('ValidValues'); if (validValues.length > 0) { this._getValidValues(validValues[0], parameter); } if(!parameterExistsInCollection) { this.add(parameter); } if (parameter.promptUser && !parameter.hidden) { this.hasUserInteractiveParameters = true; if (parameter.state != 'HasValidValue') { this.hasParametersThatNeedInput = true; } } } this.length = this.parameters.length; }, /* * This function fills the default values array with all the default parameter values. * Parameters: defaultValues is xml node from the main parameters xml node, parameter is * the specific parameter the default values are attached to. */ _getDefaultValues: function(defaultValues, parameter) { parameter.defaultValues.clear(); for (var i = 0; i < defaultValues.childNodes.length; i++) { defaultValue = defaultValues.childNodes[i]; parameterValue = new ParameterValue(); parameterValue.value = defaultValue.getAttribute('Value'); parameterValue.label = defaultValue.getAttribute('Label'); parameter.defaultValues.push(parameterValue); } }, /* * This function fills the valid values array with all the default parameter values. * Parameters: validValues is xml node from the main parameters xml node, parameter is * the specific parameter the valid values are attached to. */ _getValidValues: function(validValues, parameter) { parameter.validValues.clear(); for (var i = 0; i < validValues.childNodes.length; i++) { validValue = validValues.childNodes[i]; parameterValue = new ParameterValue(); parameterValue.value = validValue.getAttribute('Value'); parameterValue.label = validValue.getAttribute('Label'); parameter.validValues.push(parameterValue); } }, /* * This function fills the values array with all the values set for the parameter. * Parameters; values is the xml node from the main parameters xml node, parameter is * the specific parameter the values are attached to. */ _getValues: function(values, parameter) { parameter.values.clear(); for (var i = 0; i < values.childNodes.length; i++) { value = values.childNodes[i]; parameterValue = new ParameterValue(); parameterValue.value = value.getAttribute('Value'); parameterValue.label = value.getAttribute('Label'); parameter.values.push(parameterValue); } }, /* * This returns a specific parameter from the parameters array that matches the passed in index. */ getParameter: function(index) { return this.parameters[index]; }, /* * This function will add the passed in parameter to the parameters array. * Parameter, parameter is an instance of the parameter class that has the values set. */ add: function(parameter) { this.parameters.push(parameter); }, /* * Removes a parameter for the parameter array at the specific index. */ remove: function(index) { this.parameters.remove(index); }, /* * Clears the parameters array of all parameters. */ clear: function() { this.parameters.clear(); } }, /* * This class represents a specific parameter that would exist in the parameters collection. It is patterned * after the parameter object in reports. */ Parameter = Class.create(); Parameter.prototype = { initialize: function() { this.name = ""; this.allowBlank = true; this.dataType = ""; this.multiValue = false; this.prompt = ""; this.promptUser = true; this.queryParameter = true; this.value = ""; this.label = ""; this.state = ""; this.nullable = false; this.hidden = false; this.defaultValues = new Array(); this.validValues = new Array(); this.values = new Array(); this.multiline = false; this.dateOnly = false; this.definesValidValues = false; } }; //close Parameter /* * This class represents a parameter value that is used for default values and valid values. */ ParameterValue = Class.create(); ParameterValue.prototype = { initialize: function(){ this.value=""; this.label=""; } };// close ParameterValue