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.
Accepted answer
Thanh,
Term term= new Term(Operator.AND); term.add(expressionOne); term.add(expressionTwo);
...IQueryResult<IResolvedResult<IWorkItem>> result= queryService.getResolvedExpressionResults(projectArea, term, profile);
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.