001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/wms/configuration/AbstractDataSource.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035    ----------------------------------------------------------------------------*/
036    package org.deegree.ogcwebservices.wms.configuration;
037    
038    import java.net.URL;
039    import java.util.Map;
040    
041    import org.deegree.datatypes.QualifiedName;
042    import org.deegree.model.spatialschema.Geometry;
043    import org.deegree.ogcwebservices.OGCWebService;
044    import org.deegree.ogcwebservices.OGCWebServiceException;
045    import org.deegree.ogcwebservices.wms.capabilities.ScaleHint;
046    
047    /**
048     * name of the data source where the WMS can find the data of a layer. the filterServiceClassName element identifies the
049     * filter servive that's responsible for accessing the data.
050     *
051     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
052     * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
053     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
054     */
055    public abstract class AbstractDataSource {
056    
057        /**
058         * A constant indicating a local wcs.
059         */
060        public static final int LOCALWCS = 0;
061    
062        /**
063         * A constant indicating a local wfs.
064         */
065        public static final int LOCALWFS = 1;
066    
067        /**
068         * A constant indicating a remote wms.
069         */
070        public static final int REMOTEWMS = 2;
071    
072        /**
073         * A constant indicating a remote wcs.
074         */
075        public static final int REMOTEWCS = 3;
076    
077        /**
078         * A constant indicating a remote wfs.
079         */
080        public static final int REMOTEWFS = 4;
081    
082        /**
083         * A constant indicating a database
084         */
085        public static final int DATABASE = 5;
086    
087        /**
088         * A constant indicating an external data access
089         */
090        public static final int EXTERNALDATAACCESS = 6;
091    
092        protected OGCWebService ows = null;
093    
094        private URL capabilitiesURL;
095    
096        private ScaleHint scaleHint = null;
097    
098        private QualifiedName name = null;
099    
100        private boolean queryable = false;
101    
102        private boolean failOnException = true;
103    
104        private URL featureInfoTransform = null;
105    
106        private Geometry validArea = null;
107    
108        private int reqTimeLimit = 30;
109    
110        private int type = 0;
111    
112        private URL featureInfoURL;
113    
114        private Map<String, String> dimProps;
115    
116        /**
117         * Creates a new DataSource object.
118         *
119         * @param queryable
120         * @param failOnException
121         * @param name
122         * @param type
123         * @param ows
124         * @param capabilitiesURL
125         * @param scaleHint
126         * @param featureInfoTransform
127         */
128        protected AbstractDataSource( boolean queryable, boolean failOnException, QualifiedName name, int type,
129                                      OGCWebService ows, URL capabilitiesURL, ScaleHint scaleHint, Geometry validArea,
130                                      URL featureInfoTransform, int reqTimeLimit, Map<String, String> dimProps ) {
131            this.scaleHint = scaleHint;
132            this.name = name;
133            this.type = type;
134            this.ows = ows;
135            this.capabilitiesURL = capabilitiesURL;
136            this.failOnException = failOnException;
137            this.queryable = queryable;
138            this.featureInfoTransform = featureInfoTransform;
139            this.validArea = validArea;
140            this.reqTimeLimit = reqTimeLimit;
141            this.dimProps = dimProps;
142        }
143    
144        /**
145         * @return the scale interval the data source is valid
146         */
147        public ScaleHint getScaleHint() {
148            return scaleHint;
149        }
150    
151        /**
152         * @return the name of the data source. The method may returns <tt>null</tt> if so no name is defined and a online
153         *         resource or WFS filter have shall be returned.
154         */
155        public QualifiedName getName() {
156            return name;
157        }
158    
159        /**
160         * @return an instance of the <tt>OGCWebService</tt> that represents the datasource. Notice: if more than one layer
161         *         uses data that are offered by the same OWS the deegree WMS shall just use one instance for accessing the
162         *         OWS
163         * @throws OGCWebServiceException
164         *
165         */
166        public abstract OGCWebService getOGCWebService()
167                                throws OGCWebServiceException;
168    
169        /**
170         * @return the type of the data source. possible values are:
171         *         <ul>
172         *         <li>LOCALWFS</li>
173         *         <li>LOCALWCS</li>
174         *         <li>REMOTEWFS</li>
175         *         <li>REMOTEWCS</li>
176         *         <li>REMOTEWMS</li>
177         *         </ul>
178         *         the values are defined as constants in <tt>DataSource</tt>
179         *
180         */
181        public int getType() {
182            return type;
183        }
184    
185        /**
186         * @return true if the requesting of the complete layer and so of the complete request shall fail if access a
187         *         datasource fails.
188         */
189        public boolean isFailOnException() {
190            return failOnException;
191        }
192    
193        /**
194         * @return true i a datasource is queryable (considered for GetFeatureInfo requests)
195         */
196        public boolean isQueryable() {
197            return queryable;
198        }
199    
200        /**
201         * @return the URL of the capabilities document describing access to a datasource
202         */
203        public URL getCapabilitiesURL() {
204            return capabilitiesURL;
205        }
206    
207        /**
208         * @return the URL of a XSLT script to transform the GML that internaly will be returned as result to a GetFeature
209         *         or cascaded GetFeatureInfo request. The return is null if no transformation shall be performed.
210         *
211         */
212        public URL getFeatureInfoTransform() {
213            return featureInfoTransform;
214        }
215    
216        /**
217         * @return the area a datasource is valid
218         */
219        public Geometry getValidArea() {
220            return validArea;
221        }
222    
223        /**
224         * @return the maximum time in seconds a datasource shall be able to return a result.
225         */
226        public int getRequestTimeLimit() {
227            return reqTimeLimit;
228        }
229    
230        /**
231         * @param url
232         */
233        public void setFeatureInfoURL( URL url ) {
234            featureInfoURL = url;
235        }
236    
237        /**
238         * @return the feature info URL or null, if not set
239         */
240        public URL getFeatureInfoURL() {
241            return featureInfoURL;
242        }
243    
244        @Override
245        public String toString() {
246            String ret = getClass().getName() + ":\n";
247            ret += ( "scaleHint = " + scaleHint + "\n" );
248            ret += ( "name = " + name + "\n" );
249            ret += ( "type = " + type + "\n" );
250            ret += ( "queryable = " + queryable + "\n" );
251            ret += ( "failOnException = " + failOnException + "\n" );
252            ret += ( "capabilitiesURL = " + capabilitiesURL + "\n" );
253            ret += ( "validArea = " + validArea + "\n" );
254            return ret;
255        }
256    
257        /**
258         * @return the dimProps
259         */
260        public Map<String, String> getDimProps() {
261            return dimProps;
262        }
263    
264    }