Creation of Child Iterations
I have to extend a child iteration for several timelines. With the help of understanding and using the rtc java client api I was able to get the right parent iteration. Creating a new Iteration in general was also not an issue but now I struggle in adding this iteration as child. Here's the my actual code:
IIteration planIteration = deveLineHelper
.findIteration(owningProcessArea.getProjectArea(),
path, DevelopmentLineHelper.BYLABEL);
IIteration newIter = (IIteration) IIteration.ITEM_TYPE.createItem();
newIter.setName("iterationName");
newIter.setId("iterationID");
newIter.setStartDate(new Date(YYYY, MM, DD, HH, MM, SS));
newIter.setEndDate(new Date(YYYY, MM, DD, HH, MM, SS));
newIter.setParent(planIteration);
planIteration.addChild(newIter);
Set parent went fine so far but when adding the child it always failed with the exception:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2172)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:304)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
at com.ibm.team.process.internal.common.impl.IterationImpl.addChild(IterationImpl.java:1432)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at com.sun.proxy.$Proxy25.addChild(Unknown Source)
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2172)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:304)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
at com.ibm.team.process.internal.common.impl.IterationImpl.addChild(IterationImpl.java:1432)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at com.sun.proxy.$Proxy25.addChild(Unknown Source)
Could it be that I need a workingCopy? If so how to declare it...?
But as per the Iteration Documentation I have to do the linking from both sides.
Do you have an Idea what went wrong here?
Accepted answer
For most of the items in the EWM API, you require a workingcopy, if you want to modify and save them. There are various ways how to get working copies, dependent on what you operate on. Here code I have written recently:
public void processDevelopmentLine(IDevelopmentLine devLine) {
if (devLine == null) {
throw new RuntimeException("Timeline must not be null");
}
boolean dirty = false;
IDevelopmentLine workingCopy = (IDevelopmentLine) devLine.getWorkingCopy();
</pre>
</div>
Here the code how I save the working copies that have been changed:
private ArrayList<iitem> modified = new ArrayList<iitem>();IProcessItemService processItemService = (IProcessItemService) teamRepository .getClientLibrary(IProcessItemService.class); processItemService.save(modified.toArray(new IProcessItem[0]), monitor);</iitem></iitem>