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:_WInv4fawEeWWmYXMBVuVVw=<https://itec-rrc.fmr.com/rm/types/_ouuFIfasEeWWmYXMBVuVVw%2355f7b38b-b0a7-4d3d-8296-e4bfa15546fd>
&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.
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)
|
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 |
From Andri Berezovskyi:
I am unable to leave the following comment on the https://jazz.net/forum/questions/227587/how-to-use-rm-apioslc-where-clause-using-not-equal-null-conditions:
Could you please help me post this answer?
Comments
Donald Nong
commented Dec 12 '17, 12:21 a.m.
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
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.
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.