Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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();
		

0 votes



2 answers

Permanent link
 There is some code here https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/ that follows change set links. Maybe that helps.

1 vote

Comments

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


Permanent link
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);

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927

Question asked: Apr 10 '13, 3:34 p.m.

Question was seen: 6,136 times

Last updated: Apr 16 '13, 12:06 p.m.

Confirmation Cancel Confirm