/** * @return the name of the old object */ public @Nullable String oldName() { return oldObject == null ? null : oldObject.getNode().getName(); }
/** * @return the name of the new object */ public @Nullable String newName() { return newObject == null ? null : newObject.getNode().getName(); }
/** * Provides for natural ordering of {@code NodeRef}, based on {@link #path()} */ @Override public int compareTo(NodeRef o) { int c = parentPath.compareTo(o.getParentPath()); if (c == 0) { return node.compareTo(o.getNode()); } return c; }
private ObjectId getPathHash(RevTree tree, String path) { ObjectId hash = ObjectId.NULL; Optional<NodeRef> ref = findTreeChild.setChildPath(path).setParent(tree).call(); if (ref.isPresent()) { hash = ref.get().getNode().getObjectId(); } return hash; } }
public void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); data.write(nodeRef.getMetadataId().getRawValue()); data.writeUTF(nodeRef.getParentPath()); }
protected List<Node> lstree(RevTree tree) { Iterator<NodeRef> it = new DepthTreeIterator("", ObjectId.NULL, tree, objectStore, Strategy.CHILDREN); Function<NodeRef, Node> asNode = v -> { return v.getNode(); }; List<Node> nodes = Lists.newArrayList(Iterators.transform(it, asNode)); return nodes; }
public void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); nodeRef.getMetadataId().writeTo(data); data.writeUTF(nodeRef.getParentPath()); }
public static void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); nodeRef.getMetadataId().writeTo(data); data.writeUTF(nodeRef.getParentPath()); } }
private Optional<Node> findTreeChild(RevTree root, String pathRemove) { Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(root) .setChildPath(pathRemove).call(); Optional<Node> node = Optional.absent(); if (nodeRef.isPresent()) { node = Optional.of(nodeRef.get().getNode()); } return node; }
private Optional<Node> findTreeChild(RevTree root, String pathRemove) { Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(root) .setChildPath(pathRemove).call(); Optional<Node> node = Optional.absent(); if (nodeRef.isPresent()) { node = Optional.of(nodeRef.get().getNode()); } return node; }
private Optional<Node> findTreeChild(RevTree root, String pathRemove) { Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(root) .setChildPath(pathRemove).call(); Optional<Node> node = Optional.absent(); if (nodeRef.isPresent()) { node = Optional.of(nodeRef.get().getNode()); } return node; } }
private Optional<Node> findTreeChild(RevTree root, String pathRemove) { Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(root) .setChildPath(pathRemove).call(); Optional<Node> node = Optional.absent(); if (nodeRef.isPresent()) { node = Optional.of(nodeRef.get().getNode()); } return node; } }
@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()); 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 testCreateTypeTree() throws Exception { NodeRef treeRef = workTree.createTypeTree("points2", pointsType); assertNotNull(treeRef); assertEquals("points2", treeRef.path()); assertEquals("", 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); }
@Override protected void setUpInternal() throws Exception { Repository repository = getRepository(); indexdb = repository.indexDatabase(); worldPointsLayer = IndexTestSupport.createWorldPointsLayer(repository).getNode(); super.add(); super.commit("created world points layer"); this.worldPointsTree = repository.getTree(worldPointsLayer.getObjectId()); assertNotEquals(RevTree.EMPTY_TREE_ID, worldPointsLayer.getObjectId()); }
@Test public void testTree() { ObjectId oId = ObjectId.valueOf("abc123000000000000001234567890abcdef0000"); ObjectId metadataId = ObjectId.valueOf("abc123000000000000001234567890abcdef0001"); NodeRef nodeRef = NodeRef.tree("Points", oId, metadataId); assertEquals(oId, nodeRef.getObjectId()); assertEquals(metadataId, nodeRef.getMetadataId()); assertEquals("Points", nodeRef.getNode().getName()); }
@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()); }