Server Side API : saveParameter.getNewReferences() is not able to identify Contributes To (trackedBy) link
![]() Hello All,
|
Accepted answer
3 other answers
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Feb 27 '17, 11:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER This post explains the link API for these kinds of links: https://rsjazz.wordpress.com/2012/10/20/following-calm-links-using-the-java-client-or-server-api/
Here the other link API related posts: https://rsjazz.wordpress.com/?s=link+api
I would suggest to use a small RTC Client library tool to develop the API to detect the links. Run through all links the work item has. Then check what endpoints which has.
The Client link API and the server link API should be pretty much the same. In the client use the IWorkItemCommon instead of IWorkItemClient. Once you understand how the links work, take it into the server extension.
|
![]() Shwetha, this is code with which I retrieved the links types:
Collection linkTypesCollection = ILinkTypeRegistry.INSTANCE.allEntries(); Iterator linkTypesCollectionIterator = linkTypesCollection.iterator(); while (linkTypesCollectionIterator.hasNext()) { ILinkType currentLinkType = (ILinkType) linkTypesCollectionIterator.next(); String linkTypeID = currentLinkType.getLinkTypeId(); IEndPointDescriptor source = currentLinkType.getSourceEndPointDescriptor(); IEndPointDescriptor target = currentLinkType.getTargetEndPointDescriptor(); System.out.println("LINK TYPE ID: " + linkTypeID); System.out.println("SOURCE: " + source.getDisplayName() + " (" + source.getId() + ")"); if (source.isItemReference()) { IItemType referencedItemType = source.getReferencedItemType(); String referencedItemTypeName = referencedItemType.getName(); System.out.println("SOURCE ITEM TYPE: " + referencedItemTypeName + " (" + referencedItemType.toString() + ")"); } System.out.println("TARGET: " + target.getDisplayName() + " (" + target.getId() + ")"); if (target.isItemReference()) { IItemType referencedItemType = target.getReferencedItemType(); String referencedItemTypeName = referencedItemType.getName(); System.out.println("TARGET ITEM TYPE: " + referencedItemTypeName + " (" + referencedItemType.toString() + ")"); } } |
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Feb 28 '17, 3:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 28 '17, 3:42 a.m. The Link types and endpoints are defined as follows:
1. For Work Item link types (wi to wi only within a repository): com.ibm.team.workitem.common.model.WorkItemEndPoints
Example WorkItemEndPoints.PARENT_WORK_ITEM
This does not contain the endpoints for
2. For CLM Link types (cross repository, cross application): com.ibm.team.workitem.common.model.WorkItemLinkTypes
e.g.
ILinkTypeRegistry.INSTANCE
.getLinkType(WorkItemLinkTypes.TRACKS_CHANGES)
.getTargetEndPointDescriptor()
com.ibm.team.workitem.common.model.WorkItemLinkTypes contains also all the other endpoint definitions, so you can create all link points using the pattern
LinkTypeRegistry.INSTANCE
.getLinkType(WorkItemLinkTypes.MY_LINK_TYPE)
.getTargetEndPointDescriptor()
|
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.
Comments
"Contributes To" is basically the other direction of "Tracks" so I would assume both would work. I think I tried it in direction tracks and it worked for me back then.
Thanks for the reply Ralph.
But the following code,is not able to identify the workitems that are linked using "Contributes to".
IEndPointDescriptor linkDescriptor = WorkItemEndPoints.TRACKS_ITEMS;
IWorkItemReferences ref = saveParameter.getNewReferences();
List<IReference> listReferences =ref.getReferences(linkDescriptor);
though i have linked two workitems using "contributes to" link, the
listReferences size is zero.
Could you please suggest me, if there are any other APIs, for fetching the list of workitems that works for all the link types.