public String tree(@Nullable Node left, @Nullable Node right) { Preconditions.checkArgument(left != null || right != null); this.leftTrees.add(left); this.rightTrees.add(right); String name = name(left, right); if (currentPath == null) { currentPath = name; } else { currentPath = NodeRef.appendChild(currentPath, name); } return currentPath; }
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); } }
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 write() throws IOException { Preconditions.checkState(last != null, "next() hasn't been called"); String parentTreePath = typePath; RevFeature feature = RevFeature.builder().build(last); String path = NodeRef.appendChild(parentTreePath, last.getID()); FeatureInfo fi = FeatureInfo.insert(feature, featureTypeId, path); workingTree.insert(fi); }
@Override public FeatureInfo apply(SimpleFeature f) { return FeatureInfo.insert(RevFeature.builder().build(f), featureTypeId, NodeRef.appendChild(treePath, f.getID())); }};
@Override public FeatureInfo apply(SimpleFeature f) { RevFeature feature = RevFeature.builder().build(f); String fid = f.getID(); String path = NodeRef.appendChild(treePath, fid); String version = feature.getId().toString(); if (returnFidsOnInsert) { insertedFids.add(new FeatureIdVersionedImpl(fid, version)); } return FeatureInfo.insert(feature, featureTypeId, path); }};
@Test public void testDiffBetweenFeatureAndItself() { NodeRef oldRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull(); NodeRef newRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull(); FeatureDiff diff = geogig.command(DiffFeature.class) .setOldVersion(Suppliers.ofInstance(oldRef)) .setNewVersion(Suppliers.ofInstance(newRef)).call(); assertFalse(diff.hasDifferences()); System.out.println(diff); }
@Test public void testCheckoutForceDuringConflict() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); String path2 = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).addPath(path2).setForce(true).call(); }
@Test public void testGetFeatureFromWorkingTree() throws Exception { insert(points1); Feature feature = geogigAPI .getFeatureFromWorkingTree(NodeRef.appendChild(pointsName, idP1)); assertNotNull(feature); }
@Test public void testInsertSingle() throws Exception { FeatureInfo fi = featureInfo(points1); workTree.insert(fi); assertEquals(fi.getFeature().getId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId()); }
@Test public void testCheckoutOursDeleted() throws Exception { createDeleteOursConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().index().findStaged(path); assertFalse(node.isPresent()); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertFalse(id.isPresent()); }
@Test public void testCheckoutTheirsDeleted() throws Exception { createDeleteTheirsConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setTheirs(true).call(); Optional<Node> node = geogig.getRepository().index().findStaged(path); assertFalse(node.isPresent()); String headPath = Ref.MERGE_HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertFalse(id.isPresent()); }
@Test public void testCheckoutTheirs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setTheirs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.MERGE_HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
@Test public void testCheckoutOurs() throws Exception { createConflictedState(); String path = NodeRef.appendChild(pointsName, idP1); geogig.command(CheckoutOp.class).addPath(path).setOurs(true).call(); Optional<Node> node = geogig.getRepository().workingTree().findUnstaged(path); String headPath = Ref.HEAD + ":" + path; Optional<ObjectId> id = geogig.command(RevParse.class).setRefSpec(headPath).call(); assertEquals(id.get(), node.get().getObjectId()); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeatureBuilder.build(feature(type, id, values)); RevFeatureType ftype = RevFeatureTypeBuilder.build(type); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeature.builder().build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); return FeatureInfo.insert(feature, ftype.getId(), path); }
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
@Test public void testRemoveFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeature.builder().build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); return FeatureInfo.insert(feature, ftype.getId(), path); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeature.builder().build(feature(type, id, values)); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }