use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class MutableTree method createFromPaths.
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) {
List<NodeRef> refsByDepth = Lists.newArrayList(entries.values());
Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR);
Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null);
MutableTree root = new MutableTree(rootNode);
Envelope bounds = new Envelope();
for (NodeRef entry : refsByDepth) {
Node node = entry.getNode();
node.expand(bounds);
String parentPath = entry.getParentPath();
root.setChild(parentPath, node);
}
// recreate root node with the appropriate bounds
rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds);
root.setNode(rootNode);
return root;
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class CheckoutOpTest method testCheckoutPathFilter.
@Test
public void testCheckoutPathFilter() throws Exception {
ObjectId points1Id = insertAndAdd(points1);
geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
insert(points1_modified);
CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call();
Optional<RevTree> workTree = geogig.command(RevObjectParse.class).setObjectId(result.getNewTree()).call(RevTree.class);
Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get()).setChildPath("Points/Points.1").call();
assertEquals(points1Id, nodeRef.get().getNode().getObjectId());
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class GeoGigFeatureSourceTest method testFeatureIdsAreVersioned.
@Test
public void testFeatureIdsAreVersioned() throws IOException {
SimpleFeatureCollection collection = pointsSource.getFeatures(Query.ALL);
SimpleFeatureIterator features = collection.features();
Set<FeatureId> ids = Sets.newHashSet();
try {
while (features.hasNext()) {
SimpleFeature next = features.next();
FeatureId identifier = next.getIdentifier();
ids.add(identifier);
}
} finally {
features.close();
}
List<NodeRef> refs = toList(repo.command(LsTreeOp.class).setReference(pointsName).setStrategy(Strategy.FEATURES_ONLY).call());
assertEquals(3, refs.size());
Map<String, NodeRef> expected = new HashMap<String, NodeRef>();
for (NodeRef ref : refs) {
expected.put(ref.path(), ref);
}
for (FeatureId id : ids) {
assertFalse("ResourceId is a query object", id instanceof ResourceId);
assertNotNull(id.getID());
assertNotNull(id + " has no featureVersion set", id.getFeatureVersion());
NodeRef ref = expected.get(id.getID());
assertNotNull(ref);
assertEquals(ref.objectId().toString(), id.getFeatureVersion());
}
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class DiffFeatureTest method testDiffUnexistentFeature.
@Test
public void testDiffUnexistentFeature() {
try {
NodeRef oldRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, "Points.100")).call().orNull();
NodeRef newRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull();
geogig.command(DiffFeature.class).setOldVersion(Suppliers.ofInstance(oldRef)).setNewVersion(Suppliers.ofInstance(newRef)).call();
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class DiffFeatureTest method testDiffWrongPath.
@Test
public void testDiffWrongPath() {
try {
NodeRef oldRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(pointsName).call().orNull();
NodeRef newRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull();
geogig.command(DiffFeature.class).setOldVersion(Suppliers.ofInstance(oldRef)).setNewVersion(Suppliers.ofInstance(newRef)).call();
fail();
} catch (IllegalArgumentException e) {
assertTrue(true);
}
}
Aggregations