[OpenLayers-Commits] r12170 - in trunk/openlayers: lib/OpenLayers/Format/WFST tests/Format/WFST

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Jul 15 05:44:09 EDT 2011


Author: bartvde
Date: 2011-07-15 02:44:08 -0700 (Fri, 15 Jul 2011)
New Revision: 12170

Modified:
   trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
   trunk/openlayers/tests/Format/WFST/v1.html
Log:
add support for handle attribute in Format.WFST, r=ahocevar (closes #3412)

Modified: trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-07-14 18:36:48 UTC (rev 12169)
+++ trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-07-15 09:44:08 UTC (rev 12170)
@@ -224,6 +224,7 @@
                     attributes: {
                         service: "WFS",
                         version: this.version,
+                        handle: options && options.handle,
                         outputFormat: options && options.outputFormat,
                         maxFeatures: options && options.maxFeatures,
                         "xsi:schemaLocation": this.schemaLocationAttr(options)
@@ -240,15 +241,16 @@
                 return node;
             },
             "Transaction": function(obj) {
+                var options = obj && obj.options;
                 var node = this.createElementNSPlus("wfs:Transaction", {
                     attributes: {
                         service: "WFS",
-                        version: this.version
+                        version: this.version,
+                        handle: options && options.handle
                     }
                 });
                 var i, len;
                 var features = obj && obj.features;
-                var options = obj && obj.options;
                 if(features) {
                     var name, feature, geometry;
                     for(i=0, len=features.length; i<len; ++i) {
@@ -267,7 +269,10 @@
                                     }
                                 }
                             }
-                            this.writeNode(name, feature, node);
+                            this.writeNode(name, {
+                                feature: feature, 
+                                options: options
+                            }, node);
                         }
                     }
                 }
@@ -289,15 +294,24 @@
                 });
                 return node;
             },
-            "Insert": function(feature) {
-                var node = this.createElementNSPlus("wfs:Insert");
+            "Insert": function(obj) {
+                var feature = obj.feature;
+                var options = obj.options;
+                var node = this.createElementNSPlus("wfs:Insert", {
+                    attributes: {
+                        handle: options && options.handle
+                    }
+                });
                 this.srsName = this.getSrsName(feature);
                 this.writeNode("feature:_typeName", feature, node);
                 return node;
             },
-            "Update": function(feature) {
+            "Update": function(obj) {
+                var feature = obj.feature;
+                var options = obj.options;
                 var node = this.createElementNSPlus("wfs:Update", {
                     attributes: {
+                        handle: options && options.handle,
                         typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
                             this.featureType
                     }
@@ -355,9 +369,12 @@
                 }
                 return node;
             },
-            "Delete": function(feature) {
+            "Delete": function(obj) {
+                var feature = obj.feature;
+                var options = obj.options;
                 var node = this.createElementNSPlus("wfs:Delete", {
                     attributes: {
+                        handle: options && options.handle,
                         typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
                             this.featureType
                     }

Modified: trunk/openlayers/tests/Format/WFST/v1.html
===================================================================
--- trunk/openlayers/tests/Format/WFST/v1.html	2011-07-14 18:36:48 UTC (rev 12169)
+++ trunk/openlayers/tests/Format/WFST/v1.html	2011-07-15 09:44:08 UTC (rev 12170)
@@ -47,11 +47,11 @@
 
         t.plan(7);
         var snippets = {
-            "GetFeature": {maxFeatures: 1, outputFormat: 'json'},
-            "Transaction": null,
-            "Insert": insertFeature,
-            "Update": updateFeature,
-            "Delete": deleteFeature
+            "GetFeature": {handle: "handle_g", maxFeatures: 1, outputFormat: 'json'},
+            "Transaction": {handle: "handle_t"},
+            "Insert": {feature: insertFeature, options: {handle: "handle_i"}},
+            "Update": {feature: updateFeature, options: {handle: "handle_u"}},
+            "Delete": {feature: deleteFeature, options: {handle: "handle_d"}}
         }
 
         var arg;
@@ -65,14 +65,14 @@
         updateFeature.modified = {geometry: updateFeature.geometry.clone()};
         updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
         var expected = readXML("UpdateModified");
-        var got = format.writers["wfs"]["Update"].apply(format, [updateFeature]);
+        var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
         t.xml_eq(got, expected, "Update request for feature with modified geometry created correctly");
         
         updateFeature.modified.attributes = {foo: "bar"};
         updateFeature.attributes.foo = "baz";
         delete updateFeature.modified.geometry;
         var expected = readXML("UpdateModifiedNoGeometry");
-        var got = format.writers["wfs"]["Update"].apply(format, [updateFeature]);
+        var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
         t.xml_eq(got, expected, "Update request for feature with no modified geometry but modified attributes created correctly");
     }
 
@@ -114,7 +114,7 @@
 
         t.plan(1);
         var snippets = {
-            "UpdateNoGeometry": feature
+            "UpdateNoGeometry": {feature: feature}
         }
 
         var arg;
@@ -140,7 +140,7 @@
 
         t.plan(1);
         var snippets = {
-            "UpdateNullGeometry": feature
+            "UpdateNullGeometry": {feature: feature}
         };
 
         var arg;
@@ -265,7 +265,7 @@
 --></div>
 
 <div id="GetFeature"><!--
-<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" outputFormat="json" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_g" outputFormat="json" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <wfs:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
 </wfs:GetFeature>
 --></div>
@@ -321,7 +321,7 @@
 </wfs:Transaction>
 --></div>
 <div id="Insert"><!--
-<wfs:Insert xmlns:wfs="http://www.opengis.net/wfs">
+<wfs:Insert xmlns:wfs="http://www.opengis.net/wfs" handle="handle_i">
     <feature:states xmlns:feature="http://www.openplans.org/topp">
         <feature:the_geom>
             <gml:Point xmlns:gml="http://www.opengis.net/gml">
@@ -333,7 +333,7 @@
 </wfs:Insert>
 --></div>
 <div id="Update"><!--
-<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" handle="handle_u" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
     <wfs:Property>
         <wfs:Name>the_geom</wfs:Name>
         <wfs:Value>
@@ -388,7 +388,7 @@
 </wfs:Update>
 --></div>
 <div id="Delete"><!--
-<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" handle="handle_d" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
         <ogc:FeatureId fid="fid.37"/>
     </ogc:Filter>



More information about the Commits mailing list