String sql = getSql(); PreparedStatement stmt = null; if ( autogenColumn == null ) {
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 ); } } } }
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; }
ir.addPreparedArgument( new SQLIdentifier( "data" ), getAsByteArray( registryPackage.getElement() ) ); LOG.debug( "Execute statement " + ir.getSql() );