Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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)

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?

0 votes


Accepted answer

Permanent link

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

0 votes

Comments

 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 log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,936
× 411

Question asked: Aug 05 '22, 12:33 p.m.

Question was seen: 823 times

Last updated: Aug 08 '22, 2:23 a.m.

Confirmation Cancel Confirm