It's all about the answers!

Ask a question

Creation of Child Iterations


Max Adler (132) | asked Aug 05, 12:33 p.m.
edited Aug 05, 6:02 p.m.
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)

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


permanent link
Ralph Schoon (60.9k33643) | answered Aug 08, 2:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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>


Max Adler selected this answer as the correct answer

Comments
Ralph Schoon commented Aug 08, 2:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 I would suggest you perform Lab1 of https://jazz.net/library/article/1000 to have an environment with the SDK and the Plain Java Client Libraries, where you can search for the SDK source code and look at the unit tests to understand how the API works.

Your answer


Register or to post your answer.