It's all about the answers!

Ask a question

Server Side API : saveParameter.getNewReferences() is not able to identify Contributes To (trackedBy) link


1
1
Shwetha G (60331) | asked Feb 23 '17, 6:07 a.m.

Hello All,

We are developing a server side plugin, which checks for the linked type and its workitems.

we are able to get all the link types and its linked workitems, but not "Contributes To" link.

following is the code :
IWorkItemReferences ref = saveParameter.getNewReferences();
                        List<IReference> listReferences = ref.getReferences(linkDescriptor);

Here the listReference, size is zero, though we have added the workitem using "Contributes To" link.

Is there any issue with the cross project and the link type "Contribute to" link ?

but, with the same cross project, the code is working for tracks link :(

please assist me on this.

Regards,
Shwetha


Comments
Ralph Schoon commented Feb 23 '17, 7:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

"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. 



Shwetha G commented Feb 27 '17, 3:36 a.m.

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.

Accepted answer


permanent link
Luca Martinucci (1.0k397112) | answered Feb 27 '17, 11:32 a.m.

Shwetha,
I would try these code snippets to retrieve source and target endpoints:

IEndPointDescriptor tracks = ILinkTypeRegistry.INSTANCE.getLinkType("com.ibm.team.workitem.linktype.trackedworkitem").getSourceEndPointDescriptor();
IEndPointDescriptor contributesTo = ILinkTypeRegistry.INSTANCE.getLinkType("com.ibm.team.workitem.linktype.trackedworkitem").getTargetEndPointDescriptor();

Shwetha G selected this answer as the correct answer

Comments
Shwetha G commented Feb 27 '17, 11:48 p.m.

Thanks a lot Luca....This worked for me.


Shwetha G commented Feb 28 '17, 1:10 a.m.

Hello Luca,

I would like to know how this mapping is happening : 
 For tracks com.ibm.team.workitem.linktype.trackedworkitem").getSourceEndPointDescriptor();

For Contributes to :com.ibm.team.workitem.linktype.trackedworkitem").getTargetEndPointDescriptor();

Here com.ibm.team.workitem.linktype.trackedworkitem is for Contributes to.

How you decide as which is source and target ?

I had applied the similar way using com.ibm.team.workitem.linktype.tracksworkitem. :

Tracks : com.ibm.team.workitem.linktype.tracksworkitem.getSourceEndPointDescriptor();
Contributes To : com.ibm.team.workitem.linktype.tracksworkitem.getTargetEndPointDescriptor();

The above didnt work for me.

Please help me understand this.




1
Luca Martinucci commented Feb 28 '17, 3:24 a.m.

Shwetha,
using the Java SDK (see my other answer) I retrieved the list of link types and their enpoints.
So, I found:

LINK TYPE ID: com.ibm.team.workitem.linktype.trackedworkitem
SOURCE: Tracks (tracks)
SOURCE ITEM TYPE: WorkItem (com.ibm.team.repository.common.model.impl.ItemTypeImpl@1ae0fbd5 (namespaceURI: com.ibm.team.workitem, name: WorkItem, abstract: false))
TARGET: Contributes To (trackedBy)

LINK TYPE ID: com.ibm.team.workitem.linktype.tracksworkitem
SOURCE: Contributes To (trackedBy)
SOURCE ITEM TYPE: WorkItem (com.ibm.team.repository.common.model.impl.ItemTypeImpl@1ae0fbd5 (namespaceURI: com.ibm.team.workitem, name: WorkItem, abstract: false))
TARGET: Tracks (tracks)

It seems that com.ibm.team.workitem.linktype.tracksworkitem  and com.ibm.team.workitem.linktype.trackedworkitem are complementary.
If you start from com.ibm.team.workitem.linktype.tracksworkitem, "Tracks" is the target, "Contributes To" is the source.

3 other answers



permanent link
Ralph Schoon (63.5k33646) | 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.



permanent link
Luca Martinucci (1.0k397112) | answered Feb 28 '17, 3:25 a.m.

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() + ")");
    }
}


permanent link
Ralph Schoon (63.5k33646) | 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


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.