2

WFS service in Mapserver directly changes the PostgreSQL table whenever performing a transaction operation such as insert, update or delete.

I want a solution which gives me control over what happens when a transaction request is received from the client.

For example, when a new value is inserted, instead of making changes in original table I want to create another table in SQL which would be a clone of previous one and make changes in that table. So, that the original table remains the same.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185
SomeOne
  • 41
  • 5
  • 1
    Do you mean the ESRI Mapserver? And why did you set the "geoserver" tag? Anyway, yes it is possible to write special code that captures the transaction messages and manipulates them like you wish. I am pretty sure that no standard WFS server has such capabilities included. – user30184 Feb 17 '23 at 11:18
  • Do you want to hide the edits from other users? Otherwise I think it would be easier to let users update the master table and keep a backup table with static data. – user30184 Feb 17 '23 at 12:43
  • Either Mapserver or geoserver both would do. I just want control over transactions. Each user will have his own table cloned from the original version and original one will remain same for everyone. – SomeOne Feb 17 '23 at 16:16
  • This MapServer https://mapserver.org/ does not do transactions at all. You will get better answers by making clear questions. – user30184 Feb 17 '23 at 16:42
  • MapServer.org has wfs-t I think it is called tinyows but it doesn't give custom transaction control – SomeOne Feb 17 '23 at 16:46
  • Right, TinyOWS belongs to the Mapserver family. It was made to support the official WFS standards so missing customization is not surprising. – user30184 Feb 17 '23 at 17:04

2 Answers2

4

Looks like a job for a database trigger. Since you mention PostgreSQL, here is some documentation about the topic: https://www.postgresql.org/docs/current/sql-createtrigger.html

Andrea Aime
  • 17,410
  • 1
  • 18
  • 28
  • I was hoping for something which is more programmable(customizable) instead of triggers. One solution is to write wfs myself using ogc wfs specification but that will take a lot of time – SomeOne Feb 17 '23 at 16:18
  • Certainly yes. Forking some of the open source servers would save some time. – user30184 Feb 17 '23 at 16:44
  • can't find any. Are aware of any such solution – SomeOne Feb 17 '23 at 16:45
  • GeoServer and deegree are maintained Open Source WFS servers. TinyOWS not so well maintained but should work still. When I was involved in a bit similar tweaked WFS-T we captured the transaction messages when they came to web server and split and manipulated them to do custom things. We did not touch the WFS server code. – user30184 Feb 17 '23 at 17:09
  • @user30184 did you use geoserver or deegree when you you were tweaking wfs-t. Any tutorial or guide that I could follow? – SomeOne Feb 18 '23 at 10:25
1

Usually you'd handle this with updateable Views as middlelayer; I outlined the general concept in this answer, using INSTEAD OF triggers, and you'll find more info on DBA.SE.

In your case you'd likely want to use support tables much like ESRI's delta table versioning, where any data modification is logged as a sequence of INSERT (A table) and DELETE (D table) operations, including their respectively modified values, and have the View pull live data from a composition of the base table and the A & D tables.

geozelot
  • 30,050
  • 4
  • 32
  • 56