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

Search Conditions

Newbie

Search Conditions

Hello!

I was playing around with Windchill's Java API for building queries and I have figured out how to query based on most of the default fields, for example the Name on a WTPart:


QuerySpec queryspec = new QuerySpec(WTPartMaster.class);
SearchCondition searchcondition = new SearchCondition(WTPartMaster.class, WTPartMaster.NAME, SearchCondition.LIKE, "6208-001-010%");
queryspec.appendWhere(searchcondition, new int[]{0});
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) queryspec);

However, it is not clear to me how I could adapt this to query on custom attributes. Can anyone give me a quick rundown how to look up a custom attribute on an object using this interface?

Thanks for your time!

-Tom

5 REPLIES 5

RE: Search Conditions



What do you mean under "custom attributes" ? IBA ?

Search Conditions

Yup, meaning I have added soft attributes and now I wish to query on them.

-Thomas R. Busch
Sr. Software Developer
Stryker Instruments
(269) 323-7700 x4014
tom.busch@stryker.com<">mailto:tom.busch@stryker.com>

Search Conditions

From a windchill shell, run the command 'inforeport'

That handles the WTIntrospection to convert between DB column identifiers and ORM peristable identifiers.

You can also access this via the API, if desired via DatabaseInfoUtilities.getValidColumnDescriptors(WTintrospector.getClassInfo(persistable class));

You can loop through the columndescriptor objects invoking the getName() method.

This of course only works on modeled hard type elements not soft types. Those have been discussed before.

Dave


Sent from my Verizon Wireless BlackBerry

Search Conditions

This is doable. Soft attributes are in table defined by data type. Example: strings are in StringValue. What defines them is in StringDefinition or (type)Definition. Just don't get confused by two columns containing the value. An entry to these tables is created per iteration of an object EVEN if that value is unchanged during a checkout/checkin. It would be a fairly complex query to find data this way for someone new to using the persistence framework. I have done it before to update an IBA without checking out an object.

Try it out and if you get stuck, feel free to post. You are in a gray area for PTC support because it involves soft attributes, but at the same time the persistence framework is supported.

Dave

Sent from my Verizon Wireless BlackBerry

Search Conditions

Dear Tom,

Officially Info*Engine is the way to query IBAs; however we do write code to do it using SearchConditions, for example a custom search page like this one and you want to add together a number of IBA and other queries to make one very large query to get the data you need.

The IBA is held in two connected tables

e.g.
StringValue and StringDefinition
IntegerValue and IntegerDefinition
etc.

So if we say wanted to query for *MYVALUE* in all IBAs that are called "myibaname" we need to use this code

QuerySpec queryspec = new QuerySpec();

int defindex = queryspec.addClassList(StringDefinition.class,false);
int valueindex = queryspec.addClassList(StringValue.class,true);
queryspec.appendWhere(new SearchCondition(StringDefinition.class, StringDefinition.NAME, SearchCondition.EQUAL , "myibaname"),defindex );
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(StringValue.class, StringValue.VALUE, "%MYVALUE%"),valueindex );
queryspec.appendAnd();
thisQuerySpec.appendWhere(new SearchCondition(StringDefinition.class,"thePersistInfo.theObjectIdentifier.id" , StringValue.class,"definitionReference.key.id"), new int[] { defindex ,valueindex });
// Now you need to add the link to the business object
// and get only the data you actually ned

*Coded from memory so no warranty!

Note the String has VALUE and VALUE2 one is always upper case. Again as Dave said a real gray area and gets quickly very complicated, and very easy to write some poor server stopping queries

Best Regards,
Simon