Search in sources :

Example 96 with Node

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

the class WorkingTreeTest method testInsertCollectionNullCollectionSize.

@Test
public void testInsertCollectionNullCollectionSize() throws Exception {
    List<Feature> featureList = new LinkedList<Feature>();
    featureList.add(points1);
    featureList.add(points2);
    featureList.add(points3);
    List<Node> targetList = new LinkedList<Node>();
    workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, null);
    assertEquals(3, targetList.size());
    Node ref1 = targetList.get(0);
    Node ref2 = targetList.get(1);
    Node ref3 = targetList.get(2);
    assertEquals(ref1.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
    assertEquals(ref2.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP2)).get().getObjectId());
    assertEquals(ref3.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP3)).get().getObjectId());
}
Also used : Node(org.locationtech.geogig.api.Node) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 97 with Node

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

the class WorkingTreeTest method testInsertSingle.

@Test
public void testInsertSingle() throws Exception {
    Name name = points1.getType().getName();
    String parentPath = name.getLocalPart();
    Node ref = workTree.insert(parentPath, points1);
    ObjectId objectId = ref.getObjectId();
    assertEquals(objectId, workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Name(org.opengis.feature.type.Name) Test(org.junit.Test)

Example 98 with Node

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

the class WorkingTreeTest method testUpdateTypeTree.

@Test
public void testUpdateTypeTree() throws Exception {
    insert(points2, points3);
    insert(points1B);
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> typeTreeId = findTreeChild(root, pointsName);
    assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeImpl.build(pointsType).getId());
    RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    Optional<Node> featureBlobId = findTreeChild(root, path);
    assertTrue(featureBlobId.isPresent());
    assertEquals(RevFeatureTypeImpl.build(modifiedPointsType).getId(), featureBlobId.get().getMetadataId().orNull());
    path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
    featureBlobId = findTreeChild(root, path);
    assertEquals(null, featureBlobId.get().getMetadataId().orNull());
    workTree.updateTypeTree(pointsName, modifiedPointsType);
    root = repo.workingTree().getTree();
    typeTreeId = findTreeChild(root, pointsName);
    assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeImpl.build(modifiedPointsType).getId());
    typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    featureBlobId = findTreeChild(root, path);
    assertTrue(featureBlobId.isPresent());
    assertEquals(null, featureBlobId.get().getMetadataId().orNull());
    path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
    featureBlobId = findTreeChild(root, path);
    assertEquals(RevFeatureTypeImpl.build(pointsType).getId(), featureBlobId.get().getMetadataId().orNull());
}
Also used : Node(org.locationtech.geogig.api.Node) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 99 with Node

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

the class GlobalState method insert.

public static List<ObjectId> insert(Feature... features) throws Exception {
    geogigCLI.close();
    GeoGIG geogig = geogigCLI.newGeoGIG(Hints.readWrite());
    Preconditions.checkNotNull(geogig);
    List<ObjectId> ids = Lists.newArrayListWithCapacity(features.length);
    try {
        Repository repository = geogig.getRepository();
        final WorkingTree workTree = repository.workingTree();
        for (Feature f : features) {
            Name name = f.getType().getName();
            String parentPath = name.getLocalPart();
            Node ref = workTree.insert(parentPath, f);
            ObjectId objectId = ref.getObjectId();
            ids.add(objectId);
        }
    } finally {
        geogig.close();
    }
    return ids;
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) Repository(org.locationtech.geogig.repository.Repository) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Feature(org.opengis.feature.Feature) GeoGIG(org.locationtech.geogig.api.GeoGIG) Name(org.opengis.feature.type.Name)

Example 100 with Node

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

the class PostOrderDiffWalkTest method testLeafLeafWithSubStrees.

@Test
public void testLeafLeafWithSubStrees() {
    // two leaf trees
    ObjectId metadataId = ObjectId.forString("fake");
    RevTree left = createTreesTree(leftSource, 2, 2, metadataId).build();
    RevTree right = createTreesTree(rightSource, 3, 2, metadataId).build();
    PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
    visitor.walk(testConsumer);
    List<Bounded> leftCalls = testConsumer.orderedLeft;
    List<Bounded> rightCalls = testConsumer.orderedRight;
    System.err.println(leftCalls);
    System.err.println(rightCalls);
    Node lroot = nodeFor(left);
    Node rroot = nodeFor(right);
    assertEquals(4, leftCalls.size());
    assertEquals(4, rightCalls.size());
    assertNull(leftCalls.get(0));
    assertNull(leftCalls.get(1));
    assertNull(leftCalls.get(2));
    assertEquals(lroot, leftCalls.get(3));
    assertEquals(rroot, rightCalls.get(3));
    assertNotNull(rightCalls.get(2));
    assertEquals(RevObject.TYPE.TREE, ((Node) rightCalls.get(2)).getType());
    assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(1)).getType());
    assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(0)).getType());
}
Also used : Bounded(org.locationtech.geogig.api.Bounded) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Aggregations

Node (org.locationtech.geogig.api.Node)117 RevTree (org.locationtech.geogig.api.RevTree)56 Test (org.junit.Test)50 ObjectId (org.locationtech.geogig.api.ObjectId)44 NodeRef (org.locationtech.geogig.api.NodeRef)24 Bucket (org.locationtech.geogig.api.Bucket)20 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)18 Envelope (com.vividsolutions.jts.geom.Envelope)16 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)14 RevCommit (org.locationtech.geogig.api.RevCommit)10 Map (java.util.Map)9 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)9 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)9 File (java.io.File)7 RevFeature (org.locationtech.geogig.api.RevFeature)7 WorkingTree (org.locationtech.geogig.repository.WorkingTree)7 Feature (org.opengis.feature.Feature)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Stopwatch (com.google.common.base.Stopwatch)6 SortedMap (java.util.SortedMap)5