It's all about the answers!

Ask a question

How to get workitems planned for an iteration and sub iterations with Plain Java API ?


Marie Michelin (14317) | asked Oct 03 '18, 1:41 p.m.

Hello,

I'm using Plain Java API to get the list of workitems planned for an iteration like this : https://jazz.net/forum/questions/139046/how-to-query-defects-for-a-secified-iteration-in-java-client
And it works well.

Now, I'm trying to modify this to get all workitems planned for this iteration and all the sub iterations.

I was thinking I just need to change the AttributeOperation "EQUALS" to another value like when I'm creating a query in the web interface changing "is" into "is part of".

Here is the line :
 Expression expression = new AttributeExpression(attribute, AttributeOperation.EQUALS, curIteration);

But I can't find any usable value.

How could I do that ?

Thanks for your help !

3 answers



permanent link
Ralph Schoon (63.1k33646) | answered Oct 10 '18, 10:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Here some hints on the API https://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/


https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ explains how to set values. You will have to pass an iteration handle to the planned for attribute.


permanent link
Marie Michelin (14317) | answered Oct 11 '18, 11:53 a.m.
Hi Ralph,

Thanks for your answer but I'm not sure to see how this could apply to my need.
Indeed, I don't want to change the Planned For attribute or handle Iterations, I just would like to make a query to get all the work items planned for an iteration and all the subiterations.

Today, I can get all the work items for an iteration with the operator "EQUALS", but I was thinking there were another operator "IS_PART_OF" that would be the equivalent of the one that is available in the web client.

If it is not, is the solution to get the list of all the subiterations with myiteration.getChildren() and then add it to my expression with the "OR" operator ?

Thanks for your help,

Comments
Ralph Schoon commented Oct 12 '18, 2:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Once you have the IIteration you need, you can use it in the query expression. I have not played around with how to create a query you want. I think there should be an option to check "including sub iterations" .


permanent link
Marie Michelin (14317) | answered Oct 12 '18, 11:31 a.m.
I didn't find this kind of option, so I made it manually.

Before I had :
Expression inCurrentIteration = new AttributeExpression(attributeCurrentIteration, AttributeOperation.EQUALS, curIteration);

Now I have :
Expression expression = new AttributeExpression(attributeCurrentIteration, AttributeOperation.EQUALS, curIteration);
List<IIteration> SubIterations = getAllSubIterations(curIteration);
Term plannedfor= new Term(Term.Operator.OR);
 plannedfor.add(expression);
for(IIteration i : SubIterations)
{
   Expression expression_sub = new AttributeExpression(attributeCurrentIteration, AttributeOperation.EQUALS, i);
           
   plannedfor.add(expression_sub);
}

I created a function to get all the subIterations like this :
public List<IIteration> getAllSubIterations(IIteration iteration) throws TeamRepositoryException, IOException {
   List<IIteration> iterationList = new ArrayList<IIteration>();
       
   IIterationHandle handles[] = iteration.getChildren();
       
   for (IIterationHandle h : handles)
   {
      IIteration i = resolveIteration(h);
      List<IIteration> subList = getAllSubIterations(i, display);
           
      iterationList.addAll(subList);
      iterationList.add(i);
   }
   return iterationList;
}

It works, so it's ok for me.

Your answer


Register or 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.