Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.GeoGIG


        }
    }

    public void printFormatted(GeogigCLI cli) throws IOException {
        ConsoleReader console = cli.getConsole();
        GeoGIG geogig = cli.getGeogig();
        for (String ref : refs) {
            Optional<RevObject> obj = geogig.command(RevObjectParse.class).setRefSpec(ref).call();
            if (!obj.isPresent()) {
                ref = getFullRef(ref);
                obj = geogig.command(RevObjectParse.class).setRefSpec(ref).call();
            }
            checkParameter(obj.isPresent(), "refspec did not resolve to any object.");
            RevObject revObject = obj.get();
            if (revObject instanceof RevFeature) {
                Optional<RevFeatureType> opt = geogig.command(ResolveFeatureType.class)
                        .setRefSpec(ref).call();
                if (opt.isPresent()) {
                    RevFeatureType ft = opt.get();
                    ImmutableList<PropertyDescriptor> attribs = ft.sortedDescriptors();
                    RevFeature feature = (RevFeature) revObject;
                    Ansi ansi = super.newAnsi(console.getTerminal());
                    ansi.newline().fg(Color.YELLOW).a("ID:  ").reset()
                            .a(feature.getId().toString()).newline();
                    ansi.fg(Color.YELLOW).a("FEATURE TYPE ID:  ").reset().a(ft.getId().toString())
                            .newline().newline();
                    ansi.a("ATTRIBUTES  ").newline();
                    ansi.a("----------  ").newline();
                    ImmutableList<Optional<Object>> values = feature.getValues();
                    int i = 0;
                    for (Optional<Object> value : values) {
                        ansi.fg(Color.YELLOW).a(attribs.get(i).getName() + ": ").reset();
                        ansi.a(value.or("[NULL]").toString()).newline();
                        i++;
                    }
                    console.println(ansi.toString());
                } else {
                    CharSequence s = geogig.command(CatObject.class)
                            .setObject(Suppliers.ofInstance(revObject)).call();
                    console.println(s);
                }

            } else if (revObject instanceof RevTree) {
                RevTree tree = (RevTree) revObject;
                Optional<RevFeatureType> opt = geogig.command(ResolveFeatureType.class)
                        .setRefSpec(ref).call();
                checkParameter(opt.isPresent(),
                        "Refspec must resolve to a commit, tree, feature or feature type");
                RevFeatureType ft = opt.get();
                Ansi ansi = super.newAnsi(console.getTerminal());

                ansi.fg(Color.YELLOW).a("TREE ID:  ").reset().a(tree.getId().toString()).newline();
                ansi.fg(Color.YELLOW).a("SIZE:  ").reset().a(Long.toString(tree.size())).newline();
                ansi.fg(Color.YELLOW).a("NUMBER Of SUBTREES:  ").reset()
                        .a(Integer.toString(tree.numTrees()).toString()).newline();

                printFeatureType(ansi, ft, true);

                console.println(ansi.toString());
            } else if (revObject instanceof RevCommit) {
                RevCommit commit = (RevCommit) revObject;
                Ansi ansi = super.newAnsi(console.getTerminal());
                ansi.a(Strings.padEnd("Commit:", 15, ' ')).fg(Color.YELLOW)
                        .a(commit.getId().toString()).reset().newline();
                ansi.a(Strings.padEnd("Author:", 15, ' ')).fg(Color.GREEN)
                        .a(formatPerson(commit.getAuthor())).reset().newline();
                ansi.a(Strings.padEnd("Committer:", 15, ' ')).fg(Color.GREEN)
                        .a(formatPerson(commit.getAuthor())).reset().newline();
                ansi.a(Strings.padEnd("Author date:", 15, ' ')).a("(").fg(Color.RED)
                        .a(estimateSince(geogig.getPlatform(), commit.getAuthor().getTimestamp()))
                        .reset().a(") ").a(new Date(commit.getAuthor().getTimestamp())).newline();
                ansi.a(Strings.padEnd("Committer date:", 15, ' '))
                        .a("(")
                        .fg(Color.RED)
                        .a(estimateSince(geogig.getPlatform(), commit.getCommitter().getTimestamp()))
                        .reset().a(") ").a(new Date(commit.getCommitter().getTimestamp()))
                        .newline();
                ansi.a(Strings.padEnd("Subject:", 15, ' ')).a(commit.getMessage()).newline();
                console.println(ansi.toString());
            } else if (revObject instanceof RevFeatureType) {
View Full Code Here


     *
     * @param cli
     * @see org.locationtech.geogig.cli.CLICommand#run(org.locationtech.geogig.cli.GeogigCLI)
     */
    public void run(GeogigCLI cli) {
        GeoGIG geogig = cli.getGeogig();
        if (geogig == null) {
            geogig = new GeoGIG();
        }
        this.console = cli.getConsole();
        VersionInfo info = geogig.command(VersionOp.class).call();

        try {
            printVersionProperty("Project Version", info.getProjectVersion());
            printVersionProperty("Build Time", info.getBuildTime());
            printVersionProperty("Build User Name", info.getBuildUserName());
View Full Code Here

    public void runInternal(GeogigCLI cli) throws IOException {
        checkParameter(paths.size() < 2, "Only one path allowed");
        checkParameter(!paths.isEmpty(), "A path must be specified");

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

        String path = paths.get(0);

        try {
            BlameReport report = geogig.command(BlameOp.class).setPath(path).call();

            Map<String, ValueAndCommit> changes = report.getChanges();
            Iterator<String> iter = changes.keySet().iterator();
            while (iter.hasNext()) {
                String attrib = iter.next();
View Full Code Here

    @Parameter(names = { "--rename", "-m" }, description = "Rename branch ")
    private boolean rename = false;

    @Override
    public void runInternal(final GeogigCLI cli) throws IOException {
        final GeoGIG geogig = cli.getGeogig();

        final ConsoleReader console = cli.getConsole();

        if (delete) {
            checkParameter(!branchName.isEmpty(), "no name specified for deletion");

            for (String br : branchName) {
                Optional<? extends Ref> deletedBranch;
                deletedBranch = geogig.command(BranchDeleteOp.class).setName(br).call();

                checkParameter(deletedBranch.isPresent(), "No branch called '%s'.", br);

                console.println(String.format("Deleted branch '%s'.", br));
            }
            return;
        }

        checkParameter(branchName.size() < 3, "too many arguments: %s", branchName);

        if (rename) {
            checkParameter(!branchName.isEmpty(), "You must specify a branch to rename.");

            if (branchName.size() == 1) {
                Optional<Ref> headRef = geogig.command(RefParse.class).setName(Ref.HEAD).call();
                geogig.command(BranchRenameOp.class).setNewName(branchName.get(0)).setForce(force)
                        .call();
                if (headRef.isPresent()) {
                    SymRef ref = (SymRef) headRef.get();
                    console.println("renamed branch '"
                            + ref.getTarget().substring(Ref.HEADS_PREFIX.length()) + "' to '"
                            + branchName.get(0) + "'");
                }
            } else {
                geogig.command(BranchRenameOp.class).setOldName(branchName.get(0))
                        .setNewName(branchName.get(1)).setForce(force).call();
                console.println("renamed branch '" + branchName.get(0) + "' to '"
                        + branchName.get(1) + "'");
            }
            return;
        }

        if (branchName.isEmpty()) {
            listBranches(cli);
            return;
        }

        final String branch = branchName.get(0);
        final String origin = branchName.size() > 1 ? branchName.get(1) : Ref.HEAD;

        Ref newBranch = geogig.command(BranchCreateOp.class).setName(branch).setForce(force)
                .setOrphan(orphan).setAutoCheckout(checkout).setSource(origin).call();

        console.println("Created branch " + newBranch.getName());
    }
View Full Code Here

        console.println("Created branch " + newBranch.getName());
    }

    private void listBranches(GeogigCLI cli) throws IOException {
        final ConsoleReader console = cli.getConsole();
        final GeoGIG geogig = cli.getGeogig();

        boolean local = all || !(remotes);
        boolean remote = all || remotes;

        ImmutableList<Ref> branches = geogig.command(BranchListOp.class).setLocal(local)
                .setRemotes(remote).call();

        final Ref currentHead = geogig.command(RefParse.class).setName(Ref.HEAD).call().get();

        final int largest = verbose ? largestLenght(branches) : 0;

        for (Ref branchRef : branches) {
            final String branchRefName = branchRef.getName();
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

    protected void runInternal(GeogigCLI cli) throws IOException {
        checkParameter(filterFile != null ^ bbox != null || update,
                "You must specify a filter file or a bounding box");
        checkParameter((filterFile != null || bbox != null) ^ update,
                "Filters cannot be used when updating");
        GeoGIG geogig = cli.getGeogig();
        checkState(geogig.getRepository().index().isClean()
                && geogig.getRepository().workingTree().isClean(),
                "Working tree and index are not clean");

        checkParameter(!rebase || update, "--rebase switch can only be used when updating");
        checkParameter(filterFile == null || filterFile.exists(),
                "The specified filter file does not exist");
        checkParameter(bbox == null || bbox.size() == 4,
                "The specified bounding box is not correct");

        osmAPIUrl = resolveAPIURL();

        Optional<OSMReport> report;
        GeogigTransaction tx = geogig.command(TransactionBegin.class).call();
        try {
            AbstractGeoGigOp<Optional<OSMReport>> cmd;
            if (update) {
                cmd = tx.command(OSMUpdateOp.class).setAPIUrl(osmAPIUrl).setRebase(rebase)
                        .setMessage(message).setProgressListener(cli.getProgressListener());
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

            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

    @Parameter(description = "<commitish>...")
    private List<String> commits = Lists.newArrayList();

    @Override
    public void runInternal(GeogigCLI cli) {
        final GeoGIG geogig = cli.getGeogig();
        checkParameter(commits.size() > 0, "No commits specified.");
        checkParameter(commits.size() < 2, "Too many commits specified.");

        CherryPickOp cherryPick = geogig.command(CherryPickOp.class);

        Optional<ObjectId> commitId;
        commitId = geogig.command(RevParse.class).setRefSpec(commits.get(0)).call();
        checkParameter(commitId.isPresent(), "Commit not found '%s'", commits.get(0));
        cherryPick.setCommit(Suppliers.ofInstance(commitId.get()));

        cherryPick.call();
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.