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