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;
}
Aggregations