From: <svn...@os...> - 2012-05-29 07:47:31
|
Author: jive Date: 2012-05-29 00:47:24 -0700 (Tue, 29 May 2012) New Revision: 38775 Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/VersioningTransactionState.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java Log: Make DataStoreDecorator repository available through getRepository( typeName ) to allow for synchronisation sets. Signed-off-by: Jody Garnett <jod...@gm...> Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/VersioningTransactionState.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/VersioningTransactionState.java 2012-05-29 07:47:06 UTC (rev 38774) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/VersioningTransactionState.java 2012-05-29 07:47:24 UTC (rev 38775) @@ -102,16 +102,22 @@ public void setTransaction(final Transaction transaction) { if (transaction != null) { // configure - this.transaction = transaction; + if( this.transaction == null ){ + this.transaction = transaction; + } + else { + LOGGER.fine("Transaction being hot replaced!"); + this.transaction = transaction; + } } else { + // Any thing to close() or cleanup? this.transaction = null; - // TODO: is there some cleanup to do here? } } @Override public void addAuthorization(String AuthID) throws IOException { - // TODO Auto-generated method stub + // no security hooks provided for transaction state locking } @Override Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java 2012-05-29 07:47:06 UTC (rev 38774) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java 2012-05-29 07:47:24 UTC (rev 38775) @@ -46,7 +46,7 @@ /** * Decorator around an unversioned DataAccess allowing it to be used in conjunction - * with a GeoGit repository (for revision information). + * with a GeoGit {@link Repository} for revision information. * * @param <T> FeatureType * @param <F> Feature @@ -54,11 +54,19 @@ @SuppressWarnings({ "rawtypes", "unchecked" }) public class DataAccessDecorator<T extends FeatureType, F extends Feature> implements VersioningDataAccess<T, F> { - + + /** Checkout database used to reflect unversioned "live" data */ protected DataAccess<T, F> unversioned; + + /** + * Default GeoGit repository to use for storing revision history. + * <p> + * Subclasses can use {@link #getRepository(Name)} to access while still allowing support + * for multiple repositories if needed. + */ + private Repository repository; + - protected Repository repository; - public DataAccessDecorator(DataAccess unversioned, Repository versioningRepo) { Assert.notNull(unversioned); Assert.notNull(versioningRepo); @@ -129,6 +137,7 @@ @Override public void updateSchema(Name typeName, T featureType) throws IOException { unversioned.updateSchema(typeName, featureType); + // Is any effort needed to track the schema change in the geogit repository } /** @@ -148,13 +157,16 @@ } /** + * Used to retreive past revisions from GeoGit repository; the revision history range + * is provided by versionFilter (which is required tocontain a {@link ResourceId}. + * * @precondition {@code typeName != null && versioningFilter != null} * @precondition {@code versioningFilter.getIdentifiers().size() > 0} * @postcondition {@code $return != null} * @param typeName - * @param versioningFilter + * @param versioningFilter Id Filter providing revision history range * @param extraQuery - * @return + * @return features * @throws IOException */ public FeatureCollection getFeatures(final Name typeName, @@ -178,28 +190,65 @@ } final FeatureType featureType = this.getSchema(typeName); - ResourceIdFeatureCollector versionQuery; - versionQuery = new ResourceIdFeatureCollector(repository, featureType, + ResourceIdFeatureCollector versionCollector; + versionCollector = new ResourceIdFeatureCollector(repository, featureType, resourceIds); DefaultFeatureCollection features = new DefaultFeatureCollection(null, (SimpleFeatureType) featureType); - for (Feature f : versionQuery) { + + for (Feature f : versionCollector) { features.add((SimpleFeature) f); } return features; } - + + /** + * Lookup appropriate repository for provided typeName. + * <b> + * By default there is a single GeoGit repository associated with the {@link #unversioned} + * DataStore. When making use of more than one Repository you can override this method to + * perform the mapping. + * + * @param typeName + * @return Repository for use with the provided typeName + */ + protected Repository getRepository( Name typeName ){ + return repository; + } + /** + * Return a {@link FeatureSourceDecorator} using the repository provided + * by {@link #getRepository(Name)}. + * + * @param source + * @return FeatureSource allowing access to source and repository data + */ protected FeatureSource<T, F> createFeatureSource(FeatureSource<T, F> source) { - return new FeatureSourceDecorator(source, repository); + Repository repo = getRepository( source.getName() ); + return new FeatureSourceDecorator(source, repo); } - + /** + * Return a {@link FeatureStoreDecorator} using the repository provided + * by {@link #getRepository(Name)}. + * + * @param store + * @return FeatureSource allowing access to source and repository data + */ protected FeatureStore<T, F> createFeatureStore(FeatureStore<T, F> store) { - return new FeatureStoreDecorator(store, repository); + Repository repo = getRepository( store.getName() ); + return new FeatureStoreDecorator(store, repo); } + /** + * Return a {@link FeatureLockingDecorator} using the repository provided + * by {@link #getRepository(Name)}. + * + * @param locking + * @return FeatureSource allowing access to source and repository data + */ protected FeatureLocking<T, F> createFeatureLocking( FeatureLocking<T, F> locking) { - return new FeatureLockingDecorator(locking, repository); + Repository repo = getRepository( locking.getName() ); + return new FeatureLockingDecorator(locking, repo); } } Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java 2012-05-29 07:47:06 UTC (rev 38774) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java 2012-05-29 07:47:24 UTC (rev 38775) @@ -21,6 +21,7 @@ import org.geogit.repository.Repository; import org.geotools.data.DataStore; import org.geotools.data.FeatureReader; +import org.geotools.data.FeatureSource; import org.geotools.data.FeatureWriter; import org.geotools.data.LockingManager; import org.geotools.data.Query; @@ -43,8 +44,10 @@ @Override public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException { - return (SimpleFeatureSource) VersioningAdapterFactory.create( - unversioned.getFeatureSource(typeName), repository); + Repository repo = getRepository(typeName); + + FeatureSource<SimpleFeatureType, SimpleFeature> source = unversioned.getFeatureSource(typeName); + return (SimpleFeatureSource) VersioningAdapterFactory.create(source, repo); } @Override @@ -66,9 +69,9 @@ @Override public SimpleFeatureSource getFeatureSource(String typeName) throws IOException { - return (SimpleFeatureSource) VersioningAdapterFactory.create( - ((DataStore) unversioned).getFeatureSource(typeName), - repository); + SimpleFeatureSource source = ((DataStore) unversioned).getFeatureSource(typeName); + Repository repo = getRepository( source.getName() ); + return (SimpleFeatureSource) VersioningAdapterFactory.create(source,repo); } @Override |