Added support for implements and extends of GeneratedType; 57/657/1
authorlsedlak <lsedlak@cisco.com>
Tue, 7 May 2013 11:11:59 +0000 (13:11 +0200)
committerMartin Vitez <mvitez@cisco.com>
Wed, 24 Jul 2013 11:44:52 +0000 (13:44 +0200)
Added functionality to store List of implementing Generation Types into
GeneratedType and GeneratedTypeBuilder;
Added functionality to store Extending Transfer Object for
GeneratedTransferObject and GeneratedTOBuilder;

Fixed:
DataNodeIterator no longer returns augmented containers, lists, leafs
and leaflists - only non augmented module schema tree;
Added findDataSchemaNode for given SchemaPath into SchemaContextUtil;

Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java
yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java

index ded4a75179113327683a084bf15425b7b3f91d8d..b4eaed775c7d6f24f905b51e559888fa9033b674 100644 (file)
@@ -61,6 +61,9 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
         final Set<DataSchemaNode> childs = dataNode.getChildNodes();
         if (childs != null) {
             for (DataSchemaNode childNode : childs) {
+                if (childNode.isAugmenting()) {
+                    continue;
+                }
                 allChilds.add(childNode);
                 if (childNode instanceof ContainerSchemaNode) {
                     final ContainerSchemaNode container = (ContainerSchemaNode) childNode;
index ab50982f4f209dc89f6da8732cfecdfe86b209ee..8554f682198f73c95f78eb3f5cdf413131e4e2f9 100644 (file)
@@ -31,7 +31,23 @@ public final class SchemaContextUtil {
     public SchemaContextUtil(final SchemaContext context) {
         this.context = context;
     }
-
+    
+    public SchemaContext getContext() {
+        return context;
+    }
+    
+    public DataSchemaNode findDataSchemaNode(final SchemaPath schemaPath) {
+        if (schemaPath != null) {
+            final Module module = resolveModuleFromSchemaPath(schemaPath);
+            final Queue<String> prefixedPath = schemaPathToQueuedPath(schemaPath);
+            
+            if ((module != null) && (prefixedPath != null)) {
+                return findSchemaNodeForGivenPath(module, prefixedPath);
+            }
+        }
+        return null;
+    }
+    
     public DataSchemaNode findDataSchemaNode(final Module module,
             final RevisionAwareXPath nonCondXPath) {
         if (nonCondXPath != null) {
@@ -187,7 +203,30 @@ public final class SchemaContextUtil {
         }
         return retQueue;
     }
-
+    
+    private Queue<String> schemaPathToQueuedPath(final SchemaPath schemaPath) {
+        final Queue<String> retQueue = new LinkedList<String>();
+        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
+            final List<QName> listPath = schemaPath.getPath();
+            
+            for (final QName qname : listPath) {
+                if (qname != null) {
+                    final String prefix = qname.getPrefix();
+                    final String localName = qname.getLocalName();
+                    
+                    final StringBuilder builder = new StringBuilder();
+                    if (prefix != null) {
+                        builder.append(prefix);
+                        builder.append(":");
+                    }
+                    builder.append(localName);
+                    retQueue.add(builder.toString());
+                }
+            }
+        }
+        return retQueue;
+    }
+    
     private Queue<String> resolveRelativeXPath(
             final RevisionAwareXPath relativeXPath,
             final SchemaPath leafrefSchemaPath) {