Search in sources :

Example 21 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method getWorkingTree.

/**
     * @return
     */
WorkingTree getWorkingTree() {
    Context commandLocator = getCommandLocator();
    WorkingTree workingTree = commandLocator.workingTree();
    return workingTree;
}
Also used : Context(org.locationtech.geogig.api.Context) WorkingTree(org.locationtech.geogig.repository.WorkingTree)

Example 22 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class GeogigFeatureStore method getWriterInternal.

@Override
protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(Query query, final int flags) throws IOException {
    Preconditions.checkArgument(flags != 0, "no write flags set");
    Preconditions.checkState(getDataStore().isAllowTransactions(), "Transactions not supported; head is not a local branch");
    FeatureReader<SimpleFeatureType, SimpleFeature> features;
    if ((flags | WRITER_UPDATE) == WRITER_UPDATE) {
        features = delegate.getReader(query);
    } else {
        features = new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getSchema());
    }
    String path = delegate.getTypeTreePath();
    WorkingTree wtree = getFeatureSource().getWorkingTree();
    GeoGigFeatureWriter writer;
    if ((flags | WRITER_ADD) == WRITER_ADD) {
        writer = GeoGigFeatureWriter.createAppendable(features, path, wtree);
    } else {
        writer = GeoGigFeatureWriter.create(features, path, wtree);
    }
    return writer;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 23 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class GeogigFeatureStore method removeFeatures.

@Override
public void removeFeatures(Filter filter) throws IOException {
    Preconditions.checkState(getDataStore().isAllowTransactions(), "Transactions not supported; head is not a local branch");
    final WorkingTree workingTree = delegate.getWorkingTree();
    final String typeTreePath = delegate.getTypeTreePath();
    filter = (Filter) filter.accept(new SimplifyingFilterVisitor(), null);
    if (Filter.INCLUDE.equals(filter)) {
        workingTree.delete(typeTreePath);
        return;
    }
    if (Filter.EXCLUDE.equals(filter)) {
        return;
    }
    Iterator<SimpleFeature> featureIterator = featureIterator(filter);
    Iterator<String> affectedFeaturePaths = Iterators.transform(featureIterator, new Function<SimpleFeature, String>() {

        @Override
        public String apply(SimpleFeature input) {
            String fid = input.getID();
            return NodeRef.appendChild(typeTreePath, fid);
        }
    });
    workingTree.delete(affectedFeaturePaths);
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) SimplifyingFilterVisitor(org.geotools.filter.visitor.SimplifyingFilterVisitor) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 24 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class RemoteRepositoryTestCase method insert.

/**
     * Inserts the feature to the index but does not stages it to be committed
     */
protected ObjectId insert(GeoGIG geogig, Feature f) throws Exception {
    final WorkingTree workTree = geogig.getRepository().workingTree();
    Name name = f.getType().getName();
    String parentPath = name.getLocalPart();
    Node ref = workTree.insert(parentPath, f);
    ObjectId objectId = ref.getObjectId();
    return objectId;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name)

Example 25 with WorkingTree

use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.

the class RepositoryTestCase method insert.

/**
     * Inserts the feature to the index but does not stages it to be committed
     */
public ObjectId insert(GeogigTransaction transaction, Feature f) throws Exception {
    final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo.workingTree());
    Name name = f.getType().getName();
    String parentPath = name.getLocalPart();
    Node ref = workTree.insert(parentPath, f);
    ObjectId objectId = ref.getObjectId();
    return objectId;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name)

Aggregations

WorkingTree (org.locationtech.geogig.repository.WorkingTree)54 Test (org.junit.Test)32 AddOp (org.locationtech.geogig.api.porcelain.AddOp)25 List (java.util.List)18 ImmutableList (com.google.common.collect.ImmutableList)17 File (java.io.File)17 ArrayList (java.util.ArrayList)16 RevFeature (org.locationtech.geogig.api.RevFeature)15 Optional (com.google.common.base.Optional)12 SimpleFeature (org.opengis.feature.simple.SimpleFeature)12 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)11 NodeRef (org.locationtech.geogig.api.NodeRef)10 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)9 Name (org.opengis.feature.type.Name)9 GeoGIG (org.locationtech.geogig.api.GeoGIG)7 Node (org.locationtech.geogig.api.Node)7 ProgressListener (org.locationtech.geogig.api.ProgressListener)6 RevCommit (org.locationtech.geogig.api.RevCommit)6 Coordinate (com.vividsolutions.jts.geom.Coordinate)5 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)5