add support for handle attribute in Format.WFST, r=ahocevar (closes #3412)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12170 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -224,6 +224,7 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
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 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
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 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.writeNode(name, feature, node);
|
||||
this.writeNode(name, {
|
||||
feature: feature,
|
||||
options: options
|
||||
}, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,15 +294,24 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
});
|
||||
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 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user