Search in sources :

Example 31 with NodeRef

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

the class RevertOpTest method testRevertOnlyCommit.

@Test
public void testRevertOnlyCommit() throws Exception {
    insertAndAdd(points1);
    RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call();
    final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
    final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
    RevTree headTree = repo.getTree(headTreeId.get());
    Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
    assertFalse(points1Node.isPresent());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 32 with NodeRef

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

the class RevertOpTest method testRevertEntireFeatureTypeTree.

@Test
public void testRevertEntireFeatureTypeTree() throws Exception {
    insertAndAdd(points1);
    RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    insertAndAdd(points2);
    RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    insertAndAdd(points3);
    RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    insertAndAdd(lines1);
    RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
    geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c4.getId())).call();
    final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
    final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
    RevTree headTree = repo.getTree(headTreeId.get());
    Optional<NodeRef> lines1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(linesName, idL1)).setParent(headTree).call();
    assertFalse(lines1Node.isPresent());
    @SuppressWarnings("unused") Optional<NodeRef> linesNode = geogig.command(FindTreeChild.class).setChildPath(linesName).setParent(headTree).call();
    // assertFalse(linesNode.isPresent());
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    log.next();
    assertEquals(c4.getId(), log.next().getId());
    assertEquals(c3.getId(), log.next().getId());
    assertEquals(c2.getId(), log.next().getId());
    assertEquals(c1.getId(), log.next().getId());
    assertFalse(log.hasNext());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 33 with NodeRef

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

the class RevertOpTest method testRevertWithoutCommit.

@Test
public void testRevertWithoutCommit() throws Exception {
    ObjectId oId1 = insertAndAdd(points1);
    RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    insertAndAdd(points2);
    RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    insertAndAdd(points1_modified);
    RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1).call();
    ObjectId oId3 = insertAndAdd(points3);
    RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    deleteAndAdd(points3);
    RevCommit c5 = geogig.command(CommitOp.class).setMessage("commit for deleted " + idP3).call();
    // revert Points.2 add, Points.1 change, and Points.3 delete
    geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).addCommit(Suppliers.ofInstance(c3.getId())).addCommit(Suppliers.ofInstance(c5.getId())).setCreateCommit(false).call();
    final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.WORK_HEAD).call();
    final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
    RevTree headTree = repo.getTree(headTreeId.get());
    Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
    assertTrue(points1Node.isPresent());
    assertEquals(oId1, points1Node.get().getNode().getObjectId());
    Optional<NodeRef> points2Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP2)).setParent(headTree).call();
    assertFalse(points2Node.isPresent());
    Optional<NodeRef> points3Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP3)).setParent(headTree).call();
    assertTrue(points3Node.isPresent());
    assertEquals(oId3, points3Node.get().getNode().getObjectId());
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    // There should only the old commits.
    assertEquals(c5.getId(), log.next().getId());
    assertEquals(c4.getId(), log.next().getId());
    assertEquals(c3.getId(), log.next().getId());
    assertEquals(c2.getId(), log.next().getId());
    assertEquals(c1.getId(), log.next().getId());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) RevertOp(org.locationtech.geogig.api.porcelain.RevertOp) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 34 with NodeRef

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

the class IndexTest method testWriteEmptyPathAddAll.

@Test
public void testWriteEmptyPathAddAll() throws Exception {
    insert(lines1);
    WorkingTree workingTree = geogig.getRepository().workingTree();
    workingTree.createTypeTree(pointsName, pointsType);
    List<NodeRef> workHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.WORK_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
    assertEquals(3, workHead.size());
    Collection<NodeRef> filtered = Collections2.filter(workHead, new TreeNameFilter(pointsName));
    assertEquals(1, filtered.size());
    geogig.command(AddOp.class).call();
    List<NodeRef> indexHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.STAGE_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
    assertEquals(3, indexHead.size());
    filtered = Collections2.filter(indexHead, new TreeNameFilter(pointsName));
    assertEquals(1, filtered.size());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) WorkingTree(org.locationtech.geogig.repository.WorkingTree) NodeRef(org.locationtech.geogig.api.NodeRef) Test(org.junit.Test)

Example 35 with NodeRef

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

the class OSMImportOpTest method testImportMultipleRules.

@Test
public void testImportMultipleRules() {
    final Mapping mapping;
    final File data = new File(getClass().getResource("ways.xml").getFile());
    {
        final File mappingsFile = new File(getClass().getResource("../cli/commands/mapping_multiple_rules.json").getFile());
        checkState(data.exists());
        checkState(mappingsFile.exists());
        mapping = Mapping.fromFile(mappingsFile.getAbsolutePath());
        checkState(2 == mapping.getRules().size(), "expected 2 rules, got %s", mapping.getRules().size());
    }
    geogig.command(OSMImportOp.class).setDataSource(data.getAbsolutePath()).setMapping(mapping).setNoRaw(true).call();
    WorkingTree workingTree = geogig.getContext().workingTree();
    List<NodeRef> featureTypeTrees = workingTree.getFeatureTypeTrees();
    assertEquals(2, featureTypeTrees.size());
    Set<String> expectedNames = newHashSet("osm_roads", "osm_roads_main");
    assertTrue(expectedNames.contains(featureTypeTrees.get(0).name()));
    assertTrue(expectedNames.contains(featureTypeTrees.get(1).name()));
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) NodeRef(org.locationtech.geogig.api.NodeRef) File(java.io.File) Test(org.junit.Test)

Aggregations

NodeRef (org.locationtech.geogig.api.NodeRef)161 ObjectId (org.locationtech.geogig.api.ObjectId)91 RevTree (org.locationtech.geogig.api.RevTree)67 Test (org.junit.Test)62 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)40 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)27 RevFeature (org.locationtech.geogig.api.RevFeature)25 Node (org.locationtech.geogig.api.Node)24 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)24 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)23 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)22 RevObject (org.locationtech.geogig.api.RevObject)21 RevCommit (org.locationtech.geogig.api.RevCommit)19 Map (java.util.Map)15 SimpleFeature (org.opengis.feature.simple.SimpleFeature)15 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Feature (org.opengis.feature.Feature)13 Optional (com.google.common.base.Optional)12 GeoGIG (org.locationtech.geogig.api.GeoGIG)11 LsTreeOp (org.locationtech.geogig.api.plumbing.LsTreeOp)11