Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

How do I create an included-in-build link from Java API ?

Hello,

We have some java code that manages our building and testing automatically plus the movement of code.  At the moment when code is moved to a stream level a comment is placed into the workitem.  I would like to change this to create a link of "included in build".  I see there is some ant tasks perform this kind of operation but because we are performing the moves via the java code its not that simple to use the ant tasks.

Is it possible to create an "included in build" link via the Java API? and does anyone have some sample code that might do this?

Thanks

Adam

1

0 votes


Accepted answer

Permanent link
Yes, you can.
We use the code below to add a reference by server-side:
IBuildResult buildResult = ...
IWorkItem wi = ...
IReferenceFactory refFactory = IReferenceFactory.INSTANCE;
IReference source = refFactory.createReferenceToItem(buildResult);
IReference target = refFactory.createReferenceToItem(wi);
ILinkServiceLibrary linkServiceLibrary = ... 
ILink link = linkServiceLibrary.createLink(BuildLinkTypes.INCLUDED_WORK_ITEMS, source, target);
linkServiceLibrary.saveLink(link);
But the client-side is similar...
Cheers.
Ralph Schoon selected this answer as the correct answer

1 vote

Comments

 Thanks that worked a treat :-)

Hi SEC, I used your example code to create some more consistent documentation here: http://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/ . Thanks so much for sharing!

Hi Sec,

I have a doubt here . At server side I need to create a link in defect WI of project Area 1 which will link it to story WI of project Area2. which approach is better? The above one you mentioned or the below one ? What difference these two approach have.
        IWorkItemReferences references = workItemServer
                .resolveWorkItemReferences(defect, null);
        IReference wkRef = WorkItemLinkTypes.createWorkItemReference(storyWI);
IEndPointDescriptor storyEndpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TRACKS_WORK_ITEM).getTargetEndPointDescriptor();
references.add(storyEndpoint, wkRef);

Also all the link type in RTC are C/ALM type? I am very confused with the term CALM link ,can you please provide some information on the same.

Thanks & Regards,
Aastha

If you want to create tracks relationships, see https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/

This implements it. It does this in the client API, but the server API looks the same, pretty much. It is important to get the order right and it is important to create the endpoint object right. You can not just take the URL that local WI-WI links have, but xou have to construct the URI in a different way.

I created some commandline tool, that can do this kind of linking as well. See https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/

Hi Ralph,

Thanks for your reply. I went through some of your blogs about creation of CALM link ,which helped me in gaining knowledge about CALM links.
I have one question -- I noticed while creating CALM we use the URI. Is it mandatory? What is the reason behind creating CALM from the URIs?
Also my requirement is to create contributes to /track CALM between work items of two Project Area. If at all creating CALM link type via URI is not mandatory ,which approach should I follow in my case URI based or non-URI based?

Thanks & Regards,
Aastha

It is not a good practice to post additional questions to questions with accepted answers.

Please create your own question to ask about new topics. Although I could create a question from this one, I'd rather have the users to do so.

In general links use Locations to store information. There are different ways to create these Locations, resulting in different URI's. You need to use the correct way to create the locations to get the correct URI format to make the link work.

I find all that out, by looking at the data that is used/created in the tool and by trying to find out how to create that data.

Look into the source of https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/ to understand the different ways to create locations. It covers Tracks/Contributes To.

RTC is based on URI's and REST, so you will end up with URI's. This is also needed to be able to reference objects from any application external to RTC.

 

Hi Ralph,

I am sorry for the inconvenience caused. I will follow this practise from now onwards.
Thanks for the information. It is very helpful!!

Thanks & Regards,
Aastha

showing 5 of 8 show 3 more comments

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

Question asked: Jul 02 '12, 12:07 p.m.

Question was seen: 5,478 times

Last updated: Mar 31 '15, 11:54 a.m.

Confirmation Cancel Confirm