use of org.onosproject.yang.model.LeafType in project onos by opennetworkinglab.
the class DistributedDynamicConfigStore method readInner.
private void readInner(DataNode.Builder superBldr, String spath) {
CompletableFuture<Map<String, Versioned<DataNode.Type>>> ret = keystore.getChildren(DocumentPath.from(spath));
Map<String, Versioned<DataNode.Type>> entries = null;
entries = complete(ret);
log.trace(" keystore.getChildren({})", spath);
log.trace(" entries keys:{}", entries.keySet());
if (!entries.isEmpty()) {
entries.forEach((k, v) -> {
String[] names = k.split(ResourceIdParser.NM_CHK);
String name = names[0];
String nmSpc = ResourceIdParser.getNamespace(names[1]);
String keyVal = ResourceIdParser.getKeyVal(names[1]);
DataNode.Type type = v.value();
String tempPath = ResourceIdParser.appendNodeKey(spath, name, nmSpc);
if (type == DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE) {
LeafNode lfnode = readLeaf(tempPath);
// FIXME there should be builder for copying
superBldr.createChildBuilder(name, nmSpc, lfnode.value(), lfnode.valueNamespace()).type(type).leafType(lfnode.leafType()).exitNode();
} else if (type == DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE) {
String mlpath = ResourceIdParser.appendLeafList(tempPath, keyVal);
LeafNode lfnode = readLeaf(mlpath);
// FIXME there should be builder for copying
superBldr.createChildBuilder(name, nmSpc, lfnode.value(), lfnode.valueNamespace()).type(type).leafType(lfnode.leafType()).addLeafListValue(lfnode.value()).exitNode();
// TODO this alone should be sufficient and take the nm, nmspc too
} else if (type == DataNode.Type.SINGLE_INSTANCE_NODE) {
DataNode.Builder tempBldr = superBldr.createChildBuilder(name, nmSpc).type(type);
readInner(tempBldr, tempPath);
} else if (type == DataNode.Type.MULTI_INSTANCE_NODE) {
DataNode.Builder tempBldr = superBldr.createChildBuilder(name, nmSpc).type(type);
tempPath = ResourceIdParser.appendMultiInstKey(tempPath, k);
String[] keys = k.split(ResourceIdParser.KEY_CHK);
for (int i = 1; i < keys.length; i++) {
// String curKey = ResourceIdParser.appendKeyLeaf(tempPath, keys[i]);
// LeafNode lfnd = readLeaf(curKey);
String[] keydata = keys[i].split(ResourceIdParser.NM_CHK);
tempBldr.addKeyLeaf(keydata[0], keydata[1], keydata[2]);
}
readInner(tempBldr, tempPath);
} else {
throw new FailedException("Invalid node type");
}
});
}
superBldr.exitNode();
}
Aggregations