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

Deprecated appendSearchCondition

SOLVED
Highlighted
Regular Member

Deprecated appendSearchCondition

Hi,

I am writing a java class (NetBeans) that I can insert in the workflow.
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 the query 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("CADCOMPONENT"));
queryspec.appendWhere(modeltypesc, new int[] { 0 });
queryspec.appendAnd();
queryspec.appendSearchCondition(VersionControlHelper.getSearchCondition(EPMDocument.class, true));
queryspec.appendAnd();
queryspec.appendSearchCondition(new SearchCondition(cname, "master>number", "=", CurrNmbr));

. . . .

Your input is appreciated. Regards,

Bernard

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Deprecated appendSearchCondition

use appendWhere(SearchCondition,int[]) instead of appendSearchCondition. You've got your first condition correct.

I rewrote your query to use class constants instead of hardcoded String attributes. I haven't run it though... I'd probably also pull out the EPMDocumentType.toEPMDocumentType and use a public static constant for that too, assuming you depend on that enumerated type in more than one place.

QuerySpec queryspec = new QuerySpec(EPMDocument.class);

//queryspec.setAdvancedQueryEnabled(true);

queryspec.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.DOC_TYPE, SearchCondition.EQUAL, EPMDocumentType.toEPMDocumentType("CADCOMPONENT")), new int[] {0});

queryspec.appendAnd();

queryspec.appendWhere(VersionControlHelper.getSearchCondition(EPMDocument.class, true), new int[] {0});

queryspec.appendAnd();

queryspec.appendWhere(new SearchCondition(EPMDocument.class,EPMDocument.NUMBER,SearchCondition.EQUAL,CurrNmbr), new int[] {0});

View solution in original post

3 REPLIES 3
Highlighted

Re: Deprecated appendSearchCondition

use appendWhere(SearchCondition,int[]) instead of appendSearchCondition. You've got your first condition correct.

I rewrote your query to use class constants instead of hardcoded String attributes. I haven't run it though... I'd probably also pull out the EPMDocumentType.toEPMDocumentType and use a public static constant for that too, assuming you depend on that enumerated type in more than one place.

QuerySpec queryspec = new QuerySpec(EPMDocument.class);

//queryspec.setAdvancedQueryEnabled(true);

queryspec.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.DOC_TYPE, SearchCondition.EQUAL, EPMDocumentType.toEPMDocumentType("CADCOMPONENT")), new int[] {0});

queryspec.appendAnd();

queryspec.appendWhere(VersionControlHelper.getSearchCondition(EPMDocument.class, true), new int[] {0});

queryspec.appendAnd();

queryspec.appendWhere(new SearchCondition(EPMDocument.class,EPMDocument.NUMBER,SearchCondition.EQUAL,CurrNmbr), new int[] {0});

View solution in original post

Highlighted

Re: Deprecated appendSearchCondition

Matthew,

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

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

Do you know an other way that is also not deprecated, that will run in future versions ?

Best regards,
Bernard

Highlighted

Re: Deprecated appendSearchCondition

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

Announcements