create or delete iteration and timelines programatically
Accepted answer
Create Development lines:
IProcessItemService service= (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
projectArea = (IProjectArea) service.getMutableCopy(projectArea);
IDevelopmentLine developmentLine = (IDevelopmentLine) IDevelopmentLine.ITEM_TYPE.createItem();
developmentLine.setId("156");
developmentLine.setName("New Development Line");
developmentLine.setProjectArea(projectArea);
projectArea.addDevelopmentLine(developmentLine);
service.save(new IProcessItem[] { projectArea, developmentLine }, monitor);
Create Iterations:
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);
9 other answers
IProcessItemService service = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IDevelopmentLine workingDevLine = (IDevelopmentLine) createIterationDevLine.getWorkingCopy();
IIteration iterationCopy = (IIteration) newIteration.getWorkingCopy();
IIteration newSubIteration = (IIteration) IIteration.ITEM_TYPE.createItem();
newSubIteration.setName("Sub Iteration - 5");
newSubIteration.setId("185");
iterationCopy.addChild(newSubIteration);
newSubIteration.setParent(iterationCopy);
newSubIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[] { newSubIteration, iterationCopy, workingDevLine }, monitor);
return newSubIteration;
edit: Please note that our Java client library is available as-is and will change over time. It is not a supported API.
Comments
I was able to get the Timeline using GetDevelopmentLines Method, but I'm still having an issue creating the iteration.
for (IIterationHandle iteration : line.getIterations()) { IIteration iter = (IIteration) repo.itemManager().fetchCompleteItem(iteration, 0, monitor); System.out.println("Iteration: " + iter.getName()); if (iter.getName().trim().equals(str)) { System.out.println("Iteration " + str + " already exists ............." ); }else { projectArea.set iter.getWorkingCopy();
projectArea.set
line.addIteration((IIterationHandle) iter.getItemHandle());
break;
}
}
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2060)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
at com.ibm.team.process.internal.common.impl.DevelopmentLineImpl.setName(DevelopmentLineImpl.java:364)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at $Proxy14.setName(Unknown Source)
at com.progress.iterationCreation.createIteration(iterationCreation.java:73)
at com.progress.iterationCreation.main(iterationCreation.java:31)
for (Iterator e = developmentLines.iterator(); e.hasNext();)
{
IDevelopmentLine line = (IDevelopmentLine) e.next();
IIterationHandle[] iterationHandle = line.getIterations() ;
for (IIterationHandle iteration : line.getIterations()) {
IIteration iter = (IIteration) repo.itemManager().fetchCompleteItem(iteration, 0, monitor);
System.out.println("Iteration: " + iter.getName());
if (iter.getName().trim().equals(str)) {
System.out.println("Iteration " + str + " already exists ............." );
}else {
iter.getWorkingCopy();
line.setName(str);
line.addIteration((IIterationHandle) iter.getItemHandle());
break;
}
}
}
newIteration.setId(str);
newIteration.setName(str);
newIteration.setParent(iter);
workingDevLine.setName(iter.getName());
workingDevLine.addIteration((IIterationHandle) newIteration.getItemHandle());
newIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[]{workingDevLine, newIteration}, monitor);
but here is the error that I'm getting
Unable to login: Timeline 'Parent Backlog' contains iteration 'child iteration' which has a non-null parent iteration. Any idea ?
Comments
Hello Rachid,
I have a question on how do you get the id field for iteration. I am not able to find a method that will give me the last id, so that I can increment it by 1 and use it.
So I have to manually come up with an id to pass to the method : newIteration.setId(str).
Can you please help me with that?