Package org.locationtech.geogig.api.porcelain

Examples of org.locationtech.geogig.api.porcelain.DiffOp


     * so it can be used to check the new data that will get commited into the repository
     *
     * @return
     */
    public Feature[] getFeaturesToCommit(String path, boolean noDeletions) {
        DiffOp diffOp = repository.command(DiffOp.class);
        diffOp.setCompareIndex(true);
        diffOp.setFilter(path);
        Iterator<DiffEntry> diffs = diffOp.call();
        List<Feature> list = Lists.newArrayList();
        while (diffs.hasNext()) {
            DiffEntry diff = diffs.next();
            if (!diff.changeType().equals(ChangeType.REMOVED) || !noDeletions) {
                RevFeature revFeature = repository.command(RevObjectParse.class)
View Full Code Here


        insertAndAdd(modifiedFeature);
        insertAndAdd(points3);
        deleteAndAdd(points2);
        delete(points3);
        DiffOp op = geogig.command(DiffOp.class);
        op.setCompareIndex(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();

        assertEquals(3, patch.count());
        assertEquals(1, patch.getAddedFeatures().size());
        assertEquals(1, patch.getRemovedFeatures().size());
View Full Code Here

    }

    @Test
    public void testCreatePatchAddNewFeatureToEmptyRepo() throws Exception {
        insert(points1);
        DiffOp op = geogig.command(DiffOp.class);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAddedFeatures().size());
    }
View Full Code Here

    @Test
    public void testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(linesName, linesType);
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getOldFeatureType());
        assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0)
                .getNewFeatureType());
View Full Code Here

    public void testCreatePatchRemoveEmptyFeatureType() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(linesName, linesType);
        geogig.command(AddOp.class).setUpdateOnly(false).call();
        workingTree.delete(linesName);
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0)
                .getOldFeatureType());
        assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getNewFeatureType());
View Full Code Here

        assertEquals(1, patch.getFeatureTypes().size());
    }

    @Test
    public void testCreatePatchModifyFeatureType() throws Exception {
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);

        insertAndAdd(points1, points2);
        geogig.getRepository().workingTree().updateTypeTree(pointsName, modifiedPointsType);

        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(RevFeatureTypeImpl.build(pointsType).getId(), patch.getAlteredTrees().get(0)
                .getOldFeatureType());
        assertEquals(RevFeatureTypeImpl.build(modifiedPointsType).getId(),
View Full Code Here

    @Test
    public void testCreatePatchAddNewEmptyPath() throws Exception {
        insert(points1);
        delete(points1);
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
        Iterator<DiffEntry> diffs = op.call();
        // ArrayList<DiffEntry> list = Lists.newArrayList(diffs);
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
    }
View Full Code Here

                    count.treeCount(), count.featureCount()));
            console.flush();
            return;
        }

        DiffOp diff = geogig.command(DiffOp.class);
        diff.setOldVersion(oldVersion).setNewVersion(newVersion).setCompareIndex(cached);

        Iterator<DiffEntry> entries;
        if (paths.isEmpty()) {
            entries = diff.setProgressListener(cli.getProgressListener()).call();
        } else {
            entries = Iterators.emptyIterator();
            for (String path : paths) {
                Iterator<DiffEntry> moreEntries = diff.setFilter(path)
                        .setProgressListener(cli.getProgressListener()).call();
                entries = Iterators.concat(entries, moreEntries);
            }
        }
View Full Code Here

        checkParameter(refSpec.size() < 3, "Commit list is too long :%s", refSpec);

        GeoGIG geogig = cli.getGeogig();
        checkParameter(file != null, "Patch file not specified");

        DiffOp diff = geogig.command(DiffOp.class).setReportTrees(true);

        String oldVersion = resolveOldVersion();
        String newVersion = resolveNewVersion();

        diff.setOldVersion(oldVersion).setNewVersion(newVersion).setCompareIndex(cached);

        Iterator<DiffEntry> entries;
        if (paths.isEmpty()) {
            entries = diff.setProgressListener(cli.getProgressListener()).call();
        } else {
            entries = Iterators.emptyIterator();
            for (String path : paths) {
                Iterator<DiffEntry> moreEntries = diff.setFilter(path)
                        .setProgressListener(cli.getProgressListener()).call();
                entries = Iterators.concat(entries, moreEntries);
            }
        }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.porcelain.DiffOp

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.