org.geotools.data.FeatureLocking Maven / Gradle / Ivy
Show all versions of gt-main Show documentation
/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.data;
import java.io.IOException;
import java.util.Set;
import org.opengis.feature.Feature;
import org.opengis.feature.type.FeatureType;
import org.opengis.filter.Filter;
/**
* Provides Feature based locking.
*
*
* Features from individual shapefiles, database tables, etc. can be protected
* or reserved from modification through this interface.
*
*
* To use please cast your SimpleFeatureSource to this interface.
*
* SimpleFeatureSource source = dataStore.getFeatureSource("roads");
* if( source instanceof FeatureLocking ) {
* FeatureLocking locking = (FeatureLocking) source;
* ...
* }
*
* @author Jody Garnett, Refractions Research, Inc.
* @author Ray Gallagher
* @author Rob Hranac, TOPP
* @author Chris Holmes, TOPP
*
*
*
* @version $Id$
*/
public interface FeatureLocking
extends FeatureStore {
/**
* All locking operations will operate against the provided lock
.
*
* This in in keeping with the stateful spirit of DataSource in which operations are against
* the "current" transaction. If a FeatureLock is not provided lock operations will only be
* applicable for the current transaction (they will expire on the next commit or rollback).
*
*
That is lockFeatures() operations will:
*
*
* - Be recorded against the provided FeatureLock.
*
- Be recorded against the current transaction if no FeatureLock is provided.
*
*
* Calling this method with setFeatureLock( FeatureLock.TRANSACTION
* )
will revert to per transaction operation.
*
*
This design allows for the following:
*
*
* - cross DataSource FeatureLock usage
*
- not having pass in the same FeatureLock object multiple times
*
*
* @param lock FeatureLock configuration including authorization and requested duration
*/
void setFeatureLock(FeatureLock lock);
/**
* FeatureLock features described by Query.
*
* To implement WFS parcial Locking retrieve your features with a query operation first
* before trying to lock them individually. If you are not into WFS please don't ask what
* parcial locking is.
*
* @param query Query describing the features to lock
* @return Number of features locked
* @throws IOException Thrown if anything goes wrong
*/
int lockFeatures(Query query) throws IOException;
/**
* FeatureLock features described by Filter.
*
*
To implement WFS parcial Locking retrieve your features with a query operation first
* before trying to lock them individually. If you are not into WFS please don't ask what
* parcial locking is.
*
* @param filter Filter describing the features to lock
* @return Number of features locked
* @throws IOException Thrown if anything goes wrong
*/
int lockFeatures(Filter filter) throws IOException;
/**
* FeatureLock all Features.
*
*
The method does not prevent addFeatures() from being used (we could add a lockDataSource()
* method if this functionality is required.
*
* @return Number of Features locked by this opperation
*/
int lockFeatures() throws IOException;
/**
* Unlocks all Features.
*
*
Authorization must be provided prior before calling this method.
*
*
* void releaseLock( String lockId, LockingDataSource ds ){
* ds.setAuthorization( "LOCK534" );
* ds.unLockFeatures();
* }
*
*/
void unLockFeatures() throws IOException;
/**
* Unlock Features denoted by provided filter.
*
* Authorization must be provided prior before calling this method.
*/
void unLockFeatures(Filter filter) throws IOException;
/**
* Unlock Features denoted by provided query.
*
*
Authorization must be provided prior before calling this method.
*
* @param query Specifies fatures to unlock
*/
void unLockFeatures(Query query) throws IOException;
/** Idea for a response from a high-level lock( Query ) function. */
public static class Response {
String authID;
Set locked;
Set notLocked;
public Response(FeatureLock lock, Set lockedFids, Set notLockedFids) {
authID = lock.getAuthorization();
locked = lockedFids;
notLocked = notLockedFids;
}
public String getAuthorizationID() {
return authID;
}
public Set getLockedFids() {
return locked;
}
public Set getNotLockedFids() {
return notLocked;
}
}
}