diff --git a/web/client/test-resources/wfst/delete/museam_1_1_0.xml b/web/client/test-resources/wfst/delete/museam_1_1_0.xml
new file mode 100644
index 00000000000..302d269505e
--- /dev/null
+++ b/web/client/test-resources/wfst/delete/museam_1_1_0.xml
@@ -0,0 +1 @@
+
diff --git a/web/client/test-resources/wfst/insert/Wyoming_1_1_0.xml b/web/client/test-resources/wfst/insert/Wyoming_1_1_0.xml
index 7344df06491..824fd65b5af 100644
--- a/web/client/test-resources/wfst/insert/Wyoming_1_1_0.xml
+++ b/web/client/test-resources/wfst/insert/Wyoming_1_1_0.xml
@@ -1 +1 @@
-Wyoming56MtnWY251500.8011848.1494535881198251688392270072265811645611536792810929632078681311271419291570.50.583202-104.053108 41.698246 -104.054993 41.564247 -104.053505 41.388107 -104.051201 41.003227 -104.933968 40.994305 -105.278259 40.996365 -106.202896 41.000111 -106.328545 41.001316 -106.864838 40.998489 -107.303436 41.000168 -107.918037 41.00341 -109.047638 40.998474 -110.001457 40.997646 -110.062477 40.99794 -111.050285 40.996635 -111.050911 41.25848 -111.050323 41.578648 -111.047951 41.996265 -111.046028 42.503323 -111.048447 43.019962 -111.04673 43.284813 -111.045998 43.515606 -111.049629 43.982632 -111.050789 44.473396 -111.050842 44.664562 -111.05265 44.995766 -110.428894 44.992348 -110.392006 44.998688 -109.994789 45.002853 -109.798653 44.99958 -108.624573 44.997643 -108.258568 45.00016 -107.893715 44.999813 -106.258644 44.996174 -106.020576 44.997227 -105.084465 44.999832 -105.04126 45.001091 -104.059349 44.997349 -104.058975 44.574368 -104.060547 44.181843 -104.059242 44.145844 -104.05899 43.852928 -104.057426 43.503738 -104.05867 43.47916 -104.05571 43.003094 -104.055725 42.614704 -104.053009 41.999851 -104.053108 41.698246
+Wyoming56MtnWY251500.8011848.1494535881198251688392270072265811645611536792810929632078681311271419291570.50.583202-104.053108 41.698246 -104.054993 41.564247 -104.053505 41.388107 -104.051201 41.003227 -104.933968 40.994305 -105.278259 40.996365 -106.202896 41.000111 -106.328545 41.001316 -106.864838 40.998489 -107.303436 41.000168 -107.918037 41.00341 -109.047638 40.998474 -110.001457 40.997646 -110.062477 40.99794 -111.050285 40.996635 -111.050911 41.25848 -111.050323 41.578648 -111.047951 41.996265 -111.046028 42.503323 -111.048447 43.019962 -111.04673 43.284813 -111.045998 43.515606 -111.049629 43.982632 -111.050789 44.473396 -111.050842 44.664562 -111.05265 44.995766 -110.428894 44.992348 -110.392006 44.998688 -109.994789 45.002853 -109.798653 44.99958 -108.624573 44.997643 -108.258568 45.00016 -107.893715 44.999813 -106.258644 44.996174 -106.020576 44.997227 -105.084465 44.999832 -105.04126 45.001091 -104.059349 44.997349 -104.058975 44.574368 -104.060547 44.181843 -104.059242 44.145844 -104.05899 43.852928 -104.057426 43.503738 -104.05867 43.47916 -104.05571 43.003094 -104.055725 42.614704 -104.053009 41.999851 -104.053108 41.698246
diff --git a/web/client/test-resources/wfst/insert/museam_1_1_0.xml b/web/client/test-resources/wfst/insert/museam_1_1_0.xml
index 7bde3418697..1a088901fc2 100644
--- a/web/client/test-resources/wfst/insert/museam_1_1_0.xml
+++ b/web/client/test-resources/wfst/insert/museam_1_1_0.xml
@@ -1 +1 @@
-museampics/22037827-Ti.jpgpics/22037827-L.jpg-74.0104611 40.70758763
+museampics/22037827-Ti.jpgpics/22037827-L.jpg-74.0104611 40.70758763
diff --git a/web/client/test-resources/wfst/update/museam_1_1_0.xml b/web/client/test-resources/wfst/update/museam_1_1_0.xml
new file mode 100644
index 00000000000..99b59fbedcb
--- /dev/null
+++ b/web/client/test-resources/wfst/update/museam_1_1_0.xml
@@ -0,0 +1 @@
+NAMEnewName
diff --git a/web/client/utils/ogc/Filter/base.js b/web/client/utils/ogc/Filter/base.js
new file mode 100644
index 00000000000..6d205c59a5a
--- /dev/null
+++ b/web/client/utils/ogc/Filter/base.js
@@ -0,0 +1,6 @@
+const fidFilter = (fid) =>
+ ``;
+
+module.exports = {
+ fidFilter
+};
diff --git a/web/client/utils/ogc/Filter.js b/web/client/utils/ogc/Filter/index.js
similarity index 100%
rename from web/client/utils/ogc/Filter.js
rename to web/client/utils/ogc/Filter/index.js
diff --git a/web/client/utils/ogc/WFST/v1_1_0/delete.js b/web/client/utils/ogc/WFST/v1_1_0/delete.js
new file mode 100644
index 00000000000..1a897a7c5cf
--- /dev/null
+++ b/web/client/utils/ogc/WFST/v1_1_0/delete.js
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2017, GeoSolutions Sas.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+
+const {fidFilter} = require('../../Filter/base');
+const {getTypeName} = require('../../WFS/base');
+/**
+ * Generate WFS delete features
+ * @function
+ * @param {string} content The content of the delete request, e.g. the filter to use
+ * @param {object} describeFeatureType describeFeatureType object
+ * @return {string} the XML for the update
+ */
+const deleteFeatures = (content, typeName) =>
+ `${content}`;
+const deleteById = (fid, typeName) => deleteFeatures(fidFilter(fid), typeName);
+const deleteFeature = (feature, describe) => deleteById(feature.features && feature.features.length === 1 ? feature.features[0].id : feature.id, getTypeName(describe));
+module.exports = {
+ deleteFeatures,
+ deleteById,
+ deleteFeature
+};
diff --git a/web/client/utils/ogc/WFST/v1_1_0/index.js b/web/client/utils/ogc/WFST/v1_1_0/index.js
index a58fe1e69d2..8caedf3b262 100644
--- a/web/client/utils/ogc/WFST/v1_1_0/index.js
+++ b/web/client/utils/ogc/WFST/v1_1_0/index.js
@@ -7,8 +7,14 @@
*/
const {transaction} = require('./transaction');
const {insert} = require('./insert');
-
+const {update, property} = require('./update');
+const {deleteFeature, deleteFeatures, deleteById} = require('./delete');
module.exports = {
insert,
+ update,
+ property,
+ deleteFeature,
+ deleteFeatures,
+ deleteById,
transaction
};
diff --git a/web/client/utils/ogc/WFST/v1_1_0/insert.js b/web/client/utils/ogc/WFST/v1_1_0/insert.js
index 4dc2db2420a..a5dfdabcadb 100644
--- a/web/client/utils/ogc/WFST/v1_1_0/insert.js
+++ b/web/client/utils/ogc/WFST/v1_1_0/insert.js
@@ -24,7 +24,7 @@ const feature = (f, describeFeatureType) => `<${getTypeName(describeFeatureType)
const features = (fs, describeFeatureType) => fs.map(f => feature(f, describeFeatureType)).join("");
const insert = (fs, describeFeatureType) => ''
- + `${features(fs.features, describeFeatureType)}`
+ + `${features(fs.features || fs, describeFeatureType)}`
+ '';
module.exports = {
diff --git a/web/client/utils/ogc/WFST/v1_1_0/transaction.js b/web/client/utils/ogc/WFST/v1_1_0/transaction.js
index 6b767ed6cba..524eb993222 100644
--- a/web/client/utils/ogc/WFST/v1_1_0/transaction.js
+++ b/web/client/utils/ogc/WFST/v1_1_0/transaction.js
@@ -12,6 +12,7 @@ const transaction = (operations, schemaLocation) => ' ''
+ + `${propName}`
+ + `${value}`
+ + '';
+
+/**
+ * Generate update XML.
+ * @function
+ * @param {string} content the properties to update and/or features to use (inXML)
+ * @param {object} describeFeatureType describeFeatureType object
+ * @return {string} the XML for the update
+ */
+const update = (content, describeFeatureType) => `${Array.isArray(content) ? content.join("") : content}`;
+module.exports = {
+ update,
+ property
+};
diff --git a/web/client/utils/ogc/__tests__/WFS-T-test.js b/web/client/utils/ogc/__tests__/WFS-T-test.js
index c8bb2278835..2a42a010288 100644
--- a/web/client/utils/ogc/__tests__/WFS-T-test.js
+++ b/web/client/utils/ogc/__tests__/WFS-T-test.js
@@ -7,7 +7,8 @@
*/
const expect = require('expect');
-const {insert, transaction} = require('../WFST');
+const {insert, update, property, deleteFeature, transaction} = require('../WFST');
+const {fidFilter} = require('../Filter/base');
const {featureTypeSchema} = require('../WFS/base');
const describeStates = require('json-loader!../../../test-resources/wfs/describe-states.json');
const describePois = require('json-loader!../../../test-resources/wfs/describe-pois.json');
@@ -15,7 +16,8 @@ const wyoming = require('json-loader!../../../test-resources/wfs/Wyoming.json');
const museam = require('json-loader!../../../test-resources/wfs/museam.json');
const expectedInsertWyoming = require('raw-loader!../../../test-resources/wfst/insert/Wyoming_1_1_0.xml');
const expectedInsertmuseam = require('raw-loader!../../../test-resources/wfst/insert/museam_1_1_0.xml');
-
+const expectedDelete = require('raw-loader!../../../test-resources/wfst/delete/museam_1_1_0.xml');
+const expectedUpdate = require('raw-loader!../../../test-resources/wfst/update/museam_1_1_0.xml');
describe('Test WFS-T request bodies generation', () => {
it('WFS-T insert', () => {
const result = insert(wyoming, describeStates);
@@ -36,4 +38,17 @@ describe('Test WFS-T request bodies generation', () => {
expect(result).toExist();
expect(result + '\n').toEqual(expectedInsertmuseam);
});
+ it('WFS-T transaction with delete', () => {
+ const result = transaction([deleteFeature(museam, describePois)], featureTypeSchema(describePois));
+ expect(result).toExist();
+ expect(result + '\n').toEqual(expectedDelete);
+ });
+ it('WFS-T transaction with update', () => {
+ const result = transaction(
+ [update([property("NAME", "newName"), fidFilter("poi.7")], describePois)
+ ],
+ featureTypeSchema(describePois));
+ expect(result).toExist();
+ expect(result + '\n').toEqual(expectedUpdate);
+ });
});