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