Creating Tracks links using the Java API
ILink newLink = rtcDataAccessProvider.getLinkManager().createLink(this.linkTypeToCreate, srcItemRef, tgItemRef);
rtcDataAccessProvider.getLinkManager().saveLink(newLink, monitor);
2 answers
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
I will publish the whole code on my blog in the next few days.
I saw already your code using the WorkItemOperation. But that seems to be completely different than using the LinkManager interface.
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.
OK. Fine.
I will file a PMR against it and keep you posted after I get feedback.
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.
Comments
Marko Tomljenovic
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.
Geoffrey Clemm
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 07 '15, 5:36 p.m.Does this happen only for the Tracks links you create through the API, or also for those created through a GUI ?
Marko Tomljenovic
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.