Package org.geotools.data

Examples of org.geotools.data.DataAccess


        IService service = serviceExtension.createService( null, params );
        assertNotNull("connected", service );
       
        assertTrue("Datastore available", service.canResolve( DataStore.class));
       
        DataAccess dataStore = service.resolve( DataStore.class, null );
        assertNotNull("DataStore connected", dataStore );
       
        Name typeName = (Name) dataStore.getNames().get(0);;
        FeatureSource featureSource = dataStore.getFeatureSource( typeName );
       
        assertEquals( 4, featureSource.getCount( Query.ALL ) );
       
        //IServiceInfo info = service.getInfo(new NullProgressMonitor());
        IServiceInfo info = getInfo(service, new NullProgressMonitor());
View Full Code Here


                // Don't count locks from disabled datastores.
                continue;
            }

            try {
                DataAccess store = meta.getDataStore(null);
                if(store instanceof DataStore) {
                    LockingManager lockingManager = ((DataStore) store).getLockingManager();
                    if (lockingManager != null){
                        // we can't actually *count* locks right now?
                        // count += lockingManager.getLockSet().size();
View Full Code Here

    public String getProject() {
        return storeInfo.getName();
    }

    public void run() {
        DataAccess da = null;
        try {
            NamespaceInfo namespace = catalog.getNamespaceByPrefix(storeInfo.getWorkspace().getName());

            // prepare
            CatalogBuilder builder = new CatalogBuilder(catalog);
            da = storeInfo.getDataStore(null);
            StyleGenerator styles = new StyleGenerator(catalog);
           
            // cast necessary due to some classpath oddity/geoapi issue, the compiler
            // complained about getNames() returning a List<Object>...
            List<Name> names = da.getNames();
            summary.setTotalLayers(names.size());
            for (Name name : names) {
                // start information
                String layerName = name.getLocalPart();
                summary.newLayer(layerName);

                LayerInfo layer = null;
                try {
                    builder.setStore(storeInfo);
                    FeatureTypeInfo featureType = builder.buildFeatureType(name);
                    builder.lookupSRS(featureType, true);
                    builder.setupBounds(featureType);
                    layer = builder.buildLayer(featureType);
                    layer.setDefaultStyle(styles.getStyle(featureType));
                    ImportStatus status = SUCCESS;
                   
                    if(cancelled)
                        return;
                   
                    // if we have a default
                    if (layer.getResource().getSRS() == null && layer.getResource().getNativeCRS() != null
                            && defaultSRS != null) {
                        layer.getResource().setSRS(defaultSRS);
                        layer.getResource().setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
                        status = DEFAULTED_SRS;
                    }

                    // handler common error conditions
                    if (catalog.getFeatureTypeByName(namespace, layerName) != null) {
                        status = DUPLICATE;
                    } else if (layer.getResource().getSRS() == null && defaultSRS == null) {
                        status = MISSING_SRS;
                    } else if (layer.getResource().getLatLonBoundingBox() == null) {
                        status = MISSING_BBOX;
                    } else {
                        // try to save the layer
                        catalog.add(featureType);
                        try {
                            catalog.add(layer);
                        } catch(Exception e) {
                            // will be caught by the external try/catch, here we just try to undo
                            // the feature type saving (transactions, where are thou)
                            catalog.remove(featureType);
                            throw e;
                        }
                    }
                    summary.completeLayer(layerName, layer, status);
                } catch (Exception e) {
                    e.printStackTrace();
                    summary.completeLayer(layerName, layer, e);
                }
               
                if(cancelled)
                    return;
            }

            summary.end();
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Import process failed", e);
            summary.end(e);
        } finally {
            if(da != null)
                da.dispose();
        }
    }
View Full Code Here

                // Don't count locks from disabled datastores.
                continue;
            }

            try {
                DataAccess store = meta.getDataStore(null);
                if(store instanceof DataStore) {
                    LockingManager lockingManager = ((DataStore) store).getLockingManager();
                    if (lockingManager != null){
                        // we can't actually *count* locks right now?
                        // count += lockingManager.getLockSet().size();
View Full Code Here

                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;
                    }
                }
               
View Full Code Here

                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;
                    }
                }
               
View Full Code Here

                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;
                    }
                }
               
View Full Code Here

                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;
                    }
                }
               
View Full Code Here

    }
   
   
    public void testReadOnlyFeatureSourceDataAccess() throws Exception {
        // build the mock up
        DataAccess da = createNiceMock(DataAccess.class);
        replay(da);
        FeatureSource fs = createNiceMock(FeatureSource.class);
        expect(fs.getDataStore()).andReturn(da);
        replay(fs);
       
View Full Code Here

            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);
        }
        else if (store instanceof CoverageStoreInfo) {
View Full Code Here

TOP

Related Classes of org.geotools.data.DataAccess

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.