001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/io/datastore/DatastoreTransaction.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;
037    
038    import java.util.List;
039    import java.util.Map;
040    
041    import org.deegree.io.datastore.idgenerator.FeatureIdAssigner;
042    import org.deegree.io.datastore.schema.MappedFeatureType;
043    import org.deegree.model.feature.Feature;
044    import org.deegree.model.feature.FeatureProperty;
045    import org.deegree.model.filterencoding.Filter;
046    import org.deegree.ogcbase.PropertyPath;
047    import org.deegree.ogcwebservices.wfs.operation.transaction.Delete;
048    import org.deegree.ogcwebservices.wfs.operation.transaction.Insert;
049    import org.deegree.ogcwebservices.wfs.operation.transaction.Native;
050    import org.deegree.ogcwebservices.wfs.operation.transaction.TransactionOperation;
051    import org.deegree.ogcwebservices.wfs.operation.transaction.Update;
052    
053    /**
054     * Handler for {@link TransactionOperation}s ({@link Insert}, {@link Update}, {@link Delete}, {@link Native}). One
055     * instance is bound to exactly one {@link Datastore} instance (and one {@link Datastore} has no more than one active
056     * <code>DatastoreTransaction</code> at a time.
057     * 
058     * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh</a>
059     * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider</a>
060     * @author last edited by: $Author: mschneider $
061     * 
062     * @version $Revision: 18544 $, $Date: 2009-07-20 16:14:38 +0200 (Mo, 20 Jul 2009) $
063     */
064    public interface DatastoreTransaction {
065    
066        /**
067         * Returns the associated {@link Datastore} instance.
068         * 
069         * @return the associated Datastore instance
070         */
071        public Datastore getDatastore();
072    
073        /**
074         * Makes the changes persistent that have been performed in this transaction.
075         * 
076         * @throws DatastoreException
077         */
078        public void commit()
079                                throws DatastoreException;
080    
081        /**
082         * Aborts the changes that have been performed in this transaction.
083         * 
084         * @throws DatastoreException
085         */
086        public void rollback()
087                                throws DatastoreException;
088    
089        /**
090         * Releases the transaction instance so other clients may acquire a transaction (and underlying resources, such as
091         * JDBCConnections can be cleaned up).
092         * 
093         * @throws DatastoreException
094         */
095        public void release()
096                                throws DatastoreException;
097    
098        /**
099         * Inserts the given feature instances into the datastore.
100         * <p>
101         * Please note that the features to be inserted must have suitable feature ids at this point.
102         * 
103         * @param features
104         * @return feature ids of the inserted (root) features
105         * @throws DatastoreException
106         * @see FeatureIdAssigner
107         */
108        public List<FeatureId> performInsert( List<Feature> features )
109                                throws DatastoreException;
110    
111        /**
112         * Performs an update operation against the datastore.
113         * 
114         * @param mappedFeatureType
115         *            feature type that is to be updated
116         * @param replacementProps
117         *            properties and their replacement values
118         * @param filter
119         *            selects the feature instances that are to be updated
120         * @param lockId
121         *            optional id of associated lock (may be null)
122         * @return number of updated feature instances
123         * @throws DatastoreException
124         */
125        public int performUpdate( MappedFeatureType mappedFeatureType, Map<PropertyPath, FeatureProperty> replacementProps,
126                                  Filter filter, String lockId )
127                                throws DatastoreException;
128    
129        /**
130         * Performs a replace-update operation against the datastore.
131         * 
132         * @param mappedFeatureType
133         *            feature type that is to be replaced
134         * @param replacementFeature
135         *            feature instance that will be used to replace the properties of the selected features
136         * @param filter
137         *            selects the feature instances that are to be replaced
138         * @param lockId
139         *            optional id of associated lock (may be null)
140         * @return number of replaced feature instances
141         * @throws DatastoreException
142         */
143        public int performUpdate( MappedFeatureType mappedFeatureType, Feature replacementFeature, Filter filter,
144                                  String lockId )
145                                throws DatastoreException;
146    
147        /**
148         * Deletes the features from the datastore that are matched by the given filter and type.
149         * 
150         * @param mappedFeatureType
151         * @param filter
152         * @param lockId
153         *            optional id of associated lock (may be null)
154         * @return number of deleted feature instances
155         * @throws DatastoreException
156         */
157        public int performDelete( MappedFeatureType mappedFeatureType, Filter filter, String lockId )
158                                throws DatastoreException;
159    
160        /**
161         * Performs a native operation against the datastore.
162         * 
163         * @param operation
164         *            operation to perform
165         * @return int
166         * @throws DatastoreException
167         */
168        public int performNative( Native operation )
169                                throws DatastoreException;
170    
171    }