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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Deprecated function appendSearchCondition

BernardWielfaer
12-Amethyst

Deprecated function appendSearchCondition

Hi,


I am writing a java class that I can insert in the workflow using NetBeans.
When I am building a query for an EPMDocument given the number I see that the function appendSearchCondition is crossed out, meaning it is deprecated. Is there an other way of doing thequery that is not deprecated?


Sample :
--------------


Class cname = EPMDocument.class;
QuerySpec queryspec = new wt.query.QuerySpec(cname);
queryspec.setAdvancedQueryEnabled(true);
SearchCondition modeltypesc = new SearchCondition(EPMDocument.class, "master>docType", "=", EPMDocumentType.toEPMDocumentType("CADPART"));
queryspec.appendWhere(modeltypesc, new int[] { 0 });
queryspec.appendAnd();
queryspec.appendSearchCondition(new SearchCondition(cname, "master>number", "=", CurrNmbr));

5 REPLIES 5

Bernard,
We just had some code updated from 9.1 to 10.1 and the appendSearchCondition function was removed and replaced with the following:

//Added int[]arg={0,1}to fix appendWhere()as this method is deprecated in 10.1, int[]arg is dummy and kept as suggested by PTC R&D.
int[]arg={0,1};
QuerySpec spec=new QuerySpec(EPMDocumentMaster.class);
SearchCondition sc=new SearchCondition(EPMDocumentMaster.class,EPMDocumentMaster.CONTAINER_ID,SearchCondition.EQUAL,contextID);
spec.appendWhere(sc, arg);
spec.appendAnd();
SearchCondition sc1 = new SearchCondition(EPMDocumentMaster.class, "thePersistInfo.createStamp",SearchCondition.GREATER_THAN, startDate);
spec.appendWhere(sc1, arg);
spec.appendAnd();
SearchCondition sc2=new SearchCondition(EPMDocumentMaster.class, "thePersistInfo.createStamp",SearchCondition.LESS_THAN_OR_EQUAL, endDate);
spec.appendWhere(sc2, arg);
QueryResult result1=PersistenceHelper.manager.find((StatementSpec)spec);


Patrick Williams | Engineering Systems | c: 616.947.2110
[cid:image001.jpg@01CDDCF6.EDED2660]

Patrick,


Thanks for the answer. I do have although still one deprecated to go, the query function itself :


QueryResult queryresult = PersistenceHelper.manager.

Bernard,

This will work:

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

Chris

Bernard, per what Patrick showed earlier, you should type cast it to
StatementSpec, a parent class reference that QuerySpec extends. It's been
this way since I started Windchill some 7 years ago now. Some of the old
methods finally got removed after being deprecated several releases in
javadoc as is typical procedure.



May need to import or declare full reference if in workflow, read more about
it in the javadoc or customizer's guide persistence section.



QueryResult queryresult = PersistenceHelper.manager.find(queryspec);


Hello Dave,


Thanks for the reply. I am just starting in this Java programming for Windchill. Besides the Rational Rose and the Java doc what referenced do I still need to find back the info that you just explained about the casting.


Best regards,
Bernard

Announcements


Top Tags