Legend:
- Unmodified
- Added
- Removed
-
trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/IDMapperRdb.java
r318 r542 19 19 import java.io.File; 20 20 import java.io.IOException; 21 import java.sql.Connection;22 import java.sql.DriverManager;23 import java.sql.SQLException;24 21 import java.util.Collection; 25 22 import java.util.Map; … … 33 30 import org.bridgedb.IDMapperException; 34 31 import org.bridgedb.Xref; 32 import org.bridgedb.XrefIterator; 35 33 import org.bridgedb.impl.InternalUtils; 36 34 … … 39 37 * such as looking up cross-references and backpage text. 40 38 */ 41 public abstract class IDMapperRdb implements IDMapper, AttributeMapper 39 public abstract class IDMapperRdb implements IDMapper, AttributeMapper, XrefIterator 42 40 { 43 41 static … … 125 123 { 126 124 return InternalUtils.mapMultiFromSingle(this, srcXrefs, tgtDataSources); 127 } 125 } 128 126 } -
trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/SimpleGdbImplCommon.java
r473 r542 77 77 "SELECT id, code, attrvalue FROM attribute WHERE " + 78 78 "attrname = ? AND LOWER(ID) LIKE ?" 79 ); 80 final SimpleGdb.QueryLifeCycle qAllXrefs = new SimpleGdb.QueryLifeCycle( 81 "SELECT id, code FROM datanode" 82 ); 83 final SimpleGdb.QueryLifeCycle qAllXrefsByDatasource = new SimpleGdb.QueryLifeCycle( 84 "SELECT id, code FROM datanode WHERE code = ?" 79 85 ); 80 86 … … 375 381 } 376 382 383 @Override 384 public Iterable<Xref> getIterator() throws IDMapperException { 385 Set<Xref> xrefs = new HashSet<Xref>(); 386 final QueryLifeCycle pst = qAllXrefs; 387 synchronized (pst) { 388 try 389 { 390 pst.init(); 391 ResultSet rs = pst.executeQuery(); 392 while (rs.next()) 393 { 394 xrefs.add(new Xref(rs.getString(1), DataSource.getBySystemCode(rs.getString(2)))); 395 } 396 } 397 catch (SQLException ignore) 398 { 399 throw new IDMapperException(ignore); 400 } 401 finally {pst.cleanup(); } 402 return xrefs; 403 } 404 } 405 406 @Override 407 public Iterable<Xref> getIterator(DataSource ds) throws IDMapperException { 408 Set<Xref> xrefs = new HashSet<Xref>(); 409 final QueryLifeCycle pst = qAllXrefsByDatasource; 410 synchronized (pst) { 411 try 412 { 413 pst.init(); 414 pst.setString(1, ds.getSystemCode()); 415 ResultSet rs = pst.executeQuery(); 416 while (rs.next()) 417 { 418 xrefs.add(new Xref(rs.getString(1), ds)); 419 } 420 } 421 catch (SQLException ignore) 422 { 423 throw new IDMapperException(ignore); 424 } 425 finally {pst.cleanup(); } 426 return xrefs; 427 } 428 } 377 429 }
