It's all about the answers!

Ask a question

How to use IChangeSet to retrieve associated IWorkItem


Lee John (51110) | asked Apr 01 '15, 4:04 a.m.
 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


permanent link
Ralph Schoon (59.4k23642) | answered Apr 01 '15, 4:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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/
Lee John selected this answer as the correct answer

Comments
Lee John commented Apr 01 '15, 4:47 a.m.
Hi Ralph,

Many thanks! 

Since I am use plain java client libraries, the below links solve my problem:

and your information does great help!

One other answer



permanent link
Lee John (51110) | answered Apr 01 '15, 11:51 p.m.
edited Apr 01 '15, 11:53 p.m.
 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;
}

Comments
Ralph Schoon commented Apr 02 '15, 2:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Thanks for sharing!


Your answer


Register or to post your answer.