001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/io/datastore/schema/MappedFeatureType.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.io.datastore.schema; 037 038 import java.net.URI; 039 040 import org.deegree.datatypes.QualifiedName; 041 import org.deegree.io.datastore.Datastore; 042 import org.deegree.io.datastore.DatastoreException; 043 import org.deegree.io.datastore.DatastoreTransaction; 044 import org.deegree.io.datastore.FeatureId; 045 import org.deegree.io.datastore.idgenerator.IdGenerationException; 046 import org.deegree.model.crs.UnknownCRSException; 047 import org.deegree.model.feature.FeatureCollection; 048 import org.deegree.model.feature.schema.DefaultFeatureType; 049 import org.deegree.model.feature.schema.FeatureType; 050 import org.deegree.model.feature.schema.PropertyType; 051 import org.deegree.ogcwebservices.wfs.operation.Query; 052 053 /** 054 * Represents a {@link FeatureType} with mapping (persistence) information. 055 * <p> 056 * The mapping information describe how the {@link FeatureType} is mapped in the database backend. 057 * 058 * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a> 059 * @author last edited by: $Author: mschneider $ 060 * 061 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $ 062 */ 063 public class MappedFeatureType extends DefaultFeatureType { 064 065 private static final long serialVersionUID = -6091409034103779707L; 066 067 private String table; 068 069 private MappedGMLId gmlId; 070 071 private MappedGMLSchema schema; 072 073 private Datastore datastore; 074 075 private boolean isVisible; 076 077 private boolean isUpdatable; 078 079 private boolean isDeletable; 080 081 private boolean isInsertable; 082 083 private boolean isPseudoFeatureType; 084 085 private URI defaultSRS; 086 087 private URI[] otherSRS; 088 089 /** 090 * Creates a new instance of <code>MappedFeatureType</code> from the given parameters. 091 * 092 * @param name 093 * @param isAbstract 094 * @param properties 095 * @param table 096 * @param gmlId 097 * @param schema 098 * @param isVisible 099 * @param isUpdatable 100 * @param isDeletable 101 * @param isInsertable 102 * @param isPseudoFeatureType 103 * @param otherSRS 104 * @param defaultSRS 105 */ 106 MappedFeatureType( QualifiedName name, boolean isAbstract, PropertyType[] properties, String table, 107 MappedGMLId gmlId, MappedGMLSchema schema, boolean isVisible, boolean isUpdatable, 108 boolean isDeletable, boolean isInsertable, boolean isPseudoFeatureType, URI defaultSRS, 109 URI[] otherSRS ) { 110 super( name, isAbstract, properties ); 111 this.table = table; 112 this.gmlId = gmlId; 113 this.schema = schema; 114 this.datastore = schema.getDatastore(); 115 this.isVisible = isVisible; 116 this.isUpdatable = isUpdatable; 117 this.isDeletable = isDeletable; 118 this.isInsertable = isInsertable; 119 this.isPseudoFeatureType = isPseudoFeatureType; 120 this.defaultSRS = defaultSRS; 121 this.otherSRS = otherSRS; 122 } 123 124 /** 125 * Returns the name of the (database) table where the feature type is stored. 126 * 127 * @return name of the associated table 128 */ 129 public String getTable() { 130 return this.table; 131 } 132 133 /** 134 * Returns the mapping information for the "gml:Id" attribute. 135 * 136 * @return mapping information for the "gml:Id" attribute 137 */ 138 public MappedGMLId getGMLId() { 139 return this.gmlId; 140 } 141 142 /** 143 * Generates a new and unique feature identifier. 144 * 145 * @param ta 146 * @return a new and unique feature identifier. 147 * @throws IdGenerationException 148 */ 149 public FeatureId generateFid( DatastoreTransaction ta ) 150 throws IdGenerationException { 151 return this.gmlId.generateFid( this, ta ); 152 } 153 154 /** 155 * Returns the GML Application schema that defines this feature type. 156 * 157 * @return GML Application schema that defines this feature type 158 */ 159 public MappedGMLSchema getGMLSchema() { 160 return this.schema; 161 } 162 163 /** 164 * Returns whether the persistent feature type is visible (e.g. queryable in the WFS). 165 * 166 * @return true, if the persistent feature type is visible. 167 */ 168 public boolean isVisible() { 169 return this.isVisible; 170 } 171 172 /** 173 * Returns whether update operations may be performed on the persistent feature type. 174 * 175 * @return true, if update operations may be performed, false otherwise. 176 */ 177 public boolean isUpdatable() { 178 return this.isUpdatable; 179 } 180 181 /** 182 * Returns whether delete operations may be performed on the persistent feature type. 183 * 184 * @return true, if delete operations may be performed, false otherwise. 185 */ 186 public boolean isDeletable() { 187 return this.isDeletable; 188 } 189 190 /** 191 * Returns whether insert operations may be performed on the persistent feature type. 192 * 193 * @return true, if insert operations may be performed, false otherwise. 194 */ 195 public boolean isInsertable() { 196 return this.isInsertable; 197 } 198 199 /** 200 * Returns whether this feature type definition is used to store complex xml data that is not a real gml feature. 201 * <p> 202 * If this is the case, the <code>gml:id</code> and <code>gml:boundedBy</code> elements are omitted in XML output. 203 * 204 * @return true, if this feature type declaration is a pseudo feature type, false otherwise 205 */ 206 public boolean isPseudoFeatureType() { 207 return this.isPseudoFeatureType; 208 } 209 210 /** 211 * Returns the default SRS. 212 * 213 * @return the default SRS 214 */ 215 public URI getDefaultSRS() { 216 return defaultSRS; 217 } 218 219 /** 220 * Returns alternative SRS that may be used to query the feature type. 221 * 222 * @return alternative SRS 223 */ 224 public URI[] getOtherSRS() { 225 return otherSRS; 226 } 227 228 /** 229 * Performs the given {@link Query}. It must target solely this <code>MappedFeatureType</code> (joins are not 230 * allowed). 231 * <p> 232 * All members of the resulting <code>FeatureCollection</code> have this <code>MappedFeatureType</code>. 233 * 234 * @param query 235 * Query to be performed 236 * @return FeatureCollection with members that have this type 237 * @throws DatastoreException 238 * @throws UnknownCRSException 239 */ 240 public FeatureCollection performQuery( Query query ) 241 throws DatastoreException, UnknownCRSException { 242 return this.datastore.performQuery( query, new MappedFeatureType[] { this } ); 243 } 244 245 /** 246 * Performs the given <code>Query</code> <i>inside</i> the given transaction context. It must target solely this 247 * <code>MappedFeatureType</code> (joins are not allowed). 248 * <p> 249 * All members of the resulting <code>FeatureCollection</code> have this <code>MappedFeatureType</code>. 250 * 251 * @param query 252 * Query to be performed 253 * @param context 254 * transaction context (used to specify the JDBCConnection, for example) 255 * @return FeatureCollection with members that have this type 256 * @throws DatastoreException 257 * @throws UnknownCRSException 258 */ 259 public FeatureCollection performQuery( Query query, DatastoreTransaction context ) 260 throws DatastoreException, UnknownCRSException { 261 return this.datastore.performQuery( query, new MappedFeatureType[] { this }, context ); 262 } 263 264 /** 265 * Retrieves a transaction object for this feature type. 266 * 267 * @return a transaction object for this feature type 268 * @throws DatastoreException 269 * if transaction could not be acquired 270 */ 271 public DatastoreTransaction acquireTransaction() 272 throws DatastoreException { 273 return this.datastore.acquireTransaction(); 274 } 275 276 /** 277 * Returns all non-abstract feature types that may be used as substitutions for this feature type. 278 * 279 * @return all non-abstract feature types that may be used as substitutions 280 */ 281 public MappedFeatureType[] getConcreteSubstitutions() { 282 return this.schema.getSubstitutions( this ); 283 } 284 285 /** 286 * Return whether this feature type has more than one concrete substitution. 287 * <p> 288 * Read as: Is there only one concrete feature type that all instances of this type must have? Or are there several 289 * possible concrete subtypes? 290 * 291 * @return true, if the feature type has more than once concrete implementations, false otherwise 292 */ 293 public boolean hasSeveralImplementations() { 294 return this.schema.hasSeveralImplementations( this ); 295 } 296 }