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

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

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 !

0 votes



3 answers

Permanent link

 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.

0 votes


Permanent link
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,

0 votes

Comments

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

0 votes

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
× 10,937

Question asked: Oct 03 '18, 1:41 p.m.

Question was seen: 2,536 times

Last updated: Oct 12 '18, 11:31 a.m.

Confirmation Cancel Confirm