private TreeReport parentReport(String path) { String parentPath = NodeRef.parentPath(path); TreeReport treeReport = reportsByTree.computeIfAbsent(parentPath, treePath -> new TreeReport(treePath)); return treeReport; }
/** * @return an iterable with all elements in {@link #pathsToRemove} whose parent path are not in * {@code deleteTrees} */ private List<String> filterFeatures(Set<String> deleteTrees) { List<String> filtered = new ArrayList<>(this.pathsToRemove.size()); for (String pathToRemove : pathsToRemove) { if (deleteTrees.contains(pathToRemove) || deleteTrees.contains(NodeRef.parentPath(pathToRemove))) { continue; } NodeRef.checkValidPath(pathToRemove); filtered.add(pathToRemove); } return filtered; }
/** * @return an iterable with all elements in {@link #pathsToRemove} whose parent path are not in * {@code deleteTrees} */ private List<String> filterFeatures(Set<String> deleteTrees) { List<String> filtered = new ArrayList<>(this.pathsToRemove.size()); for (String pathToRemove : pathsToRemove) { if (deleteTrees.contains(pathToRemove) || deleteTrees.contains(NodeRef.parentPath(pathToRemove))) { continue; } NodeRef.checkValidPath(pathToRemove); filtered.add(pathToRemove); } return filtered; }
public void remove(String featurePath) { final String treePath = NodeRef.parentPath(featurePath); final String featureId = NodeRef.nodeFromPath(featurePath); Optional<CanonicalTreeBuilder> treeBuilder = getTreeBuilder(treePath); if (treeBuilder.isPresent()) { CanonicalTreeBuilder builder = treeBuilder.get(); builder.remove(featureId); } }
public void remove(String featurePath) { final String treePath = NodeRef.parentPath(featurePath); final String featureId = NodeRef.nodeFromPath(featurePath); Optional<RevTreeBuilder> treeBuilder = getTreeBuilder(treePath); if (treeBuilder.isPresent()) { RevTreeBuilder builder = treeBuilder.get(); Node featureNode = RevObjectFactory.defaultInstance().createNode(featureId, ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE, null, null); builder.remove(featureNode); } }
/** * Constructs a new {@code NodeRef} that points to the tree with the provided parameters. * * @param treePath the path of the tree * @param id the {@link ObjectId} of the tree * @param metadataId the metadata id of the tree * @return the newly constructed {@code NodeRef} */ public static NodeRef tree(String treePath, ObjectId id, ObjectId metadataId) { NodeRef.checkValidPath(treePath); checkNotNull(id); checkNotNull(metadataId); String parentPath = NodeRef.parentPath(treePath); String treeName = NodeRef.nodeFromPath(treePath); Node treeNode = Node.tree(treeName, id, metadataId); return NodeRef.create(parentPath, treeNode); } }
/** * Test method for {@link org.locationtech.geogig.model.Node#parentPath(java.lang.String)}. */ @Test public void testParentPath() { assertNull(parentPath(null)); assertNull(parentPath("")); assertEquals("", parentPath("node")); assertEquals("to", parentPath("to/node")); assertEquals("path/to", parentPath("path/to/node")); }
private void stageDeletes(Iterator<NodeRef> trees, Iterator<String> features) { final StagingArea index = stagingArea(); Iterator<DiffEntry> treeDeletes = Iterators.transform(trees, (treeRef) -> new DiffEntry(treeRef, null)); Iterator<DiffEntry> featureDeletes = Iterators.transform(features, (featurePath) -> { Node node = Node.create(NodeRef.nodeFromPath(featurePath), ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE, null); String parentPath = NodeRef.parentPath(featurePath); NodeRef oldFeature = new NodeRef(node, parentPath, ObjectId.NULL); return new DiffEntry(oldFeature, null); }); ProgressListener progress = DefaultProgressListener.NULL; index.stage(progress, Iterators.concat(treeDeletes, featureDeletes), -1); }
/** * Constructs a new {@code NodeRef} that points to the tree with the provided parameters. * * @param treePath the path of the tree * @param id the {@link ObjectId} of the tree * @param metadataId the metadata id of the tree * @return the newly constructed {@code NodeRef} */ public static NodeRef tree(String treePath, ObjectId id, ObjectId metadataId) { NodeRef.checkValidPath(treePath); checkNotNull(id); checkNotNull(metadataId); String parentPath = NodeRef.parentPath(treePath); String treeName = NodeRef.nodeFromPath(treePath); Node treeNode = RevObjectFactory.defaultInstance().createNode(treeName, id, metadataId, TYPE.TREE, null, null); return NodeRef.create(parentPath, treeNode); } }
@Override protected Optional<NodeRef> _call() { Optional<RevFeature> feature = getFeatureFromRefSpec(); if (feature.isPresent()) { RevFeatureType featureType = getFeatureTypeFromRefSpec(); RevFeature feat = feature.get(); Envelope bounds = SpatialOps.boundsOf(feat); Node node = RevObjectFactory.defaultInstance().createNode(NodeRef.nodeFromPath(ref), feat.getId(), featureType.getId(), TYPE.FEATURE, bounds, null); return Optional.of(new NodeRef(node, NodeRef.parentPath(ref), featureType.getId())); } return Optional.absent(); } }
@Override protected Optional<NodeRef> _call() { Optional<RevFeature> feature = getFeatureFromRefSpec(); if (feature.isPresent()) { RevFeatureType featureType = getFeatureTypeFromRefSpec(); RevFeature feat = feature.get(); Envelope bounds = SpatialOps.boundsOf(feat); Node node = Node.create(NodeRef.nodeFromPath(ref), feat.getId(), featureType.getId(), TYPE.FEATURE, bounds); return Optional.of(new NodeRef(node, NodeRef.parentPath(ref), featureType.getId())); } else { return Optional.absent(); /* * new NodeRef(Node.create("", ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE), "", * ObjectId.NULL); */ } } }
@Override public DiffEntry apply(String featurePath) { Node node = RevObjectFactory.defaultInstance().createNode( NodeRef.nodeFromPath(featurePath), ObjectId.NULL, ObjectId.NULL, TYPE.FEATURE, null, null); String parentPath = NodeRef.parentPath(featurePath); NodeRef oldFeature = new NodeRef(node, parentPath, ObjectId.NULL); return new DiffEntry(oldFeature, null); }};
private NodeRef tree(String path, ObjectId treeId, @Nullable ObjectId metadataId) { String parentPath = NodeRef.parentPath(path); String name = NodeRef.nodeFromPath(path); Node node = treeNode(name, treeId, metadataId); return new NodeRef(node, parentPath, ObjectId.NULL); }
private NodeRef tree(String path, ObjectId treeId, @Nullable ObjectId metadataId) { String parentPath = NodeRef.parentPath(path); String name = NodeRef.nodeFromPath(path); Node node = treeNode(name, treeId, metadataId); return new NodeRef(node, parentPath, ObjectId.NULL); }
protected Conflict createTestConflict(String path) { Preconditions.checkArgument(!Strings.isNullOrEmpty(path)); ObjectId ancestor = RevObjectTestSupport.hashString(NodeRef.parentPath(path)); ObjectId ours = RevObjectTestSupport.hashString(path); ObjectId theirs = RevObjectTestSupport.hashString(path + "1"); Conflict c = new Conflict(path, ancestor, ours, theirs); return c; }
protected Conflict createTestConflict(String path) { Preconditions.checkArgument(!Strings.isNullOrEmpty(path)); ObjectId ancestor = RevObjectTestSupport.hashString(NodeRef.parentPath(path)); ObjectId ours = RevObjectTestSupport.hashString(path); ObjectId theirs = RevObjectTestSupport.hashString(path + "1"); Conflict c = new Conflict(path, ancestor, ours, theirs); return c; }
private NodeRef tree(String path, ObjectId treeId, ObjectId metadataId) { String parentPath = NodeRef.parentPath(path); String name = NodeRef.nodeFromPath(path); Node node = treeNode(name, treeId, metadataId); return new NodeRef(node, parentPath, ObjectId.NULL); }
private NodeRef tree(String path, ObjectId treeId, ObjectId metadataId) { String parentPath = NodeRef.parentPath(path); String name = NodeRef.nodeFromPath(path); Node node = treeNode(name, treeId, metadataId); return new NodeRef(node, parentPath, ObjectId.NULL); }
private NodeRef findOrCreateTree(final String treePath, final FeatureType type) { RevTree tree = context.command(FindOrCreateSubtree.class).setChildPath(treePath) .setParent(workHead).setParentPath(NodeRef.ROOT).call(); ObjectId metadataId = ObjectId.NULL; if (type != null) { RevFeatureType revFeatureType = RevFeatureTypeBuilder.build(type); if (tree.isEmpty()) { db.put(revFeatureType); } metadataId = revFeatureType.getId(); } Envelope bounds = SpatialOps.boundsOf(tree); Node node = Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds); String parentPath = NodeRef.parentPath(treePath); return new NodeRef(node, parentPath, ObjectId.NULL); }
private NodeRef findOrCreateTree(final String treePath, final FeatureType type) { RevTree tree = context.command(FindOrCreateSubtree.class).setChildPath(treePath) .setParent(workHead).setParentPath(NodeRef.ROOT).call(); ObjectId metadataId = ObjectId.NULL; if (type != null) { RevFeatureType revFeatureType = RevFeatureType.builder().type(type).build(); if (tree.isEmpty()) { db.put(revFeatureType); } metadataId = revFeatureType.getId(); } Envelope bounds = SpatialOps.boundsOf(tree); Node node = RevObjectFactory.defaultInstance().createNode(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds, null); String parentPath = NodeRef.parentPath(treePath); return new NodeRef(node, parentPath, ObjectId.NULL); }