Uploaded image for project: 'Configuration Persistence Service'
  1. Configuration Persistence Service
  2. CPS-452

Support Query by leaf-list contains a value match

XMLWordPrintable

      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:

      1. text() can only be applied to leaves or leaf-list values
      2. text() can only be applied with a condition (since leaves cannot be returned in the context of their container/dataNode in CPS)
      3. 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
      4. 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)
      5. the whole string will have to match and is case-sensitive (normal behavior xPath equals operator)
      6. <cpsPath expression> has to be a valid currently supported cpsPath expression 

      A/C

      1. cpsPath query can be used to select a dataNode based on a leave text value
      2. cpsPath query can be used to select a dataNode based on a leave-list 'containing' a text value
      3. text() can be used with any data of any type (it is like a toString() function in Java)
      4. update read-the-docs (.rst)  
      5. this function should work for leaves (or leaf-lists) in both yang containers as yang lists
      6. walkthrough code as needed
      7. demo to team

      Breakdown of tasks

      1. Update antlr parser to recognize this pattern
      2. Implement required (native) query
      3. Add db-container tests for
        1. filter on string leaf-value
        2. filter on non-string leaf value
        3. filter on leaf-list value
        4. container with match (might be included in other tests)
        5. list with match (might be included in other tests)
      4. Update documentation
      5. 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')));

            ToineSiebelink Toine Siebelink
            cdgasparini cdgasparini
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: