Search in sources :

Example 51 with Node

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

the class OSMDownloadOpTest method testDowloadNodesWithDestinationFile.

@Ignore
@Test
public void testDowloadNodesWithDestinationFile() throws Exception {
    String filename = OSMImportOp.class.getResource("nodes_overpass_filter.txt").getFile();
    File filterFile = new File(filename);
    File downloadFile = File.createTempFile("osm-geogig", ".xml");
    OSMDownloadOp download = geogig.command(OSMDownloadOp.class);
    download.setFilterFile(filterFile).setSaveFile(downloadFile).setOsmAPIUrl(OSMUtils.DEFAULT_API_ENDPOINT).call();
    Optional<Node> tree = geogig.getRepository().getRootTreeChild("node");
    assertTrue(tree.isPresent());
    List<OSMLogEntry> entries = geogig.command(ReadOSMLogEntries.class).call();
    assertFalse(entries.isEmpty());
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    assertTrue(log.hasNext());
}
Also used : ReadOSMLogEntries(org.locationtech.geogig.osm.internal.log.ReadOSMLogEntries) Node(org.locationtech.geogig.api.Node) LogOp(org.locationtech.geogig.api.porcelain.LogOp) File(java.io.File) OSMLogEntry(org.locationtech.geogig.osm.internal.log.OSMLogEntry) RevCommit(org.locationtech.geogig.api.RevCommit) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 52 with Node

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

the class PreOrderDiffWalk method traverseLeafLeaf.

/**
     * Traverse and compare the {@link RevTree#children() children} nodes of two leaf trees, calling
     * {@link #node(Consumer, Node, Node)} for each diff.
     */
private void traverseLeafLeaf(Consumer consumer, Iterator<Node> leftc, Iterator<Node> rightc) {
    PeekingIterator<Node> li = Iterators.peekingIterator(leftc);
    PeekingIterator<Node> ri = Iterators.peekingIterator(rightc);
    while (li.hasNext() && ri.hasNext()) {
        Node lpeek = li.peek();
        Node rpeek = ri.peek();
        int order = ORDER.compare(lpeek, rpeek);
        if (order < 0) {
            // removal
            node(consumer, li.next(), null);
        } else if (order == 0) {
            // change
            // same feature at both sides of the traversal, consume them and check if its
            // changed it or not
            Node l = li.next();
            Node r = ri.next();
            if (!l.equals(r)) {
                node(consumer, l, r);
            }
        } else {
            // addition
            node(consumer, null, ri.next());
        }
    }
    checkState(!li.hasNext() || !ri.hasNext(), "either the left or the right iterator should have been fully consumed");
    // right fully consumed, any remaining node in left is a removal
    while (li.hasNext()) {
        node(consumer, li.next(), null);
    }
    // left fully consumed, any remaining node in right is an add
    while (ri.hasNext()) {
        node(consumer, null, ri.next());
    }
}
Also used : Node(org.locationtech.geogig.api.Node)

Example 53 with Node

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

the class CommitOpTest method testCommitWithAllOption.

