[Geoserver-users] WFS-T on PostGIS: Insert a feature comprising multiple tables

<<re-post of question in text format>>

Hi Geoserver-users and developers,

i have a question:

I have to create a WFS-T service backed by PostGIS using GeoServer. The WFS-T is supposed to insert, update a delete features of one certain type.

Problem: A feature is made up of one main table "event". The "event" table contains the only geometry. The event has a many-to-many relationship to a "category" table. I.e. the result of one WFS-T transaction has to be an INSERT on the "event" table plus several INSERTs on the "event_category" table. "event_category" is just a N:M table consisting of the primary key of "event" and "category". The primary keys on the tables are autogenerated by PostGIS.
AFAIK there is no simple solution for such a constellation.

1) Which options do I have? Use app schema? Are there any extension points I can use to alter the interaction with the database? I am a Java Developer.
2) What do you recommend?

Best regards,
waterman

On Wed, Jan 7, 2015 at 8:52 PM, <zuelpicher-wall-40@anonymised.com> wrote:

<<re-post of question in text format>>

Hi Geoserver-users and developers,

i have a question:

I have to create a WFS-T service backed by PostGIS using GeoServer. The
WFS-T is supposed to insert, update a delete features of one certain type.

Problem: A feature is made up of one main table "event". The "event" table
contains the only geometry. The event has a many-to-many relationship to a
"category" table. I.e. the result of one WFS-T transaction has to be an
INSERT on the "event" table plus several INSERTs on the "event_category"
table. "event_category" is just a N:M table consisting of the primary key
of "event" and "category". The primary keys on the tables are autogenerated
by PostGIS.
AFAIK there is no simple solution for such a constellation.

1) Which options do I have? Use app schema? Are there any extension points
I can use to alter the interaction with the database? I am a Java Developer.
2) What do you recommend?

You are right that in order to change multiple tables, you should be
working against complex features.
The app-schema data store is the only source of complex features GeoServer
has, its architecture is complex,
does not support editing, and has never been really though out to allow
editing.
In fact, while setting up the mappings from N simple feature sources to the
complex feature tree, you can
make a number of transformations that are not invertible, thus rendering
the overall complex feature
not really editable (or at least, partially not editable).

Anyways, have a look at the app-schema documentation here:
http://docs.geoserver.org/stable/en/user/data/app-schema/
and the store code here:
https://github.com/geotools/geotools/tree/master/modules/extension/app-schema

it should give you a feel of what you're up against

Other softwares are working with a simplified way of doing things, they
basically store
in the database into a field the GML of the full feature, in its complex
state, and
map out some of the fields as flat columns in the same table to allow for
fast flitering
and map rendering.
This would probably be an easier approach to the problem.

And oh, you will also have to upgrade the GeoTools GML encoder to parse
complex
features, right now there is only support for encode them.

All in all it's a significant chunk of work, no matter how you try to
address it.

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

-------------------------------------------------------