How to delete link associated as related change request to a workitem?
Hi,
I had linked a Related Change Request to my workitem and the link is perfectly visible. But now I want to programmatically delete the link thus created on triggering some event. I am unable to find any programmatic way to delete the link created after linking Related Change Request to a workitem. Can someone please help me with the problem.
Thanks in advance.
I had linked a Related Change Request to my workitem and the link is perfectly visible. But now I want to programmatically delete the link thus created on triggering some event. I am unable to find any programmatic way to delete the link created after linking Related Change Request to a workitem. Can someone please help me with the problem.
Thanks in advance.
One answer
Hi Bhushan,
Please try following method.
public void removeLinks(IWorkItem source, IWorkItem target, IProgressMonitor monitor)
throws TeamRepositoryException {
IWorkItemClient workItemClient = (IWorkItemClient) ((ITeamRepository) source
.getOrigin()).getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager copyManager = workItemClient
.getWorkItemWorkingCopyManager();
URI sourceURI = ItemURI.createWorkItemURI(
workItemClient.getAuditableCommon(), source.getId());
URI targetURI = ItemURI.createWorkItemURI(
workItemClient.getAuditableCommon(), target.getId());
IReference referenceTarget = IReferenceFactory.INSTANCE
.createReferenceFromURI(targetURI);
WorkItemWorkingCopy workingCopySource=copyManager.getWorkingCopy(source);
workingCopySource.getReferences().remove(referenceTarget);
workingCopySource.save(monitor);
}
Kindly acknowledge the result.
Please try following method.
public void removeLinks(IWorkItem source, IWorkItem target, IProgressMonitor monitor)
throws TeamRepositoryException {
IWorkItemClient workItemClient = (IWorkItemClient) ((ITeamRepository) source
.getOrigin()).getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager copyManager = workItemClient
.getWorkItemWorkingCopyManager();
URI sourceURI = ItemURI.createWorkItemURI(
workItemClient.getAuditableCommon(), source.getId());
URI targetURI = ItemURI.createWorkItemURI(
workItemClient.getAuditableCommon(), target.getId());
IReference referenceTarget = IReferenceFactory.INSTANCE
.createReferenceFromURI(targetURI);
WorkItemWorkingCopy workingCopySource=copyManager.getWorkingCopy(source);
workingCopySource.getReferences().remove(referenceTarget);
workingCopySource.save(monitor);
}
Kindly acknowledge the result.
Comments
Hi Ajay,
Thanks for your answer and really appreciate such a quick response. Apologies for asking programmatic way of doing the thing. I was just wondering can we do the same using web based rest client (like that of Mozilla Rest Client) by firing some delete query to workitem for deleting link?
Hi Bhushan and Ajay,
As per my understanding bushan is looking for removing the relatedChangeRequest from the workitem using the OSLC REST Services.
I am also interested to see how can we do the same using the OSLC REST API in RTC.
Thanks,
Rahul