Package org.geoserver.importer

Examples of org.geoserver.importer.ImportContext


        current = importIdSeq.get(null, delta);
        // verify existing doesn't exists (shouldn't but just in case)
        if (get(current) != null) {
            throw new IllegalStateException("proposed in exists!");
        }
        ImportContext reserved = new ImportContext(current);
        put(reserved);
        return id;
    }
View Full Code Here


    public JSONObject object() {
        return json;
    }

    public ImportContext context() throws IOException {
        ImportContext context = null;
        if (json.has("import")) {
            context = new ImportContext();
           
            json = json.getJSONObject("import");
            if (json.has("id")) {
                context.setId(json.getLong("id"));
            }
            if (json.has("state")) {
                context.setState(State.valueOf(json.getString("state")));
            }
            if (json.has("user")) {
                context.setUser(json.getString("user"));
            }
            if (json.has("archive")) {
                context.setArchive(json.getBoolean("archive"));
            }
            if (json.has("targetWorkspace")) {
                context.setTargetWorkspace(
                    fromJSON(json.getJSONObject("targetWorkspace"), WorkspaceInfo.class));
            }
            if (json.has("targetStore")) {
                context.setTargetStore(
                    fromJSON(json.getJSONObject("targetStore"), StoreInfo.class));
            }
            if (json.has("data")) {
                context.setData(data(json.getJSONObject("data")));
            }
        }
        return context;
    }
View Full Code Here

    }

    protected ImportContext context(boolean optional) {
        long i = Long.parseLong(getAttribute("import"));

        ImportContext context = importer.getContext(i);
        if (!optional && context == null) {
            throw new RestletException("No such import: " + i, Status.CLIENT_ERROR_NOT_FOUND);
        }
        return context;
    }
View Full Code Here

    protected ImportTask task() {
        return task(false);
    }

    protected ImportTask task(boolean optional) {
        ImportContext context = context();
        ImportTask task = null;

        String t = getAttribute("task");
        if (t != null) {
            int id = Integer.parseInt(t);
            task = context.task(id);
        }
        if (t != null && task == null) {
            throw new RestletException("No such task: " + t + " for import: " + context.getId(),
                    Status.CLIENT_ERROR_NOT_FOUND);
        }

        if (task == null && !optional) {
            throw new RestletException("No task specified",
View Full Code Here

        JSONObject source = json.getJSONObject("import").getJSONObject("data");
        assertEquals("directory", source.getString("type"));
        assertEquals("Shapefile", source.getString("format"));
       
        ImportContext context = importer.getContext(0);
        assertEquals(((Directory)context.getData()).getFile().getPath(),
            source.getString("location"));
       
        JSONArray files = source.getJSONArray("files");
        assertEquals(2, files.size());
       
View Full Code Here

        JSONObject source = imprt.getJSONArray("tasks").getJSONObject(0).getJSONObject("data");
        assertEquals("file", source.getString("type"));
        assertEquals("GeoTIFF", source.getString("format"));
       
        ImportContext context = importer.getContext(1);
        assertEquals(((SpatialFile)context.getTasks().get(0).getData()).getFile().getParentFile().getPath(),
            source.getString("location"));

        assertEquals("EmissiveCampania.tif", source.getString("file"));
    }
View Full Code Here

        assertNotNull( resp.getHeader( "Location") );

        int id = lastId();
        assertTrue( resp.getHeader("Location").endsWith( "/imports/"+ id));

        ImportContext ctx = importer.getContext(id);
        assertNotNull(ctx);
        assertNotNull(ctx.getTargetWorkspace());
        assertEquals("sf", ctx.getTargetWorkspace().getName());
        assertNotNull(ctx.getTargetStore());
        assertEquals("skunkworks", ctx.getTargetStore().getName());
    }
View Full Code Here

        DataStoreInfo ds = createH2DataStore(cat.getDefaultWorkspace().getName(), "spearfish");

        File dir = tmpDir();
        unpack("shape/archsites_no_crs.zip", dir);

        ImportContext context = importer.createContext(new Directory(dir), ds);
       
        JSONObject task = getTask(0, 0);
        assertEquals("NO_CRS", task.get("state"));

        String json = "{\"id\":0,\"layer\":{\"srs\":\"EPSG:26713\"}}";
        putTask(0, 0, json);

        task = getTask(0, 0);
        assertEquals("READY", task.get("state"));
        context = importer.getContext(context.getId());
        ReferencedEnvelope latLonBoundingBox =
            context.getTasks().get(0).getLayer().getResource().getLatLonBoundingBox();
        assertFalse("expected not empty bbox",latLonBoundingBox.isEmpty());

        DataStore store = (DataStore) ds.getDataStore(null);
        assertEquals(store.getTypeNames().length, 0);
View Full Code Here

                "}";
        int i = postNewImport(json);
        postNewTaskAsMultiPartForm(i, "mosaic/bm.zip");
        postImport(i);

        ImportContext context = importer.getContext(i);
        assertEquals(ImportContext.State.COMPLETE, context.getState());

        String layername = context.getTasks().get(0).getLayer().getName();
        runChecks(layername);
    }
View Full Code Here

       
        replay(im, pi);

        ImportJSONWriter jsonio = new ImportJSONWriter(im, pi, buffer);

        ImportContext c = new ImportContext(0);
        c.addTask(new ImportTask());

        jsonio.transform(transform, 0, c.task(0), true, 1);

        ImportTransform transform2 = new ImportJSONReader(im, buffer.toString()).transform();
        PropertyDescriptor[] pd = BeanUtils.getPropertyDescriptors(transform.getClass());

        for (int i = 0; i < pd.length; i++) {
View Full Code Here

TOP

Related Classes of org.geoserver.importer.ImportContext

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.