Author: jive Date: 2012-02-27 20:48:01 -0800 (Mon, 27 Feb 2012) New Revision: 38577 Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitDataStoreFactory.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitSimpleFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoToolsCommitStateResolver.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/ModifyingFeatureCollection.java 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/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningDataAccess.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ 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 trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/QueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdQueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionDetail.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionFilters.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionQuery.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionedFeatureWrapper.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersioningAdapterFactory.java Removed: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoToolsCommitStateResolver.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/ModifyingFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/VersioningTransactionState.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataAccess.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataAccessDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DefaultVersionedFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/QueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdQueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionDetail.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionFilters.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionQuery.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionedFeatureWrapper.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitDataStoreTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureSourceTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureStoreTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/VersioningTestSupport.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java Log: Move to org.geotools package structure Signed-off-by: Jody Garnett <jod...@gm...> Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,404 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Logger; - -import org.geogit.api.MutableTree; -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevObject.TYPE; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.storage.ObjectDatabase; -import org.geogit.storage.ObjectReader; -import org.geogit.storage.ObjectWriter; -import org.geogit.storage.RefDatabase; -import org.geogit.storage.WrappedSerialisingFactory; -import org.geogit.storage.hessian.HessianSimpleFeatureTypeReader; -import org.geogit.storage.hessian.HessianSimpleFeatureTypeWriter; -import org.geoserver.data.versioning.VersioningDataStore; -import org.geotools.data.DefaultServiceInfo; -import org.geotools.data.FeatureReader; -import org.geotools.data.FeatureWriter; -import org.geotools.data.LockingManager; -import org.geotools.data.Query; -import org.geotools.data.SchemaNotFoundException; -import org.geotools.data.ServiceInfo; -import org.geotools.data.Transaction; -import org.geotools.feature.NameImpl; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.geotools.util.logging.Logging; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; - -public class GeoGitDataStore implements VersioningDataStore { - - private static final Logger LOGGER = Logging - .getLogger(GeoGitDataStore.class); - - public static final String TYPE_NAMES_REF_TREE = "typeNames"; - - private static final String NULL_NAMESPACE = ""; - - private Repository repo; - - private final String defaultNamespace; - - public GeoGitDataStore(final Repository repo) throws IOException { - this(repo, null); - } - - public GeoGitDataStore(final Repository repo, final String defaultNamespace) - throws IOException { - Preconditions.checkNotNull(repo, "repository"); - this.repo = repo; - this.defaultNamespace = defaultNamespace; - init(); - } - - private void init() throws IOException { - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - if (null == typesTreeRef) { - LOGGER.info("Initializing type name references. Types tree does not exist"); - final RevTree typesTree = objectDatabase.newTree(); - ObjectId typesTreeId; - try { - WrappedSerialisingFactory serialisingFactory; - serialisingFactory = WrappedSerialisingFactory.getInstance(); - ObjectWriter<RevTree> treeWriter = serialisingFactory - .createRevTreeWriter(typesTree); - typesTreeId = objectDatabase.put(treeWriter); - } catch (Exception e) { - throw new IOException(e); - } - typesTreeRef = new Ref(TYPE_NAMES_REF_TREE, typesTreeId, TYPE.TREE); - refDatabase.put(typesTreeRef); - LOGGER.info("Type names tree reference initialized"); - } else { - LOGGER.info("Loading type name references"); - List<Name> names = getNamesInternal(); - LOGGER.fine("Managed types: " + names); - } - - } - - public Repository getRepository() { - return repo; - } - - /** - * @see org.geotools.data.DataAccess#getInfo() - */ - @Override - public ServiceInfo getInfo() { - DefaultServiceInfo si = new DefaultServiceInfo(); - si.setDescription("GeoGIT DataStore"); - si.setTitle("GeoGIT"); - return si; - } - - /** - * @see org.geotools.data.DataAccess#dispose() - */ - @Override - public void dispose() { - // TODO Auto-generated method stub - - } - - private List<Name> getNamesInternal() throws IOException { - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - RevTree namespacesTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(null != namespacesTree, - "Referenced types tree does not exist: " + typesTreeRef); - - List<Name> names = new ArrayList<Name>(); - for (Iterator<Ref> namespaces = namespacesTree.iterator(null); namespaces - .hasNext();) { - final Ref namespaceRef = namespaces.next(); - Preconditions.checkState(TYPE.TREE.equals(namespaceRef.getType())); - final String nsUri = namespaceRef.getName(); - final RevTree typesTree = objectDatabase.getTree(namespaceRef - .getObjectId()); - for (Iterator<Ref> simpleNames = typesTree.iterator(null); simpleNames - .hasNext();) { - final Ref typeNameRef = simpleNames.next(); - final String simpleTypeName = typeNameRef.getName(); - names.add(new NameImpl(nsUri, simpleTypeName)); - } - } - - return names; - } - - /** - * @see org.geotools.data.DataAccess#getNames() - */ - @Override - public List<Name> getNames() throws IOException { - return getNamesInternal(); - } - - /** - * @see org.geotools.data.DataStore#getTypeNames() - * @see #getNames() - */ - @Override - public String[] getTypeNames() throws IOException { - final List<Name> names = getNames(); - String[] simpleNames = new String[names.size()]; - for (int i = 0; i < names.size(); i++) { - simpleNames[i] = names.get(i).getLocalPart(); - } - return simpleNames; - } - - /** - * @see org.geotools.data.DataAccess#createSchema(org.opengis.feature.type.FeatureType) - */ - @Override - public void createSchema(final SimpleFeatureType featureType) - throws IOException { - Preconditions.checkNotNull(featureType); - - SimpleFeatureType createType = featureType; - - LOGGER.info("Creating FeatureType " + createType.getName()); - - if (getNames().contains(createType.getName())) { - throw new IOException(createType.getName() + " already exists"); - } - - { - // GeoServer calls createSchema with this namespace but then asks - // for the one passed in - // as the DataStore's namespace parameter - final String ignoreNamespace = "http://www.opengis.net/gml"; - Name name = createType.getName(); - if ((ignoreNamespace.equals(name.getNamespaceURI()) || null == name - .getNamespaceURI()) && null != defaultNamespace) { - LOGGER.info("FeatureType to be created has no namespace, assigning DataStore's default: '" - + defaultNamespace + "'"); - - SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setName(createType.getName().getLocalPart()); - builder.setNamespaceURI(defaultNamespace); - builder.addAll(createType.getAttributeDescriptors()); - createType = builder.buildFeatureType(); - } - - } - final Name typeName = createType.getName(); - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - final RevTree namespacesRootTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(namespacesRootTree != null); - - final String namespace = null == typeName.getNamespaceURI() ? NULL_NAMESPACE - : typeName.getNamespaceURI(); - final String localName = typeName.getLocalPart(); - - try { - final ObjectId featureTypeBlobId; -// WrappedSerialisingFactory serialisingFactory; -// serialisingFactory = WrappedSerialisingFactory.getInstance(); -// featureTypeBlobId = objectDatabase.put(serialisingFactory -// .createSimpleFeatureTypeWriter(createType)); - featureTypeBlobId = objectDatabase.put(new HessianSimpleFeatureTypeWriter(createType)); - - final List<String> namespaceTreePath = Collections - .singletonList(namespace); - MutableTree namespaceTree = objectDatabase.getOrCreateSubTree( - namespacesRootTree, namespaceTreePath); - - namespaceTree.put(new Ref(localName, featureTypeBlobId, TYPE.BLOB)); - - final MutableTree root = namespacesRootTree.mutable(); - final ObjectId newTypeRefsTreeId; - newTypeRefsTreeId = objectDatabase.writeBack(root, namespaceTree, - namespaceTreePath); - - final Ref newTypesTreeRef = new Ref(TYPE_NAMES_REF_TREE, - newTypeRefsTreeId, TYPE.TREE); - refDatabase.put(newTypesTreeRef); - - } catch (IOException e) { - throw e; - } catch (Exception e) { - Throwables.propagate(e); - } - } - - /** - * @see org.geotools.data.DataAccess#getSchema(org.opengis.feature.type.Name) - */ - @Override - public SimpleFeatureType getSchema(final Name name) throws IOException { - Preconditions.checkNotNull(name); - - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - final RevTree namespacesRootTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(namespacesRootTree != null); - - final String[] path = { - name.getNamespaceURI() == null ? NULL_NAMESPACE : name - .getNamespaceURI(), name.getLocalPart() }; - - final Ref typeRef = objectDatabase.getTreeChild(namespacesRootTree, - path); - if (typeRef == null) { - throw new SchemaNotFoundException(name.toString()); - } - Preconditions.checkState(TYPE.BLOB.equals(typeRef.getType())); - final ObjectId objectId = typeRef.getObjectId(); - WrappedSerialisingFactory serialisingFactory; - serialisingFactory = WrappedSerialisingFactory.getInstance(); -// final ObjectReader<SimpleFeatureType> reader = serialisingFactory -// .createSimpleFeatureTypeReader(name); - final ObjectReader<SimpleFeatureType> reader = - new HessianSimpleFeatureTypeReader(name); - final SimpleFeatureType featureType = objectDatabase.get(objectId, - reader); - return featureType; - } - - /** - * @see org.geotools.data.DataStore#getSchema(java.lang.String) - * @see #getSchema(Name) - */ - @Override - public SimpleFeatureType getSchema(final String typeName) - throws IOException { - final List<Name> names = getNames(); - for (Name name : names) { - if (name.getLocalPart().equals(typeName)) { - return getSchema(name); - } - } - throw new SchemaNotFoundException(typeName); - } - - /** - * @see org.geotools.data.DataStore#getFeatureSource(java.lang.String) - * @see #getFeatureSource(Name) - */ - @Override - public GeoGitFeatureSource getFeatureSource(final String typeName) - throws IOException { - final List<Name> names = getNames(); - for (Name name : names) { - if (name.getLocalPart().equals(typeName)) { - return getFeatureSource(name); - } - } - throw new SchemaNotFoundException(typeName); - } - - /** - * @see org.geotools.data.DataStore#getFeatureSource(org.opengis.feature.type.Name) - */ - @Override - public GeoGitFeatureSource getFeatureSource(final Name typeName) - throws IOException { - final SimpleFeatureType featureType = getSchema(typeName); - - return new GeoGitFeatureStore(featureType, this); - } - - @Override - public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( - Query query, Transaction transaction) throws IOException { - - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( - String typeName, Filter filter, Transaction transaction) - throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( - String typeName, Transaction transaction) throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend( - String typeName, Transaction transaction) throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public LockingManager getLockingManager() { - return null; - } - - /** - * @see org.geotools.data.DataAccess#updateSchema(org.opengis.feature.type.Name, - * org.opengis.feature.type.FeatureType) - */ - @Override - public void updateSchema(Name typeName, SimpleFeatureType featureType) - throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); - } - - /** - * @see org.geotools.data.DataStore#updateSchema(java.lang.String, - * org.opengis.feature.simple.SimpleFeatureType) - */ - @Override - public void updateSchema(String typeName, SimpleFeatureType featureType) - throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,143 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.awt.RenderingHints.Key; -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -import org.geogit.repository.Repository; -import org.geogit.storage.RepositoryDatabase; -import org.geogit.storage.bdbje.EntityStoreConfig; -import org.geogit.storage.bdbje.EnvironmentBuilder; -import org.geogit.storage.bdbje.JERepositoryDatabase; -import org.geotools.data.DataSourceException; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFactorySpi; - -import com.sleepycat.je.Environment; - -public class GeoGitDataStoreFactory implements DataStoreFactorySpi { - - public static final Param USE_EMBEDDED_REPO = new Param("GEOGIT_EMBEDDED", - Boolean.class, "Use Embedded GeoGIT Repository"); - - public static final Param DEFAULT_NAMESPACE = new Param("namespace", - String.class, "Default namespace", false); - - public static final Param DATA_ROOT = new Param("data_root", String.class, - "Root directory for the versioned data store", false); - - public static final Param REPO_PATH = new Param("repo_path", String.class, - "Path, within the data root, for the GeoGIT repository", false); - - public static final Param INDEX_PATH = new Param("index_path", - String.class, - "Path, within the data root, for the GeoGIT index repository", - false); - - @Override - public String getDisplayName() { - return "GeoGIT"; - } - - @Override - public String getDescription() { - return "GeoGIT Versioning DataStore"; - } - - @Override - public Param[] getParametersInfo() { - return new Param[] { USE_EMBEDDED_REPO, DEFAULT_NAMESPACE }; - } - - @Override - public boolean canProcess(Map<String, Serializable> params) { - try { - Object lookUp = USE_EMBEDDED_REPO.lookUp(params); - return Boolean.TRUE.equals(lookUp); - } catch (IOException e) { - // - } - return false; - } - - /** - * @see org.geotools.data.DataAccessFactory#isAvailable() - */ - @Override - public boolean isAvailable() { - return true; - } - - @Override - public Map<Key, ?> getImplementationHints() { - return Collections.emptyMap(); - } - - @Override - public DataStore createDataStore(Map<String, Serializable> params) - throws IOException { - Object lookUp = USE_EMBEDDED_REPO.lookUp(params); - if (!Boolean.TRUE.equals(lookUp)) { - throw new DataSourceException(USE_EMBEDDED_REPO.key - + " is not true"); - } - - String defaultNamespace = (String) DEFAULT_NAMESPACE.lookUp(params); - - String dataRootPath = (String) DATA_ROOT.lookUp(params); - String repoPath = (String) REPO_PATH.lookUp(params); - String indexPath = (String) INDEX_PATH.lookUp(params); - - final File dataRoot = new File(dataRootPath); - final File geogitRepo = new File(dataRoot, repoPath); - final File indexRepo = new File(dataRoot, indexPath); - - EnvironmentBuilder esb = new EnvironmentBuilder(new EntityStoreConfig()); - Properties bdbEnvProperties = null; - Environment geogitEnv = esb.buildEnvironment(geogitRepo, - bdbEnvProperties); - Environment indexEnv = esb - .buildEnvironment(indexRepo, bdbEnvProperties); - - RepositoryDatabase ggitRepoDb = new JERepositoryDatabase(geogitEnv, - indexEnv); - - Repository repository = new Repository(ggitRepoDb, dataRoot); - repository.create(); - - // Repository repository = GEOGIT.get().getRepository(); - GeoGitDataStore store = new GeoGitDataStore(repository, - defaultNamespace); - return store; - } - - /** - * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map) - */ - @Override - public DataStore createNewDataStore(Map<String, Serializable> params) - throws IOException { - throw new UnsupportedOperationException(); - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,342 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.awt.RenderingHints; -import java.awt.RenderingHints.Key; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.geogit.api.ObjectId; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.storage.ObjectDatabase; -import org.geoserver.data.versioning.SimpleVersioningFeatureSource; -import org.geotools.data.DataSourceException; -import org.geotools.data.DefaultResourceInfo; -import org.geotools.data.FeatureListener; -import org.geotools.data.Query; -import org.geotools.data.QueryCapabilities; -import org.geotools.data.ResourceInfo; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.store.EmptyFeatureCollection; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.factory.Hints; -import org.geotools.filter.spatial.DefaultCRSFilterVisitor; -import org.geotools.filter.spatial.ReprojectingFilterVisitor; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; -import org.opengis.filter.sort.SortBy; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.google.common.base.Throwables; - -public class GeoGitFeatureSource implements SimpleVersioningFeatureSource { - - protected final SimpleFeatureType type; - - protected final GeoGitDataStore dataStore; - - /** - * @see #getSupportedHints() - */ - private static final Set<Key> supportedHints = Collections - .unmodifiableSet(new HashSet<Key>(Arrays.asList( - Hints.FEATURE_DETACHED, Hints.JTS_GEOMETRY_FACTORY, - Hints.JTS_COORDINATE_SEQUENCE_FACTORY) - - )); - - public GeoGitFeatureSource(final SimpleFeatureType type, - final GeoGitDataStore dataStore) { - this.type = type; - this.dataStore = dataStore; - } - - /** - * @return the tree of feature references for this type - */ - public RevTree getCurrentVersion() { - // assume HEAD is at MASTER - try { - final Name typeName = this.type.getName(); - Repository repository = dataStore.getRepository(); - RevTree typeTree = repository.getWorkingTree().getHeadVersion( - typeName); - return typeTree; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * @see org.geotools.data.FeatureSource#getName() - */ - @Override - public Name getName() { - return type.getName(); - } - - /** - * @see org.geotools.data.FeatureSource#getInfo() - */ - @Override - public ResourceInfo getInfo() { - DefaultResourceInfo info = new DefaultResourceInfo(); - ReferencedEnvelope bounds; - try { - bounds = getBounds(); - if (bounds != null) { - info.setBounds(bounds); - info.setCRS(bounds.getCoordinateReferenceSystem()); - } - } catch (IOException e) { - Throwables.propagate(e); - } - info.setName(getName().getLocalPart()); - info.setDescription("GeoGit backed Feature Source"); - return info; - } - - /** - * @see org.geotools.data.FeatureSource#getDataStore() - */ - @Override - public GeoGitDataStore getDataStore() { - return dataStore; - } - - /** - * @see org.geotools.data.FeatureSource#getQueryCapabilities() - */ - @Override - public QueryCapabilities getQueryCapabilities() { - QueryCapabilities caps = new QueryCapabilities() { - /** - * @see org.geotools.data.QueryCapabilities#isUseProvidedFIDSupported() - * @return {@code true} - */ - @Override - public boolean isUseProvidedFIDSupported() { - return true; - } - - /** - * @see org.geotools.data.QueryCapabilities#supportsSorting(org.opengis.filter.sort.SortBy[]) - * @return {@code false} - */ - @Override - public boolean supportsSorting(SortBy[] sortAttributes) { - return false; - } - }; - - return caps; - } - - @Override - public void addFeatureListener(FeatureListener listener) { - // TODO Auto-generated method stub - - } - - @Override - public void removeFeatureListener(FeatureListener listener) { - // TODO Auto-generated method stub - - } - - /** - * @see org.geotools.data.FeatureSource#getSchema() - */ - @Override - public SimpleFeatureType getSchema() { - return type; - } - - /** - * @see org.geotools.data.FeatureSource#getBounds() - * @see #getBounds(Query) getBounds(Query.ALL) - */ - @Override - public ReferencedEnvelope getBounds() throws IOException { - return getBounds(Query.ALL); - } - - /** - * @see org.geotools.data.FeatureSource#getBounds(org.geotools.data.Query) - */ - @Override - public ReferencedEnvelope getBounds(final Query query) throws IOException { - // TODO optimize, please - SimpleFeatureCollection features = getFeatures(query); - ReferencedEnvelope bounds = features.getBounds(); - return bounds; - } - - @Override - public int getCount(Query query) throws IOException { - // TODO optimize, please - SimpleFeatureCollection features = getFeatures(query); - int size = features.size(); - return size; - } - - /** - * GeoGit Features are always "detached", so we return the FEATURE_DETACHED - * hint here, as well as the JTS related ones. - * <p> - * The JTS related hints supported are: - * <ul> - * <li>JTS_GEOMETRY_FACTORY - * <li>JTS_COORDINATE_SEQUENCE_FACTORY - * </ul> - * Note, however, that if a {@link GeometryFactory} is provided through the - * {@code JTS_GEOMETRY_FACTORY} hint, that very factory is used and takes - * precedence over all the other ones. - * </p> - * - * @see FeatureSource#getSupportedHints() - * @see Hints#FEATURE_DETACHED - * @see Hints#JTS_GEOMETRY_FACTORY - * @see Hints#JTS_COORDINATE_SEQUENCE_FACTORY - */ - @Override - public final Set<RenderingHints.Key> getSupportedHints() { - return supportedHints; - } - - /** - * @see org.geotools.data.simple.SimpleFeatureSource#getFeatures() - */ - @Override - public SimpleFeatureCollection getFeatures() throws IOException { - return getFeatures(Query.ALL); - } - - @Override - public SimpleFeatureCollection getFeatures(final Filter filter) - throws IOException { - return getFeatures(new Query(getName().getLocalPart(), filter)); - } - - @Override - public SimpleFeatureCollection getFeatures(final Query query) - throws IOException { - Filter filter = query.getFilter(); - if (filter == null) { - filter = Filter.INCLUDE; - } - if (Filter.EXCLUDE.equals(filter)) { - return new EmptyFeatureCollection(type); - } - - final Query query2 = reprojectFilter(query); - filter = query2.getFilter(); - - final ObjectDatabase lookupDatabase = dataStore.getRepository() - .getIndex().getDatabase(); - final RevTree typeTree = getCurrentVersion(); - GeoGitSimpleFeatureCollection featureCollection; - featureCollection = new GeoGitSimpleFeatureCollection(type, filter, - lookupDatabase, typeTree); - - final int maxFeatures = query2.getMaxFeatures(); - if (maxFeatures > 0 && maxFeatures != Query.DEFAULT_MAX) { - featureCollection.setMaxFeatures(maxFeatures); - } - - // if (null != query.getHints().get(Hints.JTS_GEOMETRY_FACTORY)) { - // GeometryFactory gfac = (GeometryFactory) query.getHints().get( - // Hints.JTS_GEOMETRY_FACTORY); - // featureCollection.setGeometryFactory(gfac); - // } else if (null != - // query.getHints().get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY)) { - // CoordinateSequenceFactory csf = (CoordinateSequenceFactory) - // query.getHints().get( - // Hints.JTS_COORDINATE_SEQUENCE_FACTORY); - // GeometryFactory gfac = new GeometryFactory(csf); - // featureCollection.setGeometryFactory(gfac); - // } - - return featureCollection; - } - - /** - * @return the id of the root tree. Defaults to the repository's root, but - * {@link GeoGitFeatureStore} shall override to account for whether - * there's a transaction in progress - */ - protected ObjectId getRootTreeId() { - Repository repository = dataStore.getRepository(); - ObjectId rootTreeId = repository.getRootTreeId(); - return rootTreeId; - } - - private Query reprojectFilter(Query query) throws IOException { - final Filter originalFilter = query.getFilter() != null ? query - .getFilter() : Filter.INCLUDE; - if (Filter.INCLUDE.equals(originalFilter)) { - return query; - } - - final SimpleFeatureType nativeFeatureType = getSchema(); - final GeometryDescriptor geom = nativeFeatureType - .getGeometryDescriptor(); - // if no geometry involved, no reprojection needed - if (geom == null) { - return query; - } - - final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); - - try { - CoordinateReferenceSystem nativeCRS = geom - .getCoordinateReferenceSystem(); - - // now we apply a default to all geometries and bbox in the filter - DefaultCRSFilterVisitor defaultCRSVisitor = new DefaultCRSFilterVisitor( - ff, nativeCRS); - final Filter defaultedFilter = (Filter) originalFilter.accept( - defaultCRSVisitor, null); - - // and then we reproject all geometries so that the datastore - // receives - // them in the native projection system (or the forced one, in case - // of force) - ReprojectingFilterVisitor reprojectingVisitor = new ReprojectingFilterVisitor( - ff, nativeFeatureType); - final Filter reprojectedFilter = (Filter) defaultedFilter.accept( - reprojectingVisitor, null); - - Query reprojectedQuery = new Query(query); - reprojectedQuery.setFilter(reprojectedFilter); - return reprojectedQuery; - } catch (Exception e) { - throw new DataSourceException( - "Had troubles handling filter reprojection...", e); - } - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,338 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import static org.geotools.data.Transaction.AUTO_COMMIT; - -import java.io.IOException; -import java.util.List; - -import org.geogit.api.GeoGIT; -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.repository.WorkingTree; -import org.geoserver.data.versioning.SimpleVersioningFeatureStore; -import org.geoserver.data.versioning.decorator.VersionFilters; -import org.geoserver.data.versioning.decorator.VersionQuery; -import org.geotools.data.FeatureReader; -import org.geotools.data.Transaction; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.NameImpl; -import org.geotools.filter.identity.ResourceIdImpl; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; -import org.opengis.filter.Id; -import org.opengis.filter.identity.FeatureId; -import org.opengis.filter.identity.Identifier; -import org.opengis.filter.identity.ResourceId; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.collect.Lists; - -@SuppressWarnings("rawtypes") -public class GeoGitFeatureStore extends GeoGitFeatureSource implements - SimpleVersioningFeatureStore { - - private Transaction transaction; - - public GeoGitFeatureStore(final SimpleFeatureType type, - final GeoGitDataStore store) { - super(type, store); - transaction = Transaction.AUTO_COMMIT; - } - - /** - * @return the object id of the current HEAD's commit if we're not inside a - * transaction, or {@code null} if we're inside a transaction - */ - @Override - public RevTree getCurrentVersion() { - if (getTransaction() == null - || Transaction.AUTO_COMMIT.equals(getTransaction())) { - return super.getCurrentVersion(); - } - - // assume HEAD is at MASTER - try { - final Name typeName = this.type.getName(); - Repository repository = dataStore.getRepository(); - WorkingTree workingTree = repository.getWorkingTree(); - RevTree typeTree = workingTree.getStagedVersion(typeName); - return typeTree; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - protected ObjectId getRootTreeId() { - final Transaction transaction = getTransaction(); - if (null == transaction || Transaction.AUTO_COMMIT.equals(transaction)) { - // no transaction in progress, return the repository's root - return super.getRootTreeId(); - } - // transaction in progress, return null to signal querying the index - // first - return null; - // Repository repository = dataStore.getRepository(); - // StagingArea index = repository.getIndex(); - // RevTree staged = index.getStaged(); - // ObjectId stagedRootId = staged.getId(); - // return stagedRootId; - } - - /** - * @see org.geotools.data.FeatureStore#getTransaction() - */ - @Override - public Transaction getTransaction() { - return transaction; - } - - /** - * @see org.geotools.data.FeatureStore#setTransaction(org.geotools.data.Transaction) - */ - @Override - public void setTransaction(final Transaction transaction) { - Preconditions.checkArgument(transaction != null, - "Transaction is null, did you mean Transaction.AUTO_COMMIT?"); - this.transaction = transaction; - } - - /** - * @see org.geotools.data.FeatureStore#addFeatures(org.geotools.feature.FeatureCollection) - */ - @Override - public List<FeatureId> addFeatures( - FeatureCollection<SimpleFeatureType, SimpleFeature> collection) - throws IOException { - Preconditions.checkNotNull(collection); - Preconditions.checkNotNull(collection.getSchema()); - Preconditions.checkArgument(type.getName().equals( - collection.getSchema().getName())); - - checkTransaction(); - - final Name typeName = getSchema().getName(); - final VersioningTransactionState versioningState = getVersioningState(); - - List<FeatureId> insertedResourceIds; - try { - insertedResourceIds = versioningState.stageInsert(typeName, - collection); - } catch (Exception e) { - throw new IOException(e); - } - - return insertedResourceIds; - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.Name[], - * java.lang.Object[], org.opengis.filter.Filter) - */ - @Override - public void modifyFeatures(final Name[] attributeNames, - final Object[] attributeValues, final Filter filter) - throws IOException { - - checkTransaction(); - // throws exception if filter has a resourceid that doesn't match the - // current version - checkEditFilterMatchesCurrentVersion(filter); - - final SimpleFeatureCollection affectedFeatures = getFeatures(filter); - final FeatureCollection newValues = new ModifyingFeatureCollection( - affectedFeatures, attributeNames, attributeValues); - - VersioningTransactionState versioningState = getVersioningState(); - try { - versioningState.stageUpdate(type.getName(), newValues); - } catch (Exception e) { - throw new IOException(e); - } - } - - /** - * @see org.geotools.data.FeatureStore#removeFeatures(org.opengis.filter.Filter) - */ - @Override - public void removeFeatures(final Filter filter) throws IOException { - Preconditions.checkNotNull(filter); - - checkTransaction(); - - FeatureCollection removed = getFeatures(filter); - try { - Name typeName = getSchema().getName(); - VersioningTransactionState versioningState = getVersioningState(); - versioningState.stageDelete(typeName, filter, removed); - } catch (Exception e) { - Throwables.propagate(e); - } - } - - /** - * Throws an IllegalArgumentException if {@code filter} contains a resource - * filter that doesn't match the current version of a feature - * - * @param filter original upate filter - */ - private void checkEditFilterMatchesCurrentVersion(final Filter filter) { - final Id versionFilter = VersionFilters.getVersioningFilter(filter); - if (versionFilter == null) { - return; - } - final Repository repository = dataStore.getRepository(); - // don't allow non current versions - GeoGIT ggit = new GeoGIT(repository); - VersionQuery query = new VersionQuery(ggit, getSchema().getName()); - for (Identifier id : versionFilter.getIdentifiers()) { - ResourceId rid = (ResourceId) id; - List<Ref> requested; - List<Ref> current; - try { - requested = Lists.newArrayList(query.get(rid)); - current = Lists.newArrayList(query.get(new ResourceIdImpl(rid - .getID(), null))); - } catch (Exception e) { - throw new RuntimeException(e); - } - if (!current.equals(requested)) { - throw new IllegalArgumentException( - "Requested resource id filter doesn't match curent version for feature " - + rid.getID()); - } - } - } - - /** - * @see org.geotools.data.FeatureStore#setFeatures(org.geotools.data.FeatureReader) - */ - @Override - public void setFeatures( - FeatureReader<SimpleFeatureType, SimpleFeature> reader) - throws IOException { - throw new UnsupportedOperationException("do versioning!"); - } - - private void checkTransaction() { - if (Transaction.AUTO_COMMIT.equals(getTransaction())) { - throw new UnsupportedOperationException( - "AUTO_COMMIT is not supported for versioned Feature Types"); - } - } - - protected VersioningTransactionState getVersioningState() { - Transaction transaction = getTransaction(); - if (AUTO_COMMIT.equals(transaction)) { - return VersioningTransactionState.VOID; - } - - final Object key = GeoGitDataStore.class; - VersioningTransactionState state = (VersioningTransactionState) transaction - .getState(key); - if (state == null) { - Repository repository = dataStore.getRepository(); - state = new VersioningTransactionState(new GeoGIT(repository)); - transaction.putState(key, state); - } - - return state; - } - - /** - * @see org.geotools.data.simple.SimpleFeatureStore#modifyFeatures(java.lang.String, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(String name, Object attributeValue, Filter filter) - throws IOException { - - Name attributeName = new NameImpl(name); - modifyFeatures(attributeName, attributeValue, filter); - } - - /** - * @see org.geotools.data.simple.SimpleFeatureStore#modifyFeatures(java.lang.String[], - * java.lang.Object[], org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(String[] names, Object[] attributeValues, - Filter filter) throws IOException { - - Name[] attributeNames = new Name[names.length]; - for (int i = 0; i < names.length; i++) { - String name = names[i]; - attributeNames[i] = new NameImpl(name); - } - modifyFeatures(attributeNames, attributeValues, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.AttributeDescriptor[], - * java.lang.Object[], org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(AttributeDescriptor[] type, Object[] value, - Filter filter) throws IOException { - - Name[] attributeNames = new Name[type.length]; - for (int i = 0; i < type.length; i++) { - attributeNames[i] = type[i].getName(); - } - modifyFeatures(attributeNames, value, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.Name, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(Name attributeName, Object attributeValue, - Filter filter) throws IOException { - - modifyFeatures(new Name[] { attributeName }, - new Object[] { attributeValue }, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.AttributeDescriptor, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(AttributeDescriptor type, Object value, - Filter filter) throws IOException { - - modifyFeatures(new Name[] { type.getName() }, new Object[] { value }, - filter); - - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,579 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevTree; -import org.geogit.api.SpatialRef; -import org.geogit.storage.ObjectDatabase; -import org.geogit.storage.ObjectReader; -import org.geogit.storage.WrappedSerialisingFactory; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.factory.Hints; -import org.geotools.feature.CollectionListener; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureIterator; -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.referencing.CRS; -import org.opengis.feature.Feature; -import org.opengis.feature.FeatureVisitor; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.filter.Filter; -import org.opengis.filter.expression.Expression; -import org.opengis.filter.expression.Literal; -import org.opengis.filter.sort.SortBy; -import org.opengis.filter.spatial.BBOX; -import org.opengis.filter.spatial.BinarySpatialOperator; -import org.opengis.filter.spatial.BoundedSpatialOperator; -import org.opengis.geometry.BoundingBox; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; -import org.opengis.util.ProgressListener; - -import com.google.common.base.Predicate; -import com.google.common.base.Throwables; -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.Iterators; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryFactory; - -public class GeoGitSimpleFeatureCollection implements SimpleFeatureCollection { - - private final SimpleFeatureType type; - - private final Filter filter; - - private final ObjectDatabase odb; - - private final FeatureReprojector reprojector; - - private Integer cachedSize; - - private ReferencedEnvelope cachedBounds; - - private GeometryFactory geometryFactory; - - private final RevTree typeTree; - - private Integer maxFeatures; - - public GeoGitSimpleFeatureCollection(final SimpleFeatureType type, - final Filter filter, final ObjectDatabase odb, - final RevTree typeTree) { - this.type = type; - this.filter = filter; - this.odb = odb; - this.typeTree = typeTree; - this.r... [truncated message content] |