Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevTree


        }
        return true;
    }

    private boolean addTreeFeatures(ObjectId treeId, boolean leftPresent, boolean rightPresent) {
        RevTree tree = db.getTree(treeId);
        long size = tree.size();
        if (leftPresent && rightPresent) {
            count.changedFeatures(size);
        } else if (leftPresent) {
            count.removedFeatures(size);
        } else {
            count.addedFeatures(size);
        }

        int numTrees = tree.numTrees();
        return numTrees > 0;
    }
View Full Code Here


        RevTreeBuilder root = new RevTreeBuilder(odb);
        root = addTree(root, "path/to/tree1", "node11", "node12", "node13");
        root = addTree(root, "path/to/tree2", "node21", "node22", "node23");
        root = addTree(root, "tree3", "node31", "node32", "node33");
        RevTree rootTree = root.build();
        odb.put(rootTree);
        rootTreeId = rootTree.getId();
    }
View Full Code Here

                subTreeBuilder.put(Node.create(singleNodeName, fakeFeatureOId, fakeTypeOId,
                        TYPE.FEATURE, null));
            }
        }

        RevTree subtree = subTreeBuilder.build();
        WriteBack writeBack = fakeGeogig.command(WriteBack.class).setAncestor(root)
                .setChildPath(treePath).setTree(subtree).setMetadataId(fakeTreeMetadataId);
        ObjectId newRootId = writeBack.call();

        return fakeGeogig.command(RevObjectParse.class).setObjectId(newRootId).call(RevTree.class)
View Full Code Here

        assertNotNull(newRootTreeId);
        assertFalse(repo.getRootTreeId().equals(newRootTreeId));
        // but the index staged root shall be pointing to it
        // assertEquals(newRootTreeId, index.getStaged().getId());

        RevTree tree = repo.getTree(newRootTreeId);
        // assertEquals(2, tree.size().intValue());

        String path = appendChild(pointsName, points1.getIdentifier().getID());
        assertTrue(repo.command(FindTreeChild.class).setParent(tree).setChildPath(path).call()
                .isPresent());
