Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.Context


    @Override
    public Context build(Hints hints) {
        FunctionalTestModule functionalTestModule = new FunctionalTestModule(platform.clone());

        Context context = Guice.createInjector(
                Modules.override(new GeogigModule()).with(new PluginsModule(),
                        new CLIContextBuilder.DefaultPlugins(), functionalTestModule,
                        new HintsModule(hints), new CachingModule())).getInstance(Context.class);
        return context;
    }
View Full Code Here


        // GlobalState.consoleReader = new ConsoleReader(stdIn,
        // new TeeOutputStream(stdOut, System.err), new UnsupportedTerminal());
        GlobalState.consoleReader = new ConsoleReader(stdIn, stdOut, new UnsupportedTerminal());

        ContextBuilder injectorBuilder = new CLITestContextBuilder(platform);
        Context injector = injectorBuilder.build();

        if (geogigCLI != null) {
            geogigCLI.close();
        }

        geogigCLI = new GeogigCLI(GlobalState.consoleReader);
        GlobalContextBuilder.builder = injectorBuilder;
        Platform platform = injector.platform();
        geogigCLI.setPlatform(platform);
        geogigCLI.tryConfigureLogging();
    }
View Full Code Here

    }

    @Override
    public Representation getRepresentation(final Variant variant) {
        final Request request = getRequest();
        Context context = getContext(request);

        Form options = getRequest().getResourceRef().getQueryAsForm();

        final String filterFileArg = options.getFirstValue("filter");
        final String bboxArg = options.getFirstValue("bbox");
        final String messageArg = options.getFirstValue("message");
        final boolean update = Boolean.valueOf(options.getFirstValue("update"));
        final boolean rebase = Boolean.valueOf(options.getFirstValue("rebase"));
        final String mappingFileArg = options.getFirstValue("mapping");

        checkArgSpec(filterFileArg != null ^ bboxArg != null || update,
                "You must specify a filter file or a bounding box");
        checkArgSpec((filterFileArg != null || bboxArg != null) ^ update,
                "Filters cannot be used when updating");

        checkArgSpec(context.index().isClean() && context.workingTree().isClean(),
                "Working tree and index are not clean");

        checkArgSpec(!rebase || update, "rebase switch can only be used when updating");

        final File filterFile = parseFile(filterFileArg);
        final File mappingFile = parseFile(mappingFileArg);
        final List<String> bbox = parseBbox(bboxArg);

        checkArgSpec(filterFile == null || filterFile.exists(),
                "The specified filter file does not exist");

        checkArgSpec(mappingFile == null || mappingFile.exists(),
                "The specified mapping file does not exist");

        AbstractGeoGigOp<Optional<OSMReport>> command;
        if (update) {
            command = context.command(OSMUpdateOp.class).setRebase(rebase).setMessage(messageArg)
                    .setAPIUrl(OSMUtils.DEFAULT_API_ENDPOINT);
        } else {
            command = context.command(OSMDownloadOp.class).setBbox(bbox).setFilterFile(filterFile)
                    .setMessage(messageArg).setMappingFile(mappingFile)
                    .setOsmAPIUrl(OSMUtils.DEFAULT_API_ENDPOINT);
        }

        AsyncCommand<Optional<OSMReport>> asyncCommand;

        URL repo = context.repository().getLocation();
        String description = String
                .format("osm download filter: %s, bbox: %s, mapping: %s, update: %s, rebase: %s, repository: %s",
                        filterFileArg, bboxArg, mappingFileArg, update, rebase, repo);
        asyncCommand = AsyncContext.get().run(command, description);
View Full Code Here

    }

    @Override
    public Representation getRepresentation(final Variant variant) {
        final Request request = getRequest();
        final Context context = super.getContext(request);

        Form options = getRequest().getResourceRef().getQueryAsForm();

        final String urlOrFilepath = options.getFirstValue("uri");
        final boolean add = Boolean.valueOf(options.getFirstValue("add"));
        final String mappingFile = options.getFirstValue("mapping");
        Mapping mapping = null;
        if (mappingFile != null) {
            mapping = Mapping.fromFile(mappingFile);
        }
        final boolean noRaw = Boolean.valueOf(options.getFirstValue("noRaw"));
        final String message = options.getFirstValue("message");

        if (urlOrFilepath == null) {
            String msg = "Missing parameter: uri\n"
                    + "Usage: GET <repo context>/osm/import?uri=<osm file URI>[&<arg>=<value>]+\n"
                    + "Arguments:\n"
                    + " * uri: Mandatory. URL or path to OSM data file in the server filesystem\n"
                    + " * add: Optional. true|false. Default: false. If true, do not remove previous data before importing.\n"
                    + " * mapping: Optional. Location of mapping file in the server filesystem\n"
                    + " * noRaw: Optional. true|false. Default: false. If true, do not import raw data when using a mapping\n"
                    + " * message: Optional. Message for the commit to create.";

            throw new CommandSpecException(msg);
        }

        OSMImportOp command = context.command(OSMImportOp.class);
        command.setAdd(add);
        command.setDataSource(urlOrFilepath);
        command.setMapping(mapping);
        command.setMessage(message);
        command.setNoRaw(noRaw);

        AsyncCommand<Optional<OSMReport>> asyncCommand;

        URL repo = context.repository().getLocation();
        String description = String.format("osm import %s, repository: %s", urlOrFilepath, repo);
        asyncCommand = AsyncContext.get().run(command, description);

        final String rootPath = request.getRootRef().toString();
        MediaType mediaType = variant.getMediaType();
View Full Code Here

            ignoreAttributes = inProcessFilteringAttributes.length == 0;
        }

        final String compareRootRef = oldRoot();
        final GeoGigDataStore.ChangeType changeType = changeType();
        final Context context = getCommandLocator();

        nativeReader = new GeogigFeatureReader<SimpleFeatureType, SimpleFeature>(context, fullType,
                filter, featureTypeTreePath, rootRef, compareRootRef, changeType, offset,
                maxFeatures, screenMap, ignoreAttributes);
        return nativeReader;
