001 //$$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wpvs/configuration/AbstractDataSource.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.configuration; 045 046 import org.deegree.datatypes.QualifiedName; 047 import org.deegree.model.spatialschema.Surface; 048 import org.deegree.ogcwebservices.OGCWebService; 049 import org.deegree.ogcwebservices.OGCWebServiceException; 050 import org.deegree.ogcwebservices.wpvs.capabilities.OWSCapabilities; 051 052 /** 053 * 054 * NB. this class is very similar to AbstractDataSource from wms 055 * TODO -> re-use ? put into common package? 056 * 057 * @author <a href="mailto:taddei@lat-lon.de">Ugo Taddei</a> 058 * @author last edited by: $Author: apoth $ 059 * 060 * @version 2.0, $Revision: 9345 $, $Date: 2007-12-27 17:22:25 +0100 (Do, 27 Dez 2007) $ 061 * 062 * @since 2.0 063 * 064 */ 065 public abstract class AbstractDataSource { 066 067 /** 068 * Identifier for a local wcs 069 */ 070 public static final int LOCAL_WCS = 0; 071 /** 072 * Identifier for a local wfs 073 */ 074 public static final int LOCAL_WFS = 1; 075 /** 076 * Identifier for a local wms 077 */ 078 public static final int LOCAL_WMS = 2; 079 /** 080 * Identifier for a remote wfs 081 */ 082 public static final int REMOTE_WFS = 3; 083 /** 084 * Identifier for a remote wcs 085 */ 086 public static final int REMOTE_WCS = 4; 087 /** 088 * Identifier for a remote wms 089 */ 090 public static final int REMOTE_WMS = 5; 091 092 protected static final String[] SERVICE_TYPE_TO_NAME = { 093 "LOCAL_WCS", "LOCAL_WFS", "LOCAL_WMS", "REMOTE_WFS", "REMOTE_WCS","REMOTE_WMS" }; 094 095 096 private int serviceType ; 097 098 private final QualifiedName name; 099 100 private OWSCapabilities owsCapabilities; 101 102 private Surface validArea; 103 104 private double minScaleDenominator; 105 106 private double maxScaleDenominator; 107 108 private Object filterCondition; 109 110 111 112 /** 113 * TODO pre-conditions. 114 * @param serviceType 115 * @param name 116 * @param owsCapabilities 117 * @param validArea 118 * @param minScaleDenominator 119 * @param maxScaleDenominator 120 * @param filterCondition 121 */ 122 public AbstractDataSource( int serviceType, QualifiedName name, OWSCapabilities owsCapabilities, 123 Surface validArea, double minScaleDenominator, 124 double maxScaleDenominator, Object filterCondition ) { 125 126 setServiceType( serviceType ); 127 128 if ( name == null ){ 129 throw new NullPointerException( "QualifiedName cannot be null."); 130 } 131 this.name = name; 132 133 this.owsCapabilities = owsCapabilities; 134 this.validArea = validArea; 135 136 //TODO min < max? 137 this.minScaleDenominator = minScaleDenominator; 138 this.maxScaleDenominator = maxScaleDenominator; 139 140 this.filterCondition = filterCondition; 141 } 142 143 /** 144 * @return Returns the serviceType (WCS, WFS, remote WMS etc...) 145 */ 146 public int getServiceType() { 147 return serviceType ; 148 } 149 150 /** 151 * Sets the type of service. A service type means whether the service is a WFS, WCS, remote WMS, 152 * etc. Allowed values are LOCAL_WCS, LOCAL_WFS, LOCAL_WMS, REMOTE_WFS, REMOTE_WCS or 153 * REMOTE_WMS. 154 * 155 * @param serviceType the service type. 156 * @throws IllegalArgumentException if the serviceType is not of know type 157 */ 158 public void setServiceType( int serviceType ) { 159 if ( serviceType < LOCAL_WCS || serviceType > REMOTE_WMS ) { 160 throw new IllegalArgumentException("serviceType must be one of: " + 161 "LOCAL_WCS, LOCAL_WFS, LOCAL_WMS, REMOTE_WFS, REMOTE_WCS or " + 162 "REMOTE_WMS"); 163 } 164 this.serviceType = serviceType; 165 } 166 167 /** 168 * @return Returns the maxScaleDenominator. 169 */ 170 public double getMaxScaleDenominator() { 171 return maxScaleDenominator; 172 } 173 174 /** 175 * @return Returns the minScaleDenominator. 176 */ 177 public double getMinScaleDenominator() { 178 return minScaleDenominator; 179 } 180 181 /** 182 * @return Returns the name. 183 */ 184 public QualifiedName getName() { 185 return name; 186 } 187 188 /** 189 * @return Returns the owsCapabilities. 190 */ 191 public OWSCapabilities getOwsCapabilities() { 192 return owsCapabilities; 193 } 194 195 /** 196 * @return Returns the validArea. 197 */ 198 public Surface getValidArea() { 199 return validArea; 200 } 201 202 /** 203 * @return Returns the filterCondition. 204 */ 205 public Object getFilterCondition() { 206 return filterCondition; 207 } 208 209 /** 210 * Returns an instance of the <code>OGCWebService</code> that represents the 211 * datasource. Notice: if more than one datasets uses data that are offered by 212 * the same OWS, deegree WPVS will use just one instance for accessing 213 * the OWS 214 * @return an OGCWebService which represents this datasource 215 * @throws OGCWebServiceException if an error occurs while creating the webservice instance 216 * 217 */ 218 public abstract OGCWebService getOGCWebService() throws OGCWebServiceException; 219 220 //protected abstract OGCWebService createOGCWebService(); 221 222 @Override 223 public String toString(){ 224 225 StringBuilder sb = new StringBuilder(512); 226 227 sb.append( "DataSource: ").append( getName() ) 228 .append( "\n\t serviceType: " ).append( SERVICE_TYPE_TO_NAME[ getServiceType() ] ) 229 .append( "\n\t minScaleDenominator: " ).append( getMinScaleDenominator() ) 230 .append( "\n\t maxScaleDenominator: " ).append( getMaxScaleDenominator() ) 231 .append( "\n\t validArea: " ).append( getValidArea() ) 232 .append( "\n\t format: " ).append( getOwsCapabilities().getFormat() ) 233 .append( "\n\t onlineResource: " ).append( getOwsCapabilities().getOnlineResource() ); 234 235 return sb.toString(); 236 } 237 238 }