Manifold.js fixed exception cases
authorLoic Baron <loic.baron@lip6.fr>
Tue, 16 Jun 2015 15:45:31 +0000 (17:45 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Tue, 16 Jun 2015 15:45:31 +0000 (17:45 +0200)
manifoldapi/static/js/manifold.js

index d6f0932..f75ae20 100644 (file)
@@ -1085,7 +1085,7 @@ var manifold = {
      * \param array results results corresponding to query
      */
     publish_result: function(query, result) {
-        if (typeof result === 'undefined')
+        if (result == null || typeof result === 'undefined')
             result = [];
 
         // NEW PLUGIN API
@@ -1116,29 +1116,31 @@ var manifold = {
     },
 
     store_records: function(query, records) {
-        // Store records
-        var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid);
-        if (query_ext.set_query_ext) {
-            // We have a domain query
-            // The results are stored in the corresponding set_query
-            manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records);
-            
-        } else if (query_ext.domain_query_ext) {
-            // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key
-            // Has it a domain query, and has it completed ?
-            $.each(records, function(i, record) {
-                var key = manifold.metadata.get_key(query.object);
-                if ( typeof record === "string" ){
-                    var record_key = record;
-                }else{
-                    var record_key = manifold.record_get_value(record, key);
-                }
-                manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN);
-            });
+        if(records != null && records.length != 0){
+            // Store records
+            var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid);
+            if (query_ext.set_query_ext) {
+                // We have a domain query
+                // The results are stored in the corresponding set_query
+                manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records);
+                
+            } else if (query_ext.domain_query_ext) {
+                // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key
+                // Has it a domain query, and has it completed ?
+                $.each(records, function(i, record) {
+                    var key = manifold.metadata.get_key(query.object);
+                    if ( typeof record === "string" ){
+                        var record_key = record;
+                    }else{
+                        var record_key = manifold.record_get_value(record, key);
+                    }
+                    manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN);
+                });
 
-        } else {
-            // We have a normal query
-            manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN);
+            } else {
+                // We have a normal query
+                manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN);
+            }
         }
     },