View Full Code Here

        }
        return featureType;
    }

    Context getCommandLocator() {
        Context commandLocator = getDataStore().getCommandLocator(getTransaction());
        return commandLocator;
    }
View Full Code Here

        final NodeRef typeRef = getTypeRef();
        final String treePath = typeRef.path();
        final ObjectId metadataId = typeRef.getMetadataId();

        Context commandLocator = getCommandLocator();
        Optional<RevFeatureType> revType = commandLocator.command(RevObjectParse.class)
                .setObjectId(metadataId).call(RevFeatureType.class);

        if (!revType.isPresent()) {
            throw new IllegalStateException(String.format("Feature type for tree %s not found",
                    treePath));
View Full Code Here

    /**
     * @return
     */
    RevTree getTypeTree() {
        String refSpec = getRootRef() + ":" + getTypeTreePath();
        Context commandLocator = getCommandLocator();
        Optional<RevTree> ref = commandLocator.command(RevObjectParse.class).setRefSpec(refSpec)
                .call(RevTree.class);
        Preconditions.checkState(ref.isPresent(), "Ref %s not found on working tree", refSpec);
        return ref.get();
    }
View Full Code Here

    /**
     * @return
     */
    WorkingTree getWorkingTree() {
        Context commandLocator = getCommandLocator();
        WorkingTree workingTree = commandLocator.workingTree();
        return workingTree;
    }
View Full Code Here

    }

    @Test
    public void testDeleteException() throws Exception {
        WorkingTree workTree = mock(WorkingTree.class);
        Context cmdl = mock(Context.class);
        when(cmdl.workingTree()).thenReturn(workTree);
        doThrow(new RuntimeException("Exception")).when(workTree).delete(any(String.class));
        ImportOp importOp = new ImportOp();
        importOp.setContext(cmdl);
        importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
        importOp.setAll(true);
View Full Code Here

TOP

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

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.