It's all about the answers!

Ask a question

Getting related ARtifacts for IWorkItems


Kim Herzig (2612) | asked Feb 12 '08, 9:20 a.m.
Hi all,

I'm trying to fetch Related Artifacts (Source code snippets) for WorkItems.
To do so, I create an LinkQuery


ILinkQueryPage page = fLinkManager.findLinksBySource(new String[]{WorkItemLinkTypes.RELATED_ARTIFACT}, new IReference[]{reference}, _monitor);
ILinkCollection linkCollection = page.getAllLinksFromHereOn();

Collection<ILink> links = linkCollection.getLinksById(WorkItemLinkTypes.RELATED_ARTIFACT);


Now, the problem is how to get the name of the file or the source code entity itself.

When the target would be an IWorkItem I would call


IWorkItemHandle targetItemHandle = (IWorkItemHandle) link.getTargetRef().resolve();
IWorkItem targetItem = (IWorkItem)_auditableClient.resolveAuditable(targetItemHandle, IWorkItem.FULL_PROFILE, _monitor);


But what to do if the target is (obviuosly) no IWorkItem?

Thanks for your help.


Kim

One answer



permanent link
Kim Herzig (2612) | answered Feb 13 '08, 4:52 a.m.
I figured it out. Here is the code in case someone is interested in it:


ILinkQueryPage page = fLinkManager.findLinksBySource(new String[]{WorkItemLinkTypes.RELATED_ARTIFACT}, new IReference[]{reference}, _monitor);
ILinkCollection linkCollection = page.getAllLinksFromHereOn();

Collection<ILink> links = linkCollection.getLinksById(WorkItemLinkTypes.RELATED_ARTIFACT);
for (ILink link : links){

IURIReference targetReference = (IURIReference) link.getTargetRef();

}

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.