How to set iteration as current
Hi,
I'm trying to set the current iteration as current grammatically.
this is my function:
public static void IterateOverIterations(IProjectArea projectArea, IProgressMonitor monitor) throws TeamRepositoryException{
IItemManager itemManager = teamRepository.itemManager();
Date today = new Date();
IProcessItemService service = (IProcessItemService) teamRepository.getClientLibrary(IProcessClientService.class);
IDevelopmentLineHandle[] devLineHandles = ((IProjectArea)projectArea).getDevelopmentLines();
@SuppressWarnings("unchecked")
List<IDevelopmentLine> devLines = itemManager.fetchCompleteItems(Arrays.asList(devLineHandles), IItemManager.DEFAULT, monitor);
for (IDevelopmentLine devLine: devLines) {
IIterationHandle[] iterationHandles = devLine.getIterations();
@SuppressWarnings("unchecked")
List<IIteration> iterations = itemManager.fetchCompleteItems(Arrays.asList(iterationHandles), IItemManager.DEFAULT, monitor);
for (IIteration iteration: iterations) {
List<IIteration> iterationNodes = getAllIterationNodes(iteration, projectArea, monitor);
for (IIteration iterationNode: iterationNodes){
System.out.println("iteration name: " + iterationNode.getName());
Date start = iterationNode.getStartDate();
Date end = iterationNode.getEndDate();
if(start != null){
System.out.println("iteration start date: " + start.toString());
System.out.println("iteration end date: " + end.toString());
if (today.after(start) && today.before(end)){
System.out.println("We are in " + iterationNode.getName() + " Iteration!, making it active");
IDevelopmentLine workingDevLine = (IDevelopmentLine)devLine.getWorkingCopy();
IIteration iterationCopy = (IIteration)iteration.getWorkingCopy();
workingDevLine.setCurrentIteration((IIterationHandle)iterationCopy.getItemHandle());
service.save(new IProcessItem[]{workingDevLine, iterationCopy}, monitor);
break;
}
}
}
}
}
}
the code passes with no errors, but in RTC I don't see any changes. I just see the old current iteration without the current icon.
can someone help me and tell me what's wrong with this code?