It's all about the answers!

Ask a question

How to create a custom link where the source is a STRING (OSLC URL) and the target is a WORKITEM.


Vijayakumar Balasubramaniyan (2845) | asked Sep 18 '12, 3:36 a.m.
edited Sep 25 '12, 8:48 a.m. by Ralph Schoon (63.1k33646)
I have a question related to creating a custom link type, where the source is a OSLC url (string) and the target is a work-item. Later I should be able to fetch those links for a given work-item using plain java client.

The plugin.xml file is:
<code>
<?xml version="1.0" encoding="UTF-8" ?>
<?eclipse version="3.4"?>
<plugin>
    <extension point="com.ibm.team.repository.common.linkTypes">
        <linkType constrained="true" id="com.test.test_link_type">
            < source >
                <endpoint displayName="Test Link" icon="images/test_link.gif"/>
            </ source >
            <target>
                <endpoint displayName="Work Item">
                    <itemReferenceType itemTypeName="WorkItem" packageURI="com.ibm.team.workitem"/>
                </endpoint>
            </target>
        </linkType>
    </extension>
</plugin>
</code>

Can anyone tell me whether the XML file is correct and is it possible to create a link where one of SOURCE/TARGET is not a work-item.

I am successfully able to creat a link using the following code and also I am able to see the link on the work-item from the eclipse client.

<code>
    ILinkManager linkManager = (ILinkManager) repository.getClientLibrary(ILinkManager.class);

    URI testUri = new URI("1234");
    ILink newLink = linkManager.createLink(
        TEST_LINK,
        IReferenceFactory.INSTANCE.createReferenceFromURI(testUri, testDisplayName),
        linkManager.referenceFactory().createReferenceToItem(workItem.getItemHandle()));

    linkManager.saveLink(link, new SubProgressMonitor(monitor, 50));
</code>

But I am not able to query for the links for the given work-item. Below is the code that I am trying to use to fetch the links for the given work-item.
   
<code>
    IReferenceFactory referenceFactory = linkManager.referenceFactory();
    IReference workItemReference = referenceFactory.createReferenceToItem(workItemHandle);

    ILinkQueryPage linkQueryPage = linkManager.findLinks(TEST_LINK, workItemReference, monitor);

    for (ILink link : linkQueryPage.getAllLinksFromHereOn())
    {
        System.out.println("Source: " + link.getSourceRef());
    }
</code>

Even-though the links are created successfully for the work-item, none of those links are returned while fetching the links. It is always empty. Please correct me if there are any issues with the above mentioned code.

Thanks,
Vijay

Comments
Vijayakumar Balasubramaniyan commented Sep 25 '12, 3:25 a.m.

Is there anyone who can answer the question or give some hints to resolve the problem.

Thanks in advance, Vijay


Stefania Axo commented Apr 17 '13, 4:43 p.m.

hi
I have the same problem
%%%%%%%%%%%%%%%%%%%%%%%%%%%
   for (ILink link : linkQueryPage.getAllLinksFromHereOn())
    {
        System.out.println("Source: " + link.getSourceRef());
    }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I am not able to see the links from the code when i run
linkQueryPage.getAllLinksFromHereOn())

I debugged the RTC code and
linkQueryPage in its content has the array with my linked work items.
It is
getAllLinksFromHereOn() that wipes them out.
It checked if the link is 'register' and i don't know what that means.
I opened today another forum just to ask that question
https://jazz.net/forum/questions/110079/rtc-how-to-register-my-custom-link-type


Stefania Axo commented Apr 17 '13, 4:43 p.m.

where you able to solve this issue?

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Sep 25 '12, 8:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Vijay,

I have not had time to play with custom link types. However, there are 13 posts around this, that I could find (using advanced search), and I would hope there is one that helps you.

https://jazz.net/search_results.jsp?q=point%3D%22com.ibm.team.repository.common.linkTypes#page=0&type=type%3DDocument-ForumThread&q=com.ibm.team.repository.common.linkTypes

