Query Soft Types through API
Hi Everyone,
I want to know, if we can use Queryspec API to query soft types.
If yes, can you please give me a simple example of how to do it.
I have been using Info engine till now.
Thanks
Sudeep
Hi Everyone,
I want to know, if we can use Queryspec API to query soft types.
If yes, can you please give me a simple example of how to do it.
I have been using Info engine till now.
Thanks
Sudeep
You can try to do something like this:
final IdentifierFactory IDENTIFIER_FACTORY = (IdentifierFactory) DefaultServiceProvider.getService(IdentifierFactory.class, "logical");
TypeIdentifier tid = (TypeIdentifier) IDENTIFIER_FACTORY.get(subtype); // Example: subtype=’com.ptc.ElectricalPart’
Class qc = WTPart.class;
QuerySpec qs = new QuerySpec();
int idx = qs.addClassList(qc, true);
SearchCondition sc = TypedUtilityServiceHelper.service.getSearchCondition(tid, true);
qs.appendWhere(sc, new int[]{idx});
System.out.println(qs);
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) qs);
WTPart part;
while (qr.hasMoreElements()) {
Persistable[] ar = (Persistable[]) qr.nextElement();
part = (WTPart) ar[idx];
System.out.println(part + " - " + part.getName() + " - " + TypedUtilityServiceHelper.service.getExternalTypeIdentifier(part));
}
Regards Björn
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.