Adding a 'related change request' between work items using the RTC Java API
2 answers
Hi Alex,
This is very much psuedo-code, but hopefully will give you enough pointers to work with the RTC API to achieve what you would like to do. You say you have your handles already, so in this example:
IWorkItemHandle localHandle;
IWorkItemHandle remoteHandle;
First up, you need a link manager:
public ILinkManager linkManager = (ILinkManager) getTeamRepository().getClientLibrary(ILinkManager.class);
The link manager is used to update the links on the localHandle to the remoteHandle. Next create a pair of localRef and remoteRef references using the link manager:
IItemReference localRef = linkManager.referenceFactory().createReferenceToItem(localHandle);
java.net.URI uri = new URI(remoteRtcServerAddress+"/resource/itemName/com.ibm.team.workitem.WorkItem/"+remoteWorkItemId);
IURIReference remoteRef = linkManager.referenceFactory().createReferenceFromURI(uri, "Link to remote repository");
Then create and save the link:
ILink link = linkManager.createLink("com.ibm.team.workitem.linktype.relatedartifact", localRef, remoteRef);
linkManager.saveLink(link, null);
Hope that helps.
Cheers, Steve
Alexander
I think this link should help you http://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/
The blog also contains other useful examples