/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2014 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ // utility function var PREVIEW_RESULT = "previewResult"; var AGENT_STATE_PARAM = "param"; var AGENT_STATE_NAME_ATTR = "name"; var VALIDATE_CONDITION_ELEMENT = "validateCondition"; var VALIDATE_CONDITION_DEFECTS = "defects"; var VALIDATE_CONDITION_MESSAGE_ELEMENT = "message"; var VALIDATE_CONDITION_CODE_ATTR = "code"; var VALIDATE_CONDITION_LOCATION_ATTR = "location"; var VALIDATE_CONDITION_SEVERITY_ATTR = "severity"; var VALIDATE_CONDITION_TITLE_ATTR = "title"; var VALIDATE_CONDITION_TYPE_ATTR = "type"; var SOAP_SEVERITY = "severity"; var SOAP_EXCEPTION_MESSAGE = "messageString"; var VALIDATE_ERRORS_KEY = "VALIDATE_SOAP_EXCEPTION_MESSAGES"; //"http://www.ibm.com/xmlns/prod/cognos/agentService/201101/"; var AGENT_SERVICE_SOAP_ACTION = "AGENT_SERVICE_SOAPACTION"; var AGENT_SERVICE = "http://developer.cognos.com/schemas/agentService/1"; var doPreviewRequestURL; var doXHTTPValidateURL; function doPreview(style) { var cf = window.parent.getConfigFrame(); if (style == "" || style == null) return; // If we are on condition page then we need to call RUN from cf var isConditionPage=false; var pageId = self.messageIFrame.document.getElementById("tabSelectedID"); if(null!=pageId && pageId.value=='AgentTask-condition'){ isConditionPage = true; } if (style == "preview_count") { // this is special - we always calls count regardless of where we are. cf.cfgSet("inlineSpec_forCount",true); cf.getCommandStackManager().initiateCommandStack("getReportSpec()","cf.runCount()"); } else if (style == "preview_task" && isConditionPage) { // this is special for condition page - we fire up reportViewer and let it handle everything cf.getCommandStackManager().initiateCommandStack("getReportSpec()","cf.run()"); } else { // we do our own preview - and the extent of the preview depends on whether or not we're running preview_task or preview_all. cf.getCommandStackManager().initiateCommandStack("getReportSpec()","commandStackHideDialogFrame()", "doWait('preview')", "getConditionParameters()", "doWait('preview')", "calcAgentState()", "preview('" + style + "')"); } } function resendCalcAgentState() { getCommandStackManager().getCommandStack().push("calcAgentState()"); } function calcAgentState() { // have to get the calcAgentState morphlet dlgReset(); //set in form vars initialiseDialog(); // set in the location of the morphlet dlgSetParm("m", "/ags/calcAgentState.xts"); dlgSetParm("forceSOAPFault","false"); // make sure that we don't have b_action set - we're adding that in the XHTTP dispatcher dlgRemoveParm("b_action"); // dispatch the request (actually using internal dlg variable - slapped wrist). var dispatcher = new XHTTPDispatcher(calcAgentStateXMLResponse, dialogFormValues); applicationActionManager.httpStart(); try { dispatcher.dispatch(); } catch(ex){ applicationActionManager.httpStop(); } } function calcAgentStateXMLResponse(responseArray) { var responseXML = responseArray[0]; var responseText = responseArray[1]; // wibble applicationActionManager.httpStop(); // create an object to return the calculated state into var agentState = new Object(); // get the values element var paramElements = responseXML.getElementsByTagName(AGENT_STATE_PARAM); //Although it is unlikely but there is a chance this may fault when calling //back to current visible task in Event Studio. var parsedResponse = parseResponse(responseXML,responseText); // decide what we're going to do if (parsedResponse.isLogonFault()) { doPassportExpire(responseXML,resendCalcAgentState,parsedResponse); } else if (parsedResponse.isSoapFault()) { // we have a fault which is a genuine fault fault doSOAPFault(responseXML,null,parsedResponse); } else if(paramElements.length>0){ for (var i = 0; i < paramElements.length; i++) { var paramName = paramElements[i].getAttribute(AGENT_STATE_NAME_ATTR); var paramValue = getTextNodeValue(paramElements[i]); // save the variable into the agent state agentState[paramName] = paramValue; } // save the agentState into global config for the time being cfgSet("AGENT_STATE", agentState); //do the next command whatever it is setTimeout("getCommandStackManager().processCommandStack();", 250); } else { // check the text response to see if we got a html page back in the response if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { doHTMLResponse(responseText); // cleanup getCommandStackManager().getCommandStack().clear(); // hide the wait dialog if(doClosePopUp){ doClosePopUp(); } } else { // tell the client what's going on alert(asyncSelectValuesError_string); } } } function resendSavePPState() { getCommandStackManager().getCommandStack().push("savePPState()"); } function savePPState() { // have to get the calcAgentState morphlet dlgReset(); //set in form vars initialiseDialog(); // set in the location of the morphlet dlgSetParm("m", "/ags/savePPState.xts"); dlgSetParm("forceSOAPFault","false"); // make sure that we don't have b_action set - we're adding that in the XHTTP dispatcher dlgRemoveParm("b_action"); // dispatch the request (actually using internal dlg variable - slapped wrist). var dispatcher = new XHTTPDispatcher(savePPStateXMLResponse, dialogFormValues); applicationActionManager.httpStart(); try { dispatcher.dispatch(); } catch(ex){ applicationActionManager.httpStop(); } } function savePPStateXMLResponse(responseArray) { var responseXML = responseArray[0]; var responseText = responseArray[1]; // wibble applicationActionManager.httpStop(); // create an object to return the calculated state into var ppState = new Object(); // get the values element var paramElements = responseXML.getElementsByTagName(AGENT_STATE_PARAM); //Although it is unlikely but there is a chance this may fault when calling //the xts. var parsedResponse = parseResponse(responseXML,responseText); // decide what we're going to do if (parsedResponse.isLogonFault()) { doPassportExpire(responseXML,resendSavePPState,parsedResponse); } else if (parsedResponse.isSoapFault()) { // we have a fault which is a genuine fault fault doSOAPFault(responseXML,null,parsedResponse); } else if(paramElements.length>0){ for (var i = 0; i < paramElements.length; i++) { var paramName = paramElements[i].getAttribute(AGENT_STATE_NAME_ATTR); var paramValue = getTextNodeValue(paramElements[i]); // save the variable into the agent state ppState[paramName] = paramValue; } // save the variables into the config for (var x in ppState) { cfgSet(x, ppState[x]); } //do the next command whatever it is setTimeout("getCommandStackManager().processCommandStack();", 250); } else { // check the text response to see if we got a html page back in the response if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { doHTMLResponse(responseText); // cleanup getCommandStackManager().getCommandStack().clear(); // hide the wait dialog if(doClosePopUp){ doClosePopUp(); } } else { // tell the client what's going on alert(asyncSelectValuesError_string); } } } function doXHTTPPreview(method, agentState, ifrmcmd, tabSelectedID) { if(isAsynchRequestCancelled()){ //if the cancel has been clicked between prompts and validate / preview processAsynchCancel(); return; } // get the request string var sURL = getValidatePreviewRequestString(method, agentState, ifrmcmd, tabSelectedID); addDebugWaitMessage("sending preview request"); // do the request doPreviewRequest(sURL); } function doXHTTPValidate(method, agentState, ifrmcmd, tabSelectedID) { if(isAsynchRequestCancelled()){ //if the cancel has been clicked between prompts and validate / preview processAsynchCancel(); return; } // get the request string var sURL = getValidatePreviewRequestString(method, agentState, ifrmcmd, tabSelectedID); addDebugWaitMessage("sending validate request"); doXHTTPValidateURL = sURL; if (ifrmcmd == IFRM_ACTION_VALIDATE_SAVE) { // do the request doValidateSaveRequest(sURL); }else{ // do the request doValidateRequest(sURL); } } function doXHTTPValidateCondition() { if(isAsynchRequestCancelled()){ //if the cancel has been clicked between prompts and validate / preview processAsynchCancel(); return; } var sURL = getValidateConditionRequestString(); addDebugWaitMessage("sending validate request"); // do the request doValidateConditionRequest(sURL); } function getValidatePreviewRequestString(method, agentState, ifrmcmd, tabSelectedID) { 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()); // need to send in the method - determine from the value of ifrmcmd if (ifrmcmd.match(/validate_save/)) { sURL += URIEncode("method", "validateAgent"); sURL += URIEncode("severity", "error"); } else if (ifrmcmd.match(/validate/)) { sURL += URIEncode("method", "validateAgent"); // we also need to set an option for validate as well sURL += URIEncode("severity", "warning"); } else if (ifrmcmd.match(/preview/)) { sURL += URIEncode("method", "previewAgent"); } else { sURL += URIEncode("method", method); } // pass in the arguments from the agentState object for (var i in agentState) { sURL += URIEncode(i, agentState[i]); } // send in the command - either validate/preview sURL += URIEncode("ifrmcmd", ifrmcmd); // send in the currently selected tab sURL += URIEncode("tabSelectedID", tabSelectedID); // send in any relevant parameters sURL += URIEncode("parameterValues", getAllParameters()); // pass in some other information which we seem to need sURL += URIEncode("model", cfgGet("cmLastModel")); sURL += URIEncode("packageRoot", cfgGet("PackageRoot")); if(ifrmcmd != IFRM_ACTION_VALIDATE_SAVE){ var reportSpec = getConfigFrame().cfgGet("inlineSpec"); sURL += URIEncode("inlineSpec", reportSpec); } return sURL; } function getValidateConditionRequestString() { var sURL = ""; var clk = "cl"; var plk = "pl"; var locales = getLocales(clk, plk); sURL += URIEncode(clk, locales[clk]); sURL += URIEncode(plk, locales[plk]); // set the method that we're going to be calling sURL += URIEncode("method", "validateSpecification"); // set the report spec var reportSpec = getConfigFrame().cfgGet("inlineSpec"); sURL += URIEncode("inlineSpec", reportSpec); // set the run options sURL += URIEncode("checkMemberUniqueNames", "true"); sURL += URIEncode("severity", "error"); sURL += URIEncode("model", cfgGet("cmLastModel")); var params = getConnectionParameterValues(); if(params){ // send in any connection parameters we will be prompted for the others by rs sURL += URIEncode("parameterValues", params); sURL += URIEncode("prompt", "false"); } return sURL; } function resendDoPreviewRequest() { getCommandStackManager().getCommandStack().push("doPreviewRequest()"); } function doPreviewRequest(request,isSecondary) { if (request == undefined || request.length ==0) { request = doPreviewRequestURL; } else if (!isSecondary) { doPreviewRequestURL = request; } var url = "b_action=xts.run"; url += URIEncode("m","/ags/async/asyncConv.xts"); url += URIEncode("buildRequestXTS","/ags/async/validatePreviewRequest.xts"); url += URIEncode("buildResponseXTS","/ags/async/previewResponse.xts"); // and the soapAction seeing as we're not calling reportServer url += URIEncode("soapAction", AGENT_SERVICE_SOAP_ACTION); url += URIEncode("requestNamespace", AGENT_SERVICE); // force SOAPFault for passport expire instead of getting a logon page url += URIEncode("forceSOAPFault","false"); url += request; if (cafContextId != "") { url += URIEncode("cafcontextid",cafContextId); } try{ // send off the resquest - keep hold of the request object this time dataRequest = sendDispatcherRequestWithXMLTextResponse(url, previewXMLTextResponse); }catch(ex){ processAsynchCancel(); throw ex; } } function doValidateSaveRequest(request) { if (request == undefined || request.length ==0) { request = doXHTTPValidateURL; } var url = "b_action=xts.run"; url += URIEncode("m","/ags/async/asyncConv.xts"); url += URIEncode("buildRequestXTS","/ags/async/validatePreviewRequest.xts"); url += URIEncode("buildResponseXTS","/ags/async/validateResponse.xts"); // and the soapAction seeing as we're not calling reportServer url += URIEncode("soapAction", AGENT_SERVICE_SOAP_ACTION); url += URIEncode("requestNamespace", AGENT_SERVICE); // force SOAPFault for passport expire instead of getting a logon page url += URIEncode("forceSOAPFault","false"); url += request; if (cafContextId != "") { url += URIEncode("cafcontextid",cafContextId); } try{ // send off the resquest - keep hold of the request object this time dataRequest = sendDispatcherRequestWithXMLTextResponse(url, saveValidateXMLTextResponse); }catch(ex){ processAsynchCancel(); throw ex; } } function doValidateRequest(request) { if (request == undefined || request.length ==0) { request = doXHTTPValidateURL; } var url = "b_action=xts.run"; url += URIEncode("m","/ags/async/asyncConv.xts"); url += URIEncode("buildRequestXTS","/ags/async/validatePreviewRequest.xts"); url += URIEncode("buildResponseXTS","/ags/async/validateResponse.xts"); // and the soapAction seeing as we're not calling reportServer url += URIEncode("soapAction", AGENT_SERVICE_SOAP_ACTION); url += URIEncode("requestNamespace", AGENT_SERVICE); // force SOAPFault for passport expire instead of getting a logon page url += URIEncode("forceSOAPFault","false"); url += request; if (cafContextId != "") { url += URIEncode("cafcontextid",cafContextId); } try{ // send off the resquest - keep hold of the request object this time dataRequest = sendDispatcherRequestWithXMLTextResponse(url, nonSaveValidateXMLTextResponse); }catch(ex){ processAsynchCancel(); throw ex; } } function doValidateConditionRequest(request) { var url = "b_action=xts.run"; url += URIEncode("m","/ags/async/asyncConv.xts"); url += URIEncode("buildResponseXTS","/ags/async/validateConditionResponse.xts"); // force SOAPFault for passport expire instead of getting a logon page url += URIEncode("forceSOAPFault","false"); // and the soapAction seeing as we're not calling reportServer url += request; if (cafContextId != "") { url += URIEncode("cafcontextid",cafContextId); } try{ // send off the resquest - keep hold of the request object this time dataRequest = sendDispatcherRequestWithXMLTextResponse(url, validateConditionXMLTextResponse); }catch(ex){ processAsynchCancel(); throw ex; } } function previewXMLTextResponse(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 cancelledRoot = responseXML.getElementsByTagName(CANCEL_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()) { doPassportExpire(responseXML,resendDoPreviewRequest,parsedResponse); } 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 resendDoPreviewRequest(); setTimeout("getCommandStackManager().processCommandStack()", 100); } else { // we have a fault which is a genuine fault fault doSOAPFault(responseXML,null,parsedResponse); } } else if (workingRoot.length == 1) { if(isAsynchRequestCancelled()){ doCancel(workingRoot[0], "doPreviewRequest", AGENT_SERVICE_SOAP_ACTION); }else{ addDebugWaitMessage("waiting for preview"); // we have a working response doWorking(workingRoot[0], "doPreviewRequest"); } } else if (cancelledRoot.length == 1 || isAsynchRequestCancelled()) { addDebugWaitMessage("cancelled in preview"); // we are cancelled processAsynchCancel(); } else if (valuesRoot.length == 1) { handlePreviewResponse(valuesRoot[0]); } else { if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { // check the text response to see if we got a html page back in the response doHTMLResponse(responseText); } else { // tell the client what's going on alert(asyncSelectValuesError_string); } } } function resendValidateNoneSaveRequest() { getCommandStackManager().getCommandStack().push("doValidateRequest()"); getCommandStackManager().getCommandStack().push("doWait('validate')"); } function resendValidateSaveRequest() { getCommandStackManager().getCommandStack().push("doValidateSaveRequest()"); if (cfgGet("NewReport") != true){ getCommandStackManager().getCommandStack().push("doWait('save')"); } } function validateXMLTextResponse(responseArray, isSave) { // 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 cancelledRoot = responseXML.getElementsByTagName(CANCEL_RESPONSE); var requestFunction = isSave ? "doValidateSaveRequest" : "doValidateRequest"; var resendRequestFunction = isSave ? resendValidateSaveRequest : resendValidateNoneSaveRequest; 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,resendRequestFunction,parsedResponse); } else if (parsedResponse.isSoapFault()) { //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 if (parsedResponse.isCancelledWait()) { resendRequestFunction(); setTimeout("getCommandStackManager().processCommandStack()", 100); } else { // we have a fault which is a genuine fault fault doValidateFault(responseXML,isSave, parsedResponse); } } else if (workingRoot.length == 1) { if(isAsynchRequestCancelled()){ doCancel(workingRoot[0], requestFunction, AGENT_SERVICE_SOAP_ACTION); }else{ addDebugWaitMessage("waiting for validate"); // we have a working response doWorking(workingRoot[0], requestFunction); } } else if (cancelledRoot.length == 1 || isAsynchRequestCancelled()) { addDebugWaitMessage("cancelled in validate"); // we are cancelled processAsynchCancel(); } else if (valuesRoot.length == 1) { //check if we have any local errors doValidate(isSave); //just pass on the call to the handling xts.... there will be no errors, and if there is a cmdStack // then go on, otherwise show the "no errors" setTimeout("getCommandStackManager().processCommandStack();", 100); } else { if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { // check the text response to see if we got a html page back in the response doHTMLResponse(responseText); } else { // tell the client what's going on // asyncSelectValuesError_string is constant string with value 'Unknown error in selectValues' setTimeout("displayUnknownAlert()"); } } } function displayUnknownAlert() { alert(asyncSelectValuesError_string); } function saveValidateXMLTextResponse(responseArray) { validateXMLTextResponse(responseArray, false); } function nonSaveValidateXMLTextResponse(responseArray) { validateXMLTextResponse(responseArray, false); } function resendValidateConditionRequest() { getCommandStackManager().getCommandStack().push("doXHTTPValidateCondition()"); } function validateConditionXMLTextResponse(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 cancelledRoot = responseXML.getElementsByTagName(CANCEL_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()) { getCommandStackManager().getCommandStack().push("reloadMetadataTree(true)"); doPassportExpire(responseXML,resendValidateConditionRequest,parsedResponse); // load the nodes after login succeeds keeploadingmdtNodes = true; } else if (parsedResponse.isSoapFault()) { //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 if (parsedResponse.isCancelledWait()) { resendValidateConditionRequest(); setTimeout("getCommandStackManager().processCommandStack()", 100); } else { // we have a fault which is a genuine fault fault doSOAPFault(responseXML,null,parsedResponse); } } else if (workingRoot.length == 1) { if(isAsynchRequestCancelled()){ doCancel(workingRoot[0], "doValidateConditionRequest", AGENT_SERVICE_SOAP_ACTION); }else{ // we have a working response doWorking(workingRoot[0], "doValidateConditionRequest"); } } else if (cancelledRoot.length == 1 || isAsynchRequestCancelled()) { addDebugWaitMessage("cancelled while validating condition"); // we are cancelled processAsynchCancel(); } else if (promptingRoot.length == 1) { // are we prompting //8. doPrompting(promptingRoot[0],'parent.getConfigFrame().promptValidateConditionResponse'); doPrompting(promptingRoot[0], 8); } else if (valuesRoot.length == 1) { // have to process the messages handleValidateConditionResponse(valuesRoot[0]); } else { if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { // check the text response to see if we got a html page back in the response doHTMLResponse(responseText); } else { // tell the client what's going on alert(asyncSelectValuesError_string); } } } function handleValidateConditionResponse(obj) { // shut down the popUP - eww eww eww doClosePopUp(); var existing_messages = cfgGet(VALIDATE_ERRORS_KEY); // look to see if there are error messages var messageElements = obj.getElementsByTagName(VALIDATE_CONDITION_MESSAGE_ELEMENT); if (messageElements.length == 0 && !existing_messages) { // set the error condition to empty setConditionError(null); } else { // have to get all the messages var allMessages = new Array(); var mustShowMessages = new Array(); if(existing_messages){ allMessages = existing_messages.allMessages; } for (var i = 0; i < messageElements.length; i++) { // get the attributes of the message var code = messageElements[i].getAttribute(VALIDATE_CONDITION_CODE_ATTR); var location = messageElements[i].getAttribute(VALIDATE_CONDITION_LOCATION_ATTR); var severity = messageElements[i].getAttribute(VALIDATE_CONDITION_SEVERITY_ATTR); var title = messageElements[i].getAttribute(VALIDATE_CONDITION_TITLE_ATTR); var type = messageElements[i].getAttribute(VALIDATE_CONDITION_TYPE_ATTR); var message = getTextNodeValue(messageElements[i]); // if we don't have a blank message if (message!='') { allMessages.push(new DefectMessage(message, 'warn', location)); } if (type=='layout' && title != '' && message!='') { mustShowMessages.push(new DefectMessage(message, 'warn', location)); } } // get the valid messages var validMessages = getValidMessages(allMessages); if(allMessages.length > validMessages.length){ var message = validationErrorsElsewhere_string + "\n" + validationErrorsElsewhereAction_string; alert(message); } cfgRemove(VALIDATE_ERRORS_KEY); setConditionError(validMessages.concat(mustShowMessages)); } // call the next command setTimeout("getCommandStackManager().processCommandStack();", 100); } function promptValidateConditionResponse(parameters, response, conversation, clientContext, tracking) { if (response == "Cancel" || response == "Error"){ //close the pop up doClosePopUp(); //and cancel the stack - users can set specific cancel behaviour, but the default is to clear getCommandStackManager().getCommandStack().cancel(); } else { // send the context and the final response from prompts back var request = URIEncode("context", clientContext); request += URIEncode("promptResponse", response); request += URIEncode("disp_trackingInfo", tracking); getCommandStackManager().getCommandStack().push("doValidateConditionRequest('" + request + "');"); // resubmit the request setTimeout("getCommandStackManager().processCommandStack()", 100); } } // go through the messages in the parser and check the location // against the validate state object, use it if it matches function getValidMessages(messages) { var validMessages = new Array(); var validateState = cfgGet("ValidateCommandStackObject"); cfgRemove("ValidateCommandStackObject"); for(var i = 0; i < messages.length; i++){ var location = messages[i].location; if(location && validateState){ if(validateState.checkLocation(location)){ validMessages.push(messages[i]); } }else { //benefit of doubt validMessages.push(messages[i]); } } return validMessages; } // obj we get is the element - parsed function doValidateFault(obj, isSave, parsedResponse) { // get all the soap fault message elements var messageStrings = parsedResponse.getErrorMessageNodes(); if(!messageStrings || messageStrings.length == 0){ doSOAPFault(obj); return; } // get the messages and severity var validateErrors = new Array(); for(var i = 0; i < messageStrings.length; i++){ // get the message + attributes var severityObj = selectSingleNode("ancestor::exception/severity", messageStrings[i]); var severityText = getTextNodeValue(severityObj); var severity = new Severity(severityText); if(isSave && severity.level >= ags_severity_enum.WARN){ continue; } var messageText = getTextNodeValue(messageStrings[i]); // build the defect message validateErrors.push(new DefectMessage(messageText, severityText, null)); } var defectMessagesHolder = cfgGet(VALIDATE_ERRORS_KEY); if(!defectMessagesHolder){ defectMessagesHolder = new DefectMessages(validateErrors); }else{ defectMessagesHolder.addMessages(validateErrors); } if(!isSave){ defectMessagesHolder = addUIValidationMessages(defectMessagesHolder) ; } // save them. cfgSet(VALIDATE_ERRORS_KEY, defectMessagesHolder); // call the next command setTimeout("getCommandStackManager().processCommandStack();", 100); } function handlePreviewResponse(obj) { // shut down the popUP - eww eww eww doClosePopUp(); // get the search path returned from the preview var previewResultElements = obj.getElementsByTagName(PREVIEW_RESULT); // if we got a searchPath back - get it and launch reportViewer if (previewResultElements[0].childNodes.length > 0) { var preview_searchPath = getTextNodeValue(previewResultElements[0]); // call report viewer if(preview_searchPath){ viewReportOutput(preview_searchPath); } } } function doValidate(isSave) { //This is special if we don't return any soapfalts and we have local errors // such as no condition in condion page if(!isSave) { // get the messages and severity var validateErrors = new Array(); var defectMessagesHolder = new DefectMessages(validateErrors); defectMessagesHolder = addUIValidationMessages(defectMessagesHolder); // save them. cfgSet(VALIDATE_ERRORS_KEY, defectMessagesHolder); } } //find and add a blank condition message if there is one function addUIValidationMessages(defectMessages){ if(!cf.buildFilterCondition() || cf.buildFilterCondition() == ""){ if(!defectMessages){ defectMessages = new cf.DefectMessages(new Array()); } //only one message from ui so far... if more use an array or Stack var ui_message = new cf.DefectMessage(cf.validateErrantCondition_string, "warn", null); defectMessages.addMessage(ui_message); } return defectMessages; } //Check if the agent has event key when do save action. function checkEventKey() { var element = document.getElementById('agentItemsTree0'); if(element == undefined) { keyValidate(); } getCommandStackManager().processCommandStack(); } // Add event key warning function keyValidate() { var validateErrors = new Array(); var defectMessagesHolder = new DefectMessages(validateErrors); var ui_message = new cf.DefectMessage(cf.suppEvtKeyWarn_string, "warn", null); // add event key warning to VALIDATE_ERRORS_KEY defectMessagesHolder.addMessage(ui_message); cfgSet(VALIDATE_ERRORS_KEY, defectMessagesHolder); }