Search in sources :

Example 11 with DepthSearch

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

the class FindTreeChild method _call.

/**
     * Executes the command.
     * 
     * @return an {@code Optional} that contains the Node if it was found, or
     *         {@link Optional#absent()} if it wasn't
     */
@Override
protected Optional<NodeRef> _call() {
    checkNotNull(childPath, "childPath");
    final RevTree tree;
    if (parent == null) {
        ObjectId rootTreeId = command(ResolveTreeish.class).setTreeish(Ref.HEAD).call().get();
        if (rootTreeId.isNull()) {
            return Optional.absent();
        }
        tree = command(RevObjectParse.class).setObjectId(rootTreeId).call(RevTree.class).get();
    } else {
        tree = parent.get();
    }
    final String path = childPath;
    final String parentPath = this.parentPath == null ? "" : this.parentPath;
    final ObjectDatabase target = indexDb ? stagingDatabase() : objectDatabase();
    DepthSearch depthSearch = new DepthSearch(target);
    Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path);
    return childRef;
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) DepthSearch(org.locationtech.geogig.repository.DepthSearch) ObjectId(org.locationtech.geogig.api.ObjectId) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) RevTree(org.locationtech.geogig.api.RevTree)

Aggregations

DepthSearch (org.locationtech.geogig.repository.DepthSearch)11 ObjectId (org.locationtech.geogig.api.ObjectId)9 NodeRef (org.locationtech.geogig.api.NodeRef)8 RevTree (org.locationtech.geogig.api.RevTree)7 Test (org.junit.Test)6 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)6 Entry (java.util.Map.Entry)3 RevFeature (org.locationtech.geogig.api.RevFeature)3 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)3 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)3 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)3 FeatureInfo (org.locationtech.geogig.api.FeatureInfo)2 RevObject (org.locationtech.geogig.api.RevObject)2 AttributeDiff (org.locationtech.geogig.api.plumbing.diff.AttributeDiff)2 FeatureDiff (org.locationtech.geogig.api.plumbing.diff.FeatureDiff)2 Optional (com.google.common.base.Optional)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1 TYPE (org.locationtech.geogig.api.RevObject.TYPE)1 DiffFeature (org.locationtech.geogig.api.plumbing.DiffFeature)1 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)1