/** * @return the id of the old version id of the object, or {@link ObjectId#NULL} if * {@link #changeType()} is {@code ADD} */ public ObjectId oldObjectId() { return oldObject == null ? ObjectId.NULL : oldObject.getObjectId(); }
public void writeNodeRef(NodeRef nodeRef, DataOutput data) throws IOException { writeNode(nodeRef.getNode(), data); nodeRef.getMetadataId().writeTo(data); data.writeUTF(nodeRef.getParentPath()); }
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())); }
private GeoGigFeatureWriter(final FeatureReader<SimpleFeatureType, SimpleFeature> reader, final NodeRef typeRef, final WorkingTree workingTree) { this.reader = reader; this.typePath = typeRef.path(); this.featureTypeId = typeRef.getMetadataId(); this.workingTree = workingTree; }
@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 UpdateTree setChild(NodeRef childTreeNode) { checkNotNull(childTreeNode); final String path = childTreeNode.path(); NodeRef.checkValidPath(path); checkArgument(RevObject.TYPE.TREE.equals(childTreeNode.getType())); childTreeRemoves.remove(path); childTreeUpdates.put(path, childTreeNode); return this; }
@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()); }
@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); }};
public Iterator<FeatureInfo> apply(List<NodeRef> refs) { Map<ObjectId, RevFeature> correlationIndex = new HashMap<>(refs.size()); ArrayList<ObjectId> ids = new ArrayList<>(refs.size()); refs.forEach(ref->ids.add(ref.getObjectId())); Iterator<RevFeature> all = odb.getAll(ids, NOOP_LISTENER, RevFeature.class); all.forEachRemaining(revFeature -> correlationIndex.put(revFeature.getId(),revFeature)); ArrayList<FeatureInfo> result = new ArrayList<>(refs.size()); refs.forEach( ref-> result.add(FeatureInfo.insert(correlationIndex.get(ref.getObjectId()), ref.getMetadataId(), ref.path() ))); return (result.iterator() ); } }
private void assertNode(Optional<NodeRef> ref, TYPE type, ObjectId expectedMdId, String path) { assertTrue(ref.isPresent()); assertEquals(type, ref.get().getType()); assertEquals(path, ref.get().path()); assertEquals(expectedMdId, ref.get().getMetadataId()); } }
@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; }
@Test public void testTree() { ObjectId oId = ObjectId.valueOf("abc123000000000000001234567890abcdef0000"); ObjectId metadataId = ObjectId.valueOf("abc123000000000000001234567890abcdef0001"); NodeRef nodeRef = NodeRef.tree("Points", oId, metadataId); assertEquals(oId, nodeRef.getObjectId()); assertEquals(metadataId, nodeRef.getMetadataId()); assertEquals("Points", nodeRef.getNode().getName()); }
private void asMap(String parentPath, TreeMap<String, MutableTree> target) { for (MutableTree childTree : this.childTrees.values()) { String childTreePath = NodeRef.appendChild(parentPath, childTree.getNode().getName()); target.put(childTreePath, childTree); childTree.asMap(childTreePath, target); } }
@Override public void endTree(NodeRef left, NodeRef right) { final String name = (left == null ? right : left).name(); if (NodeRef.ROOT.equals(name)) { LOGGER.trace("Reached end of tree traversal"); finished = true; } }
private ObjectId getMetadataId(Bounded input) { if (input instanceof Bucket) { return defaultMetadataId; } if (input instanceof Node) { return ((Node) input).getMetadataId().or(defaultMetadataId); } return ((NodeRef) input).getMetadataId(); }
/** * 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; }
String getTypeTreePath() { NodeRef typeRef = getTypeRef(); String path = typeRef.path(); return path; }
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); }