-
Story
-
Resolution: Done
-
High
-
Istanbul Release
Given a Yang leaf-list
{ "xpath": "/cps-ran-schema/NearRTRIC[@idNearRTRIC='11']/attributes", "leaves": { "ranNFNSSIIdList": [ "ac8ca1a9-e1ec-4480-8720-c74e92566885","some-other-entry" ] }, "childDataNodes": [] },
Want to retrieve any NearRTRIC (ancestor) that has an ranNFNSSIIdList entry with string of a given value:
//attributes/ranNFNSSIIdList[text()="ac8ca1a9-e1ec-4480-8720-c74e92566885"]/ancestor::NearRTRIC
This is a requirement for 2E2.
Some research shows that the correct expression for using the text() function is like so
<cpsPath expression>/<leaf-name>[text()="<string value>"] // or <cpsPath expression>/<leaf-name>[text()='<string value>']
To implement this in CPS and NCMP and fulfill the use case requirements the following restrictions apply:
- text() can only be applied to leaves or leaf-list values
- text() can only be applied with a condition (since leaves cannot be returned in the context of their container/dataNode in CPS)
- for a leaf-list the condition wil be applied to any element in the list of values. If any of them is equals to the given value it is considered a match
- Since CPS can only return DataNodes, the 'containing' DataNode with all its leaves will be returned
(/ancestor:: axis can be used to return elements higher up the tree if needed) - the whole string will have to match and is case-sensitive (normal behavior xPath equals operator)
- <cpsPath expression> has to be a valid currently supported cpsPath expression
A/C
- cpsPath query can be used to select a dataNode based on a leave text value
- cpsPath query can be used to select a dataNode based on a leave-list 'containing' a text value
- text() can be used with any data of any type (it is like a toString() function in Java)
- update read-the-docs (.rst)
- this function should work for leaves (or leaf-lists) in both yang containers as yang lists
- walkthrough code as needed
- demo to team
Breakdown of tasks
- Update antlr parser to recognize this pattern
- Implement required (native) query
- Add db-container tests for
- filter on string leaf-value
- filter on non-string leaf value
- filter on leaf-list value
- container with match (might be included in other tests)
- list with match (might be included in other tests)
- Update documentation
- demo to team (record and publish)
Solution details
native query for filter on attribute value or array attribute value example:
SELECT * FROM FRAGMENT WHERE (attributes @> jsonb_build_object('Labels','classic') OR attributes @> jsonb_build_object('Labels',json_build_array('classic')));