RM API - create implemented By link
I want to link an dng-artifact to a work item of ewm.
I have found following question: https://jazz.net/forum/questions/271787/rm-api-create-validate-by-link-using-rmdatacreatelink
Based on this I tried to create a new artifact ref for the work item:
let targetLink="https://example/ccm/oslc/workitems/12345"
targetLink= new RM.ArtifactRef(targetLink)
And then tried to create the link.
RM.Data.createLink(artRefsList[0][0], RM.Constants.IMPLEMENTED_BY, targetLink, function(cb){
console.log (cb)
})
artRefsList[0][0] is typeOf object and is used in previous function to get Attributes: RM.Data.getAttributes(
artRefsList[0][0].... and worked fine..
The error I receive by doing this: TypeError: Cannot read properties of undefined (reading 'IMPLEMENTED_BY').
Is there a way to solve this problem?
Is there another way to create a link between an artifact in Doors next in module context to a work item in EWM? I only found an article with no reference of module context: https://jazz.net/library/article/1197
2 answers
You have the reference wrong - it should be RM.Data.LinkTypes.IMPLEMENTED_BY
This is the reference to the API if you haven't already discovered it:
Thank you for your hints.
First I tried to change the RM.Data.createLink as described by Davyd:
RM.Data.createLink(artRefsList[0][0], RM.Data.LinkTypes.IMPLEMENTED_BY, targetLink, function(cb){
console.log (cb)
})
But the result was:
RM.OperationResult
code: "OPERATION_FAILED"
message: "You cannot create ELM links in this version of the API: [object Object]"
So my next trial was the official OSLC API and how the tool works as mentioned by Ralph. My code does now looks like:
- add the link to the EWM-work item
- Therefore first get the work item in the global configuration context:
Content-Type: text/plainOslc-Core-Version: 2.0Accept: application/rdf+xml2. add the link to the ERM-artifact:Oslc.Configuration: https://example/gc/configuration/693
2. GET from the answer the Etag in the header and the body3. PUT the changed body by using the Etag as If-match in the header:Accept: text/xmlContent-Type: application/rdf+xmlOslc-Core-Version: 2.0If-Match: c9981361-9bc2-34ec-88e0-d6f04ffb5d7e -- <ETAG from GET-Response beforeOslc.Configuration: https://example/gc/configuration/693
<rdf:RDF.....--< from answer and added link looking like this:<rdf:Description rdf:about="https://example/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/39572"><oslc_cm:affectsRequirement rdf:resource="https://example/rm/resources/BI_fQcOsOALEe2T6KW9b8u7AA" rdf:ID="oslc_rm_808621"/></rdf:Description><rdf:Description rdf:about="#oslc_rm_808621"><dcterms:title>808621: All requirements that are valid for this projcet stream are created or updated in this stream by using change sets. Please do not deliver these change sets to other stream(s).</dcterms:title></rdf:Description>
Accept: noneContent-Type: application/rdf+xmlDoorsrp-Request-Type: privateOslc.Configuration: https://example/gc/configuration/693Net.Jazz.Jfs.Owning-Context: https://example/rm/rm-projects/_M3l9MMaYEeq6_fWT7NFgmw/components/_5w3IoMayEeq6_fWT7NFgmw
(strange think by doing this: It works only, if the url looks like this. The characters %2F has to used instead of "/")
Comments
This is called URL Encoding. You can not have certain characters used in certain areas of an URL.
1 vote
Why do the URL's look like https://example/rm/proxy? This is unusual.
I have got it from the tool handling. But you are right: GEThttps://example/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/39572
works also.
This path /rm/linksCache is not a public OSLC API. You shouldn't use it.
You should not use /rm/proxy either.
The OSLC Way to add a link from a work item to a requirement is to first GET the WI using EWM OSLC API (you already have its EWM URL don't you), update the rdf with the link and PUT the updated rdf to EWM to update the WI.
If you're not sure how to modify the rdf to add a link, look at an example of an existing link on a WI.
What can I do alternatively to /rm/linksCache?
Only linking in EWM is not enough. I am doing this first at all. The link has additionally to be created to the artifact in ERM himself. If I do not do this, the link is not visible in ERM. We are working with change sets.
You would use the OSLC API. As an example https://rsjazz.wordpress.com/2022/02/02/ewm-work-item-oslc-cm-api/ Unfortunately I have not created an example for creating links. ERM is not storing the links. ERM has also an OSLC API.
showing 5 of 6
show 1 more comments
Comments
Antje Rößle-Tuchel
Jul 15 '24, 9:55 a.m.sorry the targeLink looks of cause like this:
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jul 15 '24, 11:09 a.m.I can not answer the first part of the question. I have no experience with that API. As far as I know there are the following other APIs that could create links between work items and requirements:
Unfortunately the OSLC Workshop is quite old.
Here might be a better maintained one: https://oslc.github.io/developing-oslc-applications/ . There are some youtube videos as well.
I published https://rsjazz.wordpress.com/2022/02/02/ewm-work-item-oslc-cm-api/ which covers all EWM rest APIs (OSLC and Reportable Rest) as well as authentication.
It would be a good idea to create the links in the tool and then get the RDF+XML representation for both ends. To look how they are changed.