Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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
Solved! Go to Solution.
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});
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});
Matthew,
Thanks for the answer. I do have although still one deprecated to go, the query function itself :
Do you know an other way that is also not deprecated, that will run in future versions ?
Best regards,
Bernard
QueryResult queryresult = PersistenceHelper.manager.find((StatementSpec)queryspec);