It's all about the answers!

Ask a question

Fetching change sets from work items is not working


S M (8622023) | asked Oct 23 '12, 5:14 a.m.
retagged Feb 21 '13, 7:56 a.m. by Morten Madsen (3053250)
Hi

I'm using the method that is described here multiple times to retrieve change sets that are associated with specific work items:

public List<IChangeSet> getChangeSets(IWorkItem workItem) {
        List<IChangeSet> changeSets = new ArrayList<IChangeSet>();        
        ILinkManager linkManager = (ILinkManager) repository.getClientLibrary(ILinkManager.class);
        IReferenceFactory referenceFactory = linkManager.referenceFactory();
        IReference reference = referenceFactory.createReferenceToItem(((com.ibm.team.workitem.common.model.IWorkItem) workItem.getInternalRepresentation()).getItemHandle());
        System.out.println(workItem.getTitle());
        ILinkQueryPage linkQueryPage = null;
        try {
            linkQueryPage = linkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", reference, monitor);
        } catch (TeamRepositoryException e) {
            e.printStackTrace();
        }
        ILinkCollection linkCollection = linkQueryPage.getAllLinksFromHereOn();
        //Put the ILinks in a list.
        List<ILink> linksById = (List<ILink>)linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set");
        return changeSets;
    }

The problem is that I don't get any links at all. I tried to get all Links for a work item and then I get some links, but all of them are of the type textual and I don't get any change set links. What am I doing wrong?

2 answers



permanent link
Chris McGee (50511117) | answered Nov 08 '12, 11:06 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
On the second last line where you call linkCollection.getLinksById() you could instead call linkCollection.iterator() and use the iterator to iterate over the collection of ILinks. For each ILink you can call link.getSourceRef().resolve() to get the changeset item.

I hope that this helps.

permanent link
Ralph Schoon (63.5k33646) | answered Nov 09 '12, 6:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find some information and example on how the link API works here. There are examples for usage in client and server extensions.

Your answer


Register or 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.