[Commits] r2846 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Wed Oct 5 10:00:33 CEST 2011


Author: elemoine
Date: 2011-10-05 10:00:33 +0200 (Wed, 05 Oct 2011)
New Revision: 2846

Modified:
   core/trunk/geoext/lib/GeoExt/data/AttributeReader.js
   core/trunk/geoext/lib/GeoExt/data/AttributeStore.js
   core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.html
   core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.js
Log:
AttributeReader & AttributeStore should handle the boolean nillable property, p=fvanderbiest, r=me (closes #439)

Modified: core/trunk/geoext/lib/GeoExt/data/AttributeReader.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/AttributeReader.js	2011-10-05 06:23:21 UTC (rev 2845)
+++ core/trunk/geoext/lib/GeoExt/data/AttributeReader.js	2011-10-05 08:00:33 UTC (rev 2846)
@@ -87,14 +87,15 @@
         var recordType = this.recordType;
         var fields = recordType.prototype.fields;
         var numFields = fields.length;
-        var attr, values, name, record, ignore, value, records = [];
+        var attr, values, name, record, ignore, value, field, records = [];
         for(var i=0, len=attributes.length; i<len; ++i) {
             ignore = false;
             attr = attributes[i];
             values = {};
             for(var j=0; j<numFields; ++j) {
-                name = fields.items[j].name;
-                value = attr[name];
+                field = fields.items[j];
+                name = field.name;
+                value = field.convert(attr[name]);
                 if(this.ignoreAttribute(name, value)) {
                     ignore = true;
                     break;

Modified: core/trunk/geoext/lib/GeoExt/data/AttributeStore.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/AttributeStore.js	2011-10-05 06:23:21 UTC (rev 2845)
+++ core/trunk/geoext/lib/GeoExt/data/AttributeStore.js	2011-10-05 08:00:33 UTC (rev 2846)
@@ -48,7 +48,9 @@
                         undefined
                     ),
                     reader: new GeoExt.data.AttributeReader(
-                        c, c.fields || ["name", "type", "restriction"]
+                        c, c.fields || ["name", "type", "restriction", {
+                            name: "nillable", type: "boolean"
+                        }]
                     )
                 })
             );

Modified: core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.html	2011-10-05 06:23:21 UTC (rev 2845)
+++ core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.html	2011-10-05 08:00:33 UTC (rev 2846)
@@ -11,12 +11,13 @@
     <script type="text/javascript">
 
     function test_read(t) {
-        t.plan(4);
+        t.plan(5);
 
         var reader = new GeoExt.data.AttributeReader({}, [
             "name",
             "type",
-            "restriction"
+            "restriction",
+            {name: "nillable", type: "boolean"}
         ]);
 
         var records = reader.read({responseXML : doc});
@@ -26,10 +27,11 @@
 
         var record = records.records[2];
 
-        //2 tests -- testing the fields of a record
+        //4 tests -- testing the fields of a record
         t.eq(record.get("name"), "STATE_FIPS", "[1] correct attribute name");
-        t.eq(record.get("type"), "xsd:string", "[2] correct attribute type name");
-        t.eq(record.get("restriction").maxLength, "2", "[3] correct attribute restriction");
+        t.eq(record.get("nillable"), false, "[2] correct attribute nillable");
+        t.eq(record.get("type"), "xsd:string", "[3] correct attribute type name");
+        t.eq(record.get("restriction").maxLength, "2", "[4] correct attribute restriction");
     }
 
     function test_read_feature(t) {

Modified: core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.js
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.js	2011-10-05 06:23:21 UTC (rev 2845)
+++ core/trunk/geoext/tests/lib/GeoExt/data/AttributeReader.js	2011-10-05 08:00:33 UTC (rev 2846)
@@ -8,7 +8,7 @@
         '<xsd:sequence>' +
           '<xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiSurfacePropertyType"/>' +
           '<xsd:element maxOccurs="1" minOccurs="0" name="STATE_NAME" nillable="true" type="xsd:string"/>' +
-          '<xsd:element maxOccurs="1" minOccurs="0" name="STATE_FIPS" nillable="true">' +
+          '<xsd:element maxOccurs="1" minOccurs="0" name="STATE_FIPS" nillable="false">' +
             '<xsd:simpleType>' +
               '<xsd:restriction base="xsd:string">' +
                 '<xsd:maxLength value="2"/>' +



More information about the Commits mailing list