Package org.geotools.data

Examples of org.geotools.data.DataStore


    private File writeShapefile(File tempDir,
            FeatureCollection<SimpleFeatureType, SimpleFeature> collection) {
        SimpleFeatureType schema = collection.getSchema();

        FeatureStore<SimpleFeatureType, SimpleFeature> fstore = null;
        DataStore dstore = null;
        File file = null;
        try {
            file = new File(tempDir, schema.getTypeName() + ".shp");
            dstore = new ShapefileDataStore(file.toURL());
            dstore.createSchema(schema);
           
            fstore = (FeatureStore<SimpleFeatureType, SimpleFeature>) dstore.getFeatureSource(schema.getTypeName());
            fstore.addFeatures(collection);
        } catch (IOException ioe) {
            LOGGER.log(Level.WARNING,
                "Error while writing featuretype '" + schema.getTypeName() + "' to shapefile.", ioe);
            throw new ServiceException(ioe);
        } finally {
            if(dstore != null) {
                dstore.dispose();
            }
        }
       
        return file;
    }
View Full Code Here


            return;
        }
       
        //load the datastore
        try {
            DataStore ds = (DataStore) info.getDataStore(null);
           
            String[] featureTypeNames = ds.getTypeNames();
            for ( int i = 0; i < featureTypeNames.length; i++ ) {
               
                //unless configure specified "all", only configure the first feature type
                if ( !"all".equalsIgnoreCase( configure ) && i > 0 ) {
                    break;
                }
               
                FeatureSource fs = ds.getFeatureSource(featureTypeNames[i]);
                FeatureTypeInfo ftinfo = null;
                if ( add ) {
                    //auto configure the feature type as well
                    ftinfo = builder.buildFeatureType(fs);
                    builder.lookupSRS(ftinfo, true);
View Full Code Here

        }
       
        //list of available feature types
        List<String> available = new ArrayList<String>();
        try {
            DataStore ds = (DataStore) info.getDataStore(null);
           
            String[] featureTypeNames = ds.getTypeNames();
            for ( String featureTypeName : featureTypeNames ) {
                FeatureTypeInfo ftinfo = catalog.getFeatureTypeByDataStore(info, featureTypeName);
                if (ftinfo == null ) {
                    //not in catalog, add it
                    available.add( featureTypeName );
View Full Code Here

            builder.setName(original.getTypeName().replace('.', '_') + suffix);
            builder.setNamespaceURI(original.getName().getURI());
            SimpleFeatureType retyped = builder.buildFeatureType();
           
            // create the datastore for the current geom type
            DataStore dstore = buildStore(tempDir, charset, retyped);
           
            // cache it
            storeWriter = new StoreWriter();
            storeWriter.dstore = dstore;
            storeWriter.writer = dstore.getFeatureWriter(retyped.getTypeName(), Transaction.AUTO_COMMIT);
            writers.put(target, storeWriter);
        }
        return storeWriter.writer;
    }
View Full Code Here

                    Transaction t = new DefaultTransaction();

                    try {
                        try {
                            t.addAuthorization(response.getLockId());
                            DataStore dataStore = (DataStore) source.getDataStore();
                            dataStore.getLockingManager().refresh(response.getLockId(), t);
                        } finally {
                            t.commit();
                        }
                    } catch (IOException e) {
                        throw new WFSException(e);
View Full Code Here

            List dataStores = catalog.getDataStores();

            for (Iterator i = dataStores.iterator(); i.hasNext();) {
                DataStoreInfo meta = (DataStoreInfo) i.next();
                DataStore dataStore = null;
               
                // TODO: support locking for DataAccess
                if (meta.isEnabled()) {
                    DataAccess da = meta.getDataStore(null);
                    if ( da instanceof DataStore ) {
                        dataStore = (DataStore) da;
                    }
                }
               
                if ( dataStore == null ) {
                    continue; // disabled or not a DataStore
                }

                LockingManager lockingManager = dataStore.getLockingManager();

                if (lockingManager == null) {
                    continue; // locks not supported
                }
View Full Code Here

        try {
            List dataStores = catalog.getDataStores();

            for (Iterator i = dataStores.iterator(); i.hasNext();) {
                DataStoreInfo meta = (DataStoreInfo) i.next();
                DataStore dataStore = null;
               
                // TODO: support locking for DataAccess
                if (meta.isEnabled()) {
                    DataAccess da = meta.getDataStore(null);
                    if ( da instanceof DataStore ) {
                        dataStore = (DataStore) da;
                    }
                }
               
                if ( dataStore == null ) {
                    continue; // disabled or not a DataStore
                }

                LockingManager lockingManager = dataStore.getLockingManager();

                if (lockingManager == null) {
                    continue; // locks not supported
                }
View Full Code Here

        try {
            List dataStores = catalog.getDataStores();

            for (Iterator i = dataStores.iterator(); i.hasNext();) {
                DataStoreInfo meta = (DataStoreInfo) i.next();
                DataStore dataStore = null;
               
                // TODO: support locking for DataAccess
                if (meta.isEnabled()) {
                    DataAccess da = meta.getDataStore(null);
                    if ( da instanceof DataStore ) {
                        dataStore = (DataStore) da;
                    }
                }
               
                if ( dataStore == null ) {
                    continue; // disabled or not a DataStore
                }

                LockingManager lockingManager = dataStore.getLockingManager();

                if (lockingManager == null) {
                    continue; // locks not supported
                }
View Full Code Here

            List dataStores = catalog.getDataStores();

            for (Iterator i = dataStores.iterator(); i.hasNext();) {
                DataStoreInfo meta = (DataStoreInfo) i.next();
                DataStore dataStore = null;
               
                // TODO: support locking for DataAccess
                if (meta.isEnabled()) {
                    DataAccess da = meta.getDataStore(null);
                    if ( da instanceof DataStore ) {
                        dataStore = (DataStore) da;
                    }
                }
               
                if ( dataStore == null ) {
                    continue; // disabled or not a DataStore
                }
               
                LockingManager lockingManager = dataStore.getLockingManager();

                if (lockingManager == null) {
                    continue; // locks not supported
                }
View Full Code Here

        // TODO: support aliasing (renaming), reprojection, versioning, and locking for DataAccess
        if (!(dataAccess instanceof DataStore)) {
            return dataAccess.getFeatureSource(info.getQualifiedName());
        }
       
        DataStore dataStore = (DataStore) dataAccess;
        FeatureSource<SimpleFeatureType, SimpleFeature> fs;
               
        //
        // aliasing and type mapping
        //
        final String typeName = info.getNativeName();
        final String alias = info.getName();
        final SimpleFeatureType nativeFeatureType = dataStore.getSchema( typeName );
        final SimpleFeatureType featureType = (SimpleFeatureType) getFeatureType( info );
        if ( !typeName.equals( alias ) || DataUtilities.compare(nativeFeatureType,featureType) != 0 ) {
           
            RetypingDataStore retyper = new RetypingDataStore(dataStore) {
           
                @Override
                protected String transformFeatureTypeName(String originalName) {
                    if(!typeName.equals(originalName))
                        return originalName;
                    return alias;
                }
               
                @Override
                protected SimpleFeatureType transformFeatureType(SimpleFeatureType original)
                        throws IOException {
                    if ( original.getTypeName().equals( typeName ) ) {
                        return featureType;
                    }
                    return super.transformFeatureType(original);
                }
           
            };
            fs = retyper.getFeatureSource(alias);
        }
        else {
            //normal case
            fs = dataStore.getFeatureSource(info.getQualifiedName());  
        }

        //
        // reprojection
        //
View Full Code Here

TOP

Related Classes of org.geotools.data.DataStore

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.