It's all about the answers!

Ask a question

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


0
1
Adam Coulthard (1322116) | asked Jul 02 '12, 12:07 p.m.
edited Jul 02 '12, 9:48 p.m. by Geoffrey Clemm (30.1k33035)
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

Accepted answer


permanent link
SEC Servizi (97123860) | answered Jul 03 '12, 5:38 a.m.
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

Comments
Adam Coulthard commented Jul 16 '12, 3:39 a.m. | edited Mar 31 '15, 11:54 a.m.

 Thanks that worked a treat :-)


Ralph Schoon commented Sep 20 '12, 11:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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!


aastha khatri commented Mar 27 '15, 5:57 a.m. | edited Mar 31 '15, 11:54 a.m.

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


Ralph Schoon commented Mar 27 '15, 6:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Mar 27 '15, 6:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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/


aastha khatri commented Mar 29 '15, 12:25 p.m. | edited Mar 31 '15, 11:54 a.m.

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


Ralph Schoon commented Mar 30 '15, 2:34 a.m. | edited Mar 30 '15, 2:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

 


aastha khatri commented Mar 30 '15, 1:24 p.m. | edited Mar 31 '15, 2:52 a.m.

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