Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

response for getDataNode is

...

Code Block
{
   "bookstore":{
      "bookstore-name":"Chapters",
      "categories":[
         ...
      ]
   }
}


SolutionsIssues
Populate the schema_node_id variable in the fragment table which would equate to the schemaSetName variable in the DataNode class/object. This variable is currently null and not used.Adds a substantial amount of extra data to the fragment table. 
Obtain the schema node from the xpath of the queried node. Node xpath will be /bookstore/categories[@code='01'] where bookstore is the container name given in the module info.
Create a query to obtain the schema node directly from the database using and propagate through persistence and service layers.Would need to create a new query
and also
which would parse the json data from the yang_resource content and find the container name. Also would need to pass a new schema node object to the toDataMap method which would not be used every time which it is called


For the JSON output of Get DataNode we need to alter the DataMapUtils class. The function toDataMap toDataMap translates a datanode object to a JSON output:


public static Map<String, Object> toDataMap(final DataNode dataNode) {
final boolean isTopLevelNode = dataNode.getXpath().lastIndexOf('/') == 0;
if (isTopLevelNode) {
String containerName = dataNode.getXpath().substring(1);
return ImmutableMap.<String, Object>builder().put(containerName,
ImmutableMap.<String, Object>builder()
.putAll(dataNode.getLeaves())
.putAll(listElementsAsMap(dataNode.getChildDataNodes()))
.putAll(containerElementsAsMap(dataNode.getChildDataNodes()))
.build()
).build();
} else {
return ImmutableMap.<String, Object>builder()
.putAll(dataNode.getLeaves())
.putAll(listElementsAsMap(dataNode.getChildDataNodes()))
.putAll(containerElementsAsMap(dataNode.getChildDataNodes()))
.build();
}
}

We only want the container name on the top level of the JSON output and as such have to distinguish between a top level node and non top level node. We create an outer map to wrap the inner map which creates the appropriate levels in the JSON output. 

Tests would need to be updated to accept the new JSON output which is returned.