API to get multilevel Where used part?
HI,
I want a API to get all levels of where used part, I am using the below API to get where used StructHelper.service.navigateUsedBy(part.getMaster(),true);
but this gives only 1st level parts. I want all levels as shown in Where Used tab in windchill.
For now I am giving recursive call to the function to get all levels, but this is taking long time, processing time is too high, Is there any better way to do so?
@SuppressWarnings("unchecked")
private ArrayList<Object> getPartStructure(WTPart part,ArrayList<Object> objectList)
{
try
{
ArrayList<WTPart> set=new ArrayList<>();
QueryResult resultWhere=StructHelper.service.navigateUsedBy(part.getMaster(),true);
while (resultWhere.hasMoreElements())
{
Object object = (Object) resultWhere.nextElement();
if(object instanceof WTPart)
{
WTPart prt=(WTPart) object;
//prt=(WTPart) VersionControlHelper.service.allIterationsOf(prt.getMaster()).nextElement();
if(!set.contains(prt))
{
set.add(prt);
if(prt.isEndItem())
{
String vehicleFamily=getIBAValue(prt,"VEHICLE_FAMILY");
if(vehicleFamily!=null && !vehicleFamily.equals(""))
{
HashSet<String>familyList=(HashSet<String>)objectList.get(0);
familyList.add(vehicleFamily);
}
else
{
HashSet<String>UndisclosedFamilyList=(HashSet<String>)objectList.get(1);
UndisclosedFamilyList.add(prt.getNumber());
}
}else{
getPartStructure(prt,objectList);
}
}
}
}
}catch (Exception ex)
{
ex.printStackTrace();
}
return objectList;
}

