Getting related ARtifacts for IWorkItems
Hi all,
I'm trying to fetch Related Artifacts (Source code snippets) for WorkItems.
To do so, I create an LinkQuery
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
But what to do if the target is (obviuosly) no IWorkItem?
Thanks for your help.
Kim
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
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();
}