One of the answers is that you need to deploy on the server and on the client (if you want to see the link type in the client) and I remember there were example XML's. I would assume something with your deployment is wrong.
Vijayakumar Balasubramaniyan selected this answer as the correct answer

Comments
Ralph Schoon commented Sep 25 '12, 8:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

And you can also search the SDK if you installed it as described in the extensions workshop to search for plugin XML of extensions that implement extension point="com.ibm.team.repository.common.linkTypes" to have some examples to compare.


Vijayakumar Balasubramaniyan commented Sep 25 '12, 8:41 a.m.

Thanks Ralph.

The jar file which is part of the plugin (custom type plugin) was not added to the client-side. After including the jar file to the client project I am able to see the custom links. Thanks for your help.


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

Great! Have fun!

3 other answers



permanent link
Ralph Schoon (63.1k33646) | answered Sep 25 '12, 3:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
To create and use these kinds of links see: https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/

Comments
Vijayakumar Balasubramaniyan commented Sep 25 '12, 8:13 a.m. | edited Sep 25 '12, 8:22 a.m.

Thanks for the link Ralph.

I have a question. Please see the plugin.xml file content in the question. The source does not have ItemReferenceType tag.

I tried to list all the link types using the following call "ILinkTypeRegistry.INSTANCE.allEntries()", it never returns the link type that I have created.

For your information, I am able to create and see the links from both the eclipse and web clients. Can you please tell me why I am not able to see the custom link-type when I query for all the link-types.


permanent link
Ralph Schoon (63.1k33646) | answered Sep 25 '12, 8:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Sep 25 '12, 8:48 a.m.
From looking at other specimen in the SDK, your endpoints look suspicious. There is no endpoint ID defined. this is one of the specifications from the SDK (for changesets which is an URI like the one you want).



Comments
Jamie Berry commented Oct 04 '12, 4:52 p.m.

I am trying to access custom linktypes from Java API as well.  My endpoints have ids as well as my linktype itself.  I can see the linktypes via the Eclipse Client, the Web UI and Visual Studio but not from a simple Java application I am trying to write.  Does the extension JAR file used for the linktypes need to be available to my Java development classpath?  Where does the ILinkTypeRegistry get its list of known linktypes? 

Thanks,

Jamie.


Ralph Schoon commented Oct 05 '12, 1:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Jamie, the custom link types need to be deployed as an extension to be visible. I assume you would have to package your custom client extension with the Plain Java Client Libraries somehow to make them visible.


Jamie Berry commented Oct 08 '12, 12:31 p.m.

Ralph,

  Do you know how to deploy them with the Plain Java Client Libraries? 

Thanks


Ralph Schoon commented Oct 08 '12, 12:51 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No, I have not tried that - yet.


1
Jamie Berry commented Oct 15 '12, 5:58 p.m.

My co-worker helped me look at the Java API project and suggested that I add the .jar file for my extension to the directory with the Plain Java Client JAR files and then add the .jar file to my Java project build path.  Once I did that, I now have access to my custom linktypes from my Java code.  I get some warnings regarding Invalid icon URLs when it tries loading the linktype in com.ibm.team.links.common.internal.registry.LinkTypeRegistry$Impl createIconURL .  Other than the warning, things seem to be working just fine.


Ralph Schoon commented Oct 16 '12, 2:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Jamie,

thanks for sharing!

showing 5 of 6 show 1 more comments

permanent link
praveen patidar (8613344) | answered Nov 19 '12, 8:11 p.m.
Hello,

Regarding to this solution, I am getting the link in the Attribute Link that I can enable, however I am not able to get the Link pointer when I am trying to add this kind of link from New Task, Link tab button add. It is having some standard links only (e.g. Parent , Child, related blockers etc.). Can you please help me how to see this link type in the UI so that user can add this from the UI. I am confident I can do this via parametrically.

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.