private Iterator<Feature> transformFeatures(SimpleFeatureType featureType, String path) { String refspec = Ref.WORK_HEAD + ":" + path; Iterator<NodeRef> oldFeatures = command(LsTreeOp.class).setReference(refspec) .setStrategy(Strategy.FEATURES_ONLY).call(); RevFeatureType revFeatureType = RevFeatureTypeBuilder.build(featureType); Iterator<Feature> transformedIterator = transformIterator(oldFeatures, revFeatureType); return transformedIterator; }
private void copyTree(final ObjectId treeId, final ObjectStore from, final ObjectStore to, final Set<ObjectId> metadataIds) { if (to.exists(treeId)) { return; } Supplier<Iterator<NodeRef>> refs = command(LsTreeOp.class).setReference(treeId.toString()) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES); // Supplier<Iterator<Node>> nodes = Suppliers.compose(// // it -> Iterators.transform(it, NodeRef::getNode)// // , refs); Iterator<Node> ns = Streams.stream(refs.get()).map(NodeRef::getNode).iterator(); Supplier<Iterator<Node>> nodes = Suppliers.ofInstance(ns); // move all features, recursively as given by the LsTreeOp strategy copyObjects(from, to, nodes, metadataIds); // iterator that traverses the tree,all its subtrees, an bucket trees Iterator<RevTree> allSubtreesAndBuckets = new AllTrees(treeId, from); to.putAll(allSubtreesAndBuckets); }
@Test public void testNonRecursiveTreeListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class).setStrategy(Strategy.TREES_ONLY) .call(); assertEquals(2, Iterators.size(iter)); }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
@Test public void testUnexistentOriginListing() { try { geogig.command(LsTreeOp.class).setReference("WRONGORIGIN").call(); fail(); } catch (IllegalArgumentException e) { assertTrue(true); } }
return Collections.emptyIterator(); LsTreeOp op = geogig.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .setReference(ref); if (bbox != null) { final Envelope env; op.setBoundsFilter(filter); Iterator<NodeRef> iterator = op.call(); final EntityConverter converter = new EntityConverter(); final Function<NodeRef, EntityContainer> function = (nr) -> {
/** * Implements {@link Supplier#get()} by deferring to {@link #call()} */ @Override public Iterator<NodeRef> get() { return call(); } }
@Test public void testRecursiveRootListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).call(); assertEquals(6, Iterators.size(iter)); }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
@Test public void testHEADNonRecursiveRootListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class).setReference("HEAD").call(); assertEquals(2, Iterators.size(iter)); }
private TreeDifference computeTreeDifference() { final String rightTreeish = Ref.STAGE_HEAD; final ObjectId rootTreeId = resolveRootTreeId(); final ObjectId stageRootId = stagingArea().getTree().getId(); final Supplier<Iterator<NodeRef>> leftTreeRefs; final Supplier<Iterator<NodeRef>> rightTreeRefs; if (rootTreeId.isNull()) { Iterator<NodeRef> empty = Collections.emptyIterator(); leftTreeRefs = Suppliers.ofInstance(empty); } else { leftTreeRefs = command(LsTreeOp.class).setReference(rootTreeId.toString()) .setStrategy(Strategy.DEPTHFIRST_ONLY_TREES); } rightTreeRefs = command(LsTreeOp.class).setReference(rightTreeish) .setStrategy(Strategy.DEPTHFIRST_ONLY_TREES); MutableTree leftTree = MutableTree.createFromRefs(rootTreeId, leftTreeRefs); MutableTree rightTree = MutableTree.createFromRefs(stageRootId, rightTreeRefs); TreeDifference treeDifference = TreeDifference.create(leftTree, rightTree); return treeDifference; }
/** * Implements {@link Supplier#get()} by deferring to {@link #call()} */ @Override public Iterator<NodeRef> get() { return call(); } }
@Override protected List<NodeRef> _call() { Preconditions.checkNotNull(refSpec, "refSpec was not provided"); Iterator<NodeRef> allTrees; try { allTrees = context.command(LsTreeOp.class).setReference(refSpec) .setStrategy(LsTreeOp.Strategy.DEPTHFIRST_ONLY_TREES).call(); } catch (IllegalArgumentException noWorkHead) { return ImmutableList.of(); } Iterator<NodeRef> typeTrees = Iterators.filter(allTrees, new Predicate<NodeRef>() { @Override public boolean apply(NodeRef input) { ObjectId metadataId = input.getMetadataId(); return !metadataId.isNull(); } }); return ImmutableList.copyOf(typeTrees); }
@Test public void testRecursiveRootListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).call(); assertEquals(6, Iterators.size(iter)); }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
@Test public void testUnexistentPathListing() { try { geogig.command(LsTreeOp.class).setReference("WORK_HEAD:WRONGPATH").call(); fail(); } catch (IllegalArgumentException e) { assertTrue(true); } }
private TreeDifference computeTreeDifference() { final String rightTreeish = Ref.STAGE_HEAD; final ObjectId rootTreeId = resolveRootTreeId(); final ObjectId stageRootId = stagingArea().getTree().getId(); final Supplier<Iterator<NodeRef>> leftTreeRefs; final Supplier<Iterator<NodeRef>> rightTreeRefs; if (rootTreeId.isNull()) { Iterator<NodeRef> empty = Collections.emptyIterator(); leftTreeRefs = Suppliers.ofInstance(empty); } else { leftTreeRefs = command(LsTreeOp.class).setReference(rootTreeId.toString()) .setStrategy(Strategy.DEPTHFIRST_ONLY_TREES); } rightTreeRefs = command(LsTreeOp.class).setReference(rightTreeish) .setStrategy(Strategy.DEPTHFIRST_ONLY_TREES); MutableTree leftTree = MutableTree.createFromRefs(rootTreeId, leftTreeRefs); MutableTree rightTree = MutableTree.createFromRefs(stageRootId, rightTreeRefs); TreeDifference treeDifference = TreeDifference.create(leftTree, rightTree); return treeDifference; }
@Test public void testNonRecursiveRootListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class).call(); assertEquals(2, Iterators.size(iter)); }
private Map<String, NodeRef> getDeleteTrees(RevTree workTree) { Iterator<NodeRef> childTrees = command(LsTreeOp.class) .setStrategy(Strategy.DEPTHFIRST_ONLY_TREES) .setReference(workTree.getId().toString()).call(); ImmutableMap<String, NodeRef> treesByPath = Maps.uniqueIndex(childTrees, (ref) -> ref.path()); Set<String> requestedTrees = Sets.intersection(treesByPath.keySet(), new HashSet<>(pathsToRemove)); Predicate<String> keyPredicate = Predicates.in(requestedTrees); Map<String, NodeRef> requestedTreesMap = Maps.filterKeys(treesByPath, keyPredicate); return requestedTreesMap; }
@Test public void testNonRecursiveTreeListing() { Iterator<NodeRef> iter = geogig.command(LsTreeOp.class).setStrategy(Strategy.TREES_ONLY) .call(); assertEquals(2, Iterators.size(iter)); }