public BBoxTableMapping( String ftTable, ICRS crs ) { this.ftTable = new TableName( ftTable ); this.crs = crs; }
/** * Creates a new {@link BlobMapping} instance. * * @param table * the name of the table that stores the BLOBs, must not be <code>null</code> * @param storageCRS * crs used for storing geometries / envelopes, must not be <code>null</code> * @param codec * the decoder / encoder used for the BLOBs, must not be <code>null</code> */ public BlobMapping( String table, ICRS storageCRS, BlobCodec codec ) { this.table = new TableName( table ); this.storageCRS = storageCRS; this.codec = codec; }
public static TableName createFromQualifiedName( String tableName ) { String table = tableName; String schema = null; if ( table.contains( "." ) ) { String[] splittedQualifiedTableName = table.split( "[.]" ); schema = splittedQualifiedTableName[0]; table = splittedQualifiedTableName[1]; } return new TableName( table, schema ); } }
private List<TableJoin> generateJoinChain( MappingContext from, MappingContext to ) { TableName fromTable = new TableName( from.getTable() ); TableName toTable = new TableName( to.getTable() ); List<String> fromColumns = Collections.singletonList( from.getIdColumn() ); List<String> toColumns = Collections.singletonList( "parentfk" ); List<String> orderColumns = Collections.singletonList( "num" ); Map<SQLIdentifier, IDGenerator> keyColumnToIdGenerator = new HashMap<SQLIdentifier, IDGenerator>(); keyColumnToIdGenerator.put( new SQLIdentifier( "id" ), new AutoIDGenerator() ); TableJoin join = new TableJoin( fromTable, toTable, fromColumns, toColumns, orderColumns, true, keyColumnToIdGenerator ); return Collections.singletonList( join ); }
private TableJoin generateFtJoin( MappingContext from, FeatureType valueFt ) { if ( valueFt != null && valueFt.getSchema().getSubtypes( valueFt ).length == 1 ) { LOG.warn( "Ambigous feature join." ); } TableName fromTable = new TableName( from.getTable() ); TableName toTable = new TableName( "?" ); List<String> fromColumns = Collections.singletonList( from.getColumn() ); List<String> toColumns = Collections.singletonList( detectPrimaryKeyColumnName() ); Map<SQLIdentifier, IDGenerator> keyColumnToIdGenerator = new HashMap<SQLIdentifier, IDGenerator>(); keyColumnToIdGenerator.put( new SQLIdentifier( "id" ), new AutoIDGenerator() ); return new TableJoin( fromTable, toTable, fromColumns, toColumns, Collections.EMPTY_LIST, false, keyColumnToIdGenerator ); }
UpdateRow ur = new UpdateRow( new TableName( mainTable ) ); ur.addPreparedArgument( "version", null ); ur.addPreparedArgument( "status", null );
private FeatureTypeMapping buildFtMapping( FeatureTypeMappingJAXB ftMappingConf ) throws FeatureStoreException { QName ftName = ftMappingConf.getName(); TableName ftTable = new TableName( ftMappingConf.getTable() ); FIDMapping fidMapping = buildFIDMapping( ftTable, ftName, ftMappingConf.getFIDMapping() ); List<Mapping> particleMappings = new ArrayList<Mapping>(); XSElementDeclaration elDecl = gmlSchema.getGMLSchema().getElementDecl( ftName ); for ( JAXBElement<? extends AbstractParticleJAXB> particle : ftMappingConf.getAbstractParticle() ) { particleMappings.add( buildMapping( ftTable, new Pair<XSElementDeclaration, Boolean>( elDecl, TRUE ), particle.getValue() ) ); } return new FeatureTypeMapping( ftName, ftTable, fidMapping, particleMappings ); }
private void process( FeatureTypeMappingJAXB ftDecl ) throws SQLException, FeatureStoreException { if ( ftDecl.getTable() == null || ftDecl.getTable().isEmpty() ) { String msg = "Feature type element without or with empty table attribute."; throw new FeatureStoreException( msg ); } TableName table = new TableName( ftDecl.getTable() ); LOG.debug( "Processing feature type mapping for table '" + table + "'." ); if ( getColumnMetadataFromDb( table ).isEmpty() ) { throw new FeatureStoreException( "No table with name '" + table + "' exists (or no columns defined)." ); } QName ftName = ftDecl.getName(); if ( ftName == null ) { LOG.debug( "Using table name for feature type." ); ftName = new QName( table.getTable() ); } ftName = makeFullyQualified( ftName, "app", "http://www.deegree.org/app" ); LOG.debug( "Feature type name: '" + ftName + "'." ); FIDMapping fidMapping = buildFIDMapping( table, ftName, ftDecl.getFIDMapping() ); List<JAXBElement<? extends AbstractParticleJAXB>> propDecls = ftDecl.getAbstractParticle(); if ( propDecls != null && !propDecls.isEmpty() ) { buildFeatureTypeAndMapping( table, ftName, fidMapping, propDecls ); } else { buildFeatureTypeAndMapping( table, ftName, fidMapping ); } }
private void process( FeatureTypeJAXB ftDecl ) throws SQLException, FeatureStoreException { if ( ftDecl.getTable() == null || ftDecl.getTable().isEmpty() ) { String msg = "Feature type element without or with empty table attribute."; throw new FeatureStoreException( msg ); } TableName table = new TableName( ftDecl.getTable() ); LOG.debug( "Processing feature type mapping for table '" + table + "'." ); if ( getColumns( table ).isEmpty() ) { throw new FeatureStoreException( "No table with name '" + table + "' exists (or no columns defined)." ); } QName ftName = ftDecl.getName(); if ( ftName == null ) { LOG.debug( "Using table name for feature type." ); ftName = new QName( table.getTable() ); } ftName = makeFullyQualified( ftName, "app", "http://www.deegree.org/app" ); LOG.debug( "Feature type name: '" + ftName + "'." ); FIDMapping fidMapping = buildFIDMapping( table, ftName, ftDecl.getFIDMapping() ); List<JAXBElement<? extends AbstractPropertyJAXB>> propDecls = ftDecl.getAbstractProperty(); if ( propDecls != null && !propDecls.isEmpty() ) { process( table, ftName, fidMapping, propDecls ); } else { process( table, ftName, fidMapping ); } }
stmt.execute(); InsertRow ir = new InsertRow( new TableName( "management" ), null ); ir.addPreparedArgument( new SQLIdentifier( "key" ), "REGISTRYPACKAGE_ID" ); ir.addPreparedArgument( new SQLIdentifier( "value" ), insertedId ); ir.performInsert( conn ); ir = new InsertRow( new TableName( "management" ), null ); ir.addPreparedArgument( new SQLIdentifier( "key" ), "LAST_INSERTED" ); ir.addPreparedArgument( new SQLIdentifier( "value" ), ISO8601Converter.formatDateTime( new Date() ) );
private void insertInKeywordTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<Keyword> keywords = qp.getKeywords(); if ( keywords != null && keywords.size() > 0 ) { for ( Keyword keyword : keywords ) { InsertRow ir = new InsertRow( new TableName( keywordTable ), null ); try { int localId = getNewIdentifier( conn, keywordTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "keywordtype", keyword.getKeywordType() ); ir.addPreparedArgument( "keywords", concatenate( keyword.getKeywords() ) ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
private void insertInOperatesOnTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<OperatesOnData> opOns = qp.getOperatesOnData(); if ( opOns != null && opOns.size() > 0 ) { for ( OperatesOnData opOn : opOns ) { InsertRow ir = new InsertRow( new TableName( opOnTable ), null ); try { int localId = getNewIdentifier( conn, opOnTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "operateson", opOn.getOperatesOnId() ); ir.addPreparedArgument( "operatesonid", opOn.getOperatesOnIdentifier() ); ir.addPreparedArgument( "operatesonname", opOn.getOperatesOnName() ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
TableName table = new TableName( mc.getTable() );
private void insertInCRSTable( Connection conn, int operatesOnId, QueryableProperties qp ) throws MetadataStoreException { List<CRS> crss = qp.getCrs(); if ( crss != null && crss.size() > 0 ) { for ( CRS crs : crss ) { InsertRow ir = new InsertRow( new TableName( crsTable ), null ); try { int localId = getNewIdentifier( conn, crsTable ); ir.addPreparedArgument( idColumn, localId ); ir.addPreparedArgument( fk_main, operatesOnId ); ir.addPreparedArgument( "authority", ( crs.getAuthority() != null && crs.getAuthority().length() > 0 ) ? crs.getAuthority() : null ); ir.addPreparedArgument( "crsid", ( crs.getCrsId() != null && crs.getCrsId().length() > 0 ) ? crs.getCrsId() : null ); ir.addPreparedArgument( "version", ( crs.getVersion() != null && crs.getVersion().length() > 0 ) ? crs.getVersion() : null ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } } } }
@Override public synchronized int executeInsert( Connection conn, ISORecord rec ) throws MetadataStoreException, XMLStreamException { int internalId = 0; InsertRow ir = new InsertRow( new TableName( mainTable ), null ); try { internalId = getLastDatasetId( conn, mainTable ); internalId++; ir.addPreparedArgument( idColumn, internalId ); ir.addPreparedArgument( recordColumn, rec.getAsByteArray() ); ir.addPreparedArgument( "fileidentifier", rec.getIdentifier() ); ir.addPreparedArgument( "version", null ); ir.addPreparedArgument( "status", null ); appendValues( rec, ir ); LOG.debug( ir.getSql() ); ir.performInsert( conn ); QueryableProperties qp = rec.getParsedElement().getQueryableProperties(); insertNewValues( conn, internalId, qp ); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", ir.getSql(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } return internalId; }
private void insertAssociation( Association association, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_association.name() ), null ); addRegistryObject( ir, association ); ir.addPreparedArgument( new SQLIdentifier( "sourceObject" ), association.getSourceObject() ); ir.addPreparedArgument( new SQLIdentifier( "targetObject" ), association.getTargetObject() ); ir.addPreparedArgument( new SQLIdentifier( "associationType" ), association.getAssociationType() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( association.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassification( Classification classification, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classification.name() ), null ); addRegistryObject( ir, classification ); ir.addPreparedArgument( new SQLIdentifier( "classificationNode" ), classification.getClassificationNode() ); ir.addPreparedArgument( new SQLIdentifier( "classifiedObject" ), classification.getClassifiedObject() ); ir.addPreparedArgument( new SQLIdentifier( "classificationScheme" ), classification.getClassificationScheme() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classification.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
private void insertClassificationNode( ClassificationNode classificationNode, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_classificationNode.name() ), null ); addRegistryObject( ir, classificationNode ); ir.addPreparedArgument( new SQLIdentifier( "parent" ), classificationNode.getParent() ); ir.addPreparedArgument( new SQLIdentifier( "code" ), classificationNode.getCode() ); ir.addPreparedArgument( new SQLIdentifier( "path" ), classificationNode.getPath() ); ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( classificationNode.getElement() ) ); ir.addPreparedArgument( new SQLIdentifier( "fk_registrypackage" ), regPackId ); ir.performInsert( conn ); }
throws MetadataStoreException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_registrypackage.name() ), null ); try { int id = getNewId( conn );
private void insertExtrinsicObject( ExtrinsicObject eo, int regPackId, Connection conn ) throws SQLException { InsertRow ir = new InsertRow( new TableName( Table.idxtb_extrinsicobject.name() ), null ); addRegistryObject( ir, eo );