001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/sos/configuration/SourceServerConfiguration.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2008 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstraße 19  
030     53177 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     lat/lon GmbH
036     Aennchenstraße 19
037     53177 Bonn
038     Germany
039     E-Mail: greve@giub.uni-bonn.de
040    
041     ---------------------------------------------------------------------------*/
042    package org.deegree.ogcwebservices.sos.configuration;
043    
044    import java.net.URL;
045    import java.util.ArrayList;
046    
047    import org.deegree.datatypes.QualifiedName;
048    import org.deegree.ogcwebservices.OGCWebService;
049    
050    /**
051     * represent a sourceServer configuration
052     * 
053     * @author <a href="mailto:mkulbe@lat-lon.de">Matthias Kulbe </a>
054     * 
055     */
056    
057    public class SourceServerConfiguration {
058    
059        private String id;
060    
061        private String service;
062    
063        private String version;
064    
065        private OGCWebService dataService;
066    
067        // platform description configs
068        private QualifiedName platformDescriptionFeatureType;
069    
070        private QualifiedName platformDescriptionIdPropertyName;
071    
072        private QualifiedName platformDescriptionCoordPropertyName;
073    
074        private URL platformDescriptionXSLTScriptSource;
075    
076        // sensorDescription configs
077        private QualifiedName sensorDescriptionFeatureType;
078    
079        private QualifiedName sensorDescriptionIdPropertyName;
080    
081        private URL sensorDescriptionXSLTScriptSource;
082    
083        // list of all provided sensors
084        private ArrayList<SensorConfiguration> sensors = new ArrayList<SensorConfiguration>();
085    
086        // list of all provided platforms
087        private ArrayList<PlatformConfiguration> platforms = new ArrayList<PlatformConfiguration>();
088    
089        /**
090         * 
091         * @param id
092         * @param service
093         * @param version
094         * @param dataService
095         * @param platformDescriptionFeatureType
096         * @param platformDescriptionIdPropertyName
097         * @param platformDescriptionCoordPropertyName
098         * @param platformDescriptionXSLTScriptSource
099         * @param sensorDescriptionFeatureType
100         * @param sensorDescriptionIdPropertyName
101         * @param sensorDescriptionXSLTScriptSource
102         */
103        public SourceServerConfiguration( String id, String service, String version, OGCWebService dataService,
104                                          QualifiedName platformDescriptionFeatureType,
105                                          QualifiedName platformDescriptionIdPropertyName,
106                                          QualifiedName platformDescriptionCoordPropertyName,
107                                          URL platformDescriptionXSLTScriptSource,
108                                          QualifiedName sensorDescriptionFeatureType,
109                                          QualifiedName sensorDescriptionIdPropertyName,
110                                          URL sensorDescriptionXSLTScriptSource ) {
111    
112            this.service = service;
113            this.id = id;
114            this.version = version;
115            this.dataService = dataService;
116            this.platformDescriptionFeatureType = platformDescriptionFeatureType;
117            this.platformDescriptionIdPropertyName = platformDescriptionIdPropertyName;
118            this.platformDescriptionCoordPropertyName = platformDescriptionCoordPropertyName;
119            this.platformDescriptionXSLTScriptSource = platformDescriptionXSLTScriptSource;
120            this.sensorDescriptionFeatureType = sensorDescriptionFeatureType;
121            this.sensorDescriptionIdPropertyName = sensorDescriptionIdPropertyName;
122            this.sensorDescriptionXSLTScriptSource = sensorDescriptionXSLTScriptSource;
123    
124        }
125    
126        public QualifiedName getPlatformDescriptionCoordPropertyName() {
127            return platformDescriptionCoordPropertyName;
128        }
129    
130        public QualifiedName getPlatformDescriptionFeatureType() {
131            return platformDescriptionFeatureType;
132        }
133    
134        public QualifiedName getPlatformDescriptionIdPropertyName() {
135            return platformDescriptionIdPropertyName;
136        }
137    
138        public QualifiedName getSensorDescriptionFeatureType() {
139            return sensorDescriptionFeatureType;
140        }
141    
142        public QualifiedName getSensorDescriptionIdPropertyName() {
143            return sensorDescriptionIdPropertyName;
144        }
145    
146        /**
147         * adds a new sensor
148         * 
149         * @param sensor
150         */
151        public void addSensor( SensorConfiguration sensor ) {
152            this.sensors.add( sensor );
153    
154        }
155    
156        /**
157         * returns all sensors
158         * 
159         * @return ll sensors
160         */
161        public SensorConfiguration[] getSensors() {
162            return this.sensors.toArray( new SensorConfiguration[this.sensors.size()] );
163        }
164    
165        /**
166         * returns the sensor by the given scs id
167         * 
168         * @param id
169         * @return the sensor by the given scs id
170         */
171        public SensorConfiguration getSensorById( String id ) {
172            for ( int i = 0; i < this.sensors.size(); i++ ) {
173                if ( this.sensors.get( i ).getId().equals( id ) ) {
174                    return this.sensors.get( i );
175                }
176            }
177            return null;
178        }
179    
180        /**
181         * returns the sensor by the given idPropertyValue on the sourceServer
182         * 
183         * @param id
184         * @return the sensor by the given idPropertyValue on the sourceServer
185         */
186        public SensorConfiguration getSensorByIdPropertyValue( String id ) {
187            for ( int i = 0; i < this.sensors.size(); i++ ) {
188                if ( this.sensors.get( i ).getIdPropertyValue().equals( id ) ) {
189                    return this.sensors.get( i );
190                }
191            }
192            return null;
193        }
194    
195        /**
196         * returns true if the sensor with the given id exists
197         * 
198         * @param id
199         * @return <code>true</code> if the sensor with the given id exists
200         */
201        public boolean haveSensorById( String id ) {
202            for ( int i = 0; i < this.sensors.size(); i++ ) {
203                if ( this.sensors.get( i ).getId().equals( id ) ) {
204                    return true;
205                }
206            }
207            return false;
208        }
209    
210        /**
211         * returns true if the sensor with the given idPropertyValue exists
212         * 
213         * @param id
214         * @return <code>true</code> if the sensor with the given idPropertyValue exists
215         */
216        public boolean haveSensorByIdPropertyValue( String id ) {
217            for ( int i = 0; i < this.sensors.size(); i++ ) {
218                if ( this.sensors.get( i ).getIdPropertyValue().equals( id ) ) {
219                    return true;
220                }
221            }
222            return false;
223        }
224    
225        public OGCWebService getDataService() {
226            return dataService;
227        }
228    
229        public String getId() {
230            return id;
231        }
232    
233        public String getService() {
234            return service;
235        }
236    
237        public String getVersion() {
238            return version;
239        }
240    
241        /**
242         * overwrites the equals function
243         */
244        public boolean equals( Object obj ) {
245            if ( !( obj instanceof SourceServerConfiguration ) ) {
246                return false;
247            }
248            if ( this.getId().equals( ( (SourceServerConfiguration) obj ).getId() ) ) {
249                return true;
250            }
251            return false;
252        }
253    
254        /**
255         * overrides the hashCode function
256         */
257        public int hashCode() {
258            return this.getId().hashCode();
259        }
260    
261        /**
262         * adds a new platform
263         * 
264         * @param platform
265         */
266        public void addPlatform( PlatformConfiguration platform ) {
267            this.platforms.add( platform );
268    
269        }
270    
271        /**
272         * returns all platforms
273         * 
274         * @return all platforms
275         */
276        public PlatformConfiguration[] getPlatforms() {
277            return this.platforms.toArray( new PlatformConfiguration[this.platforms.size()] );
278        }
279    
280        /**
281         * returns the platform by the given scs id
282         * 
283         * @param id
284         * @return the platform by the given scs id
285         */
286        public PlatformConfiguration getPlatformById( String id ) {
287            for ( int i = 0; i < this.platforms.size(); i++ ) {
288                if ( this.platforms.get( i ).getId().equals( id ) ) {
289                    return this.platforms.get( i );
290                }
291            }
292            return null;
293        }
294    
295        /**
296         * returns the platform by the given idPropertyValue on the sourceServer
297         * 
298         * @param id
299         * @return the platform by the given idPropertyValue on the sourceServer
300         */
301        public PlatformConfiguration getPlatformByIdPropertyValue( String id ) {
302    
303            for ( int i = 0; i < this.platforms.size(); i++ ) {
304                if ( this.platforms.get( i ).getId().equals( id ) ) {
305                    return this.platforms.get( i );
306                }
307            }
308    
309            return null;
310        }
311    
312        /**
313         * returns true if the platform with the given id exists
314         * 
315         * @param id
316         * @return <code>true</code> if the platform with the given id exists
317         */
318        public boolean havePlatformById( String id ) {
319            for ( int i = 0; i < this.platforms.size(); i++ ) {
320                if ( this.platforms.get( i ).getId().equals( id ) ) {
321                    return true;
322                }
323            }
324            return false;
325        }
326    
327        /**
328         * returns true if the platform with the given idPropertyValue exists
329         * 
330         * @param id
331         * @return <code>true</code> if the platform with the given idPropertyValue exists
332         */
333        public boolean havePlatformByIdPropertyValue( String id ) {
334            for ( int i = 0; i < this.platforms.size(); i++ ) {
335                if ( this.platforms.get( i ).getIdPropertyValue().equals( id ) ) {
336                    return true;
337                }
338            }
339            return false;
340        }
341    
342        /**
343         * returns true, if all parameters, to request platform metadata, is set
344         * 
345         * @return <code>true</code>, if all parameters, to request platform metadata, is set
346         */
347        public boolean havePlatformDescriptionData() {
348    
349            if ( ( this.platformDescriptionFeatureType != null ) && ( this.platformDescriptionIdPropertyName != null )
350                 && ( this.platformDescriptionCoordPropertyName != null ) ) {
351                return true;
352            }
353    
354            return false;
355        }
356    
357        /**
358         * returns true, if all parameters, to request sensor metadata, is set
359         * 
360         * @return <code>true</code>, if all parameters, to request sensor metadata, is set
361         */
362        public boolean haveSensorDescriptionData() {
363            if ( ( this.sensorDescriptionFeatureType != null ) && ( this.sensorDescriptionIdPropertyName != null ) ) {
364                return true;
365            }
366    
367            return false;
368        }
369    
370        public URL getPlatformDescriptionXSLTScriptSource() {
371            return this.platformDescriptionXSLTScriptSource;
372        }
373    
374        public URL getSensorDescriptionXSLTScriptSource() {
375            return this.sensorDescriptionXSLTScriptSource;
376        }
377    }