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; } }
/** * Determines if a specific feature type is versioned (existing in the main repository). * * @param treePath feature type to check * @return true if the feature type is versioned, false otherwise. */ @Override public boolean hasRoot(final String treePath) { Optional<NodeRef> typeNameTreeRef = context.command(FindTreeChild.class) .setChildPath(treePath).call(); return typeNameTreeRef.isPresent(); }
RevTree parent = parentSupplier.get().get(); Optional<NodeRef> treeChildRef = command(FindTreeChild.class).setParentPath(parentPath) .setChildPath(childPath).setParent(Suppliers.ofInstance(parent)).call();
/** * Executes the command. * * @return an {@code Optional} that contains the Node if it was found, or * {@link Optional#absent()} if it wasn't */ @Override protected Optional<NodeRef> _call() { checkNotNull(childPath, "childPath"); if (source == null) { this.source = objectDatabase(); } final RevTree tree; if (parent == null) { ObjectId rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(Ref.HEAD).call().get(); if (rootTreeId.isNull()) { return Optional.absent(); } tree = command(RevObjectParse.class).setSource(source).setObjectId(rootTreeId) .call(RevTree.class).get(); } else { tree = parent.get(); } final String path = childPath; final String parentPath = this.parentPath == null ? "" : this.parentPath; DepthSearch depthSearch = new DepthSearch(source); Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path); return childRef; }
RevTree parent = parentSupplier.get().get(); Optional<NodeRef> treeChildRef = command(FindTreeChild.class).setParentPath(parentPath) .setChildPath(childPath).setParent(Suppliers.ofInstance(parent)).call();
/** * Determines if a specific feature type is versioned (existing in the main repository). * * @param treePath feature type to check * @return true if the feature type is versioned, false otherwise. */ @Override public boolean hasRoot(final String treePath) { Optional<NodeRef> typeNameTreeRef = context.command(FindTreeChild.class) .setChildPath(treePath).call(); return typeNameTreeRef.isPresent(); }
/** * Executes the command. * * @return an {@code Optional} that contains the Node if it was found, or * {@link Optional#absent()} if it wasn't */ @Override protected Optional<NodeRef> _call() { checkNotNull(childPath, "childPath"); if (source == null) { this.source = objectDatabase(); } final RevTree tree; if (parent == null) { ObjectId rootTreeId = command(ResolveTreeish.class).setSource(source) .setTreeish(Ref.HEAD).call().get(); if (rootTreeId.isNull()) { return Optional.absent(); } tree = command(RevObjectParse.class).setSource(source).setObjectId(rootTreeId) .call(RevTree.class).get(); } else { tree = parent.get(); } final String path = childPath; final String parentPath = this.parentPath == null ? "" : this.parentPath; DepthSearch depthSearch = new DepthSearch(source); Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path); return childRef; }
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; } }
@Override public Void call() { RevTree tree = builder.build(); Node treeNode; { ObjectId treeMetadataId = defaultMetadataId; String name = NodeRef.nodeFromPath(treePath); ObjectId oid = tree.getId(); Envelope bounds = SpatialOps.boundsOf(tree); treeNode = Node.create(name, oid, treeMetadataId, RevObject.TYPE.TREE, bounds); } final String parentPath = NodeRef.parentPath(treePath); final ObjectId parentMetadataId; if (NodeRef.ROOT.equals(parentPath)) { parentMetadataId = ObjectId.NULL; } else { Optional<NodeRef> parentRef = context.command(FindTreeChild.class) .setChildPath(parentPath).setParent(workHead).setParentPath(NodeRef.ROOT) .call(); parentMetadataId = parentRef.isPresent() ? parentRef.get().getMetadataId() : ObjectId.NULL; } NodeRef newTreeRef = new NodeRef(treeNode, parentPath, parentMetadataId); target.put(newTreeRef, tree); return null; }
/** * @param path the path to search for * @return an {@link Optional} of the {@link Node} for the child, or {@link Optional#absent()} * if it wasn't found */ @Override public Optional<Node> getRootTreeChild(String path) { Optional<NodeRef> nodeRef = command(FindTreeChild.class).setChildPath(path).call(); if (nodeRef.isPresent()) { return Optional.of(nodeRef.get().getNode()); } else { return Optional.absent(); } }
private NodeRef resolTypeTreeRef(final String refspec, final String treePath, final RevTree rootTree) { Optional<NodeRef> typeTreeRef = command(FindTreeChild.class).setParent(rootTree) .setChildPath(treePath).call(); checkArgument(typeTreeRef.isPresent(), "Type tree %s does not exist", refspec); checkArgument(TYPE.TREE.equals(typeTreeRef.get().getType()), "%s did not resolve to a tree", refspec); return typeTreeRef.get(); }
@Override public Void call() { RevTree tree = builder.build(); Node treeNode; { ObjectId treeMetadataId = defaultMetadataId; String name = NodeRef.nodeFromPath(treePath); ObjectId oid = tree.getId(); Envelope bounds = SpatialOps.boundsOf(tree); treeNode = RevObjectFactory.defaultInstance().createNode(name, oid, treeMetadataId, RevObject.TYPE.TREE, bounds, null); } final String parentPath = NodeRef.parentPath(treePath); final ObjectId parentMetadataId; if (NodeRef.ROOT.equals(parentPath)) { parentMetadataId = ObjectId.NULL; } else { Optional<NodeRef> parentRef = context.command(FindTreeChild.class) .setChildPath(parentPath).setParent(workHead).setParentPath(NodeRef.ROOT) .call(); parentMetadataId = parentRef.isPresent() ? parentRef.get().getMetadataId() : ObjectId.NULL; } NodeRef newTreeRef = new NodeRef(treeNode, parentPath, parentMetadataId); target.put(newTreeRef, tree); return null; }
/** * @param path the path to search for * @return an {@link Optional} of the {@link Node} for the child, or {@link Optional#absent()} * if it wasn't found */ @Override public Optional<Node> getRootTreeChild(String path) { Optional<NodeRef> nodeRef = command(FindTreeChild.class).setChildPath(path).call(); if (nodeRef.isPresent()) { return Optional.of(nodeRef.get().getNode()); } else { return Optional.absent(); } }
private NodeRef resolTypeTreeRef(final String refspec, final String treePath, final RevTree rootTree) { Optional<NodeRef> typeTreeRef = command(FindTreeChild.class).setParent(rootTree) .setChildPath(treePath).call(); checkArgument(typeTreeRef.isPresent(), "Type tree %s does not exist", refspec); checkArgument(TYPE.TREE.equals(typeTreeRef.get().getType()), "%s did not resolve to a tree", refspec); return typeTreeRef.get(); }
@Test public void testMergeTwoBranchesWithNewFeatureType() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(lines1); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("branch1").call(); insertAndAdd(poly1); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(commit2.getId()).call(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(polyName).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getMetadataId().equals(ObjectId.NULL)); }
private NodeRef resolTypeTreeRef(final String refspec, final String treePath, final RevTree rootTree) { Optional<NodeRef> typeTreeRef = command(FindTreeChild.class).setParent(rootTree) .setChildPath(treePath).call(); checkArgument(typeTreeRef.isPresent(), "Type tree %s does not exist", refspec); checkArgument(TYPE.TREE.equals(typeTreeRef.get().getType()), "%s did not resolve to a tree", refspec); return typeTreeRef.get(); }
@Test public void testMergeTwoBranchesWithNewFeatureType() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); geogig.command(BranchCreateOp.class).setName("branch1").call(); insertAndAdd(lines1); geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("branch1").call(); insertAndAdd(poly1); RevCommit commit2 = geogig.command(CommitOp.class).call(); geogig.command(CheckoutOp.class).setSource("master").call(); geogig.command(MergeOp.class).addCommit(commit2.getId()).call(); Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(polyName).call(); assertTrue(ref.isPresent()); assertFalse(ref.get().getMetadataId().equals(ObjectId.NULL)); }
private NodeRef resolTypeTreeRef(final String refspec, final String treePath, final RevTree rootTree) { Optional<NodeRef> typeTreeRef = command(FindTreeChild.class).setParent(rootTree) .setChildPath(treePath).call(); checkArgument(typeTreeRef.isPresent(), "Type tree %s does not exist", refspec); checkArgument(TYPE.TREE.equals(typeTreeRef.get().getType()), "%s did not resolve to a tree", refspec); return typeTreeRef.get(); }
/** * @param path the path of the {@link Node} to find * @return the {@code Node} for the feature at the specified path if it exists in the index, * otherwise {@link Optional#absent()} */ @Override public Optional<Node> findStaged(final String path) { Optional<NodeRef> entry = context.command(FindTreeChild.class).setParent(getTree()) .setChildPath(path).call(); if (entry.isPresent()) { return Optional.of(entry.get().getNode()); } else { return Optional.absent(); } }
/** * @param path finds a {@link Node} for the feature at the given path in the index * @return the Node for the feature at the specified path if it exists in the work tree, * otherwise Optional.absent() */ @Override public Optional<Node> findUnstaged(final String path) { Optional<NodeRef> nodeRef = context.command(FindTreeChild.class).setParent(getTree()) .setChildPath(path).call(); if (nodeRef.isPresent()) { return Optional.of(nodeRef.get().getNode()); } else { return Optional.absent(); } }