001 //$$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wpvs/capabilities/WPVSOperationsMetadata.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 044 package org.deegree.ogcwebservices.wpvs.capabilities; 045 046 import java.util.ArrayList; 047 import java.util.HashMap; 048 import java.util.List; 049 import java.util.Map; 050 051 import org.deegree.ogcwebservices.getcapabilities.Operation; 052 import org.deegree.ogcwebservices.getcapabilities.OperationsMetadata; 053 import org.deegree.owscommon.com110.OWSDomainType110; 054 import org.deegree.owscommon.com110.Operation110; 055 056 /** 057 * FIXME check spec number! add "Function" to table. 058 * 059 * Represents the <code>OperationMetadata</code> part in the capabilities document of a WPVS 060 * according to the <code>Web Perspective View Service Implementation Specification 0.0.0</code>. 061 * 062 * In addition to the <code>GetCapabilities</code> operation that all <code>OWS 0.3</code> 063 * compliant services must implement, it may define some or all of the following operations: 064 * <table border="1"> 065 * <tr> 066 * <th>Name</th> 067 * <th>Mandatory?</th> 068 * <th>Function</th> 069 * <tr> 070 * <tr> 071 * <td><code>GetView</code></td> 072 * <td align="center">yes</td> 073 * <td> </td> 074 * <tr> 075 * <tr> 076 * <td><code>GetDescription</code></td> 077 * <td align="center"> </td> 078 * <td> </td> 079 * <tr> 080 * <tr> 081 * <td><code>GetLegendGraphic</code></td> 082 * <td align="center">no</td> 083 * <td> </td> 084 * <tr> 085 * </table> 086 * 087 * @see org.deegree.ogcwebservices.getcapabilities.OperationsMetadata 088 * 089 * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a> 090 * @author last edited by: $Author: apoth $ 091 * 092 * @version 2.0, $Revision: 9345 $, $Date: 2007-12-27 17:22:25 +0100 (Do, 27 Dez 2007) $ 093 * 094 * @since 2.0 095 */ 096 public class WPVSOperationsMetadata extends OperationsMetadata { 097 098 /** 099 * 100 */ 101 private static final long serialVersionUID = -4003368728363323890L; 102 /** 103 * 104 */ 105 public static final String GET_VIEW_NAME = "GetView"; 106 /** 107 * 108 */ 109 public static final String GET_CAPABILITIES_NAME = "GetCapabilities"; 110 /** 111 * 112 */ 113 public static final String GET_DESCRIPTION_NAME = "GetDescription"; 114 115 /** 116 * 117 */ 118 public static final String GET_3D_FEATURE_INFO = "Get3DFeatureInfo"; 119 120 /** 121 * 122 */ 123 public static final String GET_LEGEND_GRAPHIC_NAME = "GetLegendGraphic"; 124 125 private Operation110 getCapabilities; 126 private Operation110 getView; 127 private Operation110 getDescription; 128 private Operation110 getLegendGraphic; 129 private Operation110 get3DFeatureInfo; 130 131 private Object extendedCapabilities; 132 133 // keys are Strings (the names of the parameters), values are OWSDomainType110 - instances. 134 private Map<String, OWSDomainType110> parameters; 135 // keys are Strings (the names of constrained domains), values are OWSDomainType110 - instances. 136 private Map<String, OWSDomainType110> constraints; 137 138 139 /** 140 * Creates a new <code>WPVSOperationsMetadata</code> instance from the given parameters. 141 * 142 * @param getView 143 * mandatory operation 144 * @param getCapabilities 145 * mandatory operation 146 * @param getDescription 147 * optional operation; may be null 148 * @param getLegendGraphic 149 * optional operation; may be null 150 * @param parameters 151 * optional unordered list of parameter valid domains 152 * that each apply to one or more operations which this server interface implements. 153 * @param constraints 154 * optional unordered list of valid domain constraints on non-parameter quantaties 155 * that each apply to this server. 156 * @param extendedCapabilities 157 * optional; metadata about any additional server abilities. 158 */ 159 public WPVSOperationsMetadata( Operation110 getCapabilities, Operation110 getView, 160 Operation110 getDescription, Operation110 getLegendGraphic, 161 OWSDomainType110[] parameters, OWSDomainType110[] constraints, 162 Object[] extendedCapabilities ) { 163 164 //FIXME this is ugly 165 super( null, null, null ); 166 167 this.getCapabilities = getCapabilities; 168 this.getView = getView; 169 this.getDescription = getDescription; 170 this.getLegendGraphic = getLegendGraphic; 171 172 this.extendedCapabilities = extendedCapabilities; 173 174 setParameters110( parameters ); 175 setConstraints110( constraints ); 176 } 177 178 /** 179 * Creates a new <code>WPVSOperationsMetadata</code> instance from the given parameters. 180 * 181 * @param getView 182 * mandatory operation 183 * @param getCapabilities 184 * mandatory operation 185 * @param getDescription 186 * optional operation; may be null 187 * @param getLegendGraphic 188 * optional operation; may be null 189 * @param parameters 190 * optional unordered list of parameter valid domains 191 * that each apply to one or more operations which this server interface implements. 192 * @param constraints 193 * optional unordered list of valid domain constraints on non-parameter quantaties 194 * that each apply to this server. 195 * @param extendedCapabilities 196 * optional; metadata about any additional server abilities. 197 * @param get3DFeatureInfo 198 * optional operation; may be null 199 */ 200 public WPVSOperationsMetadata( Operation110 getCapabilities, Operation110 getView, 201 Operation110 getDescription, Operation110 getLegendGraphic, 202 OWSDomainType110[] parameters, OWSDomainType110[] constraints, 203 Object[] extendedCapabilities, Operation110 get3DFeatureInfo ) { 204 205 //FIXME this is ugly 206 super( null, null, null ); 207 208 this.getCapabilities = getCapabilities; 209 this.getView = getView; 210 this.getDescription = getDescription; 211 this.getLegendGraphic = getLegendGraphic; 212 this.get3DFeatureInfo = get3DFeatureInfo; 213 214 this.extendedCapabilities = extendedCapabilities; 215 216 setParameters110( parameters ); 217 setConstraints110( constraints ); 218 } 219 /** 220 * Returns all <code>Operations</code> known to the WPVS. 221 * 222 * @return the configured operations of the wpvs 223 */ 224 public Operation[] getAllOperations() { 225 226 List<Operation110> list = new ArrayList<Operation110>( 10 ); 227 228 list.add( getCapabilities ); 229 list.add( getView ); 230 if ( getDescription != null ) { 231 list.add( getDescription ); 232 } 233 if ( getLegendGraphic != null ) { 234 list.add( getLegendGraphic ); 235 } 236 if ( get3DFeatureInfo != null ) { 237 list.add( get3DFeatureInfo ); 238 } 239 240 Operation110 [] ops = new Operation110 [list.size()]; 241 return list.toArray( ops ); 242 } 243 244 /** 245 * @return the <code>GetCapabilities</code> -operation. 246 */ 247 public Operation getGetCapabilities() { 248 return getCapabilities; 249 } 250 251 /** 252 * Sets the configuration for the <code>GetCapabilities</code> -operation. 253 * 254 * @param getCapabilities 255 * configuration for the <code>GetCapabilities</code> -operation to be set. 256 */ 257 public void setGetCapabilities( Operation110 getCapabilities ) { 258 this.getCapabilities = getCapabilities; 259 } 260 261 /** 262 * @return Returns the getView <code>Operation</code>. 263 */ 264 public Operation getGetView() { 265 return getView; 266 } 267 268 /** 269 * @param getView The getView to set. 270 */ 271 public void setGetView( Operation110 getView ) { 272 this.getView = getView; 273 } 274 275 /** 276 * @return Returns the getDescription <code>Operation</code>. 277 */ 278 public Operation getGetDescription() { 279 return getDescription; 280 } 281 282 /** 283 * @param getDescription The getDescription to set. 284 */ 285 public void setGetDescription( Operation110 getDescription ) { 286 this.getDescription = getDescription; 287 } 288 289 /** 290 * @return Returns the getLegendGraphic <code>Operation</code>. 291 */ 292 public Operation getGetLegendGraphic() { 293 return getLegendGraphic; 294 } 295 296 /** 297 * @param getLegendGraphic The getLegendGraphic to set. 298 */ 299 public void setGetLegendGraphic( Operation110 getLegendGraphic ) { 300 this.getLegendGraphic = getLegendGraphic; 301 } 302 303 /** 304 * @return Returns the extendedCapabilities. 305 */ 306 public Object getExtendedCapabilities() { 307 return extendedCapabilities; 308 } 309 310 /** 311 * @param extendedCapabilities The extendedCapabilities to set. 312 */ 313 public void setExtendedCapabilities( Object extendedCapabilities ) { 314 this.extendedCapabilities = extendedCapabilities; 315 } 316 317 /** 318 * Returns a list of parameters assigned directly to the WPVSOperationsMetadata. 319 * 320 * @return a list of parameters assigned directly to the WPVSOperationsMetadata. 321 */ 322 public OWSDomainType110[] getParameters110() { 323 OWSDomainType110[] op = new OWSDomainType110[ parameters.size() ]; 324 return parameters.values().toArray(op); 325 } 326 327 /** 328 * Adds a parameter to the WPVSOperationsMetadata. 329 * 330 * @param parameter 331 */ 332 public void addParameter110( OWSDomainType110 parameter ) { 333 parameters.put(parameter.getName(), parameter); 334 } 335 336 /** 337 * Removes a parameter from the WPVSOperationsMetadata. 338 * 339 * @param name to be removed 340 * @return the removed OWSDomainType110 or null if not found (or if the name mapping was null) . 341 */ 342 public OWSDomainType110 removeParameter110( String name ) { 343 return parameters.remove( name ); 344 } 345 346 /** 347 * Sets a complete list of parameters to the WPVSOperationMetadata. 348 * 349 * @param parameters 350 */ 351 public void setParameters110( OWSDomainType110[] parameters ) { 352 if (this.parameters == null) { 353 this.parameters = new HashMap<String, OWSDomainType110>(); 354 } else { 355 this.parameters.clear(); 356 } 357 if (parameters != null) { 358 for (int i = 0; i < parameters.length; i++) { 359 addParameter110(parameters[i]); 360 } 361 } 362 } 363 364 /** 365 * @return Returns the constraints. 366 */ 367 public OWSDomainType110[] getConstraints110() { 368 OWSDomainType110[] op = new OWSDomainType110[ constraints.size() ]; 369 return constraints.values().toArray( op ); 370 } 371 372 /** 373 * Adds a constraint. 374 * 375 * @param constraint of OWSDomainType110 376 */ 377 private void addConstraints110( OWSDomainType110 constraint ) { 378 constraints.put( constraint.getName(), constraint ); 379 } 380 381 /** 382 * Sets the constraints of the <code>WPVSOperationMetadata</code>. 383 * 384 * @param constraints 385 * may be null 386 */ 387 private void setConstraints110( OWSDomainType110[] constraints ) { 388 if ( this.constraints == null ) { 389 this.constraints = new HashMap<String, OWSDomainType110>(); 390 } else { 391 this.constraints.clear(); 392 } 393 if ( constraints != null ) { 394 for ( int i = 0; i < constraints.length; i++ ) { 395 addConstraints110( constraints[i] ); 396 } 397 } 398 } 399 400 }