private boolean storeSupportsAllRequestedNamespaces( FeatureStore store, Collection<String> namespaces ) { Set<String> appNamespaces = store.getSchema().getAppNamespaces(); return appNamespaces.containsAll( namespaces ); }
/** * Ignores all errors, tries to aggregate all envelopes of all feature types. * * @param fs * @return null, if none of the feature types had an envelope */ public static Envelope getCombinedEnvelope( FeatureStore fs ) { Envelope env = null; for ( FeatureType ft : fs.getSchema().getFeatureTypes() ) { if ( env == null ) { try { env = fs.getEnvelope( ft.getName() ); } catch ( Throwable e ) { // ignore it } } else { try { Envelope b = fs.getEnvelope( ft.getName() ); if ( b != null ) { env = env.merge( b ); } } catch ( Throwable e ) { // ignore it } } } return env; }
@Override public FeatureCollection info() { FeatureCollection col = null; try { col = clearDuplicates( featureStore.query( queries.toArray( new Query[queries.size()] ) ) ); } catch ( Throwable e ) { LOG.warn( "Data could not be fetched from the feature store. The error was '{}'.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } return col; }
private static void insert( FeatureStore fs, String datasetFile, GMLVersion gmlVersion, IDGenMode mode ) throws XMLStreamException, FactoryConfigurationError, IOException, XMLParsingException, UnknownCRSException, FeatureStoreException { File f = new File( datasetFile ); URL url = f.toURI().toURL(); System.out.print( "- Reading dataset: '" + datasetFile + "'..." ); GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader( gmlVersion, url ); gmlReader.setApplicationSchema( fs.getSchema() ); FeatureCollection fc = gmlReader.readFeatureCollection(); System.out.println( "done." ); FeatureStoreTransaction ta = null; try { ta = fs.acquireTransaction(); System.out.print( "- Inserting features..." ); List<String> fids = ta.performInsert( fc, mode ); System.out.println( "done." ); for ( String fid : fids ) { System.out.println( "- Inserted: " + fid ); } System.out.println( "\n- Insert succeeded (" + fids.size() + " features). Committing transaction." ); ta.commit(); } catch ( Exception e ) { e.printStackTrace(); System.err.println( "Error performing insert: " + e.getMessage() ); if ( ta != null ) { ta.rollback(); } } }
Matcher m = pattern.matcher( uri ); if ( m.find() ) { List<FeatureType> fts = fs.getSchema().getFeatureTypes( null, false, false ); TypeName[] typeNames = new TypeName[fts.size()]; for ( int i = 0; i < fts.size(); ++i ) { FeatureInputStream rs = null; try { rs = fs.query( q ); Feature obj = rs.iterator().next(); if ( obj != null ) {
static LayerMetadata buildMetadataForAutoMode( FeatureStore store, FeatureType ft, String name ) { List<ICRS> crs = new ArrayList<ICRS>(); Envelope envelope = null; try { envelope = store.getEnvelope( ft.getName() ); } catch ( Throwable e ) { LOG.debug( "Could not get envelope from feature store: {}", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } if ( envelope != null ) { crs.add( envelope.getCoordinateSystem() ); } SpatialMetadata smd = new SpatialMetadata( envelope, crs ); Description desc = new Description( name, Collections.singletonList( new LanguageString( name, null ) ), null, null ); LayerMetadata md = new LayerMetadata( name, desc, smd ); md.getFeatureTypes().add( ft ); return md; }
@Override public GMLObject getObject( String uri, String baseURL ) { if ( uri.startsWith( "#" ) ) { try { return fs.getObjectById( uri.substring( 1 ) ); } catch ( FeatureStoreException e ) { throw new ReferenceResolvingException( e.getMessage(), e ); } } throw new ReferenceResolvingException( "Resolving of remote references is not implemented yet." ); } }
private FeatureStoreTransaction acquireTransaction( FeatureStore fs ) throws OWSException { FeatureStoreTransaction ta = acquiredTransactions.get( fs ); if ( ta == null ) { try { LOG.debug( "Acquiring transaction for feature store " + fs ); ta = fs.acquireTransaction(); acquiredTransactions.put( fs, ta ); } catch ( FeatureStoreException e ) { throw new OWSException( Messages.get( "WFS_CANNOT_ACQUIRE_TA", e.getMessage() ), NO_APPLICABLE_CODE ); } } return ta; }
private LockManager getLockManager() throws OWSException { LockManager manager = null; try { // TODO strategy for multiple LockManagers / feature stores manager = master.getStoreManager().getStores()[0].getLockManager(); } catch ( FeatureStoreException e ) { LOG.debug( e.getMessage(), e ); throw new OWSException( "Cannot acquire lock manager: " + e.getMessage(), NO_APPLICABLE_CODE ); } return manager; } }
try { FeatureStore fs = service.getStore( ftName ); env = fs.getEnvelope( ftName ); } catch ( FeatureStoreException e ) { LOG.error( "Error retrieving envelope from FeatureStore: " + e.getMessage(), e );
protected GMLObject retrieveObject( String id ) throws OWSException { GMLObject o = null; for ( FeatureStore fs : format.getMaster().getStoreManager().getStores() ) { try { o = fs.getObjectById( id ); } catch ( FeatureStoreException e ) { throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } if ( o != null ) { break; } } if ( o == null ) { String msg = Messages.getMessage( "WFS_NO_SUCH_OBJECT", id ); throw new OWSException( new InvalidParameterValueException( msg ) ); } return o; }
try { manager = service.getStores()[0].getLockManager(); } catch ( FeatureStoreException e ) { throw new OWSException( "Cannot acquire lock manager: " + e.getMessage(),
public FeatureLayerData( List<Query> queries, FeatureStore featureStore, int maxFeatures, Style style, QName ftName ) { this.queries = queries; this.featureStore = featureStore; this.maxFeatures = maxFeatures; this.style = style; Map<String, QName> bindings = new HashMap<String, QName>(); Set<QName> validNames = AppSchemas.collectProperyNames( featureStore.getSchema(), ftName ); for ( QName name : validNames ) { bindings.put( name.getLocalPart(), name ); } evaluator = new TypedObjectNodeXPathEvaluator( bindings ); }
AppSchema schema = this.featureStore.getSchema(); if ( schema == null ) { throw new NullPointerException( "The feature store must have an application schema to work with." ); this.envelope = this.featureStore.getEnvelope( this.rootFT ); this.rasterCache = RasterCache.getInstance( cacheDir, true ); File directory = this.rasterCache.getCacheDirectory();
@Override public void render( RenderContext context ) throws InterruptedException { FeatureInputStream features = null; try { // TODO Should this always be done on this level? What about queueSize value? features = featureStore.query( queries.toArray( new Query[queries.size()] ) ); features = new ThreadedFeatureInputStream( features, 100 ); FeatureStreamRenderer renderer = new FeatureStreamRenderer( context, maxFeatures, evaluator ); renderer.renderFeatureStream( features, style ); } catch ( InterruptedException e ) { throw e; } catch ( FilterEvaluationException e ) { LOG.warn( "A filter could not be evaluated. The error was '{}'.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } catch ( Throwable e ) { LOG.warn( "Data could not be fetched from the feature store. The error was '{}'.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } finally { if ( features != null ) { features.close(); } } }
env = fs.getEnvelope( ftName ); } catch ( FeatureStoreException e ) { LOG.error( "Error retrieving envelope from FeatureStore: " + e.getMessage(), e );
manager = storeManager.getStores()[0].getLockManager(); List<Query> queries = analyzer.getQueries().get( storeManager.getStores()[0] ); lock = manager.acquireLock( queries, lockAll, expiryInMilliseconds );
private Set<String> getExplicitlyRequestedNamespaces( DescribeFeatureType request, WfsFeatureStoreManager storeManager ) { Set<String> set = new LinkedHashSet<String>(); for ( String ns : request.getNsBindings().values() ) { for ( FeatureStore fs : storeManager.getStores() ) { AppSchema schema = fs.getSchema(); if ( schema.getNamespaceBindings().values().contains( ns ) ) { set.add( ns ); break; } } } return set; }
md.setMetadataId( lay.getMetadataSetId() ); if ( featureType != null ) { md.getFeatureTypes().add( store.getSchema().getFeatureType( featureType ) ); } else { md.getFeatureTypes().addAll( Arrays.asList( store.getSchema().getFeatureTypes() ) ); smd.setEnvelope( store.getEnvelope( featureType ) ); } else { smd.setEnvelope( getCombinedEnvelope( store ) );
FeatureStore fs = fsToQueries.getKey(); Query[] queries = fsToQueries.getValue().toArray( new Query[fsToQueries.getValue().size()] ); FeatureInputStream rs = fs.query( queries ); try { for ( Feature member : rs ) {