qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1559960 - in /qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common: UpdatableStore.js util.js
Date Tue, 21 Jan 2014 10:08:36 GMT
Author: orudyy
Date: Tue Jan 21 10:08:35 2014
New Revision: 1559960

URL: http://svn.apache.org/r1559960
Log:
QPID-5413: Fix UpdatableStore row update logic to compare correctly fields of type 'array'
and 'object'

Modified:
    qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js
    qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js?rev=1559960&r1=1559959&r2=1559960&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js
Tue Jan 21 10:08:35 2014
@@ -18,10 +18,11 @@
  * under the License.
  *
  */
-define(["dojo/store/Memory",
-				"dojox/grid/DataGrid",
-				"dojo/data/ObjectStore",
-				"dojo/store/Observable"], function (Memory, DataGrid, ObjectStore, Observable) {
+define(["qpid/common/util",
+        "dojo/store/Memory",
+        "dojox/grid/DataGrid",
+        "dojo/data/ObjectStore",
+        "dojo/store/Observable"], function (util, Memory, DataGrid, ObjectStore, Observable)
{
 
     function UpdatableStore( data, divName, structure, func, props, Grid, notObservable )
{
 
@@ -86,16 +87,7 @@ define(["dojo/store/Memory",
         if(data) {
             for(var i=0; i < data.length; i++) {
                 if(theItem = store.get(data[i].id)) {
-                    var modified;
-                    for(var propName in data[i]) {
-                        if(data[i].hasOwnProperty(propName)) {
-                            if(theItem[ propName ] != data[i][ propName ]) {
-                                theItem[ propName ] = data[i][ propName ];
-                                modified = true;
-                                changed = true;
-                            }
-                        }
-                    }
+                    var modified = !util.equals(theItem, data[i]);
                     if(modified) {
                         // ... check attributes for updates
                         store.notify(theItem, data[i].id);

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js?rev=1559960&r1=1559959&r2=1559960&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
Tue Jan 21 10:08:35 2014
@@ -369,6 +369,94 @@ define(["dojo/_base/xhr",
                {
                    alert(error);
                }
+           };
+
+           util.equals = function(object1, object2)
+           {
+             if (object1 && object2)
+             {
+               if (typeof object1 != typeof object2)
+               {
+                 return false;
+               }
+               else
+               {
+                 if (object1 instanceof Array || typeof object1 == "array")
+                 {
+                   if (object1.length != object2.length)
+                   {
+                     return false;
+                   }
+
+                   for (var i = 0, l=object1.length; i < l; i++)
+                   {
+                     var item = object1[i];
+                     if (item && (item instanceof Array  || typeof item == "array"
|| item instanceof Object))
+                     {
+                       if (!this.equals(item, object2[i]))
+                       {
+                         return false;
+                       }
+                     }
+                     else if (item != object2[i])
+                     {
+                         return false;
+                     }
+                   }
+
+                   return true;
+                 }
+                 else if (object1 instanceof Object)
+                 {
+                   for (propName in object1)
+                   {
+                       if (object1.hasOwnProperty(propName) != object2.hasOwnProperty(propName))
+                       {
+                           return false;
+                       }
+                       else if (typeof object1[propName] != typeof object2[propName])
+                       {
+                           return false;
+                       }
+                   }
+
+                   for(propName in object2)
+                   {
+                       var object1Prop = object1[propName];
+                       var object2Prop = object2[propName];
+
+                       if (object2.hasOwnProperty(propName) != object1.hasOwnProperty(propName))
+                       {
+                           return false;
+                       }
+                       else if (typeof object1Prop != typeof object2Prop)
+                       {
+                           return false;
+                       }
+
+                       if(!object2.hasOwnProperty(propName))
+                       {
+                         // skip functions
+                         continue;
+                       }
+
+                       if (object1Prop && (object1Prop instanceof Array || typeof
object1Prop == "array" || object1Prop instanceof Object))
+                       {
+                         if (!this.equals(object1Prop, object2Prop))
+                         {
+                           return false;
+                         }
+                       }
+                       else if(object1Prop != object2Prop)
+                       {
+                          return false;
+                       }
+                   }
+                   return true;
+                 }
+               }
+             }
+             return object1 === object2;
            }
 
            return util;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message