qaengine/src/TaskDriver.cxx
//------------------------------------------------------------------------------
// This function will return a map with property name/property value pairs
// represented as string/string. Will be used to dump node properties.
//------------------------------------------------------------------------------
This function will return a map with property name/property value pairs
represented as string/string. Will be used to dump node properties.
This function will return a map with property name / property value pairs represented as string / string . Will be used to dump node properties .
PropertiesMap TaskDriver::getNodeProperties(int id,ScopeSet scope) {
PropertiesMap map;
string queryId;
    if(!m_pPolicy) return map;
	PolicyTreeNode* node = (PolicyTreeNode *)m_pPolicy->find(id);
	if(node==NULL) return map;
	map["Kind"]      = node->getName();
	if(node->getName()=="Folder" || node->getName()=="Query") {
	    map["Name"]      = node->getNodeReadableName();
	    map["ID"]    = node->getNodeId();
	}
	if(node->getName()=="Query") {
	    map["Script"]    = node->getNodeScriptFile();
	    map["Procedure"] = queryId = node->getNodeProcedureName();
	}
    int hasEnabled  =0;
	int hasArguments=0;
	int hasWeight   =0;
    if(m_pProject) {
        ScopeSet::iterator i;
        for(i=scope.begin();i!=scope.end();i++) {
	        string item = *i;
		    PropertiesMap* projPropMap;
			PolicyTreeNode* n = node;
			do {
				queryId = n->getNodeProcedureName();
				if(queryId!="") { 
		            projPropMap=m_pProject->getNodeProperties(item,queryId);
                    PropertiesMap::iterator j;
                    for(j=projPropMap->begin();j!=projPropMap->end();j++) {
			            map[j->first] = j->second;
				        if(j->first=="Enabled")   hasEnabled   = 1;
				        if(j->first=="Arguments") hasArguments = 1;
				        if(j->first=="Weight")    hasWeight    = 1;
					}
		            delete projPropMap;
				} else {
					string folderId = n->getNodeReadableName();
					if(folderId!="") {
		                projPropMap=m_pProject->getFolderProperties(item,folderId);
                        PropertiesMap::iterator j;
                        for(j=projPropMap->begin();j!=projPropMap->end();j++) {
							string curAttr = map[j->first];
							if(j->first=="Enabled") {
								if(curAttr.length()==0 || curAttr=="true")
									map[j->first] = j->second;
								if(!hasEnabled) hasEnabled = 2;
							} else {
								if(curAttr.length()==0)
									map[j->first] = j->second;
								if(j->first=="Arguments") hasArguments = 1;
								if(j->first=="Weight")    hasWeight    = 1;
							}
						}
		                delete projPropMap;
					}
				}
				n=(PolicyTreeNode *)m_pPolicy->getParent(n);
			} while(n);
		}
	}
	string parentEnable = map["Enabled"];
	if(parentEnable.length()==0) {
		PolicyTreeNode* parent = (PolicyTreeNode*)node->getParent();
		while(parent) {
			parentEnable = parent->getAttributeValue("Enabled");
			if(parentEnable.length()>0) {
				map["Enabled"]=parentEnable;
				hasEnabled=2;
				if(parentEnable == "false")  break;
			}
			parent = (PolicyTreeNode*)parent->getParent();
		}
	}
	if(parentEnable=="true" && node->getNodeKind()!="Folder" && hasEnabled==2) hasEnabled = 0;
	if(parentEnable.length()==0 || (parentEnable.length()!=0 && parentEnable=="true")) {
		if(!hasEnabled) {
			string curEnabledState = node->getAttributeValue("Enabled");
			if(curEnabledState.length()!=0 && curEnabledState=="false") {
				map["Enabled"] = "false";
				hasEnabled = 1;
			} else {
				if(curEnabledState.length()!=0) {
					map["Enabled"] = curEnabledState;
					hasEnabled = 1;
				}
			}
		}
	}
	if(!hasEnabled)  {
		string val = node->getNodeParameterValue("Disabled",parentEnable.length()==0);
		if(val=="1") {
		   map["Enabled"]="false";
		   hasEnabled = 1;
		} else {
		   map["Enabled"]="true";
		}
	}
	if(!hasArguments)  {
		string val = node->getAttributeValue("Arguments");
		if(val=="") {
			val = node->getNodeParameterValue("Threshold");
			if(val!="") {
			   map["Arguments"]=val;
			   hasArguments = 1;
			}
		} else {
			map["Arguments"]=val;
			hasArguments = 1;
		}
	}
	if(!hasWeight)  {
        string val = node->getAttributeValue("Weight");
		if(val=="") {
			val = node->getNodeParameterValue("Weight");
			if(val!="") {
			   map["Weight"]=val;
			   hasWeight = 1;
			}
		} else {
			map["Weight"]=val;
			hasWeight = 1;
		}
	}
	if(!hasEnabled)   map["Enabled"]  ="true";
	if(!hasWeight)    map["Weight"]   ="100";
	return map;
}
PropertiesMap TaskDriver :: getNodeProperties ( int id , ScopeSet scope ) { PropertiesMap map ; string queryId ; if ( ! m_pPolicy ) return map ; PolicyTreeNode * node = ( PolicyTreeNode * ) m_pPolicy -> find ( id ) ; if ( node == NULL ) return map ; map [ " " ] = node -> getName ( ) ; if ( node -> getName ( ) == " " || node -> getName ( ) == " " ) { map [ " " ] = node -> getNodeReadableName ( ) ; map [ " " ] = node -> getNodeId ( ) ; } if ( node -> getName ( ) == " " ) { map [ " " ] = node -> getNodeScriptFile ( ) ; map [ " " ] = queryId = node -> getNodeProcedureName ( ) ; } int hasEnabled = 0 ; int hasArguments = 0 ; int hasWeight = 0 ; if ( m_pProject ) { ScopeSet :: iterator i ; for ( i = scope . begin ( ) ; i != scope . end ( ) ; i ++ ) { string item = * i ; PropertiesMap * projPropMap ; PolicyTreeNode * n = node ; do { queryId = n -> getNodeProcedureName ( ) ; if ( queryId != " " ) { projPropMap = m_pProject -> getNodeProperties ( item , queryId ) ; PropertiesMap :: iterator j ; for ( j = projPropMap -> begin ( ) ; j != projPropMap -> end ( ) ; j ++ ) { map [ j -> first ] = j -> second ; if ( j -> first == " " ) hasEnabled = 1 ; if ( j -> first == " " ) hasArguments = 1 ; if ( j -> first == " " ) hasWeight = 1 ; } delete projPropMap ; } else { string folderId = n -> getNodeReadableName ( ) ; if ( folderId != " " ) { projPropMap = m_pProject -> getFolderProperties ( item , folderId ) ; PropertiesMap :: iterator j ; for ( j = projPropMap -> begin ( ) ; j != projPropMap -> end ( ) ; j ++ ) { string curAttr = map [ j -> first ] ; if ( j -> first == " " ) { if ( curAttr . length ( ) == 0 || curAttr == " " ) map [ j -> first ] = j -> second ; if ( ! hasEnabled ) hasEnabled = 2 ; } else { if ( curAttr . length ( ) == 0 ) map [ j -> first ] = j -> second ; if ( j -> first == " " ) hasArguments = 1 ; if ( j -> first == " " ) hasWeight = 1 ; } } delete projPropMap ; } } n = ( PolicyTreeNode * ) m_pPolicy -> getParent ( n ) ; } while ( n ) ; } } string parentEnable = map [ " " ] ; if ( parentEnable . length ( ) == 0 ) { PolicyTreeNode * parent = ( PolicyTreeNode * ) node -> getParent ( ) ; while ( parent ) { parentEnable = parent -> getAttributeValue ( " " ) ; if ( parentEnable . length ( ) > 0 ) { map [ " " ] = parentEnable ; hasEnabled = 2 ; if ( parentEnable == " " ) break ; } parent = ( PolicyTreeNode * ) parent -> getParent ( ) ; } } if ( parentEnable == " " && node -> getNodeKind ( ) != " " && hasEnabled == 2 ) hasEnabled = 0 ; if ( parentEnable . length ( ) == 0 || ( parentEnable . length ( ) != 0 && parentEnable == " " ) ) { if ( ! hasEnabled ) { string curEnabledState = node -> getAttributeValue ( " " ) ; if ( curEnabledState . length ( ) != 0 && curEnabledState == " " ) { map [ " " ] = " " ; hasEnabled = 1 ; } else { if ( curEnabledState . length ( ) != 0 ) { map [ " " ] = curEnabledState ; hasEnabled = 1 ; } } } } if ( ! hasEnabled ) { string val = node -> getNodeParameterValue ( " " , parentEnable . length ( ) == 0 ) ; if ( val == " " ) { map [ " " ] = " " ; hasEnabled = 1 ; } else { map [ " " ] = " " ; } } if ( ! hasArguments ) { string val = node -> getAttributeValue ( " " ) ; if ( val == " " ) { val = node -> getNodeParameterValue ( " " ) ; if ( val != " " ) { map [ " " ] = val ; hasArguments = 1 ; } } else { map [ " " ] = val ; hasArguments = 1 ; } } if ( ! hasWeight ) { string val = node -> getAttributeValue ( " " ) ; if ( val == " " ) { val = node -> getNodeParameterValue ( " " ) ; if ( val != " " ) { map [ " " ] = val ; hasWeight = 1 ; } } else { map [ " " ] = val ; hasWeight = 1 ; } } if ( ! hasEnabled ) map [ " " ] = " " ; if ( ! hasWeight ) map [ " " ] = " " ; return map ; }
This function will return a map with property name/property value pairs
represented as string/string.
This function will return a map with property name / property value pairs represented as string / string .
// Scannining selection-independent properties // Scanning selection properties