Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How do I retrieve potential duplicates of a work item

Hi,

I would like to be able to retrieve potential duplicates of a work item programmatically, as is done by the context menu "Find Potential Duplicates". I used the following code snippet to do that:

IWorkItemWorkingCopyManager manager = workItemClient.getWorkItemWorkingCopyManager();
manager.connect((IWorkItemHandle) sourceItem.getItemHandle(), IWorkItem.FULL_PROFILE, null);
sourceWorkingCopy = manager.getWorkingCopy((IWorkItemHandle) sourceItem.getItemHandle());

IWorkItemReferences references = sourceWorkingCopy.getReferences();

List<IReference> duplicates = references.getReferences(WorkItemEndPoints.DUPLICATE_WORK_ITEM);

// Check whether 'duplicates' is empty. If so, do:
duplicates = references.getReferences(WorkItemEndPoints.DUPLICATE_OF_WORK_ITEM);

I expected that 'duplicates' wouldn't be empty because when I executed "Find Potential Duplicates" on the source work item via the GUI, it returned some work items that have similar description. However, with the code above, the 'duplicates' list turned out to be empty. So, I suspected that
getReferences(WorkItemEndPoints.DUPLICATE_WORK_ITEM);

only returns the duplicates that are explicitly created as duplicates.

So, what is another way to retrieve potential duplicates? Your help will be appreciated.

Thanks,
Petcharat

0 votes



One answer

Permanent link
Hi,

you can take a look at com.ibm.team.workitem.rcp.ui.QueriesUI.showRelatedWorkItems(IWorkbenchWindow, IWorkItem, boolean) which is used from the "Find potential duplicates" action. It creates an Expression for a duplicate search and sends it to the server for evaluation. Using work item references will - as you already found out - only return explicit duplicates, but not potential ones. To receive potential duplicates, a fulltext query is executed on the server.

Ben
Foundation & Work Item Team

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940

Question asked: Jul 20 '08, 2:44 p.m.

Question was seen: 7,278 times

Last updated: Jul 20 '08, 2:44 p.m.

Confirmation Cancel Confirm