Search in sources :

Example 1 with CloneOp

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

the class SparseCloneTest method testSparseShallowClone.

@Test
public void testSparseShallowClone() throws Exception {
    Map<String, String> filter = new HashMap<String, String>();
    filter.put("default", "BBOX(pp,9, -80, 15, -70,'EPSG:4326')");
    createFilterFile(filter);
    CloneOp clone = clone();
    clone.setDepth(3).setBranch("master");
    exception.expect(IllegalStateException.class);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 2 with CloneOp

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

the class SparseCloneTest method testSparseCloneAllMatch.

@Test
public void testSparseCloneAllMatch() throws Exception {
    Map<String, String> filter = new HashMap<String, String>();
    filter.put("default", "BBOX(pp,0, -125, 40, -70,'EPSG:4326')");
    createFilterFile(filter);
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(city1, city2, city3, road1, road2, road3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        oids.put(f, oId);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(0);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
    // Because all features match the filter, the history should be identical
    // Make sure the local repository got the correct commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    assertExists(localGeogig, oids.get(city1), oids.get(city2), oids.get(city3), oids.get(road1), oids.get(road2), oids.get(road3));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) HashMap(java.util.HashMap) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 3 with CloneOp

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

the class SparseCloneTest method testSparseCloneOnlyFirstMatch.

@Test
public void testSparseCloneOnlyFirstMatch() throws Exception {
    Map<String, String> filter = new HashMap<String, String>();
    filter.put("default", "BBOX(pp,9, -80, 15, -70,'EPSG:4326')");
    createFilterFile(filter);
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(city1, city2, city3, road1, road2, road3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        oids.put(f, oId);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(0);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
    // Because only the first feature matches (Cities.1), the first commit should be the same,
    // there will also be the commit that adds the "Roads" tree but no features, and finally an
    // "Empty Placeholder Commit".
    // Make sure the local repository got the correct commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(3, logged.size());
    assertEquals(AbstractMappedRemoteRepo.PLACEHOLDER_COMMIT_MESSAGE, logged.get(0).getMessage());
    assertFalse(expected.get(0).getId().equals(logged.get(0).getId()));
    assertEquals("Roads.1", logged.get(1).getMessage());
    assertFalse(expected.get(2).getId().equals(logged.get(1).getId()));
    assertEquals("Cities.1", logged.get(2).getMessage());
    assertTrue(expected.get(5).getId().equals(logged.get(2).getId()));
    assertExists(localGeogig, oids.get(city1));
    assertNotExists(localGeogig, oids.get(city2), oids.get(city3), oids.get(road1), oids.get(road2), oids.get(road3));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) HashMap(java.util.HashMap) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 4 with CloneOp

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

the class SparseCloneTest method testFeatureMovingIntoAOI.

@Test
public void testFeatureMovingIntoAOI() throws Exception {
    Map<String, String> filter = new HashMap<String, String>();
    filter.put("Cities", "BBOX(pp,30, -125, 40, -110,'EPSG:4326')");
    createFilterFile(filter);
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(city2, city1, city3, city1_modified);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        oids.put(f, oId);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(0);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
    // Cities.1 initially lies outside the filter, so the commit that adds it will not be part
    // of the sparse clone. Later the feature is moved into the AOI so it will be added at that
    // time.
    // Make sure the local repository got the correct commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(3, logged.size());
    assertEquals("Cities.1", logged.get(0).getMessage());
    assertFalse(expected.get(0).getId().equals(logged.get(0).getId()));
    assertEquals("Cities.3", logged.get(1).getMessage());
    assertFalse(expected.get(1).getId().equals(logged.get(1).getId()));
    assertEquals("Cities.2", logged.get(2).getMessage());
    assertTrue(expected.get(3).getId().equals(logged.get(2).getId()));
    assertExists(localGeogig, oids.get(city2), oids.get(city3), oids.get(city1_modified));
    assertNotExists(localGeogig, oids.get(city1));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) HashMap(java.util.HashMap) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 5 with CloneOp

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

the class SparseCloneTest method testSparseCloneWithNoBranchSpecified.

@Test
public void testSparseCloneWithNoBranchSpecified() throws Exception {
    Map<String, String> filter = new HashMap<String, String>();
    filter.put("default", "BBOX(pp,9, -80, 15, -70,'EPSG:4326')");
    createFilterFile(filter);
    CloneOp clone = clone();
    exception.expect(IllegalArgumentException.class);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

CloneOp (org.locationtech.geogig.api.porcelain.CloneOp)27 Test (org.junit.Test)20 RevCommit (org.locationtech.geogig.api.RevCommit)18 LogOp (org.locationtech.geogig.api.porcelain.LogOp)18 ArrayList (java.util.ArrayList)13 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)12 LinkedList (java.util.LinkedList)11 ObjectId (org.locationtech.geogig.api.ObjectId)9 RevObject (org.locationtech.geogig.api.RevObject)9 Feature (org.opengis.feature.Feature)9 HashMap (java.util.HashMap)8 BranchCreateOp (org.locationtech.geogig.api.porcelain.BranchCreateOp)6 FetchOp (org.locationtech.geogig.api.porcelain.FetchOp)6 File (java.io.File)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 RevTag (org.locationtech.geogig.api.RevTag)1 LsRemote (org.locationtech.geogig.api.plumbing.LsRemote)1 InitOp (org.locationtech.geogig.api.porcelain.InitOp)1 MergeReport (org.locationtech.geogig.api.porcelain.MergeOp.MergeReport)1 TagCreateOp (org.locationtech.geogig.api.porcelain.TagCreateOp)1