private Optional<ObjectId> metadataId(@Nullable Node treeNode) { if (treeNode == null) { return Optional.absent(); } return treeNode.getMetadataId(); }
private Optional<ObjectId> metadataId(@Nullable Node treeNode) { if (treeNode == null) { return Optional.absent(); } return treeNode.getMetadataId(); }
private ObjectId getMetadataId(Bounded input) { if (input instanceof Bucket) { return defaultMetadataId; } if (input instanceof Node) { return ((Node) input).getMetadataId().or(defaultMetadataId); } return ((NodeRef) input).getMetadataId(); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof MutableTree)) { return false; } MutableTree other = (MutableTree) o; return node.equals(other.node) && node.getMetadataId().equals(other.node.getMetadataId()) && childTrees.equals(other.childTrees); }
private ObjectId getMetadataId(Bounded input) { if (input instanceof Bucket) { return defaultMetadataId; } if (input instanceof Node) { return ((Node) input).getMetadataId().or(defaultMetadataId); } return ((NodeRef) input).getMetadataId(); }
private void append(StringBuilder sb, Node node, int indent) { sb.append(Strings.repeat(" ", indent)).append(node.getName()).append("->") .append(node.getObjectId()).append(" (").append(node.getMetadataId()).append(")\n"); }
private void addMetadataId(ObjectReporter progress, NodeRef right) { if (right.getNode().getMetadataId().isPresent()) { ObjectId md = right.getNode().getMetadataId().get(); if (consume(md)) { progress.addFeatureType(); } } }
public static String toString(@NonNull Node node) { Envelope env = node.bounds().orNull(); String bounds = env == null ? null : env.toString(); return String.format("%s[%s -> %s, type: %s, md id: %s, bounds: %s]", // node.getClass().getSimpleName(), // node.getName(), // toShortString(node.getObjectId()), // node.getType(), // (node.getMetadataId().isPresent() ? toShortString(node.getMetadataId().get()) : "NULL"), // bounds); }
private void verifyMetadata(Node node) { if (node.getMetadataId().isPresent()) { ObjectId mdId = node.getMetadataId().get(); String msg = "RevFeatureType " + mdId + " is not present (from " + node.getName() + ")"; assertTrue(msg, objectDb.exists(mdId)); } }
private void verifyMetadata(Node node) { if (node.getMetadataId().isPresent()) { ObjectId mdId = node.getMetadataId().get(); String msg = "RevFeatureType " + mdId + " is not present (from " + node.getName() + ")"; assertTrue(msg, objectDb.exists(mdId)); } }
private void assertNodesEqual(List<Node> l1, List<Node> l2) { assertEquals(l1, l2); for (int i = 0; i < l1.size(); i++) { Node n1 = l1.get(i); Node n2 = l2.get(i); assertEquals(n1.getExtraData(), n2.getExtraData()); assertEquals(n1.getMetadataId(), n2.getMetadataId()); assertEquals(n1.bounds(), n2.bounds()); } }
private void assertNodesEqual(List<Node> l1, List<Node> l2) { assertEquals(l1, l2); for (int i = 0; i < l1.size(); i++) { Node n1 = l1.get(i); Node n2 = l2.get(i); assertEquals(n1.getExtraData(), n2.getExtraData()); assertEquals(n1.getMetadataId(), n2.getMetadataId()); assertEquals(n1.bounds(), n2.bounds()); } }
@Test public void testCreateTypeTree() throws Exception { NodeRef treeRef = workTree.createTypeTree("points2", pointsType); assertNotNull(treeRef); assertEquals("points2", treeRef.path()); assertEquals("", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); assertEquals(pointsType, featureType.type()); }
@Test public void testCreateTypeNestedNonExistingParent() throws Exception { NodeRef treeRef = workTree.createTypeTree("path/to/nested/type", pointsType); assertNotNull(treeRef); assertEquals("path/to/nested/type", treeRef.path()); assertEquals("path/to/nested", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertEquals(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@Test public void testCreateIndexNoTreeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("treeName not provided"); geogig.command(CreateIndexOp.class)// .setCanonicalTypeTree(worldPointsTree)// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setAttributeName("geom")// .setIndexType(IndexType.QUADTREE)// .call(); }
@Test public void testCreateIndexNoAttributeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("attributeName not provided"); geogig.command(CreateIndexOp.class)// .setTreeName(worldPointsLayer.getName())// .setCanonicalTypeTree(worldPointsTree)// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setIndexType(IndexType.QUADTREE)// .call(); }
@Test public void testCreateIndexNoCanonicalTypeTree() { exception.expect(IllegalArgumentException.class); exception.expectMessage("canonicalTypeTree not provided"); geogig.command(CreateIndexOp.class)// .setTreeName(worldPointsLayer.getName())// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setAttributeName("geom")// .setIndexType(IndexType.QUADTREE)// .call(); }
@Test public void testCreateIndexNoIndexType() { exception.expect(IllegalArgumentException.class); exception.expectMessage("indexType not provided"); geogig.command(CreateIndexOp.class)// .setTreeName(worldPointsLayer.getName())// .setCanonicalTypeTree(worldPointsTree)// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setAttributeName("geom")// .call(); } }
@Test public void testCreateIndexNoAttributeName() { exception.expect(IllegalArgumentException.class); exception.expectMessage("attributeName not provided"); geogig.command(CreateIndexOp.class)// .setTreeName(worldPointsLayer.getName())// .setCanonicalTypeTree(worldPointsTree)// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setIndexType(IndexType.QUADTREE)// .call(); }
@Test public void testCreateIndexNoCanonicalTypeTree() { exception.expect(IllegalArgumentException.class); exception.expectMessage("canonicalTypeTree not provided"); geogig.command(CreateIndexOp.class)// .setTreeName(worldPointsLayer.getName())// .setFeatureTypeId(worldPointsLayer.getMetadataId().get())// .setAttributeName("geom")// .setIndexType(IndexType.QUADTREE)// .call(); }