public String parentPath() { return (newObject == null ? oldObject : newObject).getParentPath(); }
@Override public boolean tree(NodeRef left, NodeRef right) { final String parentPath = left == null ? right.getParentPath() : left.getParentPath(); if (!finished && reportTrees) { if (parentPath != null) {// do not report the root tree try { entries.put(new DiffEntry(left, right)); } catch (InterruptedException e) { // throw Throwables.propagate(e); // die gracefully return false; } } } if (recursive) { return !finished; } return parentPath == null; }
public @Override boolean tree(@Nullable NodeRef left, @Nullable NodeRef right) { if (null == (left == null ? right : left).getParentPath()) { return true; } queue.add(new DiffEntry(left, right)); return true; } };
/** * Provides for natural ordering of {@code NodeRef}, based on {@link #path()} */ @Override public int compareTo(NodeRef o) { int c = parentPath.compareTo(o.getParentPath()); if (c == 0) { return node.compareTo(o.getNode()); } return c; }
/** * Provides for natural ordering of {@code NodeRef}, based on {@link #path()} */ @Override public int compareTo(NodeRef o) { int c = parentPath.compareTo(o.getParentPath()); if (c == 0) { return node.compareTo(o.getNode()); } return c; }
@Override public boolean feature(NodeRef left, NodeRef right) { String parent = left == null ? right.getParentPath() : left.getParentPath(); String node = left == null ? right.name() : left.name(); if (filter.featureApplies(parent, node)) { return super.feature(left, right); } return true; }
public RevTreeBuilder getTreeBuilder(final NodeRef featureRef) { checkArgument(TYPE.FEATURE.equals(featureRef.getType())); final String typeTreePath = featureRef.getParentPath(); RevTreeBuilder typeTreeBuilder; typeTreeBuilder = featureTypeTrees.computeIfAbsent(typeTreePath, path -> newTreeBuilder(featureRef)); return typeTreeBuilder; }
@Override @Nullable public Feature apply(@Nullable NodeRef ref) { RevFeature revFeature = parseCommand.setObjectId(ref.getObjectId()) .call(RevFeature.class).get(); final String parentPath = ref.getParentPath(); FeatureBuilder featureBuilder = builders.get(parentPath); String fid = ref.name(); Feature feature = featureBuilder.build(fid, revFeature); return feature; }
public void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); data.write(nodeRef.getMetadataId().getRawValue()); data.writeUTF(nodeRef.getParentPath()); }
public static void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); data.write(nodeRef.getMetadataId().getRawValue()); data.writeUTF(nodeRef.getParentPath()); } }
private void handlePureMetadataChanges(TreeDifference treeDifference, Set<String> ignoreList) { Map<NodeRef, NodeRef> pureMetadataChanges = treeDifference.findPureMetadataChanges(); for (Map.Entry<NodeRef, NodeRef> e : pureMetadataChanges.entrySet()) { NodeRef newValue = e.getValue(); String treePath = newValue.path(); if (ignoreList.contains(treePath)) { continue; } ignoreList.add(treePath); if (!filterMatchesOrIsParent(treePath)) { continue;// filter doesn't apply to the changed tree } MutableTree leftTree = treeDifference.getLeftTree(); leftTree.setChild(newValue.getParentPath(), newValue.getNode()); } }
public void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); nodeRef.getMetadataId().writeTo(data); data.writeUTF(nodeRef.getParentPath()); }
public static void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); nodeRef.getMetadataId().writeTo(data); data.writeUTF(nodeRef.getParentPath()); } }
private void handlePureMetadataChanges(TreeDifference treeDifference, Set<String> ignoreList) { Map<NodeRef, NodeRef> pureMetadataChanges = treeDifference.findPureMetadataChanges(); for (Map.Entry<NodeRef, NodeRef> e : pureMetadataChanges.entrySet()) { NodeRef newValue = e.getValue(); String treePath = newValue.path(); if (ignoreList.contains(treePath)) { continue; } ignoreList.add(treePath); if (!filterMatchesOrIsParent(treePath)) { continue;// filter doesn't apply to the changed tree } MutableTree leftTree = treeDifference.getLeftTree(); leftTree.setChild(newValue.getParentPath(), newValue.getNode()); } }
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) { List<NodeRef> refsByDepth = Lists.newArrayList(entries.values()); Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR); Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null); MutableTree root = new MutableTree(rootNode); Envelope bounds = new Envelope(); for (NodeRef entry : refsByDepth) { Node node = entry.getNode(); node.expand(bounds); String parentPath = entry.getParentPath(); root.setChild(parentPath, node); } // recreate root node with the appropriate bounds rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds); root.setNode(rootNode); return root; }
@Test public void testCreateTypeNestedNonExistingParent() throws Exception { NodeRef treeRef = workTree.createTypeTree("path/to/nested/type", pointsType); assertNotNull(treeRef); assertEquals("path/to/nested/type", treeRef.path()); assertEquals("path/to/nested", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); assertEquals(pointsType, featureType.type()); }
@Test public void testCreateTypeTree() throws Exception { NodeRef treeRef = workTree.createTypeTree("points2", pointsType); assertNotNull(treeRef); assertEquals("points2", treeRef.path()); assertEquals("", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); assertEquals(pointsType, featureType.type()); }
@Test public void testCreateTypeNestedNonExistingParent() throws Exception { NodeRef treeRef = workTree.createTypeTree("path/to/nested/type", pointsType); assertNotNull(treeRef); assertEquals("path/to/nested/type", treeRef.path()); assertEquals("path/to/nested", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertEquals(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@Test public void testCreateTypeTree() throws Exception { NodeRef treeRef = workTree.createTypeTree("points2", pointsType); assertNotNull(treeRef); assertEquals("points2", treeRef.path()); assertEquals("", treeRef.getParentPath()); assertTrue(treeRef.getNode().getMetadataId().isPresent()); assertEquals(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get()); RevFeatureType featureType = repo.objectDatabase().getFeatureType(treeRef.getMetadataId()); RevObjectTestUtil.deepEquals(RevFeatureType.builder().type(pointsType).build(), featureType); }
@Test public void testAccessorsAndConstructors() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef = new NodeRef(node, "Points", ObjectId.NULL); assertEquals(ObjectId.NULL, nodeRef.getMetadataId()); assertEquals(ObjectId.NULL, nodeRef.getDefaultMetadataId()); assertEquals(node.getName(), nodeRef.name()); assertEquals(node.getObjectId(), nodeRef.getObjectId()); assertEquals(node, nodeRef.getNode()); assertEquals(node.getType(), nodeRef.getType()); assertEquals("Points", nodeRef.getParentPath()); assertEquals("Points/Points.1", nodeRef.path()); exception.expect(IllegalArgumentException.class); new NodeRef(node, null, ObjectId.NULL); }