I have been trying to write a script to find the process-oriented superior of objects.
Initially I thought this would not be very difficult, though I am unable to find a good solution.
I am looping through all Object Occurrences, then I get a connection list for each object:
aCnxDefList = aObjOcc[j].ObjDef().CxnList(); // CxnDef[]
, then I loop through connections comparing names of the known top level superiors with all aCnxDefList[k].SourceObjDef().Name(nLocale). If I don;t get a match, then I call a recursive function:
nCurrentLevel = get_nesting_level(aCnxDefList[k].SourceObjDef(), 0);
I am using a recursive function, but I am unable to walk up to the superior for some reason.I would appreciate any suggestions. Here is the code for the function:
// Takes in Source Object Def
function get_nesting_level(my_ObjDef, myLevelCount) {
aCxnDef = my_ObjDef.CxnList(Constants.EDGES_IN);
myLevelCount++; // increment new nesting level
// cycle through 'Connections IN' to find superior connection match for "CORE", "MANAGEMENT", "ENABLING"
for (var i=0; i < aCxnDef.length; i++) {
curSrc_ObjDef = aCxnDef[i].SourceObjDef();
sObjName = aCxnDef[i].SourceObjDef().Name(nLocale);
// All objects are children of the following 3 objects
if((sObjName == 'X') ||
(sObjName == 'Y') ||
(sObjName == 'Z'))
{
// we found the matching top level!!!
return (myLevelCount);
}
else
{
// we did not find the superior yet - recurse another level
return get_nesting_level(curSrc_ObjDef, myLevelCount);
}
}
}