Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Get children/links of work item combine Queries with Java Plain API

I have an work item and I have to fetch all work items link to this work item ( Ex: have Parent and Contribute to), but I also need to filter links/children with queries (Ex:I use share query to fetch work items  type is defect and file against ABC)
_First, I can run findLinks() for this work item to get all the links/childrens
_Second, I can get list result by using Query ( or Expression)
=> My problem is I don't know how to combine 2 conditions.

0 votes


Accepted answer

Permanent link

 Thanh,


please take a look at https://jazz.net/wiki/bin/view/Main/QueryDevGuide especially the section about constructing a term to combine filter expressions. If this helps please mark the answer resolved.

Term term= new Term(Operator.AND);
term.add(expressionOne);
term.add(expressionTwo);
    
...
IQueryResult<IResolvedResult<IWorkItem>> result= queryService.getResolvedExpressionResults(projectArea, term, profile);

thanh nham selected this answer as the correct answer

0 votes

Comments

Thank Ulf for your answer, but it still not solve my problem
_First, as I know: the expression can not fetch links
_Second, I run a share query / personal query (IQueryDescriptor) to get the results ( not a Expression)

  • IQueryResult unresolvedResults = queryClient.getQueryResults(query)
            


So you run a shared query and want to get the intersection of those results with the list of children work items of a particular story?

In that case it becomes a simple java exercise:
1. write a method to find the intersection of two lists
2. convert your IQueryResult to List (.toList() ) of type <IWorkItemHandle>
3. If your original IQueryResult had a lot of results you might have to loop over until all pages have been loaded
4. write code to retrieve the children of the story as IWorkItemHandle list
(Ralph Schoon has a good article on this, look for the section with "Accessing references: https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ )
5. use method from 1. to get intersection of both Lists --> this should be the result you were looking for


Thank Ulf.

I think there is only solution is using java code to intersect 2 list like you said.
Actually, I had though about that. But I have to get children (n1) combine query-1 of a list parent (p), then find children (n2) combine query-2 of n1. And I fear that java code will slow the performance, so I ask for a combine query (if it is possible).

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 411

Question asked: May 19 '18, 1:54 a.m.

Question was seen: 2,296 times

Last updated: May 22 '18, 11:09 a.m.

Confirmation Cancel Confirm