It's all about the answers!

Ask a question

Creating Tracks links using the Java API


Marko Tomljenovic (3163171) | asked Feb 07 '15, 5:13 p.m.
 Hi,
I am using the following code to create Tracks links between workitems of the same project area and repository.

        ILink newLink = rtcDataAccessProvider.getLinkManager().createLink(this.linkTypeToCreate, srcItemRef, tgItemRef);
        rtcDataAccessProvider.getLinkManager().saveLink(newLink, monitor);
If I set linkTypeToCreate to WorkItemLinkTypes.CONTRIBUTES_TO_WORK_ITEM  the link is created but shown under another (second) "Tracks" element in the Eclipse workm item editor.
Therefore I am now using WorkItemLinkTypes.TRACKS_WORK_ITEM.

Am I doing sth wrong or is this an undocumented feature of the RTC API?

Comments
Marko Tomljenovic commented Feb 07 '15, 5:22 p.m.

 And I have another problem with my approach. In the Web client I cannot delete the created tracks links. I can remove them from the work item and then save. But after saving the work item is finished they again appear in the work item editor.


I can only delete the links if I navigate to the tracked item and then delete the work item from there. Could you please try to reproduce this behaviour.

PS I am using RTC 5.0.1.


Geoffrey Clemm commented Feb 07 '15, 5:36 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Does this happen only for the Tracks links you create through the API, or also for those created through a GUI  ?


Marko Tomljenovic commented Feb 08 '15, 3:26 p.m.

If I create a tracks link via the Web Client I can properly delete it from the Web as well.

If I create the link from the other side meaning a contributes link it can also be deleted.


2 answers



permanent link
Ralph Schoon (57.1k23642) | answered Feb 09 '15, 2:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 09 '15, 2:46 a.m.
Link creation is a can of worms. The problem is understanding the correct way to create the ends. Also see: https://rsjazz.wordpress.com/2013/11/06/creating-clm-links-with-back-link/

This code works for me - note how the location is created:

Location location = Location.namedLocation(workItem,
				((ITeamRepository) workItem.getOrigin())
				.publicUriRoot());

found.add(new InternalReference(endpoint,
				IReferenceFactory.INSTANCE
				.createReferenceFromURI(location
				.toAbsoluteUri())));


If you fail to create the Location type it needs, you have trouble deleting the references. Also note the additional save parameter to create back links.
Note Internal location is just a class to hold the reference and the endpoint.

Comments
Ralph Schoon commented Feb 09 '15, 2:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I will publish the whole code on my blog in the next few days.


Marko Tomljenovic commented Feb 09 '15, 3:32 a.m.

 I saw already your code using the WorkItemOperation. But that seems to be completely different than using the LinkManager interface.


I am looking forward your code.

But why can I delete the link in the Eclipse client but not in the WebClient? For me this is a bug either in Eclipse or Web Client.


Ralph Schoon commented Feb 09 '15, 3:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The ILinkManager is a lower interface as far as I know. I am just using the methods I found in the SDK and that were working for me.
The Web  UI is different from the Eclipse UI for obvious reasons and so behavior can slightly differ. In 5.x new code was introduced to be able to delete links that are incorrectly created. I have still been able to created links wrong (typically the location) with problems recovering from it.

Feel free to file a defect, but be aware that development could retreat to the standpoint that, if you create wrong links programmatically, tidying this up is not supported.


Marko Tomljenovic commented Feb 09 '15, 3:53 a.m.

OK. Fine.

Then I will wait for your code snippet that resolves my problem.

But from what the ILinkManager description says this interface is all you need to create, save and delete links. I guess it was meant to ease the link handling.

ILinkManager interface description.
"Client library for use by Jazz clients to manage links in a particular team
  repository. See {@link ILink} for details of link terminology and semantics,
  and link type registration. This manager provides methods for creating,
 * saving and deleting links, and a variety of methods for finding links."


Marko Tomljenovic commented Feb 09 '15, 4:38 a.m.

 I will file a PMR against it and keep you posted after I get feedback.


Ralph Schoon commented Feb 09 '15, 4:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Marko,

some of the code dates back to before 2006, where there even where no CLM links like Tracks - which also goes across repositories. I have not all the facts, but my experience so far is, you can use the API and it seems to create stuff, but if you chose the wrong way to create the location for the type of link you want, you mess up the data.

You might be able to use the LinkManager, provided you provide the locations in the correct way.

showing 5 of 6 show 1 more comments

permanent link
Marko Tomljenovic (3163171) | answered Feb 09 '15, 6:44 a.m.
I changed my implementation using your proposed LinkTrackingWorkItemOperation class.
It now works as expected.

Thank you for your support.

Your answer


Register or to post your answer.