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