How to fetch current iteration/sprint using plain java API?
Accepted answer
Get IDevelopmentLineHandle and run a recursive method to get all sub iterations.
IDevelopmentLineHandle[] developmentLineHandles = projectArea.getDevelopmentLines();
for (IDevelopmentLineHandle developmentLineHandle : developmentLineHandles)
{
developmentLine = null;
try
{
developmentLine = (IDevelopmentLine) itemManager.fetchCompleteItem(developmentLineHandle, IItemManager.DEFAULT, monitor);
}
catch (TeamRepositoryException e)
{
// Handle the exception
}
if(null != developmentLine)
{
iterationHandles = developmentLine.getIterations();
if(null != iterationHandles)
{
for(IIterationHandle iterationHandle : iterationHandles)
{
fetchIterations(iterationHandle, itemManager, monitor);
}
}
}
}
void fetchIterations(IIterationHandle iterationHandle, IItemManager itemManager, IProgressMonitor monitor)
{
IIteration iteration = null;
try
{
iteration = (IIteration) itemManager.fetchCompleteItem(iterationHandle, IItemManager.DEFAULT, monitor);
}
catch (TeamRepositoryException e)
{
// Handle it
}
if(null != iteration)
{
// Scan Child iterations
IIterationHandle[] iterationHandles = iteration.getChildren();
if(null != iterationHandles)
{
for(IIterationHandle subIterationHandle : iterationHandles)
{
fetchIterations(subIterationHandle, itemManager, monitor);
}
}
}
}
One other answer
com.ibm.team.process.common.IDevelopmentLine.getCurrentIteration()
Comments
@Ralph Schoon, Thanks for your answer, I go through your code but how can I get IDevelopmentLine object?
The provided link explains all that and also comes with downloadable code.