Package org.geotools.data

Examples of org.geotools.data.DataStoreFactorySpi


    public ImportData createImportSource() {
//        try {

          // build up the store connection param map
          Map<String, Serializable> params = new HashMap<String, Serializable>();
          DataStoreFactorySpi factory = fillStoreParams(params);

          return new Database(params);

//          // ok, check we can connect
//          DataAccess store = null;
View Full Code Here


        return result;
    }
   
    @Override
    protected DataStoreFactorySpi fillStoreParams(Map<String, Serializable> params) {
        DataStoreFactorySpi factory;
        params.put(JDBCDataStoreFactory.DBTYPE.key, (String) PostgisNGDataStoreFactory.DBTYPE.sample);
        if (CONNECTION_JNDI.equals(connectionType)) {
            factory = new PostgisNGJNDIDataStoreFactory();
            fillInJndiParams(params, jndiParamPanel);
        }
View Full Code Here

     * Loads the available tables from this database.
     */
    @Override
    public void prepare(ProgressMonitor m) throws IOException {
        tables = new ArrayList<Table>();
        DataStoreFactorySpi factory =
                (DataStoreFactorySpi) DataStoreUtils.aquireFactory(parameters);
        if (factory == null) {
            throw new IOException("Unable to find data store for specified parameters");
        }

        m.setTask("Loading tables");
        DataStore store = factory.createDataStore(parameters);
        if (store == null) {
            throw new IOException("Unable to create data store from specified parameters");
        }

        format = DataFormat.lookup(parameters);
View Full Code Here

    /**
     * Looks up a format based on a set of connection parameters.
     */
    public static DataFormat lookup(Map<String,Serializable> params) {
        DataStoreFactorySpi factory = (DataStoreFactorySpi) DataStoreUtils.aquireFactory(params);
        if (factory != null) {
            return new DataStoreFormat(factory);
        }
        return null;
    }
View Full Code Here

        return result;
    }
   
    @Override
    protected DataStoreFactorySpi fillStoreParams(Map<String, Serializable> params) {
        DataStoreFactorySpi factory;
        params.put(JDBCDataStoreFactory.DBTYPE.key, "oracle");
        if (CONNECTION_JNDI.equals(connectionType)) {
            factory = new OracleNGJNDIDataStoreFactory();

            fillInJndiParams(params, jndiParamPanel);
View Full Code Here

        return result;
    }
   
    @Override
    protected DataStoreFactorySpi fillStoreParams(Map<String, Serializable> params) {
        DataStoreFactorySpi factory;
        params.put(JDBCDataStoreFactory.DBTYPE.key, "sqlserver");
        if (CONNECTION_JNDI.equals(connectionType)) {
            factory = new SQLServerJNDIDataStoreFactory();

            fillInJndiParams(params, jndiParamPanel);
View Full Code Here

        // first try and see if we know about this format directly
        String factoryClassName = formatToDataStoreFactory.get(format);
        if (factoryClassName != null) {
            try {
                Class factoryClass = Class.forName(factoryClassName);
                DataStoreFactorySpi factory = (DataStoreFactorySpi) factoryClass.newInstance();
                return factory;
            } catch (Exception e) {
                throw new RestletException("Datastore format unavailable: " + factoryClassName,
                        Status.SERVER_ERROR_INTERNAL);
            }
        }

        // if not, let's see if we have a file data store factory that knows about the extension
        String extension = "." + format;
        for (DataAccessFactory dataAccessFactory : DataStoreUtils.getAvailableDataStoreFactories()) {
            if (dataAccessFactory instanceof FileDataStoreFactorySpi) {
                FileDataStoreFactorySpi factory = (FileDataStoreFactorySpi) dataAccessFactory;
                for (String handledExtension : factory.getFileExtensions()) {
                    if (extension.equalsIgnoreCase(handledExtension)) {
                        return factory;
                    }
                }
            }
View Full Code Here

           
            //TODO: should check if the store actually supports charset
            if (charset != null && charset.length() > 0) {
                info.getConnectionParameters().put("charset", charset);
            }
            DataStoreFactorySpi targetFactory = factory;
            if (!targetDataStoreFormat.equals(sourceDataStoreFormat)) {
                //target is different, we need to create it
                targetFactory = lookupDataStoreFactory(targetDataStoreFormat);
                if (targetFactory == null) {
                    throw new RestletException( "Unable to create data store of type "
                        + targetDataStoreFormat, Status.CLIENT_ERROR_BAD_REQUEST );
                }
               
                autoCreateParameters(info, namespace, targetFactory);
                canRemoveFiles = true;
            }
            else {
                updateParameters(info, namespace, targetFactory, uploadedFile);
            }
           
            info.setType(targetFactory.getDisplayName());
        }
        else {
            LOGGER.info("Using existing datastore: " + datastore);
           
            // look up the target data store factory
View Full Code Here

        assertSame("REST API did not find custom data store", dataAccessFactory, factory);
    }

    @Test
    public void testLookupDataStoreFactoryKnownExtension() throws Exception {
        DataStoreFactorySpi factory = DataStoreFileResource.lookupDataStoreFactory("shp");
        assertEquals("Shapefile", factory.getDisplayName());
    }
View Full Code Here

      if(!destination.delete())
        throw new IOException("The provided destination maps to an existing file that cannot be deleted:"+destination);
    }
   
    // real work
    final DataStoreFactorySpi dataStoreFactory = new ShapefileDataStoreFactory();
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("url", destination.toURI().toURL());
    params.put("create spatial index", Boolean.TRUE);
 
    ShapefileDataStore store=null;
    Transaction transaction=null;
    try{
      store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
      store.createSchema(fc.getSchema());
     
      final SimpleFeatureStore featureStore =(SimpleFeatureStore) store.getFeatureSource(fc.getSchema().getName());
      transaction=featureStore.getTransaction();
     
View Full Code Here

TOP

Related Classes of org.geotools.data.DataStoreFactorySpi

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.