How to create Iteration Plan programatically?
5 answers
This is one way of creating iteration:
IProcessItemService service= (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IIteration newIteration = (IIteration) IIteration.ITEM_TYPE.createItem();
newIteration.setName("Ssdfecowsdfnd Iteration");
newIteration.setId("193");
IDevelopmentLine workingDevLine = (IDevelopmentLine) devLine.getWorkingCopy();
workingDevLine.addIteration((IIterationHandle) newIteration.getItemHandle());
newIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[] { workingDevLine, newIteration }, monitor);
I asked here but I found a solution and I created that method to do that:
public static IIteration createIteration(IRepositoryItemService repositoryService, IProcessServerService processService, IDevelopmentLine iDevelopmentLine, String name, String id, Date startDate, Date endDate) throws TeamRepositoryException {
IDevelopmentLine timeLine = (IDevelopmentLine) repositoryService.fetchItem(iDevelopmentLine, IRepositoryItemService.COMPLETE);
IIteration newIteration = (IIteration) timeLine.getCurrentIteration().getItemType().createItem();
IDevelopmentLine timeLineCopy = (IDevelopmentLine) timeLine.getWorkingCopy();
newIteration.setDevelopmentLine(iDevelopmentLine);
newIteration.setHasDeliverable(true);
newIteration.setName(name);
newIteration.setId(id);
newIteration.setStartDate(startDate);
newIteration.setEndDate(endDate);
timeLineCopy.addIteration(newIteration);
processService.saveProcessItems(new IProcessItem[] {newIteration, timeLineCopy});
return newIteration;
}
Thanks