001 // $HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/getcapabilities/OperationsMetadata.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2006 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 Aennchenstr. 19 030 53115 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.getcapabilities; 045 046 import java.io.Serializable; 047 import java.util.HashMap; 048 import java.util.Map; 049 050 import org.deegree.owscommon.OWSDomainType; 051 052 /** 053 * Represents the <code>OperationMetadata</code> part in the capabilities 054 * document of an OGC-web service according to the 055 * <code>OWS Common Implementation 056 * Specification 0.3</code> (and especially 057 * <code>owsOperationsMetadata.xsd</code>). As this class is abstract, it 058 * only defines the <code>GetCapabilities</code> operation, which all types of 059 * <code>OWS Common</code> -compliant web services must implement. 060 * <p> 061 * It consists of the following elements: <table border="1"> 062 * <tr> 063 * <th>Name</th> 064 * <th>Occurences</th> 065 * <th>Function</th> 066 * </tr> 067 * <tr> 068 * <td>ows:Operation</td> 069 * <td align="center">2-*</td> 070 * <td>Metadata for unordered list of all the (requests for) operations that 071 * this server interface implements. The list of required and optional 072 * operations implemented shall be specified in the Implementation Specification 073 * for this service.</td> 074 * </tr> 075 * <tr> 076 * <td>ows:Parameter</td> 077 * <td align="center">0-*</td> 078 * <td>Optional unordered list of parameter valid domains that each apply to 079 * one or more operations which this server interface implements. The list of 080 * required and optional parameter domain limitations shall be specified in the 081 * Implementation Specification for this service.</td> 082 * </tr> 083 * <tr> 084 * <td>ows:Constraint</td> 085 * <td align="center">0-*</td> 086 * <td>Optional unordered list of valid domain constraints on non-parameter 087 * quantities that each apply to this server. The list of required and optional 088 * constraints shall be specified in the Implementation Specification for this 089 * service.</td> 090 * </tr> 091 * <tr> 092 * <td>ows:ExtendedCapabilities</td> 093 * <td align="center">0 or 1</td> 094 * <td>Individual software vendors and servers can use this element to provide 095 * metadata about any additional server abilities.</td> 096 * </tr> 097 * </table> 098 * 099 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a> 100 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a> 101 * @author last edited by: $Author: mschneider $ 102 * 103 * @version $Revision: 6353 $, $Date: 2007-03-22 18:35:48 +0100 (Do, 22 Mär 2007) $ 104 */ 105 public abstract class OperationsMetadata implements Serializable { 106 107 /** 108 * 109 */ 110 public static final String GET_CAPABILITIES_NAME = "GetCapabilities"; 111 112 protected Operation getCapabilitiesOperation = null; 113 114 // keys are Strings (the names of the parameters), values are 115 // OWSDomainType-instances 116 protected Map<String, OWSDomainType> parameters; 117 118 // keys are Strings (the names of constrained domains), values are 119 // OWSDomainType-instances 120 protected Map<String, OWSDomainType> constraints; 121 122 /** 123 * Creates a new <code>OperationsMetadata</code> instance with the given 124 * configuration for the getCapabilitiesOperation. 125 * 126 * @param getCapabilitiesOperation 127 * @param parameters 128 * @param constraints 129 */ 130 public OperationsMetadata(Operation getCapabilitiesOperation, 131 OWSDomainType[] parameters, OWSDomainType[] constraints) { 132 this.getCapabilitiesOperation = getCapabilitiesOperation; 133 setOperationParameter(parameters); 134 setConstraints(constraints); 135 } 136 137 /** 138 * @return The configuration for the <code>GetCapabilities</code> 139 * -operation. 140 */ 141 public Operation getGetCapabilitiesOperation() { 142 return getCapabilitiesOperation; 143 } 144 145 /** 146 * Sets the configuration for the <code>GetCapabilities</code> -operation. 147 * 148 * @param getCapabilitiesOperation 149 * configuration for the <code>GetCapabilities</code> 150 * -operation to be set 151 */ 152 public void setGetCapabilitiesOperation(Operation getCapabilitiesOperation) { 153 this.getCapabilitiesOperation = getCapabilitiesOperation; 154 } 155 156 /** 157 * @return all <code>Operation</code> configurations. 158 */ 159 public Operation[] getOperations() { 160 return new Operation[] { getCapabilitiesOperation }; 161 } 162 163 /** 164 * 165 * @return a list of parameters assigned directly to the OperationsMetadata. 166 */ 167 public OWSDomainType[] getParameter() { 168 return parameters.values().toArray(new OWSDomainType[parameters.size()]); 169 } 170 171 /** 172 * adds a parameter to the OperationsMetadata 173 * 174 * @param parameter 175 */ 176 public void addParameter(OWSDomainType parameter) { 177 parameters.put(parameter.getName(), parameter); 178 } 179 180 /** 181 * 182 * 183 * @param name removes a parameter from the OperationsMetadata 184 * @return the removed parameter 185 */ 186 public OWSDomainType removeParameter( String name ) { 187 return parameters.remove(name); 188 } 189 190 /** 191 * sets a complete list of parameters to the OperationMetadata 192 * 193 * @param parameters 194 */ 195 public void setOperationParameter(OWSDomainType[] parameters) { 196 if (this.parameters == null) { 197 this.parameters = new HashMap<String, OWSDomainType>(); 198 } else { 199 this.parameters.clear(); 200 } 201 if (parameters != null) { 202 for (int i = 0; i < parameters.length; i++) { 203 addParameter(parameters[i]); 204 } 205 } 206 } 207 208 /** 209 * @return Returns the constraints. 210 */ 211 public OWSDomainType[] getConstraints() { 212 return constraints.values().toArray( 213 new OWSDomainType[constraints.values().size()]); 214 } 215 216 /** 217 * Sets the constraints of the <code>OperationMetadata</code>. 218 * 219 * @param constraints 220 * may be null 221 */ 222 public void setConstraints(OWSDomainType[] constraints) { 223 if (this.constraints == null) { 224 this.constraints = new HashMap<String,OWSDomainType>(); 225 } else { 226 this.constraints.clear(); 227 } 228 if (constraints != null) { 229 for (int i = 0; i < constraints.length; i++) { 230 addConstraint(constraints[i]); 231 } 232 } 233 } 234 235 /** 236 * Adds a constraint. 237 * 238 * @param constraint 239 */ 240 public void addConstraint(OWSDomainType constraint) { 241 constraints.put(constraint.getName(), constraint); 242 } 243 }