View Full Code Here

            newRepoTreeId1 = geogig.command(WriteTree2.class)
                    .setOldRoot(tree(repo.getHead().get().getObjectId())).call();

            // assertEquals(index.getDatabase().getStagedRootRef().getObjectId(), newRepoTreeId1);

            RevTree newRepoTree = repo.getTree(newRepoTreeId1);

            System.err.println("++++++++++ new repo tree 1: " + newRepoTreeId1 + " ++++++++++++");
            // check feature1_1 is there
            assertEquals(oId1_1, repo.getTreeChild(newRepoTree, appendChild(pointsName, idP1))
                    .get().getObjectId());

        }

        // insert and add (stage) points2, points3, and lines1
        final ObjectId oId1_2 = insertAndAdd(points2);
        final ObjectId oId1_3 = insertAndAdd(points3);
        final ObjectId oId2_1 = insertAndAdd(lines1);

        {// simulate a commit so the repo head points to this new tree
            ObjectInserter objectInserter = repo.newObjectInserter();
            List<ObjectId> parents = ImmutableList.of();

            RevCommit commit = new CommitBuilder().setTreeId(newRepoTreeId1).setParentIds(parents)
                    .build();
            ObjectId commitId = commit.getId();
            objectInserter.insert(commit);
            Optional<Ref> newHead = geogig.command(UpdateRef.class).setName("refs/heads/master")
                    .setNewValue(commitId).call();
            assertTrue(newHead.isPresent());
        }

        final ObjectId newRepoTreeId2;
        {
            // write comparing the the previously generated tree instead of the repository HEAD, as
            // it was not updated (no commit op was performed)
            newRepoTreeId2 = geogig.command(WriteTree2.class).setOldRoot(tree(newRepoTreeId1))
                    .call();

            // assertEquals(index.getDatabase().getStagedRootRef().getObjectId(), newRepoTreeId2);

            System.err.println("++++++++ new root 2:" + newRepoTreeId2 + " ++++++++++");
            RevTree newRepoTree = repo.getTree(newRepoTreeId2);

            // check feature1_2, feature1_2 and feature2_1
            Optional<Node> treeChild;
            assertNotNull(treeChild = repo.getTreeChild(newRepoTree, appendChild(pointsName, idP2)));
            assertEquals(oId1_2, treeChild.get().getObjectId());

            assertNotNull(treeChild = repo.getTreeChild(newRepoTree, appendChild(pointsName, idP3)));
            assertEquals(oId1_3, treeChild.get().getObjectId());

            assertNotNull(treeChild = repo.getTreeChild(newRepoTree, appendChild(linesName, idL1)));
            assertEquals(oId2_1, treeChild.get().getObjectId());

            // as well as feature1_1 from the previous commit
            assertNotNull(treeChild = repo.getTreeChild(newRepoTree, appendChild(pointsName, idP1)));
            assertEquals(oId1_1, treeChild.get().getObjectId());
        }

        {// simulate a commit so the repo head points to this new tree
            ObjectInserter objectInserter = repo.newObjectInserter();
            List<ObjectId> parents = ImmutableList.of();
            RevCommit commit = new CommitBuilder().setTreeId(newRepoTreeId2).setParentIds(parents)
                    .build();
            ObjectId commitId = commit.getId();

            objectInserter.insert(commit);
            Optional<Ref> newHead = geogig.command(UpdateRef.class).setName("refs/heads/master")
                    .setNewValue(commitId).call();
            assertTrue(newHead.isPresent());
        }

        // delete feature1_1, feature1_3, and feature2_1
        assertTrue(deleteAndAdd(points1));
        assertTrue(deleteAndAdd(points3));
        assertTrue(deleteAndAdd(lines1));
        // and insert feature2_2
        final ObjectId oId2_2 = insertAndAdd(lines2);

        final ObjectId newRepoTreeId3;
        {
            // write comparing the the previously generated tree instead of the repository HEAD, as
            // it was not updated (no commit op was performed)
            newRepoTreeId3 = geogig.command(WriteTree2.class).setOldRoot(tree(newRepoTreeId2))
                    .call();

            // assertEquals(index.getDatabase().getStagedRootRef().getObjectId(), newRepoTreeId3);

            System.err.println("++++++++ new root 3:" + newRepoTreeId3 + " ++++++++++");
            RevTree newRepoTree = repo.getTree(newRepoTreeId3);

            // and check only feature1_2 and feature2_2 remain
            assertFalse(repo.getTreeChild(newRepoTree, appendChild(pointsName, idP1)).isPresent());
            assertFalse(repo.getTreeChild(newRepoTree, appendChild(pointsName, idP3)).isPresent());
            assertFalse(repo.getTreeChild(newRepoTree, appendChild(linesName, idL3)).isPresent());
View Full Code Here

        // get changes (in reverse)
        Iterator<DiffEntry> reverseDiff = command(DiffTree.class).setNewTree(parentTreeId)
                .setOldTree(commit.getTreeId()).setReportTrees(false).call();

        ObjectId headTreeId = repository.getCommit(revertHead).getTreeId();
        final RevTree headTree = repository.getTree(headTreeId);

        ArrayList<Conflict> conflicts = new ArrayList<Conflict>();
        DiffEntry diff;
        while (reverseDiff.hasNext()) {
            diff = reverseDiff.next();
View Full Code Here

        FindTreeChild findTreeChild = geogig.command(FindTreeChild.class);
        findTreeChild.setIndex(true);
        ObjectId rootTreeId = geogig.command(ResolveTreeish.class).setTreeish(Ref.HEAD).call()
                .get();
        if (!rootTreeId.isNull()) {
            RevTree headTree = geogig.command(RevObjectParse.class).setObjectId(rootTreeId)
                    .call(RevTree.class).get();
            findTreeChild.setParent(headTree);
        }
        for (Long nodeId : nodes) {
            Coordinate coord = thisChangePointCache.get(nodeId);
View Full Code Here

                .setTreeish(refspec.split(":")[0]).call();

        checkParameter(rootTreeId.isPresent(), "Couldn't resolve '" + refspec
                + "' to a treeish object");

        RevTree rootTree = geogig.getRepository().getTree(rootTreeId.get());
        Optional<NodeRef> featureTypeTree = geogig.command(FindTreeChild.class)
                .setChildPath(refspec.split(":")[1]).setParent(rootTree).setIndex(true).call();

        checkParameter(featureTypeTree.isPresent(), "pathspec '" + refspec.split(":")[1]
                + "' did not match any valid path");
View Full Code Here

                .setTreeish(refspec.split(":")[0]).call();

        checkParameter(rootTreeId.isPresent(), "Couldn't resolve '" + refspec
                + "' to a treeish object");

        RevTree rootTree = geogig.getRepository().getTree(rootTreeId.get());
        Optional<NodeRef> featureTypeTree = geogig.command(FindTreeChild.class)
                .setChildPath(refspec.split(":")[1]).setParent(rootTree).setIndex(true).call();

        checkParameter(featureTypeTree.isPresent(), "pathspec '" + refspec.split(":")[1]
                + "' did not match any valid path");
View Full Code Here

                .setTreeish(refspec.split(":")[0]).call();

        checkParameter(rootTreeId.isPresent(), "Couldn't resolve '" + refspec
                + "' to a treeish object");

        RevTree rootTree = geogig.getRepository().getTree(rootTreeId.get());
        Optional<NodeRef> featureTypeTree = geogig.command(FindTreeChild.class)
                .setChildPath(refspec.split(":")[1]).setParent(rootTree).setIndex(true).call();

        checkParameter(featureTypeTree.isPresent(), "pathspec '" + refspec.split(":")[1]
                + "' did not match any valid path");
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.