Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Can anyone tell me how to fetch classification node and classification attributes on a WTPart in 10.2
Try this query report in CS129984:
This report can be generated using the following tables and joins:
Tables:
1. Part (wt.part.WTPart)
2. Classification Node (wt.csm.navigation.ClassificationNode)
3. Reference Value (wt.iba.value. ReferenceValue)
Joins:
1. Reference Value- IBAHolder Reference- Part
2. Reference Value- IBAReferenceable Reference- Classification Node
You can also take a look at this document I wrote Resource for reporting
In it you can find lots of query builder, collect from many sources, ready to use (including the one indicated by Thomas)
To see it you have to join this group Reporting
1. You can fetch the classification node on a WTPart by simply fetching the IBA value of classification attribute. Below snippet can be used to fetch the internal name of classification node:
String node = getibaValue( <WTPart Object>, <Internal name of Classification Binding attribute>);
public static String getibaValue(Persistable obj, String id) {
try {
// fetching persistable object
final PersistableAdapter obj2 = new PersistableAdapter(obj, null,
Locale.US, null);
obj2.load(id);
String value = obj2.getAsString(id).toString();
return value;
} catch (WTException e) {
// return - if exception
return "";
}
}
2. Now we need to fetch all the classification attributes corresponding to the internal name of node which we have fetched in step 1. Below code snippet returns a list with all classification attributes.
public static List<String> getPartsLinkIBA(String node)
throws WTException {
List<String> l1 = new ArrayList<String>();
final TypeDefinitionReadView localTypeDefinitionReadView = TypeDefinitionServiceHelper.service
.getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT,
CsmConstants.NAMESPACE, node);
if (localTypeDefinitionReadView != null) {
final Collection<AttributeDefinitionReadView> x = localTypeDefinitionReadView
final Iterator<AttributeDefinitionReadView> it = x.iterator();
// getting all the attributes internal name
while (it.hasNext()) {
final Object object = (Object) it.next();
final AttributeDefinitionReadView adrv = (AttributeDefinitionReadView) object;
l1.add(adrv.getName());
/*
return l1;
}
3. Once you have the WTPart Object and all the classification attributes (List in step 2), you can fetch the values of all the attributes by using any method like Persistable Adapter, IBAHolder, etc.