@Test
public void testCommitWithAllOption() throws Exception {
    try {
        geogig.command(AddOp.class).addPattern(".").call();
        geogig.command(CommitOp.class).call();
        fail("expected NothingToCommitException");
    } catch (NothingToCommitException e) {
        assertTrue(true);
    }
    insertAndAdd(points1);
    geogig.command(AddOp.class).addPattern(".").call();
    RevCommit commit = geogig.command(CommitOp.class).call();
    ObjectId oid = insertAndAdd(points1_modified);
    CommitOp commitCommand = geogig.command(CommitOp.class);
    commit = commitCommand.setAll(true).call();
    assertNotNull(commit);
    assertNotNull(commit.getParentIds());
    assertEquals(1, commit.getParentIds().size());
    assertNotNull(commit.getId());
    ObjectId treeId = commit.getTreeId();
    assertNotNull(treeId);
    RevTree root = repo.getTree(treeId);
    assertNotNull(root);
    Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
    assertTrue(typeTreeId.isPresent());
    RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    String featureId = points1.getIdentifier().getID();
    Optional<Node> featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    assertEquals(oid, featureBlobId.get().getObjectId());
    ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
    assertEquals(commit.getId(), commitId);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevParse(org.locationtech.geogig.api.plumbing.RevParse) NothingToCommitException(org.locationtech.geogig.api.porcelain.NothingToCommitException) Node(org.locationtech.geogig.api.Node) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 54 with Node

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

the class CommitOpTest method testCommitWithCustomAuthorAndCommitter.

@Test
public void testCommitWithCustomAuthorAndCommitter() throws Exception {
    try {
        geogig.command(AddOp.class).addPattern(".").call();
        geogig.command(CommitOp.class).call();
        fail("expected NothingToCommitException");
    } catch (NothingToCommitException e) {
        assertTrue(true);
    }
    ObjectId oid1 = insertAndAdd(points1);
    ObjectId oid2 = insertAndAdd(points2);
    geogig.command(AddOp.class).addPattern(".").call();
    CommitOp commitCommand = geogig.command(CommitOp.class);
    commitCommand.setAuthor("John Doe", "John@Doe.com");
    commitCommand.setCommitter("Jane Doe", "Jane@Doe.com");
    RevCommit commit = commitCommand.call();
    assertNotNull(commit);
    assertNotNull(commit.getParentIds());
    assertEquals(0, commit.getParentIds().size());
    assertFalse(commit.parentN(0).isPresent());
    assertNotNull(commit.getId());
    assertEquals("John Doe", commit.getAuthor().getName().get());
    assertEquals("John@Doe.com", commit.getAuthor().getEmail().get());
    assertEquals("Jane Doe", commit.getCommitter().getName().get());
    assertEquals("Jane@Doe.com", commit.getCommitter().getEmail().get());
    ObjectId treeId = commit.getTreeId();
    assertNotNull(treeId);
    RevTree root = repo.getTree(treeId);
    assertNotNull(root);
    Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
    assertTrue(typeTreeId.isPresent());
    RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    String featureId = points1.getIdentifier().getID();
    Optional<Node> featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    assertEquals(oid1, featureBlobId.get().getObjectId());
    featureId = points2.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    assertEquals(oid2, featureBlobId.get().getObjectId());
    ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
    assertEquals(commit.getId(), commitId);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevParse(org.locationtech.geogig.api.plumbing.RevParse) NothingToCommitException(org.locationtech.geogig.api.porcelain.NothingToCommitException) Node(org.locationtech.geogig.api.Node) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 55 with Node

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

the class CommitOpTest method testPathFiltering.

@Test
public void testPathFiltering() throws Exception {
    insertAndAdd(points1);
    insertAndAdd(points2);
    RevCommit commit = geogig.command(CommitOp.class).call();
    insertAndAdd(points3);
    insertAndAdd(lines1);
    insertAndAdd(lines2);
    insertAndAdd(lines3);
    List<String> filters = Arrays.asList("Points/Points.3", "Lines/Lines.1", "Lines/Lines.3");
    commit = geogig.command(CommitOp.class).setPathFilters(filters).call();
    assertNotNull(commit);
    assertNotNull(commit.getParentIds());
    assertEquals(1, commit.getParentIds().size());
    assertNotNull(commit.getId());
    ObjectId treeId = commit.getTreeId();
    assertNotNull(treeId);
    RevTree root = repo.getTree(treeId);
    assertNotNull(root);
    Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
    assertTrue(typeTreeId.isPresent());
    RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    String featureId = points1.getIdentifier().getID();
    Optional<Node> featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    featureId = points2.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    featureId = points3.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
    assertTrue(featureBlobId.isPresent());
    typeTreeId = repo.getTreeChild(root, linesName);
    assertTrue(typeTreeId.isPresent());
    typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    featureId = lines1.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
    assertTrue(featureBlobId.isPresent());
    featureId = lines2.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
    assertFalse(featureBlobId.isPresent());
    featureId = lines3.getIdentifier().getID();
    featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
    assertTrue(featureBlobId.isPresent());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) 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