How to use RM API/OSLC where clause using not equal / null conditions
&oslc.where=rm_property:_f1FOIfawEeWWmYXMBVuVVw=<https://itec-rrc.fmr.com/rm/types/_53IXkfasEeWWmYXMBVuVVw%2399d86095-0a43-4efd-87ce-87bb63703d02>
&oslc.where=rm_property:_T-0KwfawEeWWmYXMBVuVVw=<https://itec-rrc.fmr.com/rm/types/_i5ORYfasEeWWmYXMBVuVVw%23f481adbb-8b77-41cf-8f00-acced77cab23>
&oslc.where=rm_property:_hwzT8fawEeWWmYXMBVuVVw=<https://itec-rrc.fmr.com/rm/types/_TDTsIfatEeWWmYXMBVuVVw%2358e1fb0e-17ea-4e88-8c57-e7d0108c3d45>
&oslc.where=rm_property:_j4WPQfawEeWWmYXMBVuVVw=<https://itec-rrc.fmr.com/rm/types/_dLHpoPatEeWWmYXMBVuVVw%23acc27ca3-edeb-43cc-8949-a1eadb5f76b2>
We have an attribute that may or may not have a value assigned. From the following reference:
https://www.ibm.com/support/knowledgecenter/SSZRHJ/com.ibm.mif.doc/gp_intfrmwk/oslc/r_oslc_query_params.html
The parent!="*" query is semantically equivalent to the parent="NULL" query.
we are trying to query for artifacts where the last attribute does not have a value assigned; i.e. is null. This is needed since we need to exclude the artifacts where a value is assigned. We are unsuccessful with the following. Is there anything wrong with the use of !=%22*%22
&oslc.where=rm_property:_j4WPQfawEeWWmYXMBVuVVw!=%22*%22
We initially tried and were unsuccessful with "" or " " such as
&oslc.where=rm_property:_j4WPQfawEeWWmYXMBVuVVw=%22%22
Any other ideas would be appreciated.
3 answers
I had the same issue while is using the ClearQuest OSLC 2.0 API.
BTW, these are the specifications that RDNG would adhere to.
http://open-services.net/bin/view/Main/RmSpecificationV2#Query_Capabilities
http://open-services.net/bin/view/Main/OslcCoreSpecification#Query_Capabilities
http://open-services.net/bin/view/Main/OSLCCoreSpecQuery
P.S. In the tutorial, not even the "!=" operator is mentioned.
https://jazz.net/library/article/1197
From Andri Berezovskyi:
OSLC Query allows wildcards only on the left hand side of the operator, to filter properties. See the BNF over here https://tools.oasis-open.org/version-control/svn/oslc-core/trunk/specs/oslc-query.html#oslc.where, take a look at the following fragment:term ::= identifier_wc comparison_op value | identifier_wc space in_op space? in_valscoped_term ::= identifier_wc "{" compound_term "}"
identifier_wc ::= identifier | wildcard
The problem you have is surfacing because RDF does not allow modelling a NULL value – it is "modelled" by a nonexistence of the triple, but the OSCL Query does not allow you to test for the presence of a property alone.
BUT, all OSLC Query implementations MUST respect https://www.w3.org/TR/sparql11-query/#OperatorMapping semantics. So what you can do is the following:
oslc.where=rm_property:_j4WPQfawEeWWmYXMBVuVVw>="test" or rm_property:_j4WPQfawEeWWmYXMBVuVVw<="test"
You can try out an example in SPARQL here: http://fuseki.aide.md.kth.se/dataset.html?tab=query&ds=/aide-pror#query=SELECT+%3Fsubject+%3Fpredicate+%3Fobject%0AWHERE+%7B+GRAPH+%3Fg+%7B%0A++%3Fsubject+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2Fidentifier%3E+%3Fobject+.%0A++++FILTER(%3Fobject+%3E%3D+%22test%22+%7C%7C+%3Fobject+%3C%3D+%22test%22).%0A++%7D%7D%0ALIMIT+25
If IBM's OSLC Query implementation is compliant, it MUST retain the same semantics of the binary comparison operator.
Comments
Daniel Senko
Sep 22 '16, 3:15 p.m.Some more info:
we are working on a development project and are integrating with RDNG through the REST web service API. We have run into a roadblock that we have not been able to overcome on our own but are hopeful you can help.
In brief we are trying to query the web service for artifacts where the event attribute is set to one of a list of values, or is null.
Daniel Senko
Sep 22 '16, 3:18 p.m.• We can get attributes where the event attribute value is in the list of values by querying where event = value A, then querying where event = value B, etc, etc, and concatenating the result sets.
• We cannot get a list of attributes by running a single query for “event in [value A, value B, etc, etc].
• We also cannot get a list of attributes where event is not set.
Daniel Senko
Sep 22 '16, 3:18 p.m.As a workaround for not being able to query where event is null, we have tried querying where event is not valid value A and event is not valid value B and event is not valid value C, etc, etc, for the entire list of valid values. We were able to get this to run as a POST through the REST client in Firefox, after logging into the application directly. We were not able to get this to work in our application where the login was processed through the web service; we receive a 403 forbidden error.
Daniel Senko
Sep 22 '16, 3:19 p.m.If possible, we would prefer to find a query for “where event is null”, rather than specifically excluding the entire list of valid values for the event attribute, as that is a very large list.