MappedAppSchema getSchema() { return fs.getSchema(); }
public Map<String, String> getNamespaceContext() { if ( nsContext == null ) { nsContext = new HashMap<String, String>( getSchema().getNamespaceBindings() ); nsContext.put( "xlink", XLNNS ); nsContext.put( "xsi", XSINS ); nsContext.put( "ogc", OGCNS ); } return nsContext; }
short getFtId( QName ftName ) { return getSchema().getFtId( ftName ); }
@Override public FeatureStoreTransaction acquireTransaction() throws FeatureStoreException { SQLFeatureStoreTransaction ta = null; try { final Connection conn = getConnection(); conn.setAutoCommit( false ); ta = new SQLFeatureStoreTransaction( this, conn, getSchema(), inspectors ); transaction.set( ta ); } catch ( SQLException e ) { throw new FeatureStoreException( "Unable to acquire JDBC connection for transaction: " + e.getMessage(), e ); } return ta; }
private byte[] encodeFeatureBlob( final Feature feature, ICRS crs ) throws FactoryConfigurationError, SQLException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final BlobCodec codec = fs.getSchema().getBlobMapping().getCodec(); codec.encode( feature, fs.getNamespaceContext(), bos, crs ); } catch ( Exception e ) { String msg = "Error encoding feature for BLOB: " + e.getMessage(); LOG.error( msg ); LOG.trace( "Stack trace:", e ); throw new SQLException( msg, e ); } byte[] bytes = bos.toByteArray(); return bytes; }
/** * Creates a new {@link InsertRowManager} instance. * * @param fs * feature store, must not be <code>null</code> * @param conn * connection, must not be <code>null</code> * @param idGenMode * feature id generation mode, must not be <code>null</code> */ public InsertRowManager( SQLFeatureStore fs, Connection conn, IDGenMode idGenMode ) { this.fs = fs; this.dialect = fs.getDialect(); this.conn = conn; this.idGenMode = idGenMode; this.tableDeps = fs.getSchema().getKeyDependencies(); }
private GMLObject getObjectByIdRelational( String id ) throws FeatureStoreException { GMLObject result = null; IdAnalysis idAnalysis = getSchema().analyzeId( id ); if ( !idAnalysis.isFid() ) { String msg = "Fetching of geometries by id (relational mode) is not implemented yet."; throw new UnsupportedOperationException( msg ); } FeatureInputStream rs = queryByIdFilterRelational( null, new IdFilter( id ), null ); try { Iterator<Feature> iter = rs.iterator(); if ( iter.hasNext() ) { result = iter.next(); } } finally { rs.close(); } return result; }
@Override public GMLObject getObjectById( String id ) throws FeatureStoreException { GMLObject geomOrFeature = null; if ( getCache() != null ) { geomOrFeature = getCache().get( id ); } if ( geomOrFeature == null ) { if ( getSchema().getBlobMapping() != null ) { geomOrFeature = getObjectByIdBlob( id, getSchema().getBlobMapping() ); } else { geomOrFeature = getObjectByIdRelational( id ); } } return geomOrFeature; }
LOG.debug( "Recreating object '" + id + "' from bytea." ); BlobCodec codec = blobMapping.getCodec(); geomOrFeature = codec.decode( rs.getBinaryStream( 1 ), getNamespaceContext(), getSchema(), blobMapping.getCRS(), resolver ); if ( getCache() != null ) {
this.schema = fs.getSchema(); this.aliasManager = aliasManager; this.isSpatial = isSpatial;
ws.prepare( id ); SQLFeatureStore fs = (SQLFeatureStore) ws.init( id, null ); String[] sql = DDLCreator.newInstance( fs.getSchema(), fs.getDialect() ).getDDL(); for ( String string : sql ) { System.out.println( string + ";" );
try { for ( String fid : filter.getMatchingIds() ) { IdAnalysis analysis = getSchema().analyzeId( fid ); FeatureType ft = analysis.getFeatureType(); List<IdAnalysis> idKernels = ftNameToIdAnalysis.get( ft.getName() ); FeatureType ft = getSchema().getFeatureType( ftName ); checkIfFeatureTypIsRequested( typeNames, ft ); FeatureTypeMapping ftMapping = getSchema().getFtMapping( ftName ); FIDMapping fidMapping = ftMapping.getFidMapping(); List<IdAnalysis> idKernels = ftNameToIdAnalysis.get( ftName );
@Override public Feature buildFeature( ResultSet rs ) throws SQLException { Feature feature = null; try { String gmlId = rs.getString( 1 ); if ( fs.getCache() != null ) { feature = (Feature) fs.getCache().get( gmlId ); } if ( feature == null ) { LOG.debug( "Recreating object '" + gmlId + "' from db (BLOB/hybrid mode)." ); feature = (Feature) codec.decode( rs.getBinaryStream( 2 ), fs.getNamespaceContext(), fs.getSchema(), crs, fs.getResolver() ); if ( fs.getCache() != null ) { fs.getCache().add( feature ); } } else { LOG.debug( "Cache hit." ); } fs.checkIfFeatureTypIsRequested( typeNames, feature.getType() ); } catch ( Exception e ) { String msg = "Cannot recreate feature from result set: " + e.getMessage(); throw new SQLException( msg, e ); } return feature; }
throws SQLException, FeatureStoreException { LOG.debug( "Inserting feature with id '" + feature.getId() + "' (BLOB)" ); if ( fs.getSchema().getFeatureType( feature.getName() ) == null ) { throw new FeatureStoreException( "Cannot insert feature '" + feature.getName() + "': feature type is not served by this feature store." );
private TypedObjectNode unwrapCustomGeometry( GenericXMLElement particle ) { GMLObjectType ot = fs.getSchema().getGeometryType( particle.getName() ); Geometry geom = null; List<Property> props = new ArrayList<Property>(); return null; AppSchemaGeometryHierarchy hierarchy = fs.getSchema().getGeometryHierarchy(); geom = geomFac.createCurve( geom.getId(), geom.getCoordinateSystem(), segments ); geom.setType( fs.getSchema().getGeometryType( particle.getName() ) ); geom.setProperties( props );
@Override public FeatureInputStream query( Query query ) throws FeatureStoreException, FilterEvaluationException { if ( query.getTypeNames() == null || query.getTypeNames().length > 1 ) { String msg = "Join queries between multiple feature types are not by SQLFeatureStore (yet)."; throw new UnsupportedOperationException( msg ); } FeatureInputStream result = null; Filter filter = query.getFilter(); if ( query.getTypeNames().length == 1 && ( filter == null || filter instanceof OperatorFilter ) ) { QName ftName = query.getTypeNames()[0].getFeatureTypeName(); FeatureType ft = getSchema().getFeatureType( ftName ); if ( ft == null ) { String msg = "Feature store is not configured to serve feature type '" + ftName + "'."; throw new FeatureStoreException( msg ); } result = queryByOperatorFilter( query, ftName, (OperatorFilter) filter ); } else { // must be an id filter based query if ( query.getFilter() == null || !( query.getFilter() instanceof IdFilter ) ) { String msg = "Invalid query. If no type names are specified, it must contain an IdFilter."; throw new FilterEvaluationException( msg ); } result = queryByIdFilter( query.getTypeNames(), (IdFilter) filter, query.getSortProperties() ); } return result; }
if ( getSchema().getBlobMapping() != null && queries[0].getFilter() == null && queries[0].getSortProperties().length == 0 ) { wmsStyleQuery = true;
@Override public int queryHits( Query query ) throws FeatureStoreException, FilterEvaluationException { if ( query.getTypeNames() == null || query.getTypeNames().length > 1 ) { String msg = "Join queries between multiple feature types are not supported by the SQLFeatureStore implementation (yet)."; throw new UnsupportedOperationException( msg ); } Filter filter = query.getFilter(); int hits = 0; if ( query.getTypeNames().length == 1 && ( filter == null || filter instanceof OperatorFilter ) ) { QName ftName = query.getTypeNames()[0].getFeatureTypeName(); FeatureType ft = getSchema().getFeatureType( ftName ); if ( ft == null ) { String msg = "Feature type '" + ftName + "' is not served by this feature store."; throw new FeatureStoreException( msg ); } hits = queryHitsByOperatorFilter( query, ftName, (OperatorFilter) filter ); } else { // must be an id filter based query if ( query.getFilter() == null || !( query.getFilter() instanceof IdFilter ) ) { String msg = "Invalid query. If no type names are specified, it must contain an IdFilter."; throw new FilterEvaluationException( msg ); } // should be no problem iterating over the features (id queries usually request only a few ids) hits = queryByIdFilter( query.getTypeNames(), (IdFilter) filter, query.getSortProperties() ).count(); } return hits; }