123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2021 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- var functionsTree = null;
- var QOS_UNAVAILABLE = "unavailable";
- var QOS_RESTRICTED = "restricted";
- var QOS_LIMITED = "limited";
- var QOS_OK = "OK";
- var FUNCTION_ROOT_START = "functionRoot-start";
- var FUNCTION_ROOT_END = "functionRoot-end";
- var FUNCTION_GROUP_START = "group-start";
- var FUNCTION_GROUP_END = "group-end";
- var FUNCTION_FUNCTION = "function";
- var FUNCTION_TYPE_FUNCTION = "function";
- var FUNCTION_TYPE_SUMMARY = "summary";
- var FUNCTION_TYPE_OPERATOR = "operator";
- var FUNCTION_TYPE_LITERAL = "literal";
- var FUNCTION_TYPE_OPERATION = "operation";
- // normal response
- var FUNCTION_FUNCTIONS_ROOT = "functionsRoot";
- var FUNCTION_GROUP = "group";
- var FUNCTION_FUNCTION = "function";
- var FUNCTION_ATTR_NAME = "name";
- var FUNCTION_ATTR_QOSLEVEL = "qosLevel";
- var FUNCTION_ATTR_DROPTEXT = "dropText";
- var FUNCTION_ATTR_SYNTAX = "syntax";
- var FUNCTION_ATTR_TIP = "tip";
- var FUNCTION_ATTR_TYPE = "type";
- var FUNCTION_ATTR_ID="id";
- //function ids
- var MEMBER_SEARCH_IN_HIERARCHY = "MEMBER_SEARCH_IN_HIERARCHY";
- // an array of nodes that are to be loaded. we need the array
- // as the passport might have expired
- var loadingfunNodes = new Array();
- // utility function
- function getFunctionDataRequestString(model)
- {
- var sURL = "";
-
- var clk = "cl";
- var plk = "pl";
- var locales = getLocales(clk, plk);
-
- sURL += URIEncode(clk, locales[clk]);
- sURL += URIEncode(plk, locales[plk]);
-
- sURL += URIEncode("model", model);
- sURL += URIEncode("inlineSpecType","reportServiceMetadataSpecification");
- sURL += URIEncode("method", "runSpecification");
- sURL += URIEncode("prompt", "false");
- sURL += URIEncode("parameterValues", getConnectionParameterValues());
- // return the request
- return sURL;
- }
- function promptFunctionResponse(parameters, response, conversation, clientContext, tracking)
- {
- if (response == "Cancel" || response == "Error")
- {
- // this is reasonable in this instance - we wouldn't be able to load the metadata tree
- // if we cancel out.
- closeAGS();
- }
- else
- {
- //re write any parameterValues saved
- saveParameterValues(parameters);
-
- // send the context and the final response from prompts back
- var request = getFunctionDataRequestString()
- 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("doFunctionDataRequest('" + request + "');", 100);
- }
- }
- //at this point, we will have been through the meta data request
- //and may have connection parameter values to pass
- function doFunctionDataRequest(request)
- {
- // build up the URL
- var url = "b_action=xts.run";
- url += URIEncode("m","/ags/async/asyncConv.xts");
- url += URIEncode("buildRequestXTS","/ags/async/functionTreeRequest.xts");
- url += URIEncode("buildResponseXTS","/ags/async/functionTreeResponse.xts");
- url += URIEncode("paramterValues",getConnectionParameterValues());
- // force a SOAPFault for passport expire rather than getting a logon page
- url += URIEncode("forceSOAPFault","false");
- url += request;
-
- if (cafContextId != "") {
- url += URIEncode("cafcontextid",cafContextId);
- }
-
- try{
- // send off the resquest
- sendDispatcherRequestWithXMLTextResponse(url, functionDataXMLTextResponse);
- }catch(ex){
- applicationActionManager.httpStop();
- }
- }
- // the double click function
- function doubleClickF(evt)
- {
- insertStartMC(undefined, evt);
- }
- // the single click function
- function singleClickF(evt)
- {
- //Create dummay function.
- var selectedFunction = new fnFunction("", "", "","", "", "");
- // get the node which has been selected.
- var selectedFunctionNodes = functionsTree.getSelectedLeafNodes();
- // this should always be the case - we set the tree up to force single selection
- if (selectedFunctionNodes.length == 1) {
- var selectedFunctionNode = selectedFunctionNodes[0];
- // we've got the tree node - get the object it's carrying
- selectedFunction = selectedFunctionNode.getValue();
- }
- // have to update the information in the tip window
- displayInformationTip(selectedFunction);
- }
- //this function is called when the Function tab is clicked
- //it is called by changeMenu() in the layout.js library
- function doFunctionTree() {
- var cmLastModel = cfgGet("cmLastModel");
- if (cmLastModel != null && cfgGet("queryLoaded"))
- {
- if (functionsTree == null)
- {
- if (browserCheck.isNav6Up())
- {
- document.getElementById("functionsTreeContainer").addEventListener("mouseup", function(e) {if(e.target.toString().indexOf("XULElement") > -1){e.cancelBubble = true;return false;}}, true);
- document.getElementById("functionsTreeContainer").addEventListener("dragover", function(e) {cancelBub(e);}, true);
- document.getElementById("functionsTreeContainer").addEventListener("dragdrop", function(e) {cancelBub(e);}, true);
- }
- var functionsTreeNode = document.getElementById("functionsTreeContainer");
- // at this point - this is the only node with this id
- functionsTreeNode.setAttribute("container", "true");
- functionsTreeNode.setAttribute("tabindex", "-1");
- // now create and render the tree
- functionsTree = new CTree (functionsTreeNode, "", false, true, "functionsTree");
- functionsTree.setLoadOnTheFlyFunction(functionPushAndLoadFunc);
- functionsTree.setSelectionMode(SINGLE_TREE_SELECTION);
- functionsTree.setSelectTreeUI(NORMAL_TREE);
- functionsTree.setAllowDragDrop(true);
- functionsTree.setOnDragStart(onDragStartF);
- functionsTree.setOnDrag(onDragF);
- functionsTree.setOnDragEnd(onDragEndF);
- functionsTree.setTrackSelectionOrder(true);
- functionsTree.setHideOuterTable(true);
- //functionsTree.setForceSelectionAtLowestLevel(true);
- functionsTree.setContextMenu(function contextMenu(){return false;});
- // get the function tree to update tips section of condition dialog
- functionsTree.setSingleClickFunc(singleClickF);
- functionsTree.setDoubleClickFunc(doubleClickF);
- functionsTree.setAllowSelectionToggle(true);
- functionsTree.drawAll();
- functionsTree.checkData();
- }
- }
- else
- setTimeout(doFunctionTree, 250);
- }
- function reloadFunctionsTree()
- {
- if (cfgGet("reloadFunctionsTree") != null) {
- resetFunctionsTree();
- // load it up again
- doFunctionTree();
- } else {
- // pop the command stack
- setTimeout("getCommandStackManager().processCommandStack()", 100);
- }
- // clear out the flag
- cfgRemove("reloadFunctionsTree");
- }
- function resetFunctionsTree()
- {
- if (functionsTree != null) {
- // we have to remove the tree
- functionsTree = null;
- // remove the rendering of the tree
- removeTreeRendering("functionsTreeContainer");
- // reset this - not sure why though
- draggedTreeObj = null;
- // say that we've not loaded the tree
- cfgSet("META_FunctionTreeLoadedFirstTime",null);
- }
- }
- function functionPushAndLoadFunc(loadingNode)
- {
- loadingfunNodes.push(loadingNode);
- functionLoadFunc(loadingNode);
- }
- function functionLoadFunc(loadingNode)
- {
-
- applicationActionManager.httpStart();
-
- if (cfgGet("META_FunctionTreeLoadedFirstTime") == null)
- {
- cfgSet("META_FunctionTreeLoadedFirstTime", "loading");
- var request = getFunctionDataRequestString(cfgGet("cmLastModel"));
- doFunctionDataRequest(request);
- }
- else if (cfgGet("META_FunctionTreeLoadedFirstTime") != "loading")
- {
- var request = getFunctionDataRequestString(cfgGet("cmLastModel"));
- doFunctionDataRequest(request);
- }
- }
- // if no node is to be loaded, tidyup the tree otherwise load the nodes
- function checkfunPassportStatus() {
- // no node is in the load mode
- if (loadingfunNodes.length < 1 ) {
- tidyFunctionsTree();
- } else {
- // load all the nodes waiting to be loaded
- while (loadingfunNodes.length > 0) {
- var theLoadingNode = loadingfunNodes.pop();
- functionLoadFunc(theLoadingNode);
- }
- }
- }
- // add the command to load the nodes to the stack
- function addTofunStack()
- {
- var treeCommand = getCommandStackManager().createCommandStack("checkfunPassportStatus()");
- var currentStack = getCommandStackManager().getCommandStack();
- var newStack = currentStack.concat(treeCommand);
- getCommandStackManager().setCommandStack(newStack);
- }
- function functionDataXMLTextResponse(responseArray)
- {
- // get the values returned
- var responseXML = responseArray[0];
- var responseText = responseArray[1];
- var workingRoot = responseXML.getElementsByTagName(ASYNC_WORKING);
- var promptingRoot = responseXML.getElementsByTagName(ASYNC_PROMPTING);
- var functionsRoot = responseXML.getElementsByTagName(FUNCTION_FUNCTIONS_ROOT);
-
- var httpStop = true;
-
- // the loading nodes should be remembered only if passport has expired
- var keeploadingfunNodes = false;
- 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()) {
- doPassportExpire(responseXML,addTofunStack,parsedResponse);
- // load the nodes after login succeeds
- keeploadingmdtNodes = true;
- } else if (parsedResponse.isSoapFault()) {
- if (parsedResponse.isCancelledWait()) {
- //This was a server cancelled wait. We need to resubmit. This could happen
- //if we have a SSO on and we hit an password protected external datasource,
- //The dispacther will fire the same request again, in this wait fired twice
- //Will cancel conversation if first wait fails. WO1903, WO2338
- getCommandStackManager().getCommandStack().push("reloadFunctionsTree()");
- setTimeout("getCommandStackManager().processCommandStack()", 100);
- } else {
- // we have a fault which is a genuine fault fault
- doSOAPFault(responseXML,tidyFunctionsTree,parsedResponse);
- }
- } else if (workingRoot.length == 1) {
- httpStop = false;
- // we have a working response
- doWorking(workingRoot[0], "doFunctionDataRequest");
- } else if (promptingRoot.length == 1) {
- // are we prompting - promptFunctionResponse
- doPrompting(promptingRoot[0], 1);
- } else if (functionsRoot.length == 1) {
- // we have the actually information
- // clear the response
- response = "";
- buildFunctionRoot(functionsRoot[0].childNodes[0]);
- } else {
- tidyFunctionsTree();
- if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
- // check the text response to see if we got a html page back in the response
- doHTMLResponse(responseText);
- } else {
- alert(asyncFunctionError_string);
- }
- }
- if(httpStop){
- applicationActionManager.httpStop();
- }
-
- if (keeploadingfunNodes == false) {
- //empty the array
- loadingfunNodes.splice(0, loadingfunNodes.length);
- }
- }
- function tidyFunctionsTree() {
- resetFunctionsTree();
- var treeContainer = document.getElementById("functionsTreeContainer");
- if (treeContainer) {
- var html = '<a href="#" class="menuItem_normal" onclick="refreshFunctionsTree()">' + refresh_string + '</a>';
- treeContainer.innerHTML = html;
- }
- }
- function refreshFunctionsTree() {
- removeTreeRendering('functionsTreeContainer');
- doFunctionTree();
- }
- function buildChildNodes(obj, parentNode)
- {
- // get all the childNodes
- for (var i = 0; obj.childNodes != null && i < obj.childNodes.length; ++i) {
- var qosLevel = obj.childNodes[i].getAttribute(FUNCTION_ATTR_QOSLEVEL);
- if (!(qosLevel == QOS_UNAVAILABLE)) {
- if (obj.childNodes[i].nodeName == FUNCTION_GROUP) {
- buildFunctionGroup(obj.childNodes[i], parentNode);
- }
- if (obj.childNodes[i].nodeName == FUNCTION_FUNCTION) {
- buildFunctionFunction(obj.childNodes[i], parentNode);
- }
- }
- }
- }
- function buildFunctionRoot(obj)
- {
- try {
- functionsTree.getRootNode().setName(functionRoot_string);
- functionsTree.setRootNodeType(tntFunctionRoot);
- functionsTree.setRootNodeShowing(true);
- functionsTree.drawAll();
- // decode all the childNodes
- buildChildNodes(obj, functionsTree.getRootNode());
- // we've finished loading - so remove loading and redraw
- var rootNode = functionsTree.getRootNode();
- functionsTree.childrenReadyForNode(rootNode);
- // we've loaded this up now
- cfgSet("META_FunctionTreeLoadedFirstTime", true);
- }
- catch (ex) {
- console.error(ex);
- applicationActionManager.httpStop();
- }
- setTimeout("getCommandStackManager().processCommandStack();", 100);
- }
- function buildFunctionGroup(obj, parentNode)
- {
- var name = obj.getAttribute(FUNCTION_ATTR_NAME);
- if (name != "") {
- // get the attributes of the group element
- var qosLevel = obj.getAttribute(FUNCTION_ATTR_QOSLEVEL);
- // build the group Tree Node
- var groupObj = new fnGroup(name, qosLevel);
- var groupNode = new CTreeNode(parentNode, tntGroup, false, name, groupObj, false);
- // have to set the indicator for the node
- setNodeIndicator(groupNode, qosLevel);
- // have to set the node as being loaded as well - if there's a folder which doesn't have
- // children it will invoke the load on the fly function which is not needed for the function tree
- groupNode.setLoading(true);
- // set the tool tip
- groupNode.setTooltip(name);
- }
- buildChildNodes(obj, groupNode);
- }
- function buildFunctionFunction(obj, parentNode)
- {
- var id = obj.getAttribute(FUNCTION_ATTR_ID);
- var type = obj.getAttribute(FUNCTION_ATTR_TYPE);
-
- //get the qosLevel for hierarchy searches
- if (type==FUNCTION_TYPE_OPERATION && id==MEMBER_SEARCH_IN_HIERARCHY) {
- cfgSet(MEMBER_SEARCH_IN_HIERARCHY,obj.getAttribute(FUNCTION_ATTR_QOSLEVEL));
- }
- if (obj.getAttribute(FUNCTION_ATTR_NAME) != "") {
- // get the attributes of the function
- var dropText = obj.getAttribute(FUNCTION_ATTR_DROPTEXT);
- var name = obj.getAttribute(FUNCTION_ATTR_NAME);
- var syntax = obj.getAttribute(FUNCTION_ATTR_SYNTAX);
- var tip = obj.getAttribute(FUNCTION_ATTR_TIP);
- var qosLevel = obj.getAttribute(FUNCTION_ATTR_QOSLEVEL);
-
- // build the function object
- var useType = (type == "" ? dropText : type);
- var tntType;
- if (useType == FUNCTION_TYPE_OPERATOR) {
- tntType = tntOperator;
- } else if (useType == FUNCTION_TYPE_SUMMARY) {
- tntType = tntSummary;
- }else if (useType == FUNCTION_TYPE_LITERAL) {
- tntType = tntLiteral;
- }else if (useType == FUNCTION_TYPE_FUNCTION) {
- tntType = tntFunction;
- }
- var funcObj = new fnFunction(dropText, name, syntax, tip, type, qosLevel);
- var funcNode = new CTreeNode(parentNode, tntType, false, name, funcObj, false);
- // have to set the indicator for the node
- setNodeIndicator(funcNode, qosLevel);
- // set the tool tip
- funcNode.setTooltip(tip);
- }
- }
- function setNodeIndicator(node, qosLevel)
- {
- // only do this if the correct function is in PRMT tree
- if (node.setIndicator) {
- if (qosLevel == QOS_UNAVAILABLE) {
- } else if (qosLevel == QOS_RESTRICTED) {
- node.setIndicator("../ags/images/tree/qosLevel_restricted.gif");
- } else if (qosLevel == QOS_LIMITED) {
- node.setIndicator("../ags/images/tree/qosLevel_limited.gif");
- } else if (qosLevel == QOS_OK) {
- }
- }
- }
- function functionTreextsError(m)
- {
- // forward it
- functionsTree.xtsError(m);
- }
|