Unable to create a parent link type
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
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
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?
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.
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/