It's all about the answers!

Ask a question

Why does this code not return any changesets for the supplied IWorkItem (RTC 4.0)?


Tamir Klinger (91165) | asked Apr 10 '13, 3:34 p.m.
JAZZ DEVELOPER
edited Apr 10 '13, 3:39 p.m. by Ralph Schoon (60.7k33643)
Following the advice from this thread I tried to get the changesets for a workitem programmatically. It doesn't seem to be returning anything for a workitem which I've verified does have a changeset. I'm wondering if something changed in the link API for this since 2012? The code snippet I'm using is shown below. What's strange is that if I debug I can see that there is a changeset link in the contents field of the ILinkQueryPage but it does not appear in the ILinkCollection obtained from it, which is an empty array in my example. 

Any thoughts? 

Thanks, 
Tim 

 The code: 
 1. rtcConnection.getRepository() returns the ITeamRepository I'm using. 
 2. workItem is the IWorkItem for which I'm trying to get changesets 

ILinkManager fLinkManager = (ILinkManager)rtcConnection.getRepository().getClientLibrary(ILinkManager.class);
IReferenceFactory fReferenceFactory = fLinkManager.referenceFactory();
IReference reference = fReferenceFactory.createReferenceToItem(workItem.getItemHandle());
ILinkQueryPage page = fLinkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", reference, null);
ILinkCollection linkCollection = page.getAllLinksFromHereOn();
		

2 answers



permanent link
Ralph Schoon (60.7k33643) | answered Apr 10 '13, 3:43 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Comments
Tamir Klinger commented Apr 10 '13, 4:01 p.m.
JAZZ DEVELOPER

Hey Ralph,


Thanks for the pointer.  That code looks like it uses the server-side API.  I'm on the client side here.  I don't see a solution to this problem there...

Tim


Ralph Schoon commented Apr 15 '13, 3:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

permanent link
Tamir Klinger (91165) | answered Apr 16 '13, 11:46 a.m.
JAZZ DEVELOPER
edited Apr 16 '13, 12:06 p.m.
I've cobbled together the following code to retrieve the changeset links for a supplied workitem.  It came from a variety of sources including "Defect178748Snippet" (in the SDK snippets).  As usual it is difficult to find documentation so your milage may vary but it works for me.

--Tim

repository is an ITeamRepository
mgr is an IItemManager
workItem is the IWorkItem for which we want changesets
items holds the set of associated changeset links for the workitem

IClientLibraryContext ctx = (IClientLibraryContext)repository;
IQueryService svc = (IQueryService)ctx.getServiceInterface(IQueryService.class);
AuditableLinkQueryModel alqr = AuditableLinkQueryModel.ROOT;
IItemQuery iq = IItemQuery.FACTORY.newInstance(alqr);
iq.filter(alqr.name()._eq("com.ibm.team.filesystem.workitems.change_set")._and(
     alqr.targetRef().referencedItem().itemId()._eq(iq.newUUIDArg())));
IItemQueryPage itemQueryPage = svc.queryItems(iq,
     new Object[] { workItem.getItemId() }, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE);
List items = mgr.fetchCompleteItems(itemQueryPage.getItemHandles(), mgr.DEFAULT, null);

Your answer


Register or to post your answer.