add support for wfs:Native, r=tschaub (closes #3349)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12123 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -173,12 +173,16 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*
|
||||
* 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 @@ 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<len; ++i) {
|
||||
for(i=0, len=features.length; i<len; ++i) {
|
||||
feature = features[i];
|
||||
name = this.stateName[feature.state];
|
||||
if(name) {
|
||||
@@ -233,6 +240,22 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -294,6 +294,14 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user