private @Nullable NodeRef findTypeRef(List<NodeRef> typeRefs, String localName) { java.util.Optional<NodeRef> match = typeRefs.stream() .filter((r) -> NodeRef.nodeFromPath(r.path()).equals(localName)).findFirst(); return match.orElse(null); }
public String getName() { return NodeRef.nodeFromPath(getPath()); }
public String getName() { return NodeRef.nodeFromPath(getPath()); }
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 public void testNodeFromPath() { String node = NodeRef.nodeFromPath("Points/Points.1"); assertEquals(node, "Points.1"); node = NodeRef.nodeFromPath("refs/heads/master"); assertEquals(node, "master"); node = NodeRef.nodeFromPath("Points.1"); assertEquals(node, "Points.1"); node = NodeRef.nodeFromPath(""); assertNull(node); node = NodeRef.nodeFromPath(null); assertNull(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); }
public Name getDescriptorName(NodeRef treeRef) { Preconditions.checkNotNull(treeRef); Preconditions.checkArgument(TYPE.TREE.equals(treeRef.getType())); Preconditions.checkArgument(!treeRef.getMetadataId().isNull(), "NodeRef '%s' is not a feature type reference", treeRef.path()); return new NameImpl(getNamespaceURI(), NodeRef.nodeFromPath(treeRef.path())); }
/** * 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); */ } } }
/** * Returns a feature from the working tree of the repository, given its full path * * Returns null if the given path doesn't resolve to a feature * * @param path the path to the feature to return */ public Feature getFeatureFromWorkingTree(String path) { String name = NodeRef.nodeFromPath(path); String refSpec = "WORK_HEAD:" + path; Optional<RevFeature> revFeature = repository.command(RevObjectParse.class) .setRefSpec(refSpec).call(RevFeature.class); if (revFeature.isPresent()) { RevFeatureType revFeatureType = repository.command(ResolveFeatureType.class) .setRefSpec(refSpec).call().get(); FeatureBuilder builder = new FeatureBuilder(revFeatureType); return builder.build(name, revFeature.get()); } else { return 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); }
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); }