How to set an Iteration as Current Iteration programatically
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
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
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.