It's all about the answers!

Ask a question

How can we get the "DuplicateOf" link programmatically (java APIs)?


Susan Hanson (1.6k2201194) | asked May 07 '13, 10:57 a.m.
We have a need to be able to programmatically determine the work item that is in the "DuplicateOf" link using plain java APIs.  So if work item 3 is returned as a "DuplicateOf" work item 2, when we are reading the attributes of work item 3, we need to be able to get down to the "work item 2" part.

Thanks
Susan

One answer



permanent link
Markus Nosse (15112828) | answered May 07 '13, 11:05 a.m.
Most of the API should be available in these classes and/or interfaces:

com.ibm.team.workitem.common.model.IWorkItemReferences
com.ibm.team.workitem.common.model.WorkItemEndPoints
com.ibm.team.workitem.common.model.WorkItemLinkTypes
com.ibm.team.links.common.IReference
com.ibm.team.links.common.IItemReference
and
com.ibm.team.workitem.common.IWorkItemCommon

Use IWorkItemCommon.resolveReferences to get the references of a work item. The result will be an instance of IWorkItemReferences. Then you can use getReferences(IEndPointDescriptor) to get the links of a certain type, in your case that would be WorkItemEndPoints.DUPLICATE_OF_WORK_ITEM.

Eventually, you have a list containing IReference instances, which you can cast down to IItemReference. This interface provides access to the handle of the referenced item. To get its data, use IRepositoryItemService or similar to fetch it from the repository.

Regards
Markus

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.