Creating CLM links from a workitem save participant
Accepted answer
Simon, a bit late.....
I stumbled across this some time ago. This should be working similar in a participant. The code below is client code, I highlighted the important part. You call it with a URI to the remote object. See https://jazz.net/forum/questions/81826/how-an-operation-participant-works?page=1&focusedAnswerId=81979#81979 on how to save a work item in a participant.
private static class LinkURIOperation extends WorkItemOperation {
private URI fURI;
private IEndPointDescriptor fEndpointDescriptor;
public LinkURIOperation( IEndPointDescriptor endpointDescriptor,URI uri) {
super("Linking URL", IWorkItem.FULL_PROFILE);
fURI = uri;
fEndpointDescriptor=endpointDescriptor;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IReference reference;
reference = IReferenceFactory.INSTANCE.createReferenceFromURI(fURI);
workingCopy.getReferences().add(fEndpointDescriptor,reference);
}
}
To call it
URI uri=new URI("https://clm.example.com:9448/qm/oslc_qm/contexts/_Lm2UIACBEeGZqMjM3RLKTw/resources/com.ibm.rqm.planning.VersionedTestCase/_dJzNgQCBEeGZqMjM3RLKTw");
IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TESTED_BY_TEST_CASE).getTargetEndPointDescriptor();
LinkURIOperation linkOp = new LinkURIOperation(endpoint,uri);
linkOp.run(workItem, monitor);
// IEndPointDescriptor endpoint1 = //ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTS_EXECUTION_RESULT).getTargetEndPointDescriptor();
// IEndPointDescriptor endpoint3 = //ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTED_BY_DEFECT).getTargetEndPointDescriptor();
I stumbled across this some time ago. This should be working similar in a participant. The code below is client code, I highlighted the important part. You call it with a URI to the remote object. See https://jazz.net/forum/questions/81826/how-an-operation-participant-works?page=1&focusedAnswerId=81979#81979 on how to save a work item in a participant.
private static class LinkURIOperation extends WorkItemOperation {
private URI fURI;
private IEndPointDescriptor fEndpointDescriptor;
public LinkURIOperation( IEndPointDescriptor endpointDescriptor,URI uri) {
super("Linking URL", IWorkItem.FULL_PROFILE);
fURI = uri;
fEndpointDescriptor=endpointDescriptor;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IReference reference;
reference = IReferenceFactory.INSTANCE.createReferenceFromURI(fURI);
workingCopy.getReferences().add(fEndpointDescriptor,reference);
}
}
To call it
URI uri=new URI("https://clm.example.com:9448/qm/oslc_qm/contexts/_Lm2UIACBEeGZqMjM3RLKTw/resources/com.ibm.rqm.planning.VersionedTestCase/_dJzNgQCBEeGZqMjM3RLKTw");
IEndPointDescriptor endpoint = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.TESTED_BY_TEST_CASE).getTargetEndPointDescriptor();
LinkURIOperation linkOp = new LinkURIOperation(endpoint,uri);
linkOp.run(workItem, monitor);
// IEndPointDescriptor endpoint1 = //ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTS_EXECUTION_RESULT).getTargetEndPointDescriptor();
// IEndPointDescriptor endpoint3 = //ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTED_BY_DEFECT).getTargetEndPointDescriptor();