[OpenLayers-Commits] r12123 - in trunk/openlayers: lib/OpenLayers/Format/WFST lib/OpenLayers/Protocol/WFS tests/Format/WFST

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jun 22 03:14:16 EDT 2011


Author: bartvde
Date: 2011-06-22 00:14:15 -0700 (Wed, 22 Jun 2011)
New Revision: 12123

Modified:
   trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
   trunk/openlayers/lib/OpenLayers/Protocol/WFS/v1.js
   trunk/openlayers/tests/Format/WFST/v1.html
Log:
add support for wfs:Native, r=tschaub (closes #3349)

Modified: trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-06-22 06:30:45 UTC (rev 12122)
+++ trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js	2011-06-22 07:14:15 UTC (rev 12123)
@@ -173,12 +173,16 @@
      *
      * Parameters:
      * features - {Array(<OpenLayers.Feature.Vector>)} A list of features.
+     * options - {Object}
      *
      * Returns:
      * {String} A serialized WFS transaction.
      */
-    write: function(features) {
-        var node = this.writeNode("wfs:Transaction", features);
+    write: function(features, options) {
+        var node = this.writeNode("wfs:Transaction", {
+            features:features,
+            options: options
+        });
         var value = this.schemaLocationAttr();
         if(value) {
             this.setAttributeNS(
@@ -216,16 +220,19 @@
                 }
                 return node;
             },
-            "Transaction": function(features) {
+            "Transaction": function(obj) {
                 var node = this.createElementNSPlus("wfs:Transaction", {
                     attributes: {
                         service: "WFS",
                         version: this.version
                     }
                 });
+                var i, len;
+                var features = obj && obj.features;
+                var options = obj && obj.options;
                 if(features) {
                     var name, feature;
-                    for(var i=0, len=features.length; i<len; ++i) {
+                    for(i=0, len=features.length; i<len; ++i) {
                         feature = features[i];
                         name = this.stateName[feature.state];
                         if(name) {
@@ -233,8 +240,24 @@
                         }
                     }
                 }
+                if (options && options.nativeElements) {
+                    for (i=0, len=options.nativeElements.length; i<len; ++i) {
+                        this.writeNode("wfs:Native", 
+                            options.nativeElements[i], node);
+                    }
+                }
                 return node;
             },
+            "Native": function(nativeElement) {
+                var node = this.createElementNSPlus("wfs:Native", {
+                    attributes: {
+                        vendorId: nativeElement.vendorId,
+                        safeToIgnore: nativeElement.safeToIgnore
+                    },
+                    value: nativeElement.value
+                });
+                return node;
+            },
             "Insert": function(feature) {
                 var node = this.createElementNSPlus("wfs:Insert");
                 this.srsName = this.getSrsName(feature);

Modified: trunk/openlayers/lib/OpenLayers/Protocol/WFS/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Protocol/WFS/v1.js	2011-06-22 06:30:45 UTC (rev 12122)
+++ trunk/openlayers/lib/OpenLayers/Protocol/WFS/v1.js	2011-06-22 07:14:15 UTC (rev 12123)
@@ -294,7 +294,15 @@
      *
      * Parameters:
      * features - {Array(<OpenLayers.Feature.Vector>)}
+     * options - {Object}
      *
+     * Valid options properties:
+     * nativeElements - {Array({Object})} Array of objects with information for writing
+     * out <Native> elements, these objects have vendorId, safeToIgnore and
+     * value properties. The <Native> element is intended to allow access to 
+     * vendor specific capabilities of any particular web feature server or 
+     * datastore.
+     *
      * Returns:
      * {<OpenLayers.Protocol.Response>} A response object with a features
      *     property containing any insertIds and a priv property referencing

Modified: trunk/openlayers/tests/Format/WFST/v1.html
===================================================================
--- trunk/openlayers/tests/Format/WFST/v1.html	2011-06-22 06:30:45 UTC (rev 12122)
+++ trunk/openlayers/tests/Format/WFST/v1.html	2011-06-22 07:14:15 UTC (rev 12123)
@@ -63,6 +63,30 @@
         }
     }
 
+    function test_writeNative(t) {
+        t.plan(1);
+        var format = new OpenLayers.Format.WFST({
+            featureNS: "http://www.openplans.org/topp",
+            featureType: "states",
+            version: "1.1.0",
+            featurePrefix: "topp",
+            geometryName: null
+        });
+        var output = format.write(null, {nativeElements: [
+            {
+                vendorId: "ORACLE",
+                safeToIgnore: true,
+                value: "ALTER SESSION ENABLE PARALLEL DML"
+            }, {
+                vendorId: "ORACLE",
+                safeToIgnore: false,
+                value: "Another native line goes here"
+            }]
+        });
+        var expected = '<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Native vendorId="ORACLE" safeToIgnore="true">ALTER SESSION ENABLE PARALLEL DML</wfs:Native><wfs:Native vendorId="ORACLE" safeToIgnore="false">Another native line goes here</wfs:Native></wfs:Transaction>';
+        t.xml_eq(output, expected, "Native elements written out correctly");
+    }
+
     function test_write_no_geometry(t) {
         var format = new OpenLayers.Format.WFST({
             featureNS: "http://www.openplans.org/topp",



More information about the Commits mailing list