How to use IChangeSet to retrieve associated IWorkItem
I know how to retrieve changeset of workitem by below link:
How do I retrieve workitem from change set with plain java client libraries? (I associate the changeset with workitem.)
Many thanks!
Accepted answer
See this post and the associated code:
https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/
https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/
One other answer
Just put the working code here for other's reference:
public List<IWorkItem> getLinkWorkItemFromChangeset(IChangeSetHandle changeSetHandle) throws Exception
{
_envChk(); // Environment check
List<IWorkItem> wkiList = new ArrayList<IWorkItem>();
List<ILink> links = ChangeSetLinks.findLinks(
(ProviderFactory) TeamRepository.getClientLibrary(ProviderFactory.class),
changeSetHandle,
new String[] { ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID },
MyProgressMonitor);
for (final ILink lk : links) {
final Object resolved = lk.getTargetRef().resolve();
if (resolved instanceof IWorkItemHandle) {
IWorkItem workItem = (IWorkItem) TeamRepository.itemManager().fetchCompleteItem(
(IWorkItemHandle)resolved,
IItemManager.DEFAULT,
null);
wkiList.add(workItem);
}
}
return wkiList;
}