BUG-1382: eliminate QName.getPrefix() from binding-generator-impl. 57/10057/1
authorMartin Vitez <mvitez@cisco.com>
Tue, 19 Aug 2014 09:11:41 +0000 (11:11 +0200)
committerMartin Vitez <mvitez@cisco.com>
Tue, 19 Aug 2014 09:11:41 +0000 (11:11 +0200)
Change-Id: Idce1e0efe18c6034ec036794007ea2716799d889
Signed-off-by: Martin Vitez <mvitez@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/YangTemplate.xtend

index d657087326b61d962b025fb52fff82e1f0d883ca..0cf3a6ea03aa8bbf8a78c1380c5ad734757af7d7 100644 (file)
@@ -1436,13 +1436,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     // GeneratedType for this type definition should be already
                     // created
                     QName qname = typeDef.getQName();
-                    Module unionModule = null;
-                    String prefix = qname.getPrefix();
-                    if (prefix == null || prefix.isEmpty() || prefix.equals(module.getPrefix())) {
-                        unionModule = module;
-                    } else {
-                        unionModule = findModuleFromImports(module.getImports(), qname.getPrefix());
-                    }
+                    Module unionModule = schemaContext.findModuleByNamespaceAndRevision(qname.getNamespace(),
+                            qname.getRevision());
                     final ModuleContext mc = genCtx.get(unionModule);
                     returnType = mc.getTypedefs().get(typeDef.getPath());
                 } else {
index 396001dbd31d95fd343f73cb47e0367f37b5cc5c..98d7ef1d9e120bc4540bf7fa7e8d910ac58cf125 100644 (file)
@@ -410,7 +410,7 @@ class YangTemplate {
         '''
             identity «identity.QName.localName» {
                 «IF identity.baseIdentity != null»
-                base "«writeIdentityPrefix(identity.baseIdentity)»«identity.baseIdentity»";
+                base "(«writeIdentityNs(identity.baseIdentity)»)«identity.baseIdentity»";
                 «ENDIF»
                 «IF !identity.description.nullOrEmpty»
                 description
@@ -427,17 +427,14 @@ class YangTemplate {
         '''
     }
 
-    def static writeIdentityPrefix(IdentitySchemaNode identity) {
+    def static writeIdentityNs(IdentitySchemaNode identity) {
         if(module == null)
             return ''
 
-        if(identity.QName.prefix.nullOrEmpty || module.prefix.nullOrEmpty)
-            return ''
-
-        val identityPrefix = identity.QName.prefix
+        val identityNs = identity.QName.namespace
 
-        if(!module.prefix.equals(identity.QName.prefix))
-            return identityPrefix + ":"
+        if(!module.namespace.equals(identityNs))
+            return identityNs + ":"
         return ''
     }
 
@@ -785,12 +782,13 @@ class YangTemplate {
         val StringBuilder sb = new StringBuilder();
 
         for(pathElement : schemaPath) {
-            val prefix = pathElement.prefix
+            val ns = pathElement.namespace
             val localName = pathElement.localName
 
             sb.append("\\")
-            sb.append(prefix)
-            sb.append(":")
+            sb.append('(')
+            sb.append(ns)
+            sb.append(')')
             sb.append(localName)
         }
         return sb.toString