/********************************************************************************************************************************
* Licensed Materials - Property of IBM *
* *
* IBM Cognos Products: AGS *
* *
* (C) Copyright IBM Corp. 2005, 2010 *
* *
* US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
*********************************************************************************************************************************/
var SV_ROOT = "selectValues";
var SV_VALUES = "values";
var SV_VALUE = "value";
var SV_TYPE = "type";
var SV_SECONDARY_REQUESTS = "secondaryRequests";
var SV_SECONDARY_REQUEST = "secondaryRequest";
var SV_VALUE_USE_ATTR = "use";
var SV_VALUE_DISPLAY_ATTR = "display";
var dataRequest = null;
var callbackFn = null;
var sv_conversation = null;
var sv_tracking = null;
var sv_useValues = null;
var sv_displayValues = null;
var sv_secondaryRequests = null;
var sv_type = null;
var sv_page = null;
// some messages that we can passback to the client so it know's what's going on
var SV_PASSPORT = "passport";
var SV_FAULT = "fault";
var SV_WORKING = "working";
var SV_PROMPTING = "prompting";
var SV_FINISHED = "finished";
var SV_CANCEL = "cancel";
var SV_PROMPTING_FINISHED = "prompting_finished"
// utility function
function doSelectValuesRequest(callback_function, method, treeObj, sort, filter, filter_type, tracking, conversation)
{
// save the callback function
callbackFn = callback_function;
// get the request
var request = getDataRequestString(method, treeObj, sort, filter, filter_type, tracking, conversation);
// do it
doDataRequest(request);
}
function getDataRequestString(method, treeObj, sort, filter, filter_type, tracking, conversation)
{
var sURL = "";
var cl="";
var pl="";
//define the expression locale
var el="";
var clk = "cl";
var plk = "pl";
var locales = getLocales(clk, plk);
sURL += URIEncode(clk, locales[clk]);
sURL += URIEncode(plk, locales[plk]);
sURL += URIEncode("el",getExpressionLocale());
// add the sort order
sURL += URIEncode("sort", sort);
// add the filters - have to duplicate apostrophe's in filters
if (filter) {
sURL += URIEncode("filter", filter.replace(/'/g, "''"));
}
sURL += URIEncode("filter_type", filter_type);
// conversation
sURL += URIEncode("disp_trackingInfo", tracking);
sURL += URIEncode("conversation", conversation);
// more stuff
sURL += URIEncode("xslURL", "selectValue.xslt");
sURL += URIEncode("model", cfgGet("cmLastModel"));
// have to determine what sort of query we're doing - if we're looking for members we
// have to use the caption() function
if (treeObj.type == "level" || treeObj.type == "hierarchy") {
sURL += URIEncode("memberRequest","1");
}
// add the other parametetshttp://c1.zedo.com/jsc/c1/ff2.html?n=162;c=1159;s=175;d=16;w=720;h=300;t=UndertoneNetworks.com-Advertisement
sURL += URIEncode("method",method);
sURL += URIEncode("inlineSpecType","reportServiceReportSpecification");
// add the other parametets
sURL += URIEncode("prompt", "false");
if (treeObj != null) {
sURL += URIEncode("queryRef",treeObj.name);
var referencedQueryItems = cf.getTreeValues(getDataItemsTree());
var itemsStr="";
//build the XMl for the data item that has been selected
//Use aggregates only if it is a dataitem. i.e noAggregate should be false.
var noAggregate = !(treeObj instanceof aiDataItem);
itemsStr = buildDataItemXML(treeObj,sort,noAggregate);
/*
Loop though the query items and create a XML fragment for each one e.g.
[gosales_goretailers].[Orders].[Unit price]
*/
for (var i=0;i 0) {
sv_conversation = getTextNodeValue(conversationElements[0]);
}
if (trackingElements[0].childNodes.length > 0) {
sv_tracking = getTextNodeValue(trackingElements[0]);
}
// clear out the type
sv_type = null;
// get the type if there is one
if (typeElements.length == 1) {
if (typeElements[0].childNodes.length == 1) {
sv_type = getTextNodeValue(typeElements[0]);
}
}
// have to get all the values - loop over the childNodes
if (valuesElements.length == 1) {
var valueElements = valuesElements[0].getElementsByTagName(SV_VALUE);
for (var i = 0; i < valueElements.length; i++) {
var useValue = valueElements[i].getAttribute(SV_VALUE_USE_ATTR);
var displayValue = valueElements[i].getAttribute(SV_VALUE_DISPLAY_ATTR);
// use value might not be present - so copy the display value if not
if (useValue == null) {
useValue = displayValue;
}
// borrowed wholesale from ReportStudio - types refer to CCLDBType enumeration:
var v_sQuote = "";
switch (sv_type) {
case "1": //cclDTypeString
case "25": //cclDTypeMemberUniqueName
case "26": //cclDTypeMemberCaption
case "27": //cclDTypeDimensionUniqueName
case "28": //cclDTypeParentUniqueName
case "29": //cclDTypeDescription
case "30": //cclDTypeHierarchyUniqueName
case "31": //cclDTypeParentLevel
case "32": //cclDTypeLevelUniqueName
case "34": //cclDTypeLevelLabel
case "35": //cclDTypeFormattedValue
case "36": //cclDTypeFont
case "43": //cclDTypeMemberType
case "45": //cclDTypeExternalBuffer
case "55": //cclDTypeNChar
case "56": //cclDTypeNVarChar
v_sQuote = "'";
break;
}
// use only display values for the time being
useValue = displayValue;
// have to double quote the useValue if there are any quotes in it & trim trailing spaces.
useValue = useValue.replace(/'/g, "''");
useValue = useValue.replace(/[\s]+$/g,"");
// do the type magic on it
useValue = v_sQuote + useValue + v_sQuote;
// keep the pair of them
sv_useValues.push(useValue);
sv_displayValues.push(displayValue);
}
}
// have to get all the secondary requests - loop over the secondaryRequests
var secondaryRequestElements = secondaryRequestsElements[0].getElementsByTagName(SV_SECONDARY_REQUEST);
for (var i = 0; i < secondaryRequestElements.length; ++i) {
if (secondaryRequestElements[i].childNodes.length == 1) {
sv_secondaryRequests.push(getTextNodeValue(secondaryRequestElements[i]));
}
}
}