Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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 ?

0 votes



6 answers

Permanent link

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

1 vote


Permanent link
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

0 votes


Permanent link

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

0 votes


Permanent link
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?

0 votes


Permanent link

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.

0 votes


Permanent link

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.

0 votes

Comments

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jan 09 '14, 6:10 a.m.

Question was seen: 7,829 times

Last updated: Feb 03 '14, 12:12 a.m.

Confirmation Cancel Confirm