123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2008 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- /* ****************************************
- This is a couple of js object "classes" that will allow the creation of an action definition
- object in js that can write to and read from hidden form fields
- **************************************** */
-
- var AGENT_DEFINITION_REPORT = "agentDefinitionReport";
-
- function AgentDefinition(){
- //this is a non duplication items object
- this.summaryEventKey;
- this.m_agent_actions = new Array();
- this.agentDefinitionReport;
-
- this.setSummaryEventKeyValueFromPortalStyleTopics = function(portal_style_topics){
- var translated_item = decodeURIComponent(portal_style_topics);
- //convert it to ags stylee
- this.summaryEventKey.parseFromString(translated_item);
- }
-
- this.getSummaryEventKeyValueWithPortalStyleTopics = function(){
- //convert to portal stylee
- return this.summaryEventKey.toString();
- }
-
- /**
- * get the all items on all agent actions and check that they are not
- * in the event key
- */
- this.validateOngoingFilterTopics = function(){
- //check that the items in the summary
- var valid = true;
-
- var sek = this.summaryEventKey;
-
- for(var x_index = 0; x_index < this.getActionCount() & valid == true; x_index++){
- var an_action = this.getActionAt(x_index);
-
- if(an_action.nonDuplication && an_action.nonDuplication.size() > 0){
- var items = an_action.nonDuplication.items();
-
- for(j = 0; j < items.length & valid == true; j++){
- var la_item = items[j];
- valid = !sek.containsItem(la_item);
- }
- }
- }
- return valid;
- }
-
- /**
- * get all on all agent actions and check that it is not
- * in the event key, if it is remove it
- */
- this.removeInvalidFilterTopics = function(){
-
- for(var x_index= 0; x_index< this.getActionCount(); x_index++){
- var an_action = this.getActionAt(x_index);
-
- var finished = false;
-
- while(an_action.nonDuplication && !finished){
-
- //remove an item
- finished = !this.removeFirstInvalidTopic(an_action);
- }
- }
- }
-
- /**
- * sweep to the first invalid topic found and remove it
- * return true if a topic was found
- */
- this.removeFirstInvalidTopic = function(an_action){
- var removed = false;
- var items = an_action.nonDuplication.items();
- for(var x_index = 0; x_index < items.length; x_index++){
- var la_item = items[x_index];
- if(this.summaryEventKey.containsItem(la_item)){
- this.removeActionFilterItem(la_item);
- removed = true;
- break;
- }
- }
-
- return removed;
- }
-
- /**
- * get all items on the summary event key and check that they not
- * in any of the actions ongoing filter, if it returns the first action name its found in
- otherwise return undefined
- */
- this.validateSummaryEventKey = function (){
- //check that the items in the summary
- var offending_task = undefined;
-
- var items = this.summaryEventKey.items();
- for(var i = 0; i < items.length && offending_task == undefined; i++){
- offending_task = validateSummaryEventKeyTopic(items[i]);
- }
-
- return offending_task;
- }
-
- /**
- * check a new topic to be added to the sek that they are not already in an actions topic filter
- */
- this.validateSummaryEventKeyTopic = function (newEventKeyTopic){
- //check that the items in the summary
- var offending_task = undefined;
-
- for(i = 0; i < this.getActionCount(); i++){
- var an_action = this.getActionAt(i);
-
- if(an_action.nonDuplication && an_action.nonDuplication.containsItem(newEventKeyTopic)){
- if(offending_task != undefined){
- offending_task += ", "
- offending_task += an_action.name;
- }else{
- offending_task = an_action.name;
- }
- }
- }
-
- return offending_task;
- }
-
- /**
- * passed an item that shouldnt be in the action filters
- * remove it forthwith
- */
- this.removeActionFilterItem = function(nonDupeItem){
- for(var i = 0; i < this.getActionCount(); i++){
- var an_action = this.getActionAt(i);
-
- if(an_action.nonDuplication.size() > 0){
- an_action.nonDuplication.removeItem(nonDupeItem);
- an_action.setParam("Action_topic_filter", an_action.nonDuplication.toString());
- }
- }
- }
-
- /*
- *just a way of debug showing whats in the object
- */
- this.toString = function(){
- var description = new AttributeString();
- if(this.summaryEventKey){
- description.setAttribute("summaryEventKey",this.summaryEventKey.toString());
- }
-
- for(var i = 0; i < this.getActionCount(); i++){
- var task = this.getActionAt(i);
- description.setAttribute("action", task.toString());
- }
-
- return description.toString();
- }
-
- /*
- return an object from the string representation
- */
- this.fromString = function(attributeString){
- var attributes = new AttributeString(attributeString);
-
- if(this.summaryEventKey){
- this.summaryEventKey = this.summaryEventKey.parseFromString(attributes.getAttribute("summaryEventKey"));
- }
-
- var agent_actions_strings = attributes.getAttributes("action");
-
- for(var i = 0; i < agent_actions_strings.length; i++){
-
- var agentAction = new ActionDefinition();
- agentAction.fromString(agent_actions_strings[i]);
- this.addAction(agentAction);
- }
-
- return this;
- }
-
- /*
- array accessor
- */
- this.getActionCount = function(){
- return this.m_agent_actions.length;
- }
-
- /*
- array accessor
- */
- this.getActionAt = function(index){
- return this.m_agent_actions[index];
- }
-
- /*
- array accessor
- */
- this.removeActionAt = function(index){
-
- var new_array = new Array();
-
- for(var i = 0; i < this.m_agent_actions.length; i++){
- if(i != index){
- new_array.push(this.m_agent_actions[i]);
- }
- }
-
- this.m_agent_actions = new_array;
- }
-
- /*
- * add a new action to the collective
- */
- this.addAction = function(action){
-
- action.name_id = action.name + "_" + this.getActionCount();
-
- this.m_agent_actions[this.getActionCount()] = action;
-
- return true;
- }
-
- /*
- array accessor
- */
- this.getActionById = function(id){
- var selected_action;
-
- if(!id){
- window.alert("action with no id!");
- return;
- }
-
- for(var i = 0; i < this.getActionCount(); i++){
-
- var action = this.getActionAt(i);
-
- if(action.name_id == id){
- selected_action = action;
- break;
- }
- }
-
- return selected_action;
- }
-
- }
-
- function ActionDefinition(name, id, type, img_src,taskLevelFilter,runCondition){
-
- this.type = type ? type : "";
- this.id = id ? id : "";
- this.name_id= "";
- this.name = name ? name : "";
- this.img_src = img_src ? img_src : "";
- this.params = new Params();
- this.nonDuplication;
- this.taskLevelFilter = taskLevelFilter;
- this.runCondition = runCondition;
- this.getParams = function(){
- return this.params;
- }
-
- this.setParams = function(params){
- this.params = params;
- }
-
- this.setParam = function(name, value){
- this.params.setParam(name, value);
- }
-
- this.addParam = function(name, value){
- this.params.addParam(name, value);
- }
-
- this.addPortalStyleParam = function(name, value){
- this.params.addParam(name, decodeURIComponent(value));
- }
-
- this.removeParam = function(name){
- this.params.removeParam(name);
- }
-
- /*
- just a way of debug showing whats in the object
- */
- this.toString = function(){
-
- var description = new AttributeString();
- description.setAttribute("type",this.type);
- description.setAttribute("id",this.id);
- description.setAttribute("name",this.name);
- description.setAttribute("path" ,this.path) ;
- description.setAttribute("params",this.params.toString()) ;
- description.setAttribute("taskLevelFilter",this.taskLevelFilter) ;
- description.setAttribute("runCondition",this.runCondition) ;
- return description.toString();
- }
-
- /*
- return an object from the string representation
- */
- this.fromString = function(attributeString){
- var attributes = new AttributeString(attributeString);
-
- this.type = attributes.getAttribute("type");
- this.id = attributes.getAttribute("id");
- this.name_id= attributes.getAttribute("name_id");
- this.name = attributes.getAttribute("name");
- this.path = attributes.getAttribute("path");
- this.img_src = attributes.getAttribute("img_src");
- this.taskLevelFilter = attributes.getAttribute("taskLevelFilter");
- this.runCondition = attributes.getAttribute("runCondition");
-
- var params_string= attributes.getAttribute("params");
-
- this.params = new Params().fromString(params_string);
-
- return this;
- }
-
- }
-
-
- function Params(vals){
- this.m_params = new Array();
-
- if(isArray(vals)){
- for(var i = 0; i < this.vals.length; ){
-
- var name = vals[i++];
- var value = vals[i++];
-
- this.setParam(name, value);
- }
- }
-
- this.addParam = function(name, value){
- this.setParam(name, value);
- }
-
- this.setParam = function(p_name, p_value){
-
-
- if(p_value == undefined || p_value == ""){
- p_value = null;
- }
-
- if(p_value != null){
- p_value = decodeURIComponent(p_value);
- }
-
- var param = this.getParam(p_name);
-
- if(param == undefined && p_value != null){
-
- this.m_params.push(new Param(p_name, p_value));
- }else{
-
- if(p_value == null){
- this.removeParam(p_name);
- }else{
- param.param_value = p_value;
- }
- }
-
- }
-
- this.getParamCount= function(){
- return this.m_params.length;
- }
-
- this.getParamValue = function(name){
- for(var i = 0; i < this.m_params.length; i++){
- if(this.m_params[i].param_name == name){
- return this.m_params[i].param_value;
- }
- }
- }
-
-
- this.getParam = function(name){
- for(var i = 0; i < this.m_params.length; i++){
- if(this.m_params[i].param_name == name){
- return this.m_params[i];
- }
- }
- }
-
- this.getParamAt = function(index){
- return this.m_params[index];
- }
-
- this.removeParam = function(name){
-
- var new_array = new Array();
-
- for(var i = 0; i < this.m_params.length; i++){
- if(this.m_params[i].param_name != name){
- new_array.push(this.m_params[i]);
- }
- }
-
- this.m_params = new_array;
- }
-
- /*
- just a way of debug showing whats in the object
- */
- this.toString = function(){
- var description = new AttributeString(undefined);
-
- for(var i = 0; i < this.m_params.length; i++){
- if(i != 0){description += "&";}
-
- description.setAttribute("param",this.m_params[i].toString());
- }
-
- return description.toString();
- }
-
- /*
- return an object from the string representation
- */
- this.fromString = function(attributeString){
- var attributes = new AttributeString(attributeString);
-
- var params = attributes.getAttributes("param");
- for(var i = 0; i < params.length; i++){
-
- var param_attributes = new AttributeString(params[i]);
- this.setParam(param_attributes.getAttribute("param_name"), param_attributes.getAttribute("param_value"));
- }
- return this;
- }
-
- function isArray(a) {
- if (a != null && typeof a == "object") return true;
- return false;
- }
- }
-
- function Param(name, value){
- this.param_name = name;
- this.param_value = value;
-
- /**
- check for ![ ]! and use the agent tree to return the portal style
- */
- this.getPortalStyleValue = function(){
-
- if(this.param_value == undefined || this.param_value == null){
- return this.param_value;
- }
- return this.param_value;
- }
-
- /*
- just a way of debug showing whats in the object
- */
- this.toString = function(){
- var description = new AttributeString();
-
- description.setAttribute("param_name",this.param_name);
-
- description.setAttribute("param_value",this.param_value);
-
- return description;
- }
-
-
-
- }
- function AttributeString(attribute_String) {
- this.value_array = new Array();
-
- if(undefined != attribute_String){
- // parse out name/value pairs separated via &
- var args = attribute_String.split('&');
-
- for (var i=0;i<args.length;i++){
- this.value_array.push(args[i].split('='));
- }
- }
-
- this.setAttribute = function(name, value){
- this.value_array.push(new Array(name, encodeURIComponent(value)));
- }
-
- this.getAttributes = function(name){
- var attributes = new Array();
- // split out each name = value pair
- for (var i=0;i<this.value_array.length;i++){
- if(this.value_array[i][0] == name){
- attributes.push(decodeURIComponent(this.value_array[i][1]));
- break;
- }
- }
-
- return attributes;
- }
-
- this.getAttribute = function(name){
- var attribute;
- // split out each name = value pair
- for (var i=0;i<this.value_array.length;i++){
- if(this.value_array[i][0] == name){
- attribute = decodeURIComponent(this.value_array[i][1]);
- break;
- }
- }
- return attribute;
- }
-
- this.toString = function(){
- var buffer = "";
-
- // split out each name = value pair
- for (var i=0;i<this.value_array.length;i++){
- if(i != 0)buffer += "&";
- buffer += this.value_array[i][0];
- buffer += "=";
- buffer += this.value_array[i][1];
- }
-
- return buffer;
- }
- }
-
|