Search in sources :

Example 26 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class ApplyPatchOpTest method testRemoveEmptyFeatureTypePatch.

@Test
public void testRemoveEmptyFeatureTypePatch() throws Exception {
    WorkingTree workingTree = geogig.getRepository().workingTree();
    workingTree.createTypeTree(pointsName, pointsType);
    geogig.command(AddOp.class).setUpdateOnly(false).call();
    Patch patch = new Patch();
    RevFeatureType featureType = RevFeatureTypeImpl.build(pointsType);
    patch.addFeatureType(featureType);
    patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null));
    geogig.command(ApplyPatchOp.class).setPatch(patch).call();
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> typeTree = findTreeChild(root, pointsName);
    assertFalse(typeTree.isPresent());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) FeatureTypeDiff(org.locationtech.geogig.api.plumbing.diff.FeatureTypeDiff) Node(org.locationtech.geogig.api.Node) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 27 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class ApplyPatchOpTest method testPartialApplication.

@Test
public void testPartialApplication() throws Exception {
    insert(points1, points2);
    Patch patch = new Patch();
    String pathRemove = NodeRef.appendChild(pointsName, points2.getIdentifier().getID());
    patch.addRemovedFeature(pathRemove, points2, RevFeatureTypeImpl.build(pointsType));
    String pathModify = NodeRef.appendChild(pointsName, points1B.getIdentifier().getID());
    Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
    Optional<?> oldValue = Optional.fromNullable(points1B.getProperty("extra").getValue());
    GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null);
    map.put(modifiedPointsType.getDescriptor("extra"), diff);
    FeatureDiff featureDiff = new FeatureDiff(pathModify, map, RevFeatureTypeImpl.build(modifiedPointsType), RevFeatureTypeImpl.build(pointsType));
    patch.addModifiedFeature(featureDiff);
    Patch rejected = geogig.command(ApplyPatchOp.class).setPatch(patch).setApplyPartial(true).call();
    assertFalse(rejected.isEmpty());
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> featureBlobId = findTreeChild(root, pathRemove);
    assertFalse(featureBlobId.isPresent());
    // now we take the rejected patch and apply it, and the new rejected should be identical to
    // it
    Patch newRejected = geogig.command(ApplyPatchOp.class).setPatch(rejected).setApplyPartial(true).call();
    assertEquals(rejected, newRejected);
}
Also used : FeatureDiff(org.locationtech.geogig.api.plumbing.diff.FeatureDiff) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) GenericAttributeDiffImpl(org.locationtech.geogig.api.plumbing.diff.GenericAttributeDiffImpl) Node(org.locationtech.geogig.api.Node) AttributeDiff(org.locationtech.geogig.api.plumbing.diff.AttributeDiff) ApplyPatchOp(org.locationtech.geogig.api.porcelain.ApplyPatchOp) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 28 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class ApplyPatchOpTest method testRemoveFeaturePatch.

@Test
public void testRemoveFeaturePatch() throws Exception {
    insert(points1);
    Patch patch = new Patch();
    String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    patch.addRemovedFeature(path, points1, RevFeatureTypeImpl.build(pointsType));
    geogig.command(ApplyPatchOp.class).setPatch(patch).call();
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> featureBlobId = findTreeChild(root, path);
    assertFalse(featureBlobId.isPresent());
}
Also used : Node(org.locationtech.geogig.api.Node) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 29 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class RevTreeSerializationTest method testRoundTripSpatialInternalTree.

@Test
public void testRoundTripSpatialInternalTree() {
    RevTree roundTripped = read(tree5_spatial_internal.getId(), write(tree5_spatial_internal));
    assertTreesAreEqual(tree5_spatial_internal, roundTripped);
}
Also used : RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 30 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class RevTreeSerializationTest method write.

private byte[] write(RevTree tree) {
    try {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectWriter<RevTree> treeWriter = factory.<RevTree>createObjectWriter(RevObject.TYPE.TREE);
        treeWriter.write(tree, bout);
        return bout.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) RevTree(org.locationtech.geogig.api.RevTree)

Aggregations

RevTree (org.locationtech.geogig.api.RevTree)214 Test (org.junit.Test)120 ObjectId (org.locationtech.geogig.api.ObjectId)91 NodeRef (org.locationtech.geogig.api.NodeRef)73 Node (org.locationtech.geogig.api.Node)56 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)47 RevCommit (org.locationtech.geogig.api.RevCommit)36 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)29 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)27 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)24 RevObject (org.locationtech.geogig.api.RevObject)21 RevFeature (org.locationtech.geogig.api.RevFeature)18 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)18 Bucket (org.locationtech.geogig.api.Bucket)17 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)17 File (java.io.File)16 Ref (org.locationtech.geogig.api.Ref)16 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)15 GeoGIG (org.locationtech.geogig.api.GeoGIG)14 OSMImportOp (org.locationtech.geogig.osm.internal.OSMImportOp)14