/** * Creates a new {@link DDLCreator} instance for the given {@link MappedAppSchema}. * * @param schema * mapped application schema, must not be <code>null</code> * @param dialect * SQL dialect, must not be <code>null</code> */ protected DDLCreator( MappedAppSchema schema, SQLDialect dialect ) { this.schema = schema; this.dialect = dialect; hasBlobTable = schema.getBlobMapping() != null; }
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; }
TableName blobTable = schema.getBlobMapping().getTable(); ddl.add( "CREATE TABLE " + blobTable + " (id integer not null, " + "gml_id varchar2(4000) NOT NULL, ft_type integer REFERENCES " + ftTable + " for each row begin select " + blobTable + "_id_seq.nextval into :new.id from dual; end;" ); double[] dom = schema.getBlobMapping().getCRS().getValidDomain();
@Override protected List<String> getBLOBCreates() { List<String> ddl = new ArrayList<String>(); // create feature_type table TableName ftTable = schema.getBBoxMapping().getTable(); String ftTableSchema = ftTable.getSchema() == null ? "public" : ftTable.getSchema(); ddl.add( "CREATE TABLE " + ftTable + " (id smallint PRIMARY KEY, qname text NOT NULL)" ); ddl.add( "COMMENT ON TABLE " + ftTable + " IS 'Ids and bboxes of concrete feature types'" ); ddl.add( "SELECT ADDGEOMETRYCOLUMN('" + ftTableSchema.toLowerCase() + "', '" + ftTable.getTable().toLowerCase() + "','bbox','" + undefinedSrid + "','GEOMETRY',2)" ); // populate feature_type table for ( short ftId = 0; ftId < schema.getFts(); ftId++ ) { QName ftName = schema.getFtName( ftId ); ddl.add( "INSERT INTO " + ftTable + " (id,qname) VALUES (" + ftId + ",'" + ftName + "')" ); } // create gml_objects table TableName blobTable = schema.getBlobMapping().getTable(); String blobTableSchema = blobTable.getSchema() == null ? "public" : blobTable.getSchema(); ddl.add( "CREATE TABLE " + blobTable + " (id serial PRIMARY KEY, " + "gml_id text UNIQUE NOT NULL, ft_type smallint REFERENCES " + ftTable + " , binary_object bytea)" ); ddl.add( "COMMENT ON TABLE " + blobTable + " IS 'All objects (features and geometries)'" ); ddl.add( "SELECT ADDGEOMETRYCOLUMN('" + blobTableSchema.toLowerCase() + "', '" + blobTable.getTable().toLowerCase() + "','gml_bounded_by','" + undefinedSrid + "','GEOMETRY',2)" ); ddl.add( "ALTER TABLE " + blobTable + " ADD CONSTRAINT gml_objects_geochk CHECK (ST_IsValid(gml_bounded_by))" ); ddl.add( "CREATE INDEX gml_objects_sidx ON " + blobTable + " USING GIST (gml_bounded_by)" ); // ddl.add( "CREATE TABLE gml_names (gml_object_id integer REFERENCES gml_objects," // + "name text NOT NULL,codespace text,prop_idx smallint NOT NULL)" ); return ddl; }
@Override protected List<String> getBLOBCreates() { List<String> ddl = new ArrayList<String>(); // create feature_type table TableName ftTable = schema.getBBoxMapping().getTable(); ddl.add( "CREATE TABLE " + ftTable + " (id integer PRIMARY KEY, qname text NOT NULL, bbox GEOMETRY)" ); // populate feature_type table for ( short ftId = 0; ftId < schema.getFts(); ftId++ ) { QName ftName = schema.getFtName( ftId ); ddl.add( "INSERT INTO " + ftTable + " (id,qname) VALUES (" + ftId + ",'" + ftName + "')" ); } // create gml_objects table TableName blobTable = schema.getBlobMapping().getTable(); ddl.add( "CREATE TABLE " + blobTable + " (id integer IDENTITY(1,1) PRIMARY KEY, " + "gml_id varchar(2000) NOT NULL, ft_type integer REFERENCES " + ftTable + " , binary_object varbinary(max), gml_bounded_by GEOMETRY)" ); ddl.add( "ALTER TABLE " + blobTable + " ADD CONSTRAINT gml_objects_geochk CHECK (gml_bounded_by.STIsValid() = 1)" ); double[] dom = schema.getBlobMapping().getCRS().getValidDomain(); ddl.add( "CREATE SPATIAL INDEX gml_objects_sidx ON " + blobTable + "(gml_bounded_by) WITH ( BOUNDING_BOX = ( " + ArrayUtils.join( ",", dom ) + " ) )" ); // ddl.add( "CREATE INDEX gml_objects_sidx ON " + blobTable + " USING GIST (gml_bounded_by GIST_GEOMETRY_OPS)" // ); // ddl.add( "CREATE TABLE gml_names (gml_object_id integer REFERENCES gml_objects," // + "name text NOT NULL,codespace text,prop_idx smallint NOT NULL)" ); return ddl; }
@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; }
conn = getConnection(); BlobMapping blobMapping = getSchema().getBlobMapping();
if ( schema.getBlobMapping() != null ) { writeBlobMapping( writer, schema.getBlobMapping() );
this.blobMapping = schema.getBlobMapping(); initConverters(); try {
if ( getSchema().getBlobMapping() != null ) { return queryHitsByOperatorFilterBlob( query, ftName, filter );
BlobMapping blobMapping = getSchema().getBlobMapping(); FeatureBuilder builder = new FeatureBuilderBlob( this, blobMapping ); List<String> columns = builder.getInitialSelectList();
if ( getSchema().getBlobMapping() != null ) { return queryByOperatorFilterBlob( query, ftName, filter ); List<String> columns = builder.getInitialSelectList(); BlobMapping blobMapping = getSchema().getBlobMapping();
/** * Creates a new {@link SQLFeatureStoreTransaction} instance. * * @param store * corresponding feature store instance, must not be <code>null</code> * @param conn * JDBC connection associated with the transaction, must not be <code>null</code> and have * <code>autocommit</code> set to <code>false</code> * @param schema * application schema with mapping information, must not be <code>null</code> * @param inspectors * feature inspectors, must not be <code>null</code> */ SQLFeatureStoreTransaction( SQLFeatureStore store, Connection conn, MappedAppSchema schema, List<FeatureInspector> inspectors ) { this.fs = store; this.conn = conn; this.schema = schema; this.inspectors = inspectors; blobMapping = schema.getBlobMapping(); if ( blobMapping != null ) { DBField bboxColumn = new DBField( blobMapping.getBBoxColumn() ); GeometryStorageParams geometryParams = new GeometryStorageParams( blobMapping.getCRS(), null, DIM_2 ); GeometryMapping blobGeomMapping = new GeometryMapping( null, true, bboxColumn, GeometryType.GEOMETRY, geometryParams, null ); blobGeomConverter = fs.getGeometryConverter( blobGeomMapping ); } this.bboxTracker = new BBoxTracker(); }
if ( getSchema().getBlobMapping() != null && queries[0].getFilter() == null && queries[0].getSortProperties().length == 0 ) { wmsStyleQuery = true;