Search in sources :

Example 56 with RevTree

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

the class ApplyPatchOpTest method testAddFeatureWithNonDefaultFeatureType.

@Test
public void testAddFeatureWithNonDefaultFeatureType() throws Exception {
    insert(points2, points3);
    Patch patch = new Patch();
    String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    patch.addAddedFeature(path, points1B, RevFeatureTypeImpl.build(modifiedPointsType));
    geogig.command(ApplyPatchOp.class).setPatch(patch).call();
    RevTree root = repo.workingTree().getTree();
    assertNotNull(root);
    Optional<Node> typeTreeId = findTreeChild(root, pointsName);
    assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeImpl.build(pointsType).getId());
    RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
    assertNotNull(typeTree);
    Optional<Node> featureBlobId = findTreeChild(root, path);
    assertEquals(RevFeatureTypeImpl.build(modifiedPointsType).getId(), featureBlobId.get().getMetadataId().orNull());
    assertTrue(featureBlobId.isPresent());
    path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
    featureBlobId = findTreeChild(root, path);
    assertEquals(null, featureBlobId.get().getMetadataId().orNull());
}
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 57 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 58 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 59 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 60 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)

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