Merge "Fix bug 2554 - XSQL getting stuck on some models"
authorEd Warnicke <eaw@cisco.com>
Wed, 7 Jan 2015 20:05:00 +0000 (20:05 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 7 Jan 2015 20:05:00 +0000 (20:05 +0000)
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java

index ad4bd46d719e6dbf286f3dafd408c38dd4fbece4..a5658ccc9ed661b9b2d616f2ca70a2303e875bb0 100644 (file)
@@ -164,13 +164,14 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
                     return result;
                 }
 
-                // XSQLAdapter.log(""+node);
                 Map<?, ?> children = XSQLODLUtils.getChildren(node);
                 for (Object c : children.values()) {
+                    result.add(c);
+                    /* I don't remember why i did this... possibly to prevent different siblings queried together
                     Map<?, ?> sons = XSQLODLUtils.getChildren(c);
                     for (Object child : sons.values()) {
                         result.add(child);
-                    }
+                    }*/
                 }
 
                 return result;
index d37fdb8819b9d037356a7c38b525fbe8bc6e3074..757f1a8b0487d675661bc35c45ef8a38ae1c6861 100644 (file)
@@ -423,20 +423,20 @@ public class JDBCResultSet implements Serializable, ResultSet,
         return result;
     }
 
-    public List<Record> addRecords(Object element, XSQLBluePrintNode node,
-            boolean root, String tableName, XSQLBluePrint bluePrint) {
-
+    public List<Record> addRecords(Object element, XSQLBluePrintNode node,boolean root, String tableName, XSQLBluePrint bluePrint) {
         List<Record> result = new LinkedList<Record>();
+        //In case this is a sibling to the requested table, the elenment type
+        //won't be in the path of the leaf node
+        if(node==null){
+            return result;
+        }
         String nodeID = XSQLODLUtils.getNodeIdentiofier(element);
         if (node.getODLTableName().equals(nodeID)) {
-            XSQLBluePrintNode bluePrintNode = bluePrint
-                    .getBluePrintNodeByODLTableName(nodeID)[0];
+            XSQLBluePrintNode bluePrintNode = bluePrint.getBluePrintNodeByODLTableName(nodeID)[0];
             Record rec = new Record();
             rec.element = element;
-            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode
-                    .getBluePrintNodeName());
-            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName())
-                    || bpn != null) {
+            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode.getBluePrintNodeName());
+            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName()) || bpn != null) {
                 Map<String, Object> allKeyValues = collectColumnValues(element, bpn);
                 if (!(isObjectFitCriteria(allKeyValues,
                         bpn.getBluePrintNodeName()) == 1)) {
@@ -453,8 +453,7 @@ public class JDBCResultSet implements Serializable, ResultSet,
         }
 
         XSQLBluePrintNode parent = node.getParent();
-        List<Record> subRecords = addRecords(element, parent, false, tableName,
-                bluePrint);
+        List<Record> subRecords = addRecords(element, parent, false, tableName,bluePrint);
         for (Record subRec : subRecords) {
             List<Object> subO = getChildren(subRec.element, tableName,
                     bluePrint);