Search in sources :

Example 51 with NodeRef

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

the class MutableTreeTest method tree.

private NodeRef tree(String path, ObjectId treeId, ObjectId metadataId) {
    String parentPath = NodeRef.parentPath(path);
    String name = NodeRef.nodeFromPath(path);
    Node node = treeNode(name, treeId, metadataId);
    return new NodeRef(node, parentPath, ObjectId.NULL);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Node(org.locationtech.geogig.api.Node)

Example 52 with NodeRef

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

the class MutableTreeTest method setUp.

@Before
public void setUp() {
    ObjectId md1 = id("d1");
    ObjectId md2 = id("d2");
    ObjectId md3 = id("d3");
    ObjectId md4 = id("d4");
    ObjectId t1 = id("a1");
    ObjectId t2 = id("a2");
    ObjectId t3 = id("a3");
    ObjectId t4 = id("a4");
    ObjectId t5 = id("a5");
    ObjectId t6 = id("a6");
    NodeRef r1 = tree("roads", t1, ObjectId.NULL);
    NodeRef r11 = tree("roads/highways", t2, md1);
    NodeRef r12 = tree("roads/streets", t3, md2);
    NodeRef r2 = tree("buildings", t4, ObjectId.NULL);
    NodeRef r21 = tree("buildings/stores", t5, md3);
    NodeRef r22 = tree("buildings/unknown", t6, md4);
    ImmutableList<NodeRef> refs = ImmutableList.of(r1, r11, r12, r2, r21, r22);
    root = MutableTree.createFromRefs(id("abc"), refs.iterator());
    assertNotNull(root);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Before(org.junit.Before)

Example 53 with NodeRef

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

the class WriteTree2Test method testEmptyRepoSingleStagedTree.

@Test
public void testEmptyRepoSingleStagedTree() {
    rightTree = createStageHeadTree(//
    indexTree("roads", "a1", "d1", 10));
    ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    // print(newRepoRoot);
    // check all blobs have been moved from the index to the object database
    verifyRepositoryTree(NodeRef.ROOT, newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(1, refsByPath.size());
    assertTrue(refsByPath.keySet().contains("roads"));
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 54 with NodeRef

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

the class WriteTree2Test method testDeleteAll.

@Test
public void testDeleteAll() {
    leftTree = createHeadTree(//
    repoTree("roads", EMPTY_ID, null, 0), //
    repoTree("roads/highways", "a2", "d1", 10), //
    repoTree("roads/streets", "a3", "d2", 10), //
    repoTree("buildings", EMPTY_ID, null, 0), //
    repoTree("buildings/stores", "a5", "d3", 5), //
    repoTree("buildings/unknown", "a6", "d4", 5), //
    repoTree("buildings/towers", "a7", "d5", 5));
    rightTree = createStageHeadTree();
    final ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(set(), refsByPath.keySet());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 55 with NodeRef

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

the class WriteTree2Test method tree.

/**
     * Creates a tree reference for testing, forcing the specified id and metadata id, and with the
     * specified number of features (zero or more).
     * <p>
     * Note the tree is saved to the specified database only if its a leaf tree (more than zero
     * features), in order for the {@link #createFromRefs} method to be able of saving the parent
     */
private NodeRef tree(ObjectDatabase db, String path, String id, String mdId, int numFeatures) {
    Preconditions.checkArgument(numFeatures != 0 || EMPTY_ID.equals(id), "for zero features trees use RevTree.EMPTY_TREE_ID");
    final ObjectId treeId = id(id);
    final ObjectId metadataId = id(mdId);
    final String feturePrefix = NodeRef.nodeFromPath(path);
    RevTreeBuilder b = new RevTreeBuilder(db);
    if (numFeatures > 0) {
        for (int i = 0; i < numFeatures; i++) {
            Node fn = feature(db, feturePrefix, i);
            b.put(fn);
        }
    }
    RevTree fakenId = forceTreeId(b, treeId);
    if (!db.exists(fakenId.getId())) {
        db.put(fakenId);
    }
    if (!metadataId.isNull()) {
        RevFeatureType fakeType = new RevFeatureTypeImpl(metadataId, pointsType);
        if (!db.exists(fakeType.getId())) {
            db.put(fakeType);
        }
    }
    String name = NodeRef.nodeFromPath(path);
    String parent = NodeRef.parentPath(path);
    Envelope bounds = SpatialOps.boundsOf(fakenId);
    Node node = Node.create(name, treeId, metadataId, TYPE.TREE, bounds);
    return new NodeRef(node, parent, ObjectId.NULL);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) RevFeatureTypeImpl(org.locationtech.geogig.api.RevFeatureTypeImpl) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree)

Aggregations

NodeRef (org.locationtech.geogig.api.NodeRef)161 ObjectId (org.locationtech.geogig.api.ObjectId)91 RevTree (org.locationtech.geogig.api.RevTree)67 Test (org.junit.Test)62 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)40 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)27 RevFeature (org.locationtech.geogig.api.RevFeature)25 Node (org.locationtech.geogig.api.Node)24 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)24 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)23 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)22 RevObject (org.locationtech.geogig.api.RevObject)21 RevCommit (org.locationtech.geogig.api.RevCommit)19 Map (java.util.Map)15 SimpleFeature (org.opengis.feature.simple.SimpleFeature)15 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Feature (org.opengis.feature.Feature)13 Optional (com.google.common.base.Optional)12 GeoGIG (org.locationtech.geogig.api.GeoGIG)11 LsTreeOp (org.locationtech.geogig.api.plumbing.LsTreeOp)11