It's all about the answers!

Ask a question

How to associate change set with work item using RTC Plain JAVA API ?


Dashrath Kale (1542723) | asked Jan 09 '14, 6:10 a.m.

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



permanent link
Dashrath Kale (1542723) | answered Feb 03 '14, 12:12 a.m.

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


permanent link
Lauren Hayward Schaefer (3.3k11727) | answered Jan 09 '14, 7:02 a.m.
JAZZ DEVELOPER
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

permanent link
Dashrath Kale (1542723) | answered Jan 09 '14, 7:55 a.m.

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


permanent link
Ralph Schoon (63.1k33645) | 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?

permanent link
Dashrath Kale (1542723) | answered Jan 10 '14, 2:15 a.m.

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.


permanent link
Dashrath Kale (1542723) | answered Jan 10 '14, 2:16 a.m.

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


Comments
Ralph Schoon commented Jan 10 '14, 5:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I can unfortunately don't hint another solution. Sorry. I am not sure why you get the null pointer. Please be careful with the link types. They mean different things and link different elements.  RELATED_CHANGE_MANAGEMENT is probably for work item to work item links.

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.