It's all about the answers!

Ask a question

Unable to create a parent link type


ast java (4512049) | asked Jun 09 '15, 4:08 a.m.
edited Jun 09 '15, 4:12 a.m.
Hi,
LinkWorkItemOperation  is my custom private class.
I have below code,
 LinkWorkItemOperation operation =
          new LinkWorkItemOperation(ILinkTypeRegistry.INSTANCE.getLinkType(linkType).getTargetEndPointDescriptor(),
              targetWorkItem);
      operation.run(sourceWorkItem, monitor);

In the above code I can able to create other link types ex: tracks, contributes...
When I try to create a parent link I am getting the below exception.

com.ibm.team.repository.common.TeamRepositoryException: Change would introduce non-item reference for item end point
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.saveAddedLinks(WorkItemRepositoryService.java:1008)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.saveLinks(WorkItemRepositoryService.java:951)
    at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.plainSave(WorkItemRepositoryService.java:656)
    at com.ibm.team.workitem.service.internal.WorkItemProcessAreaOperation.run(WorkItemProcessAreaOperation.java:45)
........

Am I doing anything wrong here? Please help me on this.

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Jun 09 '15, 4:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jun 09 '15, 4:36 a.m.
The error message says it all:

com.ibm.team.repository.common.TeamRepositoryException: Change would introduce non-item reference for item end point

If you create links, there are different ways how to create the end point. One way is an item reference e.g. based on a work item. Another is based on a location - these are used for CLM links e.g. tracks. You apparently create one of the end points not as item reference

If you pass an URI to the code, look at the different URI's you get in the web UI for different link ends. There are different forms for the different link types..

Comments
ast java commented Jun 09 '15, 5:09 a.m.

Hi Schoon,

Thanks for your reply. I have changed my code to create the IReference according to the linktype endpoint reference.
As like below code,

 if (!this.targetEndPointDescriptor.isItemReference()) {
       "create reference from URI"           
      }
      else {
      ".createReferenceToItem"
      }

It's working fine. But is it the right approach?


Ralph Schoon commented Jun 09 '15, 5:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

When I developed the Work Item Command Line, I ran into the issue of the different types and you simply have to find out which URI/endpoint type you need.

If you pass an URI to the code, look at the different URI's you get in the web UI for different link ends. There are different forms for the different link types.

I has to basically figure what to use where. The best test s to create a link and to try to follow it from both ends and to try to delete it. Also, does it display like one such a link created by the tool.

If not, check directions and URI formats until you get it right. Sorry, I have no better answer. I am not aware of documentation on this other than looking deeply into the SDK.


Ralph Schoon commented Jun 09 '15, 5:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You might want to check the code in
https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/
Some data is also here, e.g. how to use Locations to create URI's
https://rsjazz.wordpress.com/2013/11/06/creating-clm-links-with-back-link/

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.