001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/sos/configuration/SourceServerConfiguration.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.sos.configuration;
037    
038    import java.net.URL;
039    import java.util.ArrayList;
040    
041    import org.deegree.datatypes.QualifiedName;
042    import org.deegree.ogcwebservices.OGCWebService;
043    
044    /**
045     * represent a sourceServer configuration
046     *
047     * @author <a href="mailto:mkulbe@lat-lon.de">Matthias Kulbe </a>
048     *
049     */
050    
051    public class SourceServerConfiguration {
052    
053        private String id;
054    
055        private String service;
056    
057        private String version;
058    
059        private OGCWebService dataService;
060    
061        // platform description configs
062        private QualifiedName platformDescriptionFeatureType;
063    
064        private QualifiedName platformDescriptionIdPropertyName;
065    
066        private QualifiedName platformDescriptionCoordPropertyName;
067    
068        private URL platformDescriptionXSLTScriptSource;
069    
070        // sensorDescription configs
071        private QualifiedName sensorDescriptionFeatureType;
072    
073        private QualifiedName sensorDescriptionIdPropertyName;
074    
075        private URL sensorDescriptionXSLTScriptSource;
076    
077        // list of all provided sensors
078        private ArrayList<SensorConfiguration> sensors = new ArrayList<SensorConfiguration>();
079    
080        // list of all provided platforms
081        private ArrayList<PlatformConfiguration> platforms = new ArrayList<PlatformConfiguration>();
082    
083        /**
084         *
085         * @param id
086         * @param service
087         * @param version
088         * @param dataService
089         * @param platformDescriptionFeatureType
090         * @param platformDescriptionIdPropertyName
091         * @param platformDescriptionCoordPropertyName
092         * @param platformDescriptionXSLTScriptSource
093         * @param sensorDescriptionFeatureType
094         * @param sensorDescriptionIdPropertyName
095         * @param sensorDescriptionXSLTScriptSource
096         */
097        public SourceServerConfiguration( String id, String service, String version, OGCWebService dataService,
098                                          QualifiedName platformDescriptionFeatureType,
099                                          QualifiedName platformDescriptionIdPropertyName,
100                                          QualifiedName platformDescriptionCoordPropertyName,
101                                          URL platformDescriptionXSLTScriptSource,
102                                          QualifiedName sensorDescriptionFeatureType,
103                                          QualifiedName sensorDescriptionIdPropertyName,
104                                          URL sensorDescriptionXSLTScriptSource ) {
105    
106            this.service = service;
107            this.id = id;
108            this.version = version;
109            this.dataService = dataService;
110            this.platformDescriptionFeatureType = platformDescriptionFeatureType;
111            this.platformDescriptionIdPropertyName = platformDescriptionIdPropertyName;
112            this.platformDescriptionCoordPropertyName = platformDescriptionCoordPropertyName;
113            this.platformDescriptionXSLTScriptSource = platformDescriptionXSLTScriptSource;
114            this.sensorDescriptionFeatureType = sensorDescriptionFeatureType;
115            this.sensorDescriptionIdPropertyName = sensorDescriptionIdPropertyName;
116            this.sensorDescriptionXSLTScriptSource = sensorDescriptionXSLTScriptSource;
117    
118        }
119    
120        public QualifiedName getPlatformDescriptionCoordPropertyName() {
121            return platformDescriptionCoordPropertyName;
122        }
123    
124        public QualifiedName getPlatformDescriptionFeatureType() {
125            return platformDescriptionFeatureType;
126        }
127    
128        public QualifiedName getPlatformDescriptionIdPropertyName() {
129            return platformDescriptionIdPropertyName;
130        }
131    
132        public QualifiedName getSensorDescriptionFeatureType() {
133            return sensorDescriptionFeatureType;
134        }
135    
136        public QualifiedName getSensorDescriptionIdPropertyName() {
137            return sensorDescriptionIdPropertyName;
138        }
139    
140        /**
141         * adds a new sensor
142         *
143         * @param sensor
144         */
145        public void addSensor( SensorConfiguration sensor ) {
146            this.sensors.add( sensor );
147    
148        }
149    
150        /**
151         * returns all sensors
152         *
153         * @return ll sensors
154         */
155        public SensorConfiguration[] getSensors() {
156            return this.sensors.toArray( new SensorConfiguration[this.sensors.size()] );
157        }
158    
159        /**
160         * returns the sensor by the given scs id
161         *
162         * @param id
163         * @return the sensor by the given scs id
164         */
165        public SensorConfiguration getSensorById( String id ) {
166            for ( int i = 0; i < this.sensors.size(); i++ ) {
167                if ( this.sensors.get( i ).getId().equals( id ) ) {
168                    return this.sensors.get( i );
169                }
170            }
171            return null;
172        }
173    
174        /**
175         * returns the sensor by the given idPropertyValue on the sourceServer
176         *
177         * @param id
178         * @return the sensor by the given idPropertyValue on the sourceServer
179         */
180        public SensorConfiguration getSensorByIdPropertyValue( String id ) {
181            for ( int i = 0; i < this.sensors.size(); i++ ) {
182                if ( this.sensors.get( i ).getIdPropertyValue().equals( id ) ) {
183                    return this.sensors.get( i );
184                }
185            }
186            return null;
187        }
188    
189        /**
190         * returns true if the sensor with the given id exists
191         *
192         * @param id
193         * @return <code>true</code> if the sensor with the given id exists
194         */
195        public boolean haveSensorById( String id ) {
196            for ( int i = 0; i < this.sensors.size(); i++ ) {
197                if ( this.sensors.get( i ).getId().equals( id ) ) {
198                    return true;
199                }
200            }
201            return false;
202        }
203    
204        /**
205         * returns true if the sensor with the given idPropertyValue exists
206         *
207         * @param id
208         * @return <code>true</code> if the sensor with the given idPropertyValue exists
209         */
210        public boolean haveSensorByIdPropertyValue( String id ) {
211            for ( int i = 0; i < this.sensors.size(); i++ ) {
212                if ( this.sensors.get( i ).getIdPropertyValue().equals( id ) ) {
213                    return true;
214                }
215            }
216            return false;
217        }
218    
219        public OGCWebService getDataService() {
220            return dataService;
221        }
222    
223        public String getId() {
224            return id;
225        }
226    
227        public String getService() {
228            return service;
229        }
230    
231        public String getVersion() {
232            return version;
233        }
234    
235        /**
236         * overwrites the equals function
237         */
238        public boolean equals( Object obj ) {
239            if ( !( obj instanceof SourceServerConfiguration ) ) {
240                return false;
241            }
242            if ( this.getId().equals( ( (SourceServerConfiguration) obj ).getId() ) ) {
243                return true;
244            }
245            return false;
246        }
247    
248        /**
249         * overrides the hashCode function
250         */
251        public int hashCode() {
252            return this.getId().hashCode();
253        }
254    
255        /**
256         * adds a new platform
257         *
258         * @param platform
259         */
260        public void addPlatform( PlatformConfiguration platform ) {
261            this.platforms.add( platform );
262    
263        }
264    
265        /**
266         * returns all platforms
267         *
268         * @return all platforms
269         */
270        public PlatformConfiguration[] getPlatforms() {
271            return this.platforms.toArray( new PlatformConfiguration[this.platforms.size()] );
272        }
273    
274        /**
275         * returns the platform by the given scs id
276         *
277         * @param id
278         * @return the platform by the given scs id
279         */
280        public PlatformConfiguration getPlatformById( String id ) {
281            for ( int i = 0; i < this.platforms.size(); i++ ) {
282                if ( this.platforms.get( i ).getId().equals( id ) ) {
283                    return this.platforms.get( i );
284                }
285            }
286            return null;
287        }
288    
289        /**
290         * returns the platform by the given idPropertyValue on the sourceServer
291         *
292         * @param id
293         * @return the platform by the given idPropertyValue on the sourceServer
294         */
295        public PlatformConfiguration getPlatformByIdPropertyValue( String id ) {
296    
297            for ( int i = 0; i < this.platforms.size(); i++ ) {
298                if ( this.platforms.get( i ).getId().equals( id ) ) {
299                    return this.platforms.get( i );
300                }
301            }
302    
303            return null;
304        }
305    
306        /**
307         * returns true if the platform with the given id exists
308         *
309         * @param id
310         * @return <code>true</code> if the platform with the given id exists
311         */
312        public boolean havePlatformById( String id ) {
313            for ( int i = 0; i < this.platforms.size(); i++ ) {
314                if ( this.platforms.get( i ).getId().equals( id ) ) {
315                    return true;
316                }
317            }
318            return false;
319        }
320    
321        /**
322         * returns true if the platform with the given idPropertyValue exists
323         *
324         * @param id
325         * @return <code>true</code> if the platform with the given idPropertyValue exists
326         */
327        public boolean havePlatformByIdPropertyValue( String id ) {
328            for ( int i = 0; i < this.platforms.size(); i++ ) {
329                if ( this.platforms.get( i ).getIdPropertyValue().equals( id ) ) {
330                    return true;
331                }
332            }
333            return false;
334        }
335    
336        /**
337         * returns true, if all parameters, to request platform metadata, is set
338         *
339         * @return <code>true</code>, if all parameters, to request platform metadata, is set
340         */
341        public boolean havePlatformDescriptionData() {
342    
343            if ( ( this.platformDescriptionFeatureType != null ) && ( this.platformDescriptionIdPropertyName != null )
344                 && ( this.platformDescriptionCoordPropertyName != null ) ) {
345                return true;
346            }
347    
348            return false;
349        }
350    
351        /**
352         * returns true, if all parameters, to request sensor metadata, is set
353         *
354         * @return <code>true</code>, if all parameters, to request sensor metadata, is set
355         */
356        public boolean haveSensorDescriptionData() {
357            if ( ( this.sensorDescriptionFeatureType != null ) && ( this.sensorDescriptionIdPropertyName != null ) ) {
358                return true;
359            }
360    
361            return false;
362        }
363    
364        public URL getPlatformDescriptionXSLTScriptSource() {
365            return this.platformDescriptionXSLTScriptSource;
366        }
367    
368        public URL getSensorDescriptionXSLTScriptSource() {
369            return this.sensorDescriptionXSLTScriptSource;
370        }
371    }