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