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
Solved! Go to Solution.
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
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
Can i provide a custom attribute in search condition??
No, you can't. Have a look at the case CS125877
Because the IBA's are not stored in the same table as the object itself.
Probably you can query the standard attributes... I never tried it.
Thanks a lot !!!
Hi ,
without using below API' how we can get soft type ?
SearchCondition sc = TypedUtility.getSearchCondition(softype, true);
Thanks,
Vishvanatha