Linking RTC files to RQM
String gcURL, String[] options,
IRepositoryProgressMonitorHandle monitor)
3 answers
The API mentioned above is internal API. Please use public API - Reportable Rest API or OSLC API. For more details check https://jazz.net/wiki/bin/view/Main/RqmApi
Creating links programmatically is possible but it is a bit complicated. Also, one of the DTOs that you need to use is in an internal package. I don't know if this was intentional or a mistake on the part of the developers who implemented the feature.
The first thing you will need to do is pick a specific link type. The out-of-the-box link types for SCM to RQM links are defined in the plugin.xml of the com.ibm.team.filesystem.common bundle.
"com.ibm.team.scm.service.file.implements.testscript.link"
"com.ibm.team.scm.service.file.references.testcase.link"
"com.ibm.team.scm.service.file.references.testcase.result.link"
"com.ibm.team.scm.service.file.references.testsuite.result.link"
It sounds like you want the References Test Case type
String linkTypeId = "com.ibm.team.scm.service.file.references.testcase.link";
Next, you will need a handle to the component that contains the file
IComponentHandle component
Along with either a workspace or a stream handle.
IWorkspaceHandle workspaceHandle
IWorkspaceHandle streamHandle
You will also need to use the SCM service
IScmService scm
The below code shows how to create the link in a workspace, which is the usual SCM flow
// Create a change set on the workspace
IChangeSetHandle cs = (IChangeSetHandle) scm.createChangeSet(workspaceHandle, component, "", false, null, null, null).getItem();
// Create the link description
ILinkType linkType = ILinkTypeRegistry.INSTANCE.getLinkType(linkTypeId);
ExternalLinkEntry entry = ScmDtoFactory.eINSTANCE.createExternalLinkEntry();
entry.setType(linkType.toLinkServiceId());
entry.setTypeInstanceId(linkType.getInstanceId());
final String resourceUri = "http://www.example.com/qm/" + ?;
entry.setToLink(resourceUri);
// Create a commit parameter
ICommitParameter parm = ICommitParameter.FACTORY.create(cs);
parm.addItemToSave(item, links);
// Commit the link addition to the change set and close the change set
scm.batchCommit(workspaceHandle, new ICommitParameter[] {parm}, IScmService.DELTA_PER_INVOCATION, null, null);
scm.closeChangeSets(workspaceHandle, new IChangeSetHandle[] {cs}, true, null, null, null);
// Deliver the change set to the stream
scm.deliverCombined(null, null, streamHandle, new IBaselineHandle[0], new IChangeSetHandle[]{cs}, null, null, null, null);
As an alternative, you could create the change set directly on the stream using the following API.
IChangeSetHandle cs = scm.createChangeSetForStream(streamHandle, component, "comment", commitParameter, null, null);
Hope that helps,
Michael
Comments
parm.addItemToSave(item, links);
Hello Michael,
Comments
Michael Valenta
FORUM MODERATOR / JAZZ DEVELOPER Nov 30 '20, 9:00 a.m.Michael
Jitesh Saha
Nov 30 '20, 11:28 p.m.