001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wpvs/capabilities/WPVSCapabilities.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 Department of Geography
036 University of Bonn
037 Meckenheimer Allee 166
038 53115 Bonn
039 Germany
040 E-Mail: greve@giub.uni-bonn.de
041
042 ---------------------------------------------------------------------------*/
043 package org.deegree.ogcwebservices.wpvs.capabilities;
044
045 import org.deegree.ogcwebservices.getcapabilities.Contents;
046 import org.deegree.ogcwebservices.getcapabilities.OperationsMetadata;
047 import org.deegree.ogcwebservices.getcapabilities.ServiceIdentification;
048 import org.deegree.ogcwebservices.getcapabilities.ServiceProvider;
049 import org.deegree.owscommon.OWSCommonCapabilities;
050
051 /**
052 * This class represents a <code>WPVSCapabilities</code> object.
053 *
054 * @author <a href="mailto:taddei@lat-lon.de">Ugo Taddei</a>
055 * @author last edited by: $Author: apoth $
056 *
057 * @version 2.0, $Revision: 9345 $, $Date: 2007-12-27 17:22:25 +0100 (Do, 27 Dez 2007) $
058 *
059 * @since 2.0
060 */
061 public class WPVSCapabilities extends OWSCommonCapabilities {
062
063 /**
064 *
065 */
066 private static final long serialVersionUID = 957878718619030101L;
067 private Dataset dataset;
068
069 /**
070 * Creates a new wpvsCapabilities object from the given parameters.
071 *
072 * @param version
073 * @param updateSequence
074 * @param serviceIdentification
075 * @param serviceProvider
076 * @param operationsMetadata
077 * @param contents
078 * TODO field not verified! Check spec.
079 * @param dataset
080 */
081 public WPVSCapabilities( String version, String updateSequence,
082 ServiceIdentification serviceIdentification,
083 ServiceProvider serviceProvider, OperationsMetadata operationsMetadata,
084 Contents contents, Dataset dataset ) {
085
086 super( version, updateSequence, serviceIdentification, serviceProvider, operationsMetadata,
087 contents );
088 this.dataset = dataset;
089
090 }
091
092 /**
093 * @return the root dataset of this wpvs
094 */
095 public Dataset getDataset() {
096 return dataset;
097 }
098
099 /**
100 * recursion over all layers to find the layer that matches the submitted name. If no layer can
101 * be found that fullfills the condition <code>null</code> will be returned.
102 *
103 * @param name
104 * name of the layer to be found
105 * @param datasets
106 * list of searchable layers
107 *
108 * @return a layer object or <code>null</code>
109 */
110 private Dataset findDataset( String name, Dataset[] datasets ) {
111 Dataset dset = null;
112
113 if ( datasets != null ) {
114 for ( Dataset set : datasets ) {
115 dset = findDataset( name, set.getDatasets() );
116 if ( dset != null )
117 return dset;
118 if ( name.equals( set.getName() ) ) {
119 return set;
120 }
121 }
122 }
123 return dset;
124 }
125
126 /**
127 * returns a DataSet provided by a WPVS with the given name
128 * @param name the name of the DataSet
129 *
130 * @return a DataSet with a given Name or <code>null</code> if no such DataSet exists.
131 */
132 public Dataset findDataset( String name ) {
133 if ( name == null )
134 return null;
135 if ( dataset.getName() != null && name.equals( dataset.getName() ) ) {
136 return dataset;
137 }
138 return findDataset( name, dataset.getDatasets() );
139 }
140
141 /**
142 * Finds an <code>ElevationModel</code> in this dataset or in its children. This method return
143 * the first dataset it finds or null, otherwise.
144 *
145 * @param elevationModelName
146 * the name identifying the <code>ElevationModel</code>
147 * @return the <code>ElevationModel</code> with the given name or null
148 */
149 public ElevationModel findElevationModel( String elevationModelName ) {
150
151 ElevationModel elevModel = null;
152 Dataset ds = dataset;
153
154 if ( ds != null ) {
155
156 ElevationModel em = ds.getElevationModel();
157 if ( elevationModelName == null )
158 return null;
159 if ( em != null && elevationModelName.equals( em.getName() ) ) {
160 return em;
161 }
162 Dataset[] datasets = ds.getDatasets();
163 elevModel = findElevationModel( elevationModelName, datasets );
164 }
165 return elevModel;
166 }
167
168 /**
169 * @param elevationModelName
170 * @param datasets
171 */
172 private ElevationModel findElevationModel( String elevationModelName, Dataset[] datasets ) {
173
174 if ( elevationModelName == null || datasets == null )
175 return null;
176 for ( Dataset dset : datasets ) {
177 ElevationModel elevModel = findElevationModel( elevationModelName, dset.getDatasets() );
178 if ( elevModel != null )
179 return elevModel;
180
181 elevModel = dset.getElevationModel();
182 if ( elevModel != null && elevationModelName.equals( elevModel.getName() ) ) {
183 return elevModel;
184 }
185 }
186 return null;
187 }
188
189 }