Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.GeoGIG


            refspec = "WORK_HEAD:" + path;
        }

        checkParameter(!refspec.endsWith(":"), "No path specified.");

        final GeoGIG geogig = cli.getGeogig();

        Optional<ObjectId> rootTreeId = geogig.command(ResolveTreeish.class)
                .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


            refspec = "WORK_HEAD:" + path;
        }

        checkParameter(!refspec.endsWith(":"), "No path specified.");

        final GeoGIG geogig = cli.getGeogig();

        Optional<ObjectId> rootTreeId = geogig.command(ResolveTreeish.class)
                .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

    public void runInternal(GeogigCLI cli) throws IOException {
        checkParameter(patchFiles.size() < 2, "Only one single patch file accepted");
        checkParameter(!patchFiles.isEmpty(), "No patch file specified");

        ConsoleReader console = cli.getConsole();
        GeoGIG geogig = cli.getGeogig();

        File patchFile = new File(patchFiles.get(0));
        checkParameter(patchFile.exists(), "Patch file cannot be found");
        FileInputStream stream;
        try {
            stream = new FileInputStream(patchFile);
        } catch (FileNotFoundException e1) {
            throw new CommandFailedException("Can't open patch file " + patchFile, e1);
        }
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            Closeables.closeQuietly(reader);
            Closeables.closeQuietly(stream);
            throw new CommandFailedException("Error reading patch file " + patchFile, e);
        }
        Patch patch = PatchSerializer.read(reader);
        Closeables.closeQuietly(reader);
        Closeables.closeQuietly(stream);

        if (reverse) {
            patch = patch.reversed();
        }

        if (summary) {
            console.println(patch.toString());
        } else if (check) {
            VerifyPatchResults verify = cli.getGeogig().command(VerifyPatchOp.class)
                    .setPatch(patch).call();
            Patch toReject = verify.getToReject();
            Patch toApply = verify.getToApply();
            if (toReject.isEmpty()) {
                console.println("Patch can be applied.");
            } else {
                console.println("Error: Patch cannot be applied\n");
                console.println("Applicable entries:\n");
                console.println(toApply.toString());
                console.println("\nConflicting entries:\n");
                console.println(toReject.toString());
            }
        } else {
            try {
                Patch rejected = geogig.command(ApplyPatchOp.class).setPatch(patch)
                        .setApplyPartial(reject).call();
                if (reject) {
                    if (rejected.isEmpty()) {
                        console.println("Patch applied succesfully");
                    } else {
View Full Code Here

    @Parameter(names = "--theirs", description = "When checking out paths from the index, check out 'theirs' version for unmerged paths")
    private boolean theirs;

    @Override
    public void runInternal(GeogigCLI cli) throws IOException {
        final GeoGIG geogig = cli.getGeogig();
        checkParameter(branchOrStartPoint.size() != 0 || !paths.isEmpty(),
                "no branch or paths specified");
        checkParameter(branchOrStartPoint.size() < 2, "too many arguments");

        try {
            final ConsoleReader console = cli.getConsole();
            String branchOrCommit = (branchOrStartPoint.size() > 0 ? branchOrStartPoint.get(0)
                    : null);

            CheckoutResult result = geogig.command(CheckoutOp.class).setForce(force)
                    .setSource(branchOrCommit).addPaths(paths).setOurs(ours).setTheirs(theirs)
                    .call();

            switch (result.getResult()) {
            case CHECKOUT_LOCAL_BRANCH:
View Full Code Here

            refspec = "WORK_HEAD:" + path;
        }

        checkParameter(!refspec.endsWith(":"), "No path specified.");

        final GeoGIG geogig = cli.getGeogig();

        Optional<ObjectId> rootTreeId = geogig.command(ResolveTreeish.class)
                .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

                throw new CommandFailedException("Can't create directory "
                        + repoDir.getAbsolutePath());
            }
        }

        GeoGIG geogig = new GeoGIG(cli.getGeogigInjector(), repoDir);

        checkParameter(!geogig.command(ResolveGeogigDir.class).call().isPresent(),
                "Destination path already exists and is not an empty directory.");

        geogig.command(InitOp.class).setConfig(Init.splitConfig(config)).setFilterFile(filterFile)
                .call();

        cli.setGeogig(geogig);
        cli.getPlatform().setWorkingDir(repoDir);
View Full Code Here

    @Override
    protected void runInternal(GeogigCLI cli) throws IOException {

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

        GeoGIG geogig = cli.getGeogig();

        CreateOSMChangesetOp op = geogig.command(CreateOSMChangesetOp.class);

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

        op.setOldVersion(oldVersion).setNewVersion(newVersion).setId(id);
View Full Code Here

    public synchronized GeoGIG getGeogig() {
        if (providedGeogig != null) {
            return providedGeogig;
        }
        if (geogig == null) {
            GeoGIG geogig = loadRepository();
            setGeogig(geogig);
        }
        return geogig;
    }
View Full Code Here

    }

    @VisibleForTesting
    public synchronized GeoGIG getGeogig(Hints hints) {
        close();
        GeoGIG geogig = loadRepository(hints);
        setGeogig(geogig);
        return geogig;
    }
View Full Code Here

        return loadRepository(this.hints);
    }

    @Nullable
    private GeoGIG loadRepository(Hints hints) {
        GeoGIG geogig = newGeoGIG(hints);

        if (geogig.command(ResolveGeogigDir.class).call().isPresent()) {
            geogig.getRepository();
            return geogig;
        }
        geogig.close();

        return null;
    }
View Full Code Here

TOP

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

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.