/** * @return the {@link ObjectId} of the {@code Node} this object points to */ @Override public ObjectId getObjectId() { return node.getObjectId(); }
/** * @deprecated use {@link #getObjectId()} instead */ @Deprecated public ObjectId objectId() { return node.getObjectId(); }
/** * @deprecated use {@link #getObjectId()} instead */ @Deprecated public ObjectId objectId() { return node.getObjectId(); }
/** * @return the Node represented as a readable string. */ @Override public String toString() { return new StringBuilder("NodeRef").append('[').append(path()).append(" -> ") .append(node.getObjectId()).append(']').toString(); }
/** * Equality check based on {@link #getName() name}, {@link #getType() type}, and * {@link #getObjectId() objectId}; {@link #getMetadataId()} is NOT part of the equality check. */ public static boolean equals(@NonNull Node node, @Nullable Object o) { if (o instanceof Node) { Node r = (Node) o; return node.getType().equals(r.getType()) && node.getName().equals(r.getName()) && node.getObjectId().equals(r.getObjectId()); } return false; }
/** * Hash code is based on {@link #getParentPath() parent path}, {@link #getNode() node} name and * id, and {@link #getMetadataId()} */ @Override public int hashCode() { return 17 ^ (parentPath != null ? parentPath.hashCode() : 1) * node.getObjectId().hashCode() * getMetadataId().hashCode(); }
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 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 long sumTreeSizes(Iterable<Node> trees) { long size = 0; for (Node n : trees) { RevTree tree = state.getTree(n.getObjectId()); if (state.isCancelled()) { return -1L; } size += tree.size(); } return size; } }
public boolean remove(Node node) { if (!node.getObjectId().isNull()) { node = node.update(ObjectId.NULL); } int delta = put(node); return -1 == delta; }
private void verifyFeature(Node node) { ObjectId objectId = node.getObjectId(); assertTrue("feature " + node.getName() + " -> " + objectId + " is not present in objectDb", objectDb.exists(objectId)); }
private void verifyFeature(Node node) { ObjectId objectId = node.getObjectId(); assertTrue("feature " + node.getName() + " -> " + objectId + " is not present in objectDb", objectDb.exists(objectId)); }
public static Set<ObjectId> verifyAllReachableTrees(ObjectStore store, ObjectId treeId) { Set<ObjectId> allIds = new HashSet<>(); RevTree tree = store.getTree(treeId); allIds.add(tree.getId()); tree.trees() .forEach(node -> allIds.addAll(verifyAllReachableTrees(store, node.getObjectId()))); tree.getBuckets() .forEach(b -> allIds.addAll(verifyAllReachableTrees(store, b.getObjectId()))); return allIds; } }
@Test public void testNodeAndNodeRefToString() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef = new NodeRef(node, "Points", ObjectId.NULL); String readableNode = nodeRef.toString(); assertTrue(readableNode .equals("NodeRef[Points/Points.1 -> " + node.getObjectId().toString() + "]")); }
@Test public void testInsertSingle() throws Exception { FeatureInfo fi = featureInfo(points1); workTree.insert(fi); assertEquals(fi.getFeature().getId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId()); }
@Test public void testInsertSingle() throws Exception { FeatureInfo fi = featureInfo(points1); workTree.insert(fi); assertEquals(fi.getFeature().getId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId()); }
@Test public void testCheckoutTheirs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setTheirs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.MERGE_HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@Test public void testCheckoutOurs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@Test public void testCheckoutOurs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@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()); }