How to associate change set with work item using RTC Plain JAVA API ?
I am trying to associate the change set with work item with the following code and it saves the work item succefully but I can not see the Change set in the links of the work item.
IItemType changeItemType= changSet.getItemType(); IItemHandle changeItemHandle = changeItemType.createItemHandle(changSet.getItemId(), changSet.getStateId()); IItemReference reference = IReferenceFactory.INSTANCE .createReferenceToItem(changeItemHandle);
IEndPointDescriptor endpoint = LinkTypeRegistry.INSTANCE.getLinkType(
WorkItemLinkTypes.CHANGE_SET).getTargetEndPointDescriptor();
workItemWorkingCopy.getReferences().add(endpoint, reference);
workItemWorkingCopy.save(monitor);
However when I change the WorkItemLinkTypes to
'RELATED_CHANGE_MANAGEMENT' instead of 'CHANGE_SET' then the change set gets linked with work item.
Is there any way to link the 'WorkItemLinkTypes.CHANGE_SET' or can anyone check if I am missing anything in the above code ?
|
6 answers
Hi I can successfully attach the changeset to the work item with the IFileSystemWorkItemManager as given below : IFileSystemWorkItemManager fileSystemWorkItemManager = (IFileSystemWorkItemManager) teamRepository.getClientLibrary(IFileSystemWorkItemManager.class); fileSystemWorkItemManager.createLink(workspaceHandle , changeSetHandle,workItemhandle , null); |
Hi Dashrath,
The following forum post might be helpful to you: https://jazz.net/forum/questions/82384/serverside-create-link-from-a-workitem-to-a-changeset |
Hi Lauren Thanks for your quick reply and suggestion. I have tried the given solution but getting NullPointerException while retreving the ILinkServiceLibrary i.e. line marked in bold below. Also I am trying to do this using RTC JAVA client/plain API's and not using participant from server side.
ILinkService linkService = (ILinkService)repo.getClientLibrary(ILinkService.class);
ILinkServiceLibrary ls = (ILinkServiceLibrary) linkService.getServiceLibrary(ILinkServiceLibrary.class);
IReference changeReference= IReferenceFactory.INSTANCE.createReferenceToItem(changeSetHandle);
IReference workItemReference= IReferenceFactory.INSTANCE.createReferenceToItem(((IItem) workItemWorkingCopy).getItemHandle());
ILink il = ls.createLink(WorkItemLinkTypes.CHANGE_SET, changeReference, workItemReference);
ls.saveLink(il);
|
Ralph Schoon (63.7k●3●36●48)
| answered Jan 09 '14, 9:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would suggest to follow https://rsjazz.wordpress.com/2012/10/20/following-calm-links-using-the-java-client-or-server-api/ and especially http://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ and to check if the code displayed there helps you with your task. I don't seem to need the ILinkServiceLibrary that you have trouble using. Maybe you don't need it either?
|
Hi Ralph Thanks for your suggestions. I have refered the links you given , however the change set is not getting linked with the work item with below code first without using ILinkServiceLibrary.
IItemType changeItemType= changSet.getItemType(); IItemHandle changeItemHandle = changeItemType.createItemHandle(changSet.getItemId(), changSet.getStateId()); IItemReference reference = IReferenceFactory.INSTANCE .createReferenceToItem(changeItemHandle); IEndPointDescriptor endpoint = LinkTypeRegistry.INSTANCE.getLinkType( WorkItemLinkTypes.CHANGE_SET).getTargetEndPointDescriptor(); workItemWorkingCopy.getReferences().add(endpoint, reference); workItemWorkingCopy.save(monitor);
When I change the WorkItemLinkTypes to 'RELATED_CHANGE_MANAGEMENT' instead of 'CHANGE_SET' then the change set gets linked with work item as Related Change request and not as the ChangeSets . Not sure if I am missing anything in the above code to link the change set as 'WorkItemLinkTypes.CHANGE_SET' 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.