It's all about the answers!

Ask a question

Query artifacts that have a specific attribute value via API in DOORS Next Generation 7.0.3


Joshua Baxter (511715) | asked Nov 06, 5:57 p.m.
edited Nov 06, 6:12 p.m.

Is it possible to query for artifacts that have a specific value in one of their attributes via an API call? For example, query for artifacts in a specific project in a specific stream that have value "ID1" in their "Work Item ID" attribute. Or query for artifacts in a specific project in a specific stream that have a non empty value in their "Work Item ID" attribute.

Accepted answer


permanent link
Ian Barnard (2.3k613) | answered Nov 08, 4:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Nov 11, 3:44 a.m.
Yes you can use OSLC Query to filter results by the value of one or more attributes. The filters are ‘and’ed. Attribute values for attributes included in the oslc.select are returned in the results.

But no the OSLC Query specification can't test for empty or non-empty attributes - you have to get the value (using oslc.select) and then filter afterwards.

Joshua Baxter selected this answer as the correct answer

Comments
Joshua Baxter commented Nov 11, 2:15 p.m. | edited Nov 11, 2:27 p.m.

Is it possible to query for artifacts that have an attribute value that starts with a specific value? For example, query for artifacts where the value for the Work Item attribute starts with the string "WorkId". 


1
Ian Barnard commented Nov 13, 4:28 a.m. | edited Nov 13, 5:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No I don't think this is possible - you'll have to get the attribute value and post-process looking for what you want.


Joshua Baxter commented Nov 13, 5:27 p.m. | edited Nov 13, 5:28 p.m.

For future reference, is there a URL that displays all the possible query parameters that you can use in DNG 7.0.3 OSLC queries? The Using OSLC capabilities in the Requirements Management application only has a small amount of examples and was created in 2013. 


1
Ian Barnard commented Nov 13, 6:30 p.m. | edited Nov 13, 6:31 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The OSLC Query specification https://docs.oasis-open-projects.org/oslc-op/query/v3.0/os/oslc-query.html hasn’t changed a lot. It gives the full picture of what might be possible. AFAIK DOORS Next uses the oslc.where, oslc.select, oslc.prefix and (since a fairly recent version that I can’t specify but should work in 7.0.3) oslc.searchTerms parameters. AFAIK oslc.searchTerms matches only against the primary content.


Ian Barnard commented Nov 13, 6:49 p.m. | edited Nov 13, 6:50 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As a soft entry into OSLC Query you might want to look at https://github.com/IBM/ELM-Python-Client which has an oslcquery command that lets you work with Query at a human-friendly level, i.e. without having to deal with the details of how Query works in terms of HTTP GET URLs. oslcquery may not do everything you might want to do but it’s OSS and you can modify/extend/contribute :-)


Joshua Baxter commented Nov 13, 8:49 p.m.

Thanks for the resources. I'm assuming that it's not possible to query for artifacts that have a specific attribute value if it is a custom attribute that we have created since if I understand correctly can only query for attribute types that are listed at http://purl.org/dc/terms/ ?


Joshua Baxter commented Nov 13, 8:53 p.m.

Also from following the OSLC examples I tried to query for artifacts that are in a specific module with ID 1294667https://server/rm/views?oslc.query=true&projectURL=value&oslc_config.context=value&oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses&oslc.where=dcterms:identifier=1294667

However I got the following error: com.ibm.oslc.query.parser.select.ParseException: Invalid prefix definition: oslc_rm


1
Ian Barnard commented Nov 14, 7:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I'm suspicious of the url in your oslc.prefix oslc_rm=<http://open-services.net/ns/rm%23> - the encoding looks wrong, the %23 should be a #.. Also in the actual URL all the query parameter values MUST be url-encoded not plaintext like you're showing - so for your query I'd expect the actual URL too look like https://server/rm/views?oslc.query=true&projectURL=value&oslc_config.context=value&oslc.prefix=oslc_rm%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Frm%23%3E,dcterms%3D%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E&oslc.select=oslc_rm%3Auses&oslc.where=dcterms%3Aidentifier%3D1294667



