It's all about the answers!

Ask a question

Struggling with RM OSLC API


Dave Evans (1362032) | asked Oct 13, 3:08 p.m.

Is there a way in oslc to query and find all artifacts that have a certain custom attribute (a string attribute named 'UID') set to something other than blank?


If not, even just knowing how to get this custom attribute's value for all artifacts of type X would be helpful. I am new to the RM OSLC API and am struggling to understand the documentation...

Thank you!
Dave

One answer



permanent link
Gabriel Ruelas (1.1k13) | answered Oct 13, 3:12 p.m.

 Have you checked this article? It describes some ways to do the queries: https://jazz.net/library/article/1197


Comments
Dave Evans commented Oct 13, 3:20 p.m.

 Thank you Gabriel, yes. I have read that article and several others. I have failed to find out if its even possible to query for what I need. I have authentication working and have successfully found an artifact by id in my javascript.


Dave Evans commented Oct 13, 5:55 p.m. | edited Oct 13, 6:07 p.m.

Using the following URL (with the OSLC headers), this has got to be SO close:


URL:
<queryBase from project's services.xml>
&oslc.prefix=rt=<namespace for rt from services.xml>
&oslc.select=
&oslc.where=rt:attributeId>0

But this returns success, but no results. How would I specify the oslc.where to find a non-blank string? >0 Does not work. I also tried more...
These get me ALL artifacts:
="" (this is a * in quotes, but the forum won't show it)

These get me NO artifacts:
!=""
!="NULL"

Also, I found the attribute id was found from an OSLC query of a specific artifact....can I get this in an easier way?


Ian Barnard commented Oct 14, 5:59 a.m.
JAZZ DEVELOPER

 AFAIK if this is a string attribute then you can only use = and != also note that DOORS Next doesn't support the use of wildcards _ and % described (and optional) in the OSLC Query specification.


I don't think there is a way to query "where attribute is empty (or non-empty)" so I guess you will have to get all candidates with the attribute value included in the results by adding the attribute to the oslc.select and then postprocess.


1
Ian Barnard commented Oct 14, 7:17 a.m. | edited Oct 14, 7:18 a.m.
JAZZ DEVELOPER

Updated:

> &oslc.where=rt:attributeId>0

rt:attributeId must be the URI of the attribute definition, e.g. for my test env where my custom attribute type definition is https://SERVER:9443/rm/types/_i9G_YQ4AEeuyn_ocqKJ0aA then the prefix rt would be declared in oslc.prefix as https://SERVER:9443/rm/types/ and attributeId is _i9G_YQ4AEeuyn_ocqKJ0aA

You say the attribute is a string so you'll have to compare with a string, i.e. >0 won't work - but you can use >"" to match any attribute with a non-empty value, then postprocess.

You can use rt:attributeId in ["a","b","c"] to match specific values.

Note that DOORS Next doesn't support the use of wildcards _ and % described (and optional) in the OSLC Query specification.

You should add rt:attributeId to oslc.select to get the value in the results - prefer this to using oslc.select=* because of reduced server load when returning less data.


Ian Barnard commented Oct 14, 7:59 a.m. | edited Oct 14, 8:00 a.m.
JAZZ DEVELOPER

 As a debugging method to show you're on the right lines, set oslc.select to * and then check a specific id e.g. 12345 then set the oslc.where to dcterms:identifier=12345 then you can check you're getting the custom attribute in the results - obviously it will only appear where the attribute has a value on the artifact. dcterms:identifier in [12345,123,99] also works



Your answer


Register or to post your answer.