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: {
|
attributes: {
|
||||||
service: "WFS",
|
service: "WFS",
|
||||||
version: this.version,
|
version: this.version,
|
||||||
|
handle: options && options.handle,
|
||||||
outputFormat: options && options.outputFormat,
|
outputFormat: options && options.outputFormat,
|
||||||
maxFeatures: options && options.maxFeatures,
|
maxFeatures: options && options.maxFeatures,
|
||||||
"xsi:schemaLocation": this.schemaLocationAttr(options)
|
"xsi:schemaLocation": this.schemaLocationAttr(options)
|
||||||
@@ -240,15 +241,16 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
"Transaction": function(obj) {
|
"Transaction": function(obj) {
|
||||||
|
var options = obj && obj.options;
|
||||||
var node = this.createElementNSPlus("wfs:Transaction", {
|
var node = this.createElementNSPlus("wfs:Transaction", {
|
||||||
attributes: {
|
attributes: {
|
||||||
service: "WFS",
|
service: "WFS",
|
||||||
version: this.version
|
version: this.version,
|
||||||
|
handle: options && options.handle
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var i, len;
|
var i, len;
|
||||||
var features = obj && obj.features;
|
var features = obj && obj.features;
|
||||||
var options = obj && obj.options;
|
|
||||||
if(features) {
|
if(features) {
|
||||||
var name, feature, geometry;
|
var name, feature, geometry;
|
||||||
for(i=0, len=features.length; i<len; ++i) {
|
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;
|
return node;
|
||||||
},
|
},
|
||||||
"Insert": function(feature) {
|
"Insert": function(obj) {
|
||||||
var node = this.createElementNSPlus("wfs:Insert");
|
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.srsName = this.getSrsName(feature);
|
||||||
this.writeNode("feature:_typeName", feature, node);
|
this.writeNode("feature:_typeName", feature, node);
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
"Update": function(feature) {
|
"Update": function(obj) {
|
||||||
|
var feature = obj.feature;
|
||||||
|
var options = obj.options;
|
||||||
var node = this.createElementNSPlus("wfs:Update", {
|
var node = this.createElementNSPlus("wfs:Update", {
|
||||||
attributes: {
|
attributes: {
|
||||||
|
handle: options && options.handle,
|
||||||
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
|
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
|
||||||
this.featureType
|
this.featureType
|
||||||
}
|
}
|
||||||
@@ -355,9 +369,12 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
"Delete": function(feature) {
|
"Delete": function(obj) {
|
||||||
|
var feature = obj.feature;
|
||||||
|
var options = obj.options;
|
||||||
var node = this.createElementNSPlus("wfs:Delete", {
|
var node = this.createElementNSPlus("wfs:Delete", {
|
||||||
attributes: {
|
attributes: {
|
||||||
|
handle: options && options.handle,
|
||||||
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
|
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
|
||||||
this.featureType
|
this.featureType
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -47,11 +47,11 @@
|
|||||||
|
|
||||||
t.plan(7);
|
t.plan(7);
|
||||||
var snippets = {
|
var snippets = {
|
||||||
"GetFeature": {maxFeatures: 1, outputFormat: 'json'},
|
"GetFeature": {handle: "handle_g", maxFeatures: 1, outputFormat: 'json'},
|
||||||
"Transaction": null,
|
"Transaction": {handle: "handle_t"},
|
||||||
"Insert": insertFeature,
|
"Insert": {feature: insertFeature, options: {handle: "handle_i"}},
|
||||||
"Update": updateFeature,
|
"Update": {feature: updateFeature, options: {handle: "handle_u"}},
|
||||||
"Delete": deleteFeature
|
"Delete": {feature: deleteFeature, options: {handle: "handle_d"}}
|
||||||
}
|
}
|
||||||
|
|
||||||
var arg;
|
var arg;
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
updateFeature.modified = {geometry: updateFeature.geometry.clone()};
|
updateFeature.modified = {geometry: updateFeature.geometry.clone()};
|
||||||
updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
|
updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
|
||||||
var expected = readXML("UpdateModified");
|
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");
|
t.xml_eq(got, expected, "Update request for feature with modified geometry created correctly");
|
||||||
|
|
||||||
updateFeature.modified.attributes = {foo: "bar"};
|
updateFeature.modified.attributes = {foo: "bar"};
|
||||||
updateFeature.attributes.foo = "baz";
|
updateFeature.attributes.foo = "baz";
|
||||||
delete updateFeature.modified.geometry;
|
delete updateFeature.modified.geometry;
|
||||||
var expected = readXML("UpdateModifiedNoGeometry");
|
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");
|
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);
|
t.plan(1);
|
||||||
var snippets = {
|
var snippets = {
|
||||||
"UpdateNoGeometry": feature
|
"UpdateNoGeometry": {feature: feature}
|
||||||
}
|
}
|
||||||
|
|
||||||
var arg;
|
var arg;
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
|
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
var snippets = {
|
var snippets = {
|
||||||
"UpdateNullGeometry": feature
|
"UpdateNullGeometry": {feature: feature}
|
||||||
};
|
};
|
||||||
|
|
||||||
var arg;
|
var arg;
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
--></div>
|
--></div>
|
||||||
|
|
||||||
<div id="GetFeature"><!--
|
<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:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
|
||||||
</wfs:GetFeature>
|
</wfs:GetFeature>
|
||||||
--></div>
|
--></div>
|
||||||
@@ -321,7 +321,7 @@
|
|||||||
</wfs:Transaction>
|
</wfs:Transaction>
|
||||||
--></div>
|
--></div>
|
||||||
<div id="Insert"><!--
|
<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:states xmlns:feature="http://www.openplans.org/topp">
|
||||||
<feature:the_geom>
|
<feature:the_geom>
|
||||||
<gml:Point xmlns:gml="http://www.opengis.net/gml">
|
<gml:Point xmlns:gml="http://www.opengis.net/gml">
|
||||||
@@ -333,7 +333,7 @@
|
|||||||
</wfs:Insert>
|
</wfs:Insert>
|
||||||
--></div>
|
--></div>
|
||||||
<div id="Update"><!--
|
<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:Property>
|
||||||
<wfs:Name>the_geom</wfs:Name>
|
<wfs:Name>the_geom</wfs:Name>
|
||||||
<wfs:Value>
|
<wfs:Value>
|
||||||
@@ -388,7 +388,7 @@
|
|||||||
</wfs:Update>
|
</wfs:Update>
|
||||||
--></div>
|
--></div>
|
||||||
<div id="Delete"><!--
|
<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:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
||||||
<ogc:FeatureId fid="fid.37"/>
|
<ogc:FeatureId fid="fid.37"/>
|
||||||
</ogc:Filter>
|
</ogc:Filter>
|
||||||
|
|||||||
Reference in New Issue
Block a user