Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to use RM API/OSLC where clause using not equal / null conditions

We've come a ways with our application that is using the RM API.  When we use the following to query against 5 custom attributes, we are able to retrieve a list of artifacts.

&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. 

0 votes

Comments

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. 

• 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.


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.

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.

 

We have reviewed the OSLC standards for processing this type of query and believe what we are attempting to do should be possible. 



3 answers

Permanent link

 I had the same issue while is using the ClearQuest OSLC 2.0 API.


My use case:
check if an attribute has a value

My solution:
oslc.where=cq:myField>"!"

Limitations:
Will find all records where the 'myField' attribute is NOT:
- null
- empty ("")
AND the first character is NOT
-  space (" ")
- control character (see ASCII table)

1 vote


Permanent link
With my limited experience with OSLC API in CLM applications (RTC, QM and RM) and previously ClearQuest, I have never come across any implementation that can test for null, or empty value, or "not exists". The specification is one thing, and the implementation is another. Unless the OSLC specification says something is a MUST or SHOULD, it is up to the application to decide how to implement. The particular sample that you quoted may be just a smart way to achieve this, but I haven't seen it in CLM.

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

0 votes


Permanent link

 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_val

scoped_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" 


If IBM's OSLC Query implementation is compliant, it MUST retain the same semantics of the binary comparison operator.

Could you please help me post this answer?

0 votes

Comments

By the look of it, the sample oslc.where clause is testing "exists", right? The OP wants to test "not exists", or null.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 139

Question asked: Sep 01 '16, 2:33 p.m.

Question was seen: 5,503 times

Last updated: Jan 16 '19, 2:59 p.m.

Confirmation Cancel Confirm