Search in sources :

Example 21 with NodeRef

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

the class MutableTree method createFromPaths.

public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) {
    List<NodeRef> refsByDepth = Lists.newArrayList(entries.values());
    Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR);
    Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null);
    MutableTree root = new MutableTree(rootNode);
    Envelope bounds = new Envelope();
    for (NodeRef entry : refsByDepth) {
        Node node = entry.getNode();
        node.expand(bounds);
        String parentPath = entry.getParentPath();
        root.setChild(parentPath, node);
    }
    // recreate root node with the appropriate bounds
    rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds);
    root.setNode(rootNode);
    return root;
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 22 with NodeRef

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

the class CheckoutOpTest method testCheckoutPathFilter.

@Test
public void testCheckoutPathFilter() throws Exception {
    ObjectId points1Id = insertAndAdd(points1);
    geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    insert(points1_modified);
    CheckoutResult result = geogig.command(CheckoutOp.class).addPath("Points/Points.1").call();
    Optional<RevTree> workTree = geogig.command(RevObjectParse.class).setObjectId(result.getNewTree()).call(RevTree.class);
    Optional<NodeRef> nodeRef = geogig.command(FindTreeChild.class).setParent(workTree.get()).setChildPath("Points/Points.1").call();
    assertEquals(points1Id, nodeRef.get().getNode().getObjectId());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) CheckoutResult(org.locationtech.geogig.api.porcelain.CheckoutResult) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 23 with NodeRef

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

the class GeoGigFeatureSourceTest method testFeatureIdsAreVersioned.

@Test
public void testFeatureIdsAreVersioned() throws IOException {
    SimpleFeatureCollection collection = pointsSource.getFeatures(Query.ALL);
    SimpleFeatureIterator features = collection.features();
    Set<FeatureId> ids = Sets.newHashSet();
    try {
        while (features.hasNext()) {
            SimpleFeature next = features.next();
            FeatureId identifier = next.getIdentifier();
            ids.add(identifier);
        }
    } finally {
        features.close();
    }
    List<NodeRef> refs = toList(repo.command(LsTreeOp.class).setReference(pointsName).setStrategy(Strategy.FEATURES_ONLY).call());
    assertEquals(3, refs.size());
    Map<String, NodeRef> expected = new HashMap<String, NodeRef>();
    for (NodeRef ref : refs) {
        expected.put(ref.path(), ref);
    }
    for (FeatureId id : ids) {
        assertFalse("ResourceId is a query object", id instanceof ResourceId);
        assertNotNull(id.getID());
        assertNotNull(id + " has no featureVersion set", id.getFeatureVersion());
        NodeRef ref = expected.get(id.getID());
        assertNotNull(ref);
        assertEquals(ref.objectId().toString(), id.getFeatureVersion());
    }
}
Also used : FeatureId(org.opengis.filter.identity.FeatureId) NodeRef(org.locationtech.geogig.api.NodeRef) SimpleFeatureIterator(org.geotools.data.simple.SimpleFeatureIterator) HashMap(java.util.HashMap) ResourceId(org.opengis.filter.identity.ResourceId) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection) Test(org.junit.Test)

Example 24 with NodeRef

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

the class DiffFeatureTest method testDiffUnexistentFeature.

@Test
public void testDiffUnexistentFeature() {
    try {
        NodeRef oldRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, "Points.100")).call().orNull();
        NodeRef newRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull();
        geogig.command(DiffFeature.class).setOldVersion(Suppliers.ofInstance(oldRef)).setNewVersion(Suppliers.ofInstance(newRef)).call();
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FeatureNodeRefFromRefspec(org.locationtech.geogig.api.porcelain.FeatureNodeRefFromRefspec) Test(org.junit.Test)

Example 25 with NodeRef

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

the class DiffFeatureTest method testDiffWrongPath.

@Test
public void testDiffWrongPath() {
    try {
        NodeRef oldRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(pointsName).call().orNull();
        NodeRef newRef = geogig.command(FeatureNodeRefFromRefspec.class).setRefspec(NodeRef.appendChild(pointsName, idP1)).call().orNull();
        geogig.command(DiffFeature.class).setOldVersion(Suppliers.ofInstance(oldRef)).setNewVersion(Suppliers.ofInstance(newRef)).call();
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FeatureNodeRefFromRefspec(org.locationtech.geogig.api.porcelain.FeatureNodeRefFromRefspec) 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