It's all about the answers!

Ask a question

How to set an Iteration as Current Iteration programatically


Rachid Halloul (144) | asked Sep 17 '12, 10:56 a.m.
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?

                               

One answer



permanent link
Parker Dunton (4064) | answered Sep 17 '12, 1:22 p.m.
JAZZ DEVELOPER
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.

Comments
Rachid Halloul commented Sep 17 '12, 2:22 p.m. | edited Feb 26 '17, 6:18 p.m.

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)


Parker Dunton commented Sep 18 '12, 11:50 a.m.
JAZZ DEVELOPER

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


Rachid Halloul commented Sep 19 '12, 9:38 a.m. | edited Feb 26 '17, 6:18 p.m.

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


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


Parker Dunton commented Sep 19 '12, 12:27 p.m.
JAZZ DEVELOPER

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?


Rachid Halloul commented Sep 19 '12, 3:24 p.m.

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,


Rachid Halloul commented Sep 20 '12, 1:46 p.m.

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