Add Insert, Update and Delete writers
This change also adds some type annotations for better type checking, introduces different write options for writing transactions and queries, and provides new writeGetFeature and writeTransaction methods.
This commit is contained in:
@@ -19,17 +19,15 @@ describe('ol.parser.ogc.WFS', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeature.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
|
||||
apply(p, [{
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureTypes: ['states'],
|
||||
featurePrefix: 'topp',
|
||||
handle: 'handle_g',
|
||||
maxFeatures: 1,
|
||||
outputFormat: 'json'
|
||||
}
|
||||
]);
|
||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
||||
var output = p.writeGetFeature({
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureTypes: ['states'],
|
||||
featurePrefix: 'topp',
|
||||
handle: 'handle_g',
|
||||
maxFeatures: 1,
|
||||
outputFormat: 'json'
|
||||
});
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -38,12 +36,44 @@ describe('ol.parser.ogc.WFS', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Transaction.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||
var output = p.writers[p.defaultNamespaceURI]['Transaction'].
|
||||
apply(p, [{
|
||||
options: {handle: 'handle_t'}
|
||||
}
|
||||
]);
|
||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
||||
var output = p.writeTransaction(null, null, null, {handle: 'handle_t'});
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handles writing out transactions', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/TransactionMulti.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var parser = new ol.parser.ogc.WFS_v1_0_0();
|
||||
|
||||
var insertFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
foo: 'bar',
|
||||
nul: null
|
||||
});
|
||||
var inserts = [insertFeature];
|
||||
var updateFeature = new ol.Feature({
|
||||
the_geom: new ol.geom.MultiPoint([[1, 2]]),
|
||||
foo: 'bar',
|
||||
// null value gets Property element with no Value
|
||||
nul: null,
|
||||
// undefined value means don't create a Property element
|
||||
unwritten: undefined
|
||||
});
|
||||
updateFeature.setId('fid.42');
|
||||
var updates = [updateFeature];
|
||||
|
||||
var deleteFeature = new ol.Feature();
|
||||
deleteFeature.setId('fid.37');
|
||||
var deletes = [deleteFeature];
|
||||
|
||||
var output = parser.writeTransaction(inserts, updates, deletes, {
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureType: 'states',
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -52,7 +82,7 @@ describe('ol.parser.ogc.WFS', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/Native.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.WFS_v1_1_0();
|
||||
var output = p.write(null, {nativeElements: [{
|
||||
var output = p.writeTransaction(null, null, null, {nativeElements: [{
|
||||
vendorId: 'ORACLE',
|
||||
safeToIgnore: true,
|
||||
value: 'ALTER SESSION ENABLE PARALLEL DML'
|
||||
@@ -70,14 +100,12 @@ describe('ol.parser.ogc.WFS', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.WFS_v1_0_0();
|
||||
var output = p.writers[p.defaultNamespaceURI]['GetFeature'].
|
||||
apply(p, [{
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureTypes: ['states', 'cities'],
|
||||
featurePrefix: 'topp'
|
||||
}
|
||||
]);
|
||||
expect(goog.dom.xml.loadXml(p.serialize(output))).to.xmleql(xml);
|
||||
var output = p.writeGetFeature({
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
featureTypes: ['states', 'cities'],
|
||||
featurePrefix: 'topp'
|
||||
});
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -87,6 +115,8 @@ describe('ol.parser.ogc.WFS', function() {
|
||||
});
|
||||
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.parser.ogc.WFS');
|
||||
goog.require('ol.parser.ogc.WFS_v1_0_0');
|
||||
goog.require('ol.parser.ogc.WFS_v1_1_0');
|
||||
|
||||
@@ -1 +1 @@
|
||||
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_t" />
|
||||
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.0.0" handle="handle_t" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"/>
|
||||
|
||||
45
test/spec/ol/parser/ogc/xml/wfs_v1/TransactionMulti.xml
Normal file
45
test/spec/ol/parser/ogc/xml/wfs_v1/TransactionMulti.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
|
||||
<wfs:Insert>
|
||||
<feature:states xmlns:feature="http://www.openplans.org/topp">
|
||||
<feature:the_geom>
|
||||
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
|
||||
<gml:pointMember>
|
||||
<gml:Point>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
|
||||
</gml:Point>
|
||||
</gml:pointMember>
|
||||
</gml:MultiPoint>
|
||||
</feature:the_geom>
|
||||
<feature:foo>bar</feature:foo>
|
||||
</feature:states>
|
||||
</wfs:Insert>
|
||||
<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
|
||||
<wfs:Property>
|
||||
<wfs:Name>the_geom</wfs:Name>
|
||||
<wfs:Value>
|
||||
<gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
|
||||
<gml:pointMember>
|
||||
<gml:Point>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
|
||||
</gml:Point>
|
||||
</gml:pointMember>
|
||||
</gml:MultiPoint>
|
||||
</wfs:Value>
|
||||
</wfs:Property>
|
||||
<wfs:Property>
|
||||
<wfs:Name>foo</wfs:Name>
|
||||
<wfs:Value>bar</wfs:Value>
|
||||
</wfs:Property>
|
||||
<wfs:Property>
|
||||
<wfs:Name>nul</wfs:Name>
|
||||
</wfs:Property>
|
||||
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
||||
<ogc:FeatureId fid="fid.42"/>
|
||||
</ogc:Filter>
|
||||
</wfs:Update>
|
||||
<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" 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>
|
||||
</wfs:Delete>
|
||||
</wfs:Transaction>
|
||||
Reference in New Issue
Block a user