Skip to main content
1-Visitor
June 2, 2014
Question

How to search multiple WTDocument numbers through WC API

  • June 2, 2014
  • 5 replies
  • 3215 views

Hi,

I am trying to find multiple document numbers through WC API.

If I use only one part number in below code, it works fine. If I use search string like "65832A00.*;1234.*" it won't return anything.

qs = new QuerySpec(wtDocCls);

SearchCondition sc = new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, "65832A00.*;1234.*");

qs.appendWhere(sc);

qr = PersistenceHelper.manager.find(qs);

How can I search multiple documents using API?

5 replies

1-Visitor
June 2, 2014

Try following (with modification for WTDoc).

final QuerySpec querySpec = new QuerySpec(WTPart.class);

querySpec.appendWhere(new SearchCondition(WTPart.class, WTPart.NUMBER, SearchCondition.LIKE, desiredPartNumber.replace('*', '%')), null);

final QueryResult partQueryResult = PersistenceHelper.manager.find((StatementSpec)querySpec);

1-Visitor
June 2, 2014

OK. I am now using "65832A00.%;1234.%". That also do not work. I think I need to use qs.appendOr();

Below code works. But I have query string which contains 10 or more docs. I am thinking of appending Or condition in a loop. It seems that we can not directly use query string in code.

qs = new QuerySpec(wtDocCls);

SearchCondition sc = new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, "1234%");

qs.appendWhere(sc);

qs.appendOr();

SearchCondition sc1 = new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, "65832A00.%");

qs.appendWhere(sc1);

qr = PersistenceHelper.manager.find(qs);

1-Visitor
June 2, 2014

You can concat you query results. For example:

qs = new QuerySpec(wtDocCls);

SearchCondition sc = new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, "1234%");

qs.appendWhere(sc);

qr1 = PersistenceHelper.manager.find(qs);

SearchCondition sc1 = new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.LIKE, "65832A00.%");

qr2 = PersistenceHelper.manager.find(qs1);

qr2.append(qr1.method);

* check the method. It must be like "toObjectVector", don't remember...