Ziegler Stefan wrote:
> Hi Andrea
> 
> thanks, it works. I was able to add a process.
> Is there an easy way to use the datastores and featuretypes defined in 
> GeoServer? I tried to connect to a postgis database in the execute 
> method of my process:
> 
> Map params= new HashMap();
> params.put("dbtype", "postgis");
> params.put("host", "localhost");
> params.put("port", 5432);
> params.put("database", "xanadu");
> params.put("schema", "chenyx06");
> params.put("user", "stefan");
> params.put("passwd", "XXXXX");
> 
> DataStore datastore = DataStoreFinder.getDataStore( params );
> 
> String tableNameLV03 = "chenyx06-lv03";
> FeatureSource<SimpleFeatureType, SimpleFeature> source = 
> datastore.getFeatureSource( tableNameLV03 );
> 
> This works in a standalone GeoTools project but throws some error here:
> 
> Running org.geoserver.wps.CataisFreeFrameTest
> 21 Feb 21:08:23 ERROR [geoserver.ows] -
> org.geoserver.wps.WPSException: InternalError: 
> java.lang.NullPointerException

It's difficult to say what the NPE is due to without seeing the code,
my guess is that you're not getting any datastore back from the 
datastorefinder (no idea why).

Yes, once you're running from within GeoServer you can have your
process use the catalog and get a datastore.

Try with something like this:

Catalog catalog = GeoServerExtensions.getBean("catalog");
FeatureTypeInfo fti = catalog.getFeatureTypeByName(namespace, name);
fti.getFeatureSource();

(not tested).

However, I'd say it's bad practice for a process to connect to a data
source, it should receive whatever it needs from its inputs instead
(a FeatureCollection with the data you need might be a good idea, not
sure, don't know exactly what you're trying to do).

Cheers
Andrea

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to