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