How to retrieve the changesets associated to a workitem via Java API
I am developing a Java extension (a follow-up action) to RTC 4.0.5, and I need to retrieve the list of changesets associated to a work item.
I have already managed to retrieve a IWorkItem object; how can I retrieve its changesets (using server-side classes)?
|
Accepted answer
Hi,
see below an example :
private List<IChangeSet> getChangeSets(IWorkItem wi)
throws TeamRepositoryException {
IRepositoryItemService repositoryItemService = getService(IRepositoryItemService.class);
ILinkService linkService = getService(ILinkService.class);
ILinkServiceLibrary linkLibrary = (ILinkServiceLibrary) linkService
.getServiceLibrary(ILinkServiceLibrary.class);
IItemReference workItemRef = IReferenceFactory.INSTANCE
.createReferenceToItem(wi);
ILinkQueryPage linkPage = linkLibrary.findLinks(
WorkItemLinkTypes.CHANGE_SET, workItemRef);
List<IChangeSet> changeSets = new ArrayList<IChangeSet>();
for (ILink link : linkPage.getAllLinksFromHereOn()) {
// Change set links should be item references
IChangeSetHandle changeSetHandle = (IChangeSetHandle) link
.getSourceRef().resolve();
IChangeSet changeSet = (IChangeSet) repositoryItemService
.fetchItem(changeSetHandle, IRepositoryItemService.COMPLETE);
changeSets.add(changeSet);
}
return changeSets;
}
Luca Martinucci selected this answer as the correct answer
Comments
Luca Martinucci
commented Sep 04 '14, 5:59 a.m.
Olivier, thanks for providing me with this example: it worked, with some minor corrections. Hello,
In this example there is getService method:
IRepositoryItemService repositoryItemService = getService(IRepositoryItemService.class);
ILinkService linkService = getService(ILinkService.class);
Where does this come from/what are the contents of this method?
Thanks!
Ralph Schoon
commented May 18 '17, 1:44 p.m.
| edited May 18 '17, 1:46 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
That is server side API. The extension extends AbstractService which provides getService().
|
3 other answers
Hi Olivier,
In your above answer to fetch change set associated to work item, you have used server API.
Could you please tell me about java client API which does similar thing.
I figured out that instead of IRepositoryItemService we can use IItemManager at client side.
instead of ILinkServiceLibrary we can use ILinkManager at client side.
Other are common API.
but
IChangeSet changeSet = (IChangeSet) repositoryItemService
.fetchItem(changeSetHandle, IRepositoryItemService.COMPLETE);
I replaced it with
IChangeSet changeSet = (IChangeSet) itemManager.fetchCompleteItem(changeSetHandle,itemManager.DEFAULT, monitor);
but at this line it is throwing null pointer exception
Could you please tell me about client API which will does similar thing.
|
Hi,
I think it should work : for (Object o : changeSet.changes()) { IChange change = (IChange) o; IVersionableHandle handle = change.item(); IVersionable afterVersionable = workspaceManager.versionableManager().fetchCompleteState(handle, new SysoutProgressMonitor()); afterVersionable.getName(); } |
Hi lucca?
Do you know how can we get filenames of changeset associated to work item
|
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.
Comments