cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

Query WTPart using SUBTYPE NAME

hmungekar
1-Newbie

Query WTPart using SUBTYPE NAME

I previously queried WTPart using subtype reference:-

TypeDefinitionReference typeDefRef = TypedUtility.getTypeDefinitionReference("subtypename"));

sc = new SearchCondition(WTPart.class, "typeDefinitionReference.key.id", SearchCondition.EQUAL, typeDefRef.getKey().getId());

however i now have a requirement to query this using subtype name directy as in:-

sc = new SearchCondition(WTPart.class, ----- WTPart.Subtype ------, .......);

is it possible?

2 REPLIES 2

Yes, it is possible. Try the following piece of code:

final public static IdentifierFactory IDENTIFIER_FACTORY = (IdentifierFactory) DefaultServiceProvider.getService(IdentifierFactory.class, "logical");

.............

TypeIdentifier tid = (TypeIdentifier) IDENTIFIER_FACTORY.get("WCTYPE|wt.doc.WTDocument|com.ptc.ReferenceDocument");

QuerySpec qs = new QuerySpec();

int idx = qs.addClassList(WTDocument.class, true);

SearchCondition sc = TypedUtilityServiceHelper.service.getSearchCondition(tid, true);

qs.appendWhere(sc, new int[] { idx });

qs.appendAnd();

int index = 0;

qs.appendWhere(new SearchCondition(WTDocument.class, Iterated.LATEST_ITERATION, SearchCondition.IS_TRUE), new int[] { index });

QueryResult qr = PersistenceHelper.manager.find((StatementSpec) qs);

............

Thanks for the reply

but my problem is because of migration i am getting some duplicate values of id for a single subtype

I hence want to completly base the search on subtype name only and dont want to use TypeIdentifier at all

Top Tags