1
Ian Barnard commented Nov 14, 7:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Yes it is possible to query custom attributes, you need to know the type URI and convert it to a prefixed name (adding the prefix to the oslc.prefix too), and if the comparison is with e.g. an enumeration value then in the query you use the URI of the enumeration value.
Finding these URIs can be complicated you can see the shapes in the services.xml.
But for example if I define a custom attribute OriginID which is ineger then I can query for value 23 with a URL (decoded) which includes:

oslc.where=rp0:AD_QFRd4KG4Ee-bktCwEBzc1A=23
oslc.select=rp0:AD_QFRd4KG4Ee-bktCwEBzc1A,dcterms:identifier,rm_nav:parent


Joshua Baxter commented Nov 14, 8:23 a.m.

Thanks for your responses. I will try out your suggestion to see if it fixes my error. And thanks for confirming that you can query for custom attributes. I have another question. I know you can query for global streams in GCM via API, as well as create global streams via API as how to do that is detailed at this link. But is it possible to query for local streams that are in a Doors Next project via API, as well as create local streams in Doors next via API?


1
Ian Barnard commented Nov 14, 9:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please submit that as a new question and I'll answer



Davyd Norris commented Nov 14, 6:41 p.m.

@Ian - regarding your comment talking about the %23, that's the URL encoded # symbol. You can't include it directly in the query parameters as it's also use for the anchor and so it'll cause errors in the URL


Ian Barnard commented yesterday | edited yesterday
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Joshua Baxter commented 11 hours ago | edited 11 hours ago

@Ian Barnard, regarding your comment on how to query for custom attributes, I got the services.xml for the component. In that services.xml there are multiple <oslc:resourceShape> entries. For example one <oslc:CreationFactory> entry called "Requirement Creation Factory" has 6 <oslc:resourceShape> entries, and another <oslc:CreationFactory> entry called "Collection Creation Factory" has  3 <oslc:resourceShape> entries. I called all of the <oslc:resourceShape> entries URLs but none of them had anything pertaining to the custom attribute that we created, so I'm not sure where I would find the "shape" for it. Our custom attribute is a string.


Also I see that when calling the <oslc:resourceShape> URLs, there are multiple entries in the results. I'm assuming that the URL in the <oslc:propertyDefinition> would be what I would need to include in the oslc.prefix value for the query?



Joshua Baxter commented 10 hours ago

Also, I'm assuming that custom attributes that we created can be included in the oslc.select parameter for OSLC queries as well?

showing 5 of 16 show 11 more comments

One other answer



permanent link
Davyd Norris (2.8k217) | answered Nov 06, 9:10 p.m.
edited Nov 06, 9:12 p.m.
You should be able to use the oslc.where parameter to filter dynamically, for example:


Comments
Joshua Baxter commented Nov 07, 8:23 a.m.

I'll take a look at that, thanks. So you can query for a certain value, but is it possible to query for if an attribute's value is not empty? For example, query for artifacts in project where a "State" attribute is not empty? Is it possible to specify the stream in the query? I didn't see any examples at Using OSLC capabilities in the Requirements Management application that showed how to specify the stream in a query.


Davyd Norris commented Nov 07, 4:54 p.m. | edited Nov 07, 5:09 p.m.
Yes, you can use != or <> from memory

For some stupid reason I can't add the solution to how you reference a stream because the forum won't let me save the post, saying it's got invalid text :-(


Joshua Baxter commented Nov 13, 8:55 a.m.

Thanks for your response. I'm assuming it's not possible to include more than one stream/config in the oslc_config:context/oslc_config:configuration parameters?


1
Davyd Norris commented Nov 13, 3:44 p.m.

No - and it wouldn't make sense to, as the context of artefacts has to be within the requested stream. You wouldn't be able to untangle the various versions of each artefact


Ian Barnard commented Nov 13, 5:02 p.m. | edited Nov 13, 6:34 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Agree with Davyd - you can’t use a list of configs - but you can use a global configuration and get results from the RM components contributing to that GC. From a pragmatic perspective, for this to work in terms of types in the different components, you need to have diligently applied URIs on all types. For background on this refer to https://jazz.net/library/article/92352

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.