/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2009 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ // Handles Suppression Validation var Filter_ongoing_changed = "Filter_changed"; var Filter_ongoing_unchanged = "Filter_unchanged"; var Filter_new = "Filter_new"; var Filter_stopped = "Filter_deleted"; var Action_topic_filter = "Action_topic_filter"; var Task_level_filter_checkbox = "action_task_filter_checkbox"; var RunCondition = "runCondition"; var topicError = false; /** * validate the whole agent, the summary event key is checked and all the actions * if there are no actions, then the wizard is moved to the end */ function validateAgent(){ var agent = parent.getAgentDefinition(); var valid = agent.summaryEventKey.size() > 0 || document.pform.Event_Key[0].checked ; if(!valid){ //You must select at least one item to uniquely identify the event. window.alert(parent.getConfigFrame().suppEvtKeyWarn_string); return valid; } var items = agent.summaryEventKey.items(); for(var i = 0; valid && i < items.length; i++){ valid = valid & validateEventKeyTopic(items[i]); } if(topicError){ topicError = false; return false; } if(valid){ //& agent.getActionCount() == 0){ valid = validateOngoingFilterTopics(); //we can bin out if there are no more actions // how? }else{ return false; } return valid; } /** * A new topic is added to the current selected actions filter topics * check if it exists in the sumary event key and ban it if it does */ function validateActionFilterTopic(newActionFilterTopic){ var inValid = true; if(document.pform.Event_Key[0].checked){ inValid = false; }else{ inValid = !parent.getAgentDefinition().summaryEventKey.containsItem(newActionFilterTopic); } if(!inValid){ var remove_newItem = window.confirm( parent.getConfigFrame().suppOngFilAddWarn_string.replace('zzxx',newActionFilterTopic) ); if(remove_newItem){ setTabVisible('taskExecutionRulesPane',false); setTabVisible('setEventKeyPane',true); } inValid = remove_newItem; } return inValid; } /** * A new topic is added to the summary event key. check that it doesnt exist in any of the ongoing filter topics of any * of the actions. if it does allow the user to remove that topic from the actions, or allow the addition to become invalid */ function validateEventKeyTopic(newEventKeyTopic){ var valid = true; var offending_task; //check for a containing action, till we get nothing back if((offending_task = parent.getAgentDefinition().validateSummaryEventKeyTopic(newEventKeyTopic)) != undefined) { //This query item's value is in the event key of task "taskname" //OK if you want to remove this query item or Cancel. // zpzp is the placeholder which gets replaced in the message with the task name var remove_newItem = window.confirm(parent.getConfigFrame().suppOngEvntKeyWarn_string.replace('zpzp',offending_task).replace('zzxx',newEventKeyTopic)); if(remove_newItem){ parent.getAgentDefinition().removeActionFilterItem(newEventKeyTopic); removeEventFilterItem(newEventKeyTopic); changeTaskLevelFilterState(); }else{ // SelectAll uses this info to check if there was any conflict, topicError = true; } valid = false;//remove_newItem; } return valid; } // Removes Event Filter topic function removeEventFilterItem(topic){ var mylist = getActionTopicFilterElementProcessor().list ; for(var i=0; i< mylist.size(); i++){ var node = mylist.getNodeByIndex(i); if(node.innerText == topic){ mylist.remove(i); break; } } } /** * check the ongoing filter topics for all actions and warn if any are in the summary event key. * if they are remove them. */ function validateOngoingFilterTopics(){ //check that the items in the summary var valid = parent.getAgentDefinition().validateOngoingFilterTopics(); if(!valid){ //This query item cannot be inserted because it is used in the event key. window.alert(parent.getConfigFrame().suppOngFilAddWarn_string); parent.getAgentDefinition().removeInvalidFilterTopics(); } return valid; } /** * make sure that this action has the required minimum, do the warning if necessary * the action must have at least one filter type and if it has ongoing changed or unchanged then * topics must have been specified for the filter */ function validateAgentAction(action){ var valid = true; var f_new = action.getParams().getParamValue(Filter_new) != undefined; var f_stopped = action.getParams().getParamValue(Filter_stopped) != undefined; var f_changed = action.getParams().getParamValue(Filter_ongoing_changed) != undefined; var f_unchanged = action.getParams().getParamValue(Filter_ongoing_unchanged) != undefined; var f_none = action.getParams().getParamValue(Filter_no_events) != undefined; var f_taskLevelFilter = action.getParams().getParamValue(Task_level_filter_checkbox) != undefined; var f_runCondition = action.runCondition == "runOnFailure"; valid = f_new || f_stopped || f_changed || f_unchanged || f_none || f_runCondition; if(!valid){ window.alert(parent.getConfigFrame().suppFilWarn_string); }else{ if(valid & (f_changed || f_unchanged) & ! (f_changed & f_unchanged)){ valid = action.getParams().getParamValue(Action_topic_filter); if(!valid){ //You must select at least one query item //window.alert(parent.getConfigFrame().suppOngFiltWarn_string); window.alert(parent.getConfigFrame().suppNoItemForEventWarn_string); } } if (f_taskLevelFilter) { valid = action.taskLevelFilter && action.taskLevelFilter.length > 0; if (!valid) { window.alert(parent.getConfigFrame().suppTaskLvlFiltWarn_string); } } if (valid && (f_changed ^ f_unchanged) && parent.getAgentDefinition().summaryEventKey.size() == 0) { valid = false; alert(parent.getConfigFrame().suppnoEvtKeyWarn_string); } } //valid = valid & validateOngoingFilterTopics(); return valid; } /** * If there are no filter parameters set... then set the defualt values for this agent */ function addDefaultFilterValues(action){ var f_new = action.getParams().getParamValue(Filter_new) != undefined; var f_stopped = action.getParams().getParamValue(Filter_stopped) != undefined; var f_changed = action.getParams().getParamValue(Filter_ongoing_changed) != undefined; var f_unchanged = action.getParams().getParamValue(Filter_ongoing_unchanged) != undefined; var f_none = action.getParams().getParamValue(Filter_no_events) != undefined; var none_set = !f_new & !f_stopped & !f_changed & !f_unchanged & !f_none ; if(none_set){ //we can safely set the defaults action.getParams().setParam(Filter_new, 'new'); action.getParams().setParam(Filter_ongoing_changed, 'changed'); action.getParams().setParam(Filter_ongoing_unchanged, 'unchanged'); } } function setIndicAllTopicsInTree(){ var dataItemTree = parent.getDataItemsTree(); var elements = parent.getTreeChildNodes(dataItemTree); for (var i=0;i < elements.length;i++) { var item = elements[i]; parent.setIndicator(item); // Fill items in the items area /*var items = this.list.getAllItems(); for (var i=0;i < items.length;i++) { var dropValue = items[i].nodeValue; parent.removeIndicator(dropValue.replace(";",'')); }*/ //var node = document.createTextNode(item); //this.list.add(node); } return true; } // ********** Initialisations ************* // moved From suppressionDialog.xts var eventKeyElementProcessor; var actionTopicFilterElementProcessor; function initActionTopicFilter() { //call the js to display the tasks loadAgentsToPage(); //register the dz and the delete listener var id = getSelectedAction() ? getSelectedAction().id : undefined; var uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null); var cList = new CList("myCList",false, "CList_ul",uiStyle); var div = document.getElementById('Action_topic_filter'); div.className = "CList_hintText_inactive"; var textNode = document.createTextNode(""); //This will need to be merged with the one in start.xts var elementProcessor = new ElementProcessor("Action_topic_filter","",false); setActionTopicFilterElementProcessor(elementProcessor) ; elementProcessor.defaultNode = textNode; elementProcessor.list = cList; elementProcessor.element.appendChild(cList.getListElement()); elementProcessor.element.appendChild(textNode); elementProcessor.DELIM = ';'; elementProcessor.remove = function() { if (this.list.isDisabled()) { return; } this.list.removeSelected(); try {this.element.focus();} catch(e) {} this.element.blur(); updateActionListValues(); } elementProcessor.doSelectAction = function() { //Always use getSelectedAction just incase it changes //the action becuase it is not a valid. if (onSelectAction()) { this.list.removeAllNodes(); this.setElementValue(getSelectedAction().getParams().getParamValue('Action_topic_filter')); cList.deSelectAll(); this.updateList(); } } elementProcessor.updateList = function () { var disable = document.pform.Filter_ongoing_specified_value.selectedIndex == 0; disable = disable || document.getElementById('event_rules_table').disabled; disable = disable || !document.pform.Filter_ongoing_group.checked; this.list.setDisabled(disable); } elementProcessor.setElementValue = function (value) { var canDrop = document.pform.Filter_ongoing_specified_value.selectedIndex != 0; canDrop = canDrop && !document.getElementById('event_rules_table').disabled; canDrop = canDrop && document.pform.Filter_ongoing_group.checked; if (!value || value.localeCompare("") == 0 || !canDrop) { if (!this.isDefaultMode()) { this.list.removeAllNodes(); this.setDefaultValue(); } //This is remove is helping to avoid //recursive calls. This should be //looked at and resolved. return; } //No event key so notify. //Make sure we only pop the message when there is nothing in the liste already and we are trying to add a new item. //The other case is where an item is already there and Event key is removed. //&& !document.pform.Event_Key[0].checked : DIALOG_SUPPRESSION_NO_EVENT_KEY_WARNING if (parent.getAgentDefinition().summaryEventKey.size() == 0 && getSelectedAction().nonDuplication.size() == 0 ) { alert(parent.getConfigFrame().suppnoEvtKeyWarn_string); return; } var elements = value.split(this.DELIM); for (var i=0;i < elements.length;i++) { if (elements[i].localeCompare("") != 0) { var sItem = elements[i] + this.DELIM; if (validateActionFilterTopic(sItem)) { var node = document.createTextNode(sItem); this.list.add(node); //If we are in default mode and we have just added //Remove the default. if (this.isDefaultMode()) { this.removeDefaultValue(); } } } } updateActionListValues(); } elementProcessor.getElementValue = function () { var textNodes = this.list.getAllItems(); var result = ''; for (var i=0;i 0 && useDefault) { this.element.className="CList_hintText_active"; } else { this.element.className="CList_hintText_inactive"; } } elementProcessor.isDefaultMode = function () { var node = this.element.firstChild; var result = false; if (node && node.nodeType == 3) { result = node.nodeValue.localeCompare(this.defaultValue) == 0; } return result; } elementProcessor.isEmpty = function () { return this.getElementValue().localeCompare("") == 0; } elementProcessor.setDefaultValue = function () { //This is just a guard. Some calls do not check //if we arleady are in default and mode. if (!this.isDefaultMode()) { this.element.removeChild(this.list.getListElement()); this.element.appendChild(this.defaultNode); this.updateStyle(true); } } elementProcessor.removeDefaultValue = function() { if (this.isDefaultMode()) { this.element.removeChild(this.defaultNode); this.element.appendChild(this.list.getListElement()); this.updateStyle(false); } } elementProcessor.setDropLocation = function(event) { return false; } /** * Drop text is an array of text. */ elementProcessor.process = function(dropText) { if (dropText) { if (this.overwrite) { if (dropText.length == 1) { this.list.removeAllNodes(); } else { alert(parent.singleItemAllowed_string); return; } } this.setElementValue(dropText.join(this.DELIM)); } else { return; } } // cool have a built in on load handler droppy.registerDropZone("Action_topic_filter","","", true, '', "", false, elementProcessor); cList.setOnDropFunc(actionTopicFilterListOnDrop); cList.setEqualityFunc(listEqualityCheck); droppy.setDropZoneValue(getSelectedAction().nonDuplication.items().join(''),'Action_topic_filter'); cList.deSelectAll(); } // //