[Geoserver-devel] accessing the store from transaction plugin

I'm trying to wriite a WFS transaction plugin to determine the 'damaged' area
as a result of the transaction. I've got a prototype version that does what
I need, but it's tightly coupled to the core WFS code (in Transaction.java).
I'm trying to move the logic into a proper pluging (in the beforeTransaction
and afterTransaction event handlers). These event handlers are passed a
TransactionType.

I've been able to get much of what I need from the transactiontype, but now
I need to access the same store (postgres) that will be used for the
transaction. It looks to me like the key is to be able to access the
'catalog' and catalog.getFeatureTypeInfo. I've looked at code in vain to see
how I get access to this context from within my handler, can someone please
provide an hint?

Regards,

Tom
--
View this message in context: http://www.nabble.com/accessing-the-store-from-transaction-plugin-tp22248045p22248045.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

tlaverty wrote:

I'm trying to wriite a WFS transaction plugin to determine the 'damaged' area
as a result of the transaction. I've got a prototype version that does what
I need, but it's tightly coupled to the core WFS code (in Transaction.java).
I'm trying to move the logic into a proper pluging (in the beforeTransaction
and afterTransaction event handlers). These event handlers are passed a
TransactionType.

I've been able to get much of what I need from the transactiontype, but now
I need to access the same store (postgres) that will be used for the
transaction. It looks to me like the key is to be able to access the
'catalog' and catalog.getFeatureTypeInfo. I've looked at code in vain to see
how I get access to this context from within my handler, can someone please
provide an hint?

Well, since your plugin is declared in Spring, you can add a dependency
to the "catalog" bean declared in the main module spring context, which
  is the catalog (the spring beans declared in each module are available
to all other modules to use).

However, I'm not sure why you want to access the store, that might not
be a good idea, if there is any feature type transformation in the pipe,
accessing the store directly will bypass it. As a rule of thumb always
try to use FeatureSource/FeatureStore instead (so access the featuretypeinfo and then grab the feature source, eventually cast to
FeatureStore if you need write access).

Cheers
Andrea

tlaverty wrote:

I'm trying to wriite a WFS transaction plugin to determine the 'damaged' area
as a result of the transaction.

Actually,
the transaction plugin inherits from transaction listener, that gives you a TransactionEvent, which in turn contains the modified feature
  collection, you can just ask for the bounds of that collection and
you're done.

Cheers
Andrea

Andrea,

Thanks very much, your advice was super-helpful for a newb to the geoserver
internals like me.

The final challenge I have is getting the fid of a newly inserted feature.
In my non-plugin version I'm able to access the TransactionResponseType
result var and get the fid after an insert. Is that same information
available anywhere to a plugin?

Thanks,

Tom

Andrea Aime-4 wrote:

tlaverty wrote:

I'm trying to wriite a WFS transaction plugin to determine the 'damaged'
area
as a result of the transaction.

Actually,
the transaction plugin inherits from transaction listener, that gives
you a TransactionEvent, which in turn contains the modified feature
  collection, you can just ask for the bounds of that collection and
you're done.

Cheers
Andrea

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
-OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
-Strategies to boost innovation and cut costs with open source
participation
-Receive a $600 discount off the registration fee with the source code:
SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
View this message in context: http://www.nabble.com/accessing-the-store-from-transaction-plugin-tp22248045p22254206.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

tlaverty ha scritto:

Andrea,

Thanks very much, your advice was super-helpful for a newb to the geoserver
internals like me.

The final challenge I have is getting the fid of a newly inserted feature.
In my non-plugin version I'm able to access the TransactionResponseType
result var and get the fid after an insert. Is that same information
available anywhere to a plugin?

Hum, good question. Does the the feature collection attached to the
event contains feature with the updated fid? (haven't checked).

If not, I guess we need to amend the TransactionPlugin interface
and turn:

void afterTransaction(TransactionType request, boolean committed);

into

void afterTransaction(TransactionType request, TransactionResponseType response, boolean committed);

If the latter is what you need, please open a improvement report on
jira.codehaus.org, I'll handle it as time allows.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.