It's all about the answers!

Ask a question

How to find the Author and WI associated to change set using plain java Api


gaurao khadse (15114) | asked Jul 12 '21, 1:47 a.m.

 Hello,


I want to get report with change set comment,author, date of checkin, and summary of WI associated with it.


2 answers



permanent link
Luca Martinucci (1.0k397112) | answered Jul 12 '21, 2:26 a.m.

Assuming you got an IChangeSet cs, you can retrieve the author this way:

IContributorHandle authorHandle = cs.getModifiedBy();

I have no examples of retrieving the work item associated to a change set using plain Java API, but I think that this example that makes use of server side Java API can be adapted to plain Java API:

AbstractService abstractService = ....;
linkService = abstractService.getService(ILinkService.class);
ILinkServiceLibrary linkLibrary = (ILinkServiceLibrary) this.linkService.getServiceLibrary(ILinkServiceLibrary.class); 
IItemReference changeSetRef = IReferenceFactory.INSTANCE.createReferenceToItem(cs); 
ILinkQueryPage linkPage = linkLibrary.findLinks(ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID, changeSetRef);
List<IWorkItem> workItems = new ArrayList<IWorkItem>(); 
IWorkItem workItem = null;

for (ILink link : linkPage.getAllLinksFromHereOn()) {
IWorkItemHandle IWorkItemHandle = (IWorkItemHandle) link.getTargetRef().resolve();
workItem = (IWorkItem) this.repositoryItemService.fetchItem(IWorkItemHandle, IRepositoryItemService.COMPLETE);
workItems.add(workItem);
}


Comments
gaurao khadse commented Jul 12 '21, 4:14 a.m.
Thanks for answer

But user name i get it in uuid format not proper name or ID.

I will try to get the link WI.
 


Ralph Schoon commented Jul 12 '21, 5:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The Java API usually returns handles and you have to resolve the handle, to get all the data. See https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ for some introduction. On that blog are many examples with code. You can search also e.g. for IContributorHandle and find code that uses this. 


permanent link
Ralph Schoon (63.3k33646) | answered Jul 12 '21, 2:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 See https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/ for the genral approach. That is however server API. Instead of WorkItemService you want to use the IWorkitemCommon or IWorkItemClient and instead of the itemservice you use the ITeamRepository you get. Also see

for client link APIs.


Your answer


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