01: package org.geotools.catalog.postgis;
02:
03: /*
04: * Geotools2 - OpenSource mapping toolkit
05: * http://geotools.org
06: * (C) 2002, Geotools Project Managment Committee (PMC)
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public
10: * License as published by the Free Software Foundation;
11: * version 2.1 of the License.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Lesser General Public License for more details.
17: *
18: */
19: import java.net.URI;
20: import java.net.URISyntaxException;
21: import java.util.Map;
22:
23: import org.geotools.catalog.Catalog;
24: import org.geotools.catalog.DataStoreService;
25: import org.geotools.catalog.GeoResource;
26: import org.geotools.catalog.ServiceInfo;
27: import org.geotools.catalog.defaults.DefaultServiceInfo;
28: import org.geotools.data.DataStore;
29: import org.geotools.data.DataStoreFactorySpi;
30: import org.geotools.data.postgis.PostgisDataStore;
31: import org.geotools.data.postgis.PostgisDataStoreFactory;
32: import org.geotools.util.ProgressListener;
33:
34: public class PostGISService extends DataStoreService {
35:
36: public PostGISService(Catalog parent, Map params,
37: PostgisDataStoreFactory dataStoreFactory) {
38: super (parent, params, dataStoreFactory);
39: }
40:
41: protected GeoResource createGeoResource(String typeName,
42: DataStore dataStore) {
43: return new PostGISGeoResource(this , typeName);
44: }
45:
46: public URI getIdentifier() {
47: //return the jdbc uri
48: Map params = getConnectionParams();
49: String host = (String) params
50: .get(PostgisDataStoreFactory.HOST.key);
51: String port = (String) params
52: .get(PostgisDataStoreFactory.PORT.key);
53: String database = (String) params
54: .get(PostgisDataStoreFactory.DATABASE.key);
55:
56: try {
57: return new URI(null, host, database, null);
58: } catch (URISyntaxException e) {
59: //should not happen
60: return null;
61: }
62: }
63:
64: protected ServiceInfo createMetaData(DataStore dataStore,
65: ProgressListener monitor) {
66: //set the namespace
67: URI schema = null;
68: try {
69: String ns = (String) PostgisDataStoreFactory.NAMESPACE
70: .lookUp(getConnectionParams());
71: if (ns != null) {
72: schema = new URI(ns);
73: }
74: } catch (Exception e) {
75: //do nothing
76: }
77:
78: ServiceInfo info = super .createMetaData(dataStore, monitor);
79:
80: return new DefaultServiceInfo(info.getTitle(), info
81: .getDescription(), info.getAbstract(),
82: info.getSource(), info.getPublisher(), schema, info
83: .getKeywords(), info.getIcon());
84:
85: }
86:
87: }
|