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

Serverside create link from a WorkItem to a Changeset

 Hi

My task is to create a link between a Workitem and a changeset in a Participant on delivery. I have access to both the workitem and the changeset, and I am able of establishling a link, but the link is not registered as link to a Changeset.

My code looks like this:

IWorkItemServer workItemservice = this.getService(IWorkItemServer.class); 
IWorkItem workItemWC = (IWorkItem) workItem.getWorkingCopy();
IWorkItemReferences references = workItemservice.resolveWorkItemReferences(workItemWC, monitor);
IReference reference= IReferenceFactory.INSTANCE.createReferenceToItem(changeSet.getWorkingCopy().getItemHandle());

references. add(WorkItemEndPoints.RELATED_ARTIFACT, reference);
workItemservice.saveWorkItem2(workItemWC, references, null);

I do get a reference created, but as is actually says on the WorkItemEndPoints.RELATED_ARTIFACT, only as a related artifact. How do I make i proper reference to a Changeset?

Thx in advance

/Erling

0 votes


Accepted answer

Permanent link
 HI

I think I've solved it myself. This code does the trick:

ILinkService linkService = getService(ILinkService.class);
ILinkServiceLibrary ls = (ILinkServiceLibrary) linkService.getServiceLibrary(ILinkServiceLibrary.class);
...
IReference changeReference= IReferenceFactory.INSTANCE.createReferenceToItem(changeSet.getItemHandle());
IReference workItemReference= IReferenceFactory.INSTANCE.createReferenceToItem(workItemWC.getItemHandle());
ILink il = ls.createLink(WorkItemLinkTypes.CHANGE_SET, changeReference, workItemReference);
ls.saveLink(il);

Maybe somebody else but me can use it.

/Erling
Ralph Schoon selected this answer as the correct answer

2 votes

Comments

Thanks for sharing Erling.

What did you include in your plug-in.xml file?  I keep getting this error when I try to run my participant.
CRJAZ1115I The "com.ibm.team.links.common.factory.IReferenceFactory" service was not registered.  I have the following pre-requisites:
<requiredService interface="com.ibm.team.links.common.service.ILinkService" />
                    <requiredService interface="com.ibm.team.links.service.ILinkServiceLibrary" />
                    <requiredService interface="com.ibm.team.links.common.factory.IReferenceFactory" />

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
× 7,496

Question asked: Jul 20 '12, 6:54 a.m.

Question was seen: 6,363 times

Last updated: Sep 24 '14, 10:02 a.m.

Confirmation Cancel Confirm