How to create a custom link where the source is a STRING (OSLC URL) and the target is a WORKITEM.
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
Accepted answer
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.
Comments
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.
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.
Great! Have fun!
3 other answers
Comments
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.
Comments
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.
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.
Ralph,
Do you know how to deploy them with the Plain Java Client Libraries?
Thanks
No, I have not tried that - yet.
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.
1 vote
Hi Jamie,
thanks for sharing!
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.
Comments
Vijayakumar Balasubramaniyan
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
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
Apr 17 '13, 4:43 p.m.where you able to solve this issue?