How can we get the "DuplicateOf" link programmatically (java APIs)?
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
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
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.