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

How to set an Iteration as Current Iteration programatically

I'm trying to set an Iteration as current iteration but it did not work, here is a code simple.

IIteration newIteration = (IIteration) IIteration.ITEM_TYPE.createItem();
 IDevelopmentLine workingDevLine  = (IDevelopmentLine) line.getWorkingCopy() ;
workingDevLine.setCurrentIteration(newIteration);
service.save(new IProcessItem[]{iter, newIteration}, monitor);

Any idea?

                               

0 votes



One answer

Permanent link
Hi Rachid,

From your code it does not look like you are saving the development line after setting the current iteration. You will need to save the dev line as well as the new iteration.

0 votes

Comments

Hi Parker,

when I tried to save the development line, I got the following exception :

com.ibm.team.process.common.service.ProcessDataValidationException: Iteration 'Corticon Sprint 34' has a parent 'Next Release', but its parent doesn't consider it a child.
    at com.ibm.team.process.internal.service.ProcessService.validateIteration(ProcessService.java:671)
    at com.ibm.team.process.internal.service.ProcessService.validateIterationStructure(ProcessService.java:453)
    at com.ibm.team.process.internal.service.ProcessService.doSaveProcessItemsWithOverride(ProcessService.java:983)
    at com.ibm.team.process.internal.service.ProcessService$1.run(ProcessService.java:868)
    at com.ibm.team.repository.service.internal.TransactionService$2.run(TransactionService.java:204)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:458)
    at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:285)
    at com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentConnection(ConnectionPoolService.java:379)
    at sun.reflect.GeneratedMethodAccessor122.invoke(null)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:618)

Sounds like you need to add the iteration to the dev line as well, try IDevelopmentLine#addIteration(IIterationHandle iteration)

still same error message even after adding the iteration to DevelopmentLine. Any idea ?


workingDevLine.addIteration(newIteration);
workingDevLine.setCurrentIteration(newIteration);
                             

If you read the documentation for IDevelopmentLine#addIteration it indicates that you also must call IIteration#setDevelopmentLine(IDevelopmentLineHandle developmentLine) on the iteration. Are you doing this?

here is the code sample workingDevLine.getWorkingCopy(); workingDevLine.setName(iter.getName()); newIteration.setDevelopmentLine(workingDevLine); workingDevLine.insertIterationAfter(newIteration, iter); iter.addChild(newIteration); workingDevLine.addIteration(newIteration); workingDevLine.setCurrentIteration(newIteration); service.save(new IProcessItem[]{newIteration,workingDevLine}, monitor);

iter is the Release iteration (parrent) and the newIteration is the child,

Hi Parker,

I was able to figure out the issue, I was not getting a working copy of the parent iteration.

Thanks of your help.

showing 5 of 6 show 1 more comments

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,938

Question asked: Sep 17 '12, 10:56 a.m.

Question was seen: 5,945 times

Last updated: Feb 26 '17, 6:18 p.m.

Confirmation Cancel Confirm