From 39d97158532517876054c068bed6ce2040651a95 Mon Sep 17 00:00:00 2001 From: bartvde Date: Wed, 22 Jun 2011 07:14:15 +0000 Subject: [PATCH] add support for wfs:Native, r=tschaub (closes #3349) git-svn-id: http://svn.openlayers.org/trunk/openlayers@12123 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/WFST/v1.js | 31 +++++++++++++++++++++++++++---- lib/OpenLayers/Protocol/WFS/v1.js | 8 ++++++++ tests/Format/WFST/v1.html | 24 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Format/WFST/v1.js b/lib/OpenLayers/Format/WFST/v1.js index 07052218aa..f810cc03d6 100644 --- a/lib/OpenLayers/Format/WFST/v1.js +++ b/lib/OpenLayers/Format/WFST/v1.js @@ -173,12 +173,16 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { * * Parameters: * features - {Array()} 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 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { } 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)} + * options - {Object} + * + * Valid options properties: + * nativeElements - {Array({Object})} Array of objects with information for writing + * out elements, these objects have vendorId, safeToIgnore and + * value properties. The element is intended to allow access to + * vendor specific capabilities of any particular web feature server or + * datastore. * * Returns: * {} A response object with a features diff --git a/tests/Format/WFST/v1.html b/tests/Format/WFST/v1.html index 9a01e7f6ae..a65d795e53 100644 --- a/tests/Format/WFST/v1.html +++ b/tests/Format/WFST/v1.html @@ -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 = 'ALTER SESSION ENABLE PARALLEL DMLAnother native line goes here'; + 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",