Package org.geoserver.catalog

Examples of org.geoserver.catalog.DataStoreInfo


     */
    public DefaultDataStoreEditPanel(final String componentId, final Form storeEditForm) {
        super(componentId, storeEditForm);

        final IModel model = storeEditForm.getModel();
        final DataStoreInfo info = (DataStoreInfo) model.getObject();
        final Catalog catalog = getCatalog();
        final ResourcePool resourcePool = catalog.getResourcePool();
        DataAccessFactory dsFactory;
        try {
            dsFactory = resourcePool.getDataStoreFactory(info);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        final Map<String, ParamInfo> paramsMetadata = new LinkedHashMap<String, ParamInfo>();

        {
            final boolean isNew = null == info.getId();
            final Param[] dsParams = dsFactory.getParametersInfo();
            for (Param p : dsParams) {
                ParamInfo paramInfo = new ParamInfo(p);
                paramsMetadata.put(p.key, paramInfo);

                if (isNew) {
                    // set default value
                    Serializable defValue;
                    if ("namespace".equals(paramInfo.getName())) {
                        defValue = catalog.getDefaultNamespace().getURI();
                    } else if (URL.class == paramInfo.getBinding()) {
                        defValue = "file:data/example.extension";
                    } else {
                        defValue = paramInfo.getValue();
                    }
                    info.getConnectionParameters().put(paramInfo.getName(), defValue);
                }
            }
        }

        final List<String> keys = new ArrayList<String>(paramsMetadata.keySet());
View Full Code Here


     * @param parameters
     */
    public DataAccessEditPage(PageParameters parameters) {
        String wsName = parameters.getString(WS_NAME);
        String storeName = parameters.getString(STORE_NAME);
        DataStoreInfo dsi = getCatalog().getDataStoreByName(wsName, storeName);
       
        if(dsi == null) {
            error(new ParamResourceModel("DataAccessEditPage.notFound", this, wsName, storeName).getString());
            setResponsePage(StorePage.class);
            return;
View Full Code Here

     * @param dataStoreInfoId
     *            the datastore id to modify, as per {@link DataStoreInfo#getId()}
     */
    public DataAccessEditPage(final String dataStoreInfoId) throws IllegalArgumentException {
        final Catalog catalog = getCatalog();
        final DataStoreInfo dataStoreInfo = catalog.getDataStore(dataStoreInfoId);

        if (null == dataStoreInfo) {
            throw new IllegalArgumentException("DataStore " + dataStoreInfoId + " not found");
        }

View Full Code Here

        assertPathExists(root, "styles/stuff.xml");
        assertPathExists(root, "styles/stuff.sld");
        assertPathExists(root, "data/bar/stuff.properties");

        // ensure the exported store config points to the properties
        DataStoreInfo store = new XStreamPersisterFactory().createXMLPersister()
                .load(new FileInputStream(root.resolve("bar/datastore.xml").toFile()), DataStoreInfo.class);

        assertEquals("file:%WORKSPACE%/data/bar", store.getConnectionParameters().get("directory"));
    }
View Full Code Here

        finally {
            gpkg.close();
        }

        // ensure the exported store config points to the geopackage
        DataStoreInfo store = new XStreamPersisterFactory().createXMLPersister()
            .load(new FileInputStream(root.resolve("bar/datastore.xml").toFile()), DataStoreInfo.class);

        assertEquals("geopkg", store.getConnectionParameters().get("dbtype"));
        assertEquals("file:%WORKSPACE%/data/bar.gpkg", store.getConnectionParameters().get("database"));
    }
View Full Code Here

        else {
            file = new File(storeDir, "store.xml");
        }

        if (s instanceof DataStoreInfo) {
            DataStoreInfo ds = (DataStoreInfo) s;

            FileParam dataFile = isFileBased(ds);
            if (dataFile != null && options.bounds() == null) {
                // optimize by copying files over directly
                File storeDataDir = new File(wsDataDir, s.getName());
                storeDataDir.mkdirs();

                copyFilesTo(dataFile.file, storeDataDir, ds);

                // update the store configuration to point to the newly copied files
                File newFileRef = null;
                if (dataFile.file.isDirectory()) {
                    newFileRef = storeDataDir;
                }
                else {
                    newFileRef = new File(storeDataDir, dataFile.file.getName());
                }


                // TODO: convert back to whatever format the parameter expects
                DataStoreInfo clone = copy(ds, catalog.getFactory().createDataStore(), DataStoreInfo.class);

                //clone.getConnectionParameters().put(dataFile.param.key, "file:%WORKSPACE%/"+newPath.toString());
                clone.getConnectionParameters().put(dataFile.param.key, toWorkspaceRelativePath(newFileRef));


                s = clone;
            }
            else {
                // copy into a new geopackage
                GeoPackage gpkg = new GeoPackage(new File(wsDataDir, ds.getName()+".gpkg"));
                try {
                    ingestInto(gpkg, ds);
                }
                finally {
                    gpkg.close();
                }

                // update the connection parameters
                DataStoreInfo clone = copy(ds, catalog.getFactory().createDataStore(), DataStoreInfo.class);
                clone.setType("GeoPackage");

                Map<String,Serializable> oldParams = clone.getConnectionParameters();
                Map<String,Serializable> params = Maps.newHashMap();

                params.put(GeoPkgDataStoreFactory.DBTYPE.key, "geopkg");
                params.put(GeoPkgDataStoreFactory.DATABASE.key, toWorkspaceRelativePath(gpkg.getFile()));
                params.put(GeoPkgDataStoreFactory.NAMESPACE.key,
View Full Code Here

        CatalogBuilder builder = new CatalogBuilder(cat);

        StoreInfo store = findStore(ws.getName(), storeName, cat);

        if( store instanceof DataStoreInfo){
            DataStoreInfo dataStore = (DataStoreInfo) store;
            builder.setStore(dataStore);

            // create from the resource
            FeatureTypeInfo ft = null;
            try {
                ft = builder.buildFeatureType(resourceName);
            }
            catch(Exception e) {
                Throwables.propagateIfInstanceOf(e, IOException.class);
                Throwables.propagate(e);
            }

            DataAccess data = dataStore.getDataStore(null);

            FeatureSource source = data.getFeatureSource(resourceName);
            builder.setupBounds(ft, source);

            return builder.buildLayer(ft);
View Full Code Here

            Map resolved = ResourcePool.getParams(map, cat.getResourceLoader() );
            DataAccess dataStore = DataAccessFinder.getDataStore(resolved);           
            if( dataStore == null ){
                throw new IllegalArgumentException("Connection parameters incomplete (does not match an available data store, coverage store or wms store).");
            }
            DataStoreInfo info = factory.createDataStore();
            info.setWorkspace(workspace);
            info.setType(name);
            info.getConnectionParameters().putAll(map);
            try {
                info.setDescription( dataStore.getInfo().getDescription());
                info.setEnabled(true);
            } catch (Throwable e) {
                info.setError(e);
                info.setEnabled(false);
            }
            store = info;
        }       
        boolean refresh = define( store, obj );
        if( refresh ){
View Full Code Here

                        }
                    }
                }
            }
            if( store instanceof DataStoreInfo){
                DataStoreInfo info = (DataStoreInfo) store;
                if("connection".equals(prop)){
                    JSONObj connection = obj.object(prop);
                    info.getConnectionParameters().clear();
                    info.getConnectionParameters().putAll( connection.raw() );
                    reconnect = true;
                }
            }
        }
       
View Full Code Here

    }
   
    private JSONObj resource(JSONObj obj, StoreInfo store, String name, HttpServletRequest req) throws IOException {
        obj.put("name", name);
        if(store instanceof DataStoreInfo){
            DataStoreInfo data = (DataStoreInfo) store;
           
            @SuppressWarnings("rawtypes")
            DataAccess dataStore = data.getDataStore(new NullProgressListener());
            FeatureType schema;
            org.geotools.data.ResourceInfo info;
            if (dataStore instanceof DataStore) {
                schema = ((DataStore) dataStore).getSchema(name);
                info = ((DataStore) dataStore).getFeatureSource(name).getInfo();
            } else {
                NameImpl qname = new NameImpl(name);
                schema = dataStore.getSchema(qname);
                info = dataStore.getFeatureSource(qname).getInfo();
            }
            String title = info.getTitle() == null
                    ? WordUtils.capitalize(name)
                    : info.getTitle();
            String description = info.getDescription() == null ? "" : info.getDescription();
            obj.put("title", title);
            obj.put("description", description);
           
            JSONArr keywords = obj.putArray("keywords");
            keywords.raw().addAll( info.getKeywords() );
            IO.bounds(obj.putObject("bounds"),info.getBounds());
            IO.schema(obj.putObject("schema"), schema, false);
        }
        if(store instanceof CoverageStoreInfo){
            CoverageStoreInfo data = (CoverageStoreInfo) store;
            GridCoverageReader r = data.getGridCoverageReader(null, null);
            obj.put("title", WordUtils.capitalize(name));
            obj.put("description", "");
            if( r instanceof GridCoverage2DReader){
                GridCoverage2DReader reader = (GridCoverage2DReader) r;
                CoordinateReferenceSystem crs = reader.getCoordinateReferenceSystem(name);
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.DataStoreInfo

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.