Search in sources :

Example 1 with DefaultPlatform

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

the class Main method loadGeoGIG.

static GeoGIG loadGeoGIG(String repo) {
    Platform platform = new DefaultPlatform();
    platform.setWorkingDir(new File(repo));
    Context inj = GlobalContextBuilder.builder.build();
    GeoGIG geogig = new GeoGIG(inj, platform.pwd());
    if (geogig.command(ResolveGeogigDir.class).call().isPresent()) {
        geogig.getRepository();
        return geogig;
    }
    return geogig;
}
Also used : Context(org.locationtech.geogig.api.Context) DefaultPlatform(org.locationtech.geogig.api.DefaultPlatform) Platform(org.locationtech.geogig.api.Platform) DefaultPlatform(org.locationtech.geogig.api.DefaultPlatform) File(java.io.File) GeoGIG(org.locationtech.geogig.api.GeoGIG)

Example 2 with DefaultPlatform

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

the class SilentProgressListener method runCommand.

/**
     * Runs a command on a given repository
     * 
     * @param folder the repository folder
     * @param args the args to run, including the command itself and additional parameters
     * @return
     * @throws IOException
     */
public int runCommand(String folder, String[] args) throws IOException {
    System.gc();
    GeogigCLI cli = new GeogigCLI(consoleReader) {

        @Override
        public synchronized ProgressListener getProgressListener() {
            if (super.progressListener == null) {
                super.progressListener = new DefaultProgressListener() {

                    @Override
                    public void setDescription(String s) {
                        GeogigPy4JEntryPoint.this.listener.setProgressText(s);
                    }

                    @Override
                    public synchronized void setProgress(float percent) {
                        GeogigPy4JEntryPoint.this.listener.setProgress(percent);
                    }
                };
            }
            return super.progressListener;
        }
    };
    DefaultPlatform platform = new DefaultPlatform();
    platform.setWorkingDir(new File(folder));
    cli.setPlatform(platform);
    String command = Joiner.on(" ").join(args);
    os.clear();
    pages = null;
    System.out.print("Running command: " + command);
    int ret = cli.execute(args);
    cli.close();
    if (ret == 0) {
        System.out.println(" [OK]");
    } else {
        System.out.println(" [Error]");
    }
    stream.flush();
    os.flush();
    return ret;
}
Also used : DefaultProgressListener(org.locationtech.geogig.api.DefaultProgressListener) DefaultPlatform(org.locationtech.geogig.api.DefaultPlatform) File(java.io.File)

Example 3 with DefaultPlatform

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

the class Serve method loadGeoGIG.

GeoGIG loadGeoGIG(String repo, GeogigCLI cli) {
    Platform platform = new DefaultPlatform();
    platform.setWorkingDir(new File(repo));
    GeoGIG geogig = new GeoGIG(cli.getGeogigInjector(), platform.pwd());
    if (geogig.command(ResolveGeogigDir.class).call().isPresent()) {
        geogig.getRepository();
    }
    return geogig;
}
Also used : DefaultPlatform(org.locationtech.geogig.api.DefaultPlatform) Platform(org.locationtech.geogig.api.Platform) DefaultPlatform(org.locationtech.geogig.api.DefaultPlatform) File(java.io.File) GeoGIG(org.locationtech.geogig.api.GeoGIG)

Aggregations

File (java.io.File)3 DefaultPlatform (org.locationtech.geogig.api.DefaultPlatform)3 GeoGIG (org.locationtech.geogig.api.GeoGIG)2 Platform (org.locationtech.geogig.api.Platform)2 Context (org.locationtech.geogig.api.Context)1 DefaultProgressListener (org.locationtech.geogig.api.DefaultProgressListener)1