123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- /********************************************************************************************************************************
- * 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 <dataItem/> XML fragment for each one e.g.
- <dataItem name="Unit price" aggregate="average">
- <expression>[gosales_goretailers].[Orders].[Unit price]</expression>
- </dataItem>
- */
- for (var i=0;i<referencedQueryItems.length;i++) {
- var qi=referencedQueryItems[i];
- //exclude the queryRef data item
- if (qi.ref != treeObj.ref) {
- itemsStr += buildDataItemXML(qi);
- }
- }
- }
- sURL += URIEncode("queryItems",itemsStr);
-
- // add the 888 parameter condom - safe sex sort of thing
- sURL += URIEncode("parameterValues",getConnectionParameterValues());
-
- // return the request
- return sURL;
- }
- function doDataRequest(request)
- {
- var url = "b_action=xts.run";
- url += URIEncode("m","/ags/async/asyncConv.xts");
- url += URIEncode("buildRequestXTS","/ags/async/selectValuesRequest.xts");
- url += URIEncode("buildResponseXTS","/ags/async/selectValuesResponse.xts");
- // force SOAPFault for passport expire instead of getting a logon page
- url += URIEncode("forceSOAPFault","false");
- url += request;
- if (cafContextId != "") {
- url += URIEncode("cafcontextid",cafContextId);
- }
- // remove the previous request if it's possible
- if (dataRequest!= null) {
- cancelDispatcherRequest(dataRequest);
- }
- // send off the resquest - keep hold of the request object this time
- dataRequest = sendDispatcherRequestWithXMLTextResponse(url, selectDataXMLTextResponse);
- }
- function promptSelectDataResponse(parameters, response, conversation, clientContext, tracking)
- {
- if (response == "Cancel" || response == "Error")
- {
- doClosePopUp();
- // we just want to cancel out of here - though error should be different
- callClientCallback(SV_CANCEL);
- }
- else
- {
- callClientCallback(SV_PROMPTING_FINISHED);
-
- //re write any parameterValues saved
- saveParameterValues(parameters);
-
- // send the context and the final response from prompts back
- var request = URIEncode("context", clientContext);
- request += URIEncode("promptResponse", response);
- request += URIEncode("disp_trackingInfo", tracking);
- // hide the dialog frame and pop up frame(and make sure they dont re open)
- showDialogFrame(0);
- doSetPopUpClosureFlag();
- // resubmit the request
- setTimeout("doDataRequest('" + request + "');", 100);
- }
- }
- function callClientCallback(status)
- {
- if (callbackFn != null)
- {
- try {
- callbackFn(status);
- } catch(ex) {
- //This might fail so capture the expection and do nothing
- }
- }
- }
- function selectDataXMLTextResponse(responseArray)
- {
- // get the values returned
- var responseXML = responseArray[0];
- var responseText = responseArray[1];
- // the request is finished - we can just remove it
- dataRequest = null;
- var workingRoot = responseXML.getElementsByTagName(ASYNC_WORKING);
- var promptingRoot = responseXML.getElementsByTagName(ASYNC_PROMPTING);
- var valuesRoot = responseXML.getElementsByTagName(ASYNC_RESPONSE);
- var parsedResponse = parseResponse(responseXML,responseText);
- // decide what we're going to do
- //This is a case when getContent in asyncConv faults with either session expiry or
- //external logon to a different name space fault.
- if (parsedResponse.isLogonFault()) {
- // tell the client what's going on
- callClientCallback(SV_PASSPORT);
- doPassportExpire(responseXML,null,parsedResponse);
- } else if (parsedResponse.isSoapFault()) {
- // tell the client what's going on
- callClientCallback(SV_FAULT);
- // we have a fault which is a genuine fault fault
- doSOAPFault(responseXML,null,parsedResponse);
- } else if (workingRoot.length == 1) {
- // tell the client what's going on
- callClientCallback(SV_WORKING);
- // we have a working response
- doWorking(workingRoot[0], "doDataRequest");
- } else if (promptingRoot.length == 1) {
- // tell the client what's going after getting all the values
- callClientCallback(SV_PROMPTING);
-
- // are we prompting
- //7.doPrompting(promptingRoot[0],"parent.getConfigFrame().promptSelectDataResponse","selectValue.xslt");
- doPrompting(promptingRoot[0], 7, "selectValue.xslt");
- } else if (valuesRoot.length == 1) {
- buildSelectValues(valuesRoot[0]);
- // tell the client what's going after getting all the values
- callClientCallback(SV_FINISHED);
- } else {
- // tell the client what's going on
- callClientCallback(SV_FAULT);
- // check the text response to see if we got a html page back in the response
- if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
- doHTMLResponse(responseText);
- } else {
- alert(asyncSelectValuesError_string);
- }
- }
- }
- function buildSelectValues(obj)
- {
- // get the conversation element
- var conversationElements = obj.getElementsByTagName(ASYNC_CONVERSATION);
- // get the tracking element
- var trackingElements = obj.getElementsByTagName(ASYNC_TRACKING);
- // get the values element
- var valuesElements = obj.getElementsByTagName(SV_VALUES);
- // get the type element
- var typeElements = obj.getElementsByTagName(SV_TYPE);
- // get the secondary request elements
- var secondaryRequestsElements = obj.getElementsByTagName(SV_SECONDARY_REQUESTS);
- // we want the actual values
- sv_conversation = null;
- sv_tracking = null;
- sv_useValues = new Array();
- sv_displayValues = new Array();
- sv_secondaryRequests = new Array();
-
- // check to see if the converstaion/tracking is valid - we might return nothing
- // if the conversation completed.
- if (conversationElements[0].childNodes.length > 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]));
- }
- }
- }
|