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