model registration using classes issue

Change-Id: I6eae322e3a4653ee5c403c32ac59cd4092c313ac
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
index bd684e6..87f6c78 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
@@ -125,12 +125,22 @@
         Set<YangNode> curNodes = getNodes(model);
 
         //adding class info if added by application.
-        updateRegClassStore(param);
+        AppModuleInfo info = null;
+        for (YangModuleId id : param.getYangModel().getYangModulesId()) {
+            info = param.getAppModuleInfo(id);
+            if (info != null) {
+                break;
+            }
+        }
 
-        if (modelIdStore.containsKey(model.getYangModelId())) {
-            throw new IllegalArgumentException(E_MEXIST);
+        if (!modelIdStore.containsKey(model.getYangModelId())) {
+            updateRegClassStore(param);
+            modelIdStore.put(model.getYangModelId(), model);
+        } else if ((info != null) && (!registerClassStore
+                .containsKey(info.getModuleClass()))) {
+            updateRegClassStore(param);
         } else {
-            modelIdStore.put(model.getYangModelId(), param.getYangModel());
+            throw new IllegalArgumentException(E_MEXIST);
         }
 
         //Register all the YANG nodes.