Search in sources :

Example 1 with CreateTree

use of org.locationtech.geogig.api.plumbing.CreateTree in project GeoGig by boundlessgeo.

the class DepthSearchTest method addTree.

private RevTreeBuilder addTree(RevTreeBuilder root, final String treePath, String... singleNodeNames) {
    Context mockInjector = mock(Context.class);
    when(mockInjector.objectDatabase()).thenReturn(odb);
    CreateTree op = new CreateTree().setIndex(false);
    op.setContext(mockInjector);
    RevTreeBuilder subTreeBuilder = op.call();
    if (singleNodeNames != null) {
        for (String singleNodeName : singleNodeNames) {
            String nodePath = NodeRef.appendChild(treePath, singleNodeName);
            ObjectId fakeFeatureOId = ObjectId.forString(nodePath);
            // forString(treePath);
            ObjectId fakeTypeOId = ObjectId.NULL;
            subTreeBuilder.put(Node.create(singleNodeName, fakeFeatureOId, fakeTypeOId, TYPE.FEATURE, null));
        }
    }
    RevTree subtree = subTreeBuilder.build();
    WriteBack writeBack = fakeGeogig.command(WriteBack.class).setAncestor(root).setChildPath(treePath).setTree(subtree).setMetadataId(fakeTreeMetadataId);
    ObjectId newRootId = writeBack.call();
    return fakeGeogig.command(RevObjectParse.class).setObjectId(newRootId).call(RevTree.class).get().builder(odb);
}
Also used : Context(org.locationtech.geogig.api.Context) WriteBack(org.locationtech.geogig.api.plumbing.WriteBack) CreateTree(org.locationtech.geogig.api.plumbing.CreateTree) ObjectId(org.locationtech.geogig.api.ObjectId) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree)

Aggregations

Context (org.locationtech.geogig.api.Context)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 RevTree (org.locationtech.geogig.api.RevTree)1 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)1 CreateTree (org.locationtech.geogig.api.plumbing.CreateTree)1 WriteBack (org.locationtech.geogig.api.plumbing.WriteBack)1