DOORS NG: obtain the direction of linkTypes through REST API
I'm trying to develop a widget for DOORS NG in which I need to navigate the linked artifacts, and I need to know which link types exist along with their directions (IN or OUT). I've already used the REST endpoint "rm/types?resourceContext=PROJECT_ID", where all link types are defined, but the directions are either missing or incorrect (subToObj or ObjToSub).
Do you know REST API that returns the direction (IN or OUT) for each linktypes?
THANKS!
4 answers
Hi,
My idea:
Is the 'IN/OUT link type' the same for every requirement?
-> If yes then I would create a getter. Parse through every requirements and see what this getter returns.
The getter consists mainly of the query(target URL). Do you already know which xml field/attribute is responsible for containing this link?
-> if yes then make the query. Query example using the cap 5.4 LinkType ResourceShape you shared: query = (
r"{}/views?oslc.query=true&projectURL={}&"
r"oslc.prefix=label=<http://...>&" # <- IDK what prefix this label is used with or if it even requires one.
r"oslc.where=rdfs:label=%22MyLinkTypeOut%22".format(rm_url, project_area_url), #<- %22 might not be needed, they mark the string.
)
And another query for the xml field where you store the IN (in the cap 5.4 that would be "<oslc:inverseLabel>".
-> if not, GET some requirements and look at their XML. You should see similar IN/OUT link type fields then.
-> if not, I can't think of anything.
Alex
In the Type System XML, do you want to check the following node. Node name mentioned "To". Check this node name in the other link also.
objectToSubjectLabel
I'm also unable to see information about links in the Requirement XML itself, let's try a different approach.
I'll provide an example that works for me, please let me know if I misunderstood what you're looking for.
rm_nr = 'rm1' # for me.
For the next variable, you need to know your element/artifact/requirement URL.
E.g. a requirement URL from me: 'https://my_jazz_site/rm1/resources/BI_oVSksBOREfCyoOBaQxWUzQ'
artifact_itemId = 'BI_oVSksBOREfCyoOBaQxWUzQ'
query_url = f"https://{your_jazz_site}/{rm_nr }/publish/resources?linksonly=true&resourceURI={artifact_itemId}"
configuration_context = 'This_must_be_your_GLOBAL_config.' # I did not find a way to work with links in change sets / local configurations, please use your global one.
Your GET consists of URL=query_url and headers = {'Configuration-Context': 'configuration_context'}
If you print the response text, you'll see all the links you have. e.g. I only have 'ValidatedBy'.
You can then play with the response, encode it, parse it etc.
Comments
okay, this work for custom type links, but not work standard link type like "Parent of" or "Satisfied By Architecture Element", because it retrieved URI: "http://jazz.net/ns/dm/linktypes#satisfy" or "http://www.ibm.com/xmlns/rdm/types/Decomposition" from which i can't get any other information.
'Decomposition'/'Parent Of' worked for me:<ds:Link type="Decomposition"><rrm:title>Parent Of</rrm:title><ds:linkType>
But you're right about 'Satisfied By Architecture Element'. It might be because on my end it's a weak/superficial link, it doesn't require a change-set to deliver the changes, creating a dummy link by itself works.
I have another idea that I can't make ends meet with.
query_url = f'https://server/rm1/links?sourceOrTarget={requirement_url}
My 2 cents if you still wanna investigate: play around with Developer Tools (Section Network) and search for 'satisfy'. I found a great response XML that lists the links (with the ones you want too). E.g.:
<rdf:Description rdf:nodeID="A1">
<rdf:subject rdf:resource="url"/>
<rdf:predicate rdf:resource="http://jazz.net/ns/dm/linktypes#satisfy"/>
<rdf:object rdf:resource="url"/>
<dcterms:format>application/rdf+xml</dcterms:format>
<dcterms:title>link title (I think)</dcterms:title>
</rdf:Description>
Best of luck.
Comments
Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 01, 10:33 a.m.Pippo Franco
May 05, 5:20 a.m.Pippo Franco
May 05, 5:24 a.m.Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 06, 10:40 a.m.Strongly suggest you only provide outgoing link creation, because allowing incoming link creation means your code has to go to the thing at the other end of the link and create it there, which makes it an outgoing link from that end. The DOORS Next UI hides this from you, but that's what it does.
Pippo Franco
May 06, 11:06 a.m.Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 07, 4:57 a.m.Using the OSLC APIs the only links you'll see on an artifact are outgoing links - so there's zero confusion about direction.
Pippo Franco
May 07, 8:57 a.m.@Ian Barnard, Okay, but in my case, I am developing a widget for DOORS NG, where I can use the client extension API 'RM.Data.getLinkedArtifacts' from RMExtensionsAPI703, which returns all the links present on an artifact, including both incoming links like 'satisfied by' and outgoing links like 'satisfies'.
Pippo Franco
May 07, 8:57 a.m.At this link: "https://jazz.net/wiki/bin/view/Main/DNGTypeAPI" (cap 5.4 LinkType ResourceShape), I found the result of a REST that shows the two directions of a link type under different tags: "label" and "inverseLabel".
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 08, 8:22 a.m.That API is the OSLC RM API. https://docs.oasis-open-projects.org/oslc-op/rm/v2.1/requirements-management-spec.html You are supposed to discover the endpoint. You get the rootservices document, then you look up the service provider for the rm application. Then you look up the project area service provider, from there you can find the factories and resource shapes.
Pippo Franco
May 09, 7:25 a.m.Hi @rschoon,
yes, I had already obtained the URIs of the Resource Shapes (for each project area there are several), for example:
"https://server/rm/types/OT_FmdoQPDVEe6urYqUOHltWQ"
but none of them contain "Property" elements with tags like
"<rdfs:label>MyLinkTypeOut</rdfs:label>" or
"<oslc:inverseLabel>MyLinkTypeIn</oslc:inverseLabel>".
All the links are listed in the resource shape URIs, but the link directions are not defined in the properties.
Maybe a specific parameter needs to be added to the request?
Or would you happen to have more information about this URI ("http://jazz.net/ns/rm/dng/types#LinkType")?
Thanks.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 12, 2:09 a.m.I don't. What I have done in the past is to use a REST client and GET the pages I am interested in and then try to find out what is in there. You seem to avoid providing useful examples of what calls you do, so do not expect useful answers. Tips
If there is a link returned with a link type, you can try to follow that, if there is useful information.
Pippo Franco
May 12, 6:56 a.m.@rschoon, I can provide you with as many examples as you want; the problem is that the REST results are large, and I can't include more than a certain number of characters here (in the comments). Moreover, I can't avoid mixing REST APIs because the client JavaScript API (RMExtensions) isn't able to retrieve all types of links, unlike OSLC API. The Reportable REST API — specifically this one: "https://server/rm/publish/linktypes" (with accept=application/xml and content=null) — returns an empty response. Below, I will try to provide the response XMLs and the OSLC URIs I queried in order to retrieve the link types (although I wasn’t able to get information about the directions).
Pippo Franco
May 12, 7:05 a.m.Using this URI: "https://server/rm/oslc_rm/catalog" i get the service.xml URI for the specific project area.