Changeset 473
- Timestamp:
- 01/24/11 12:50:33 (16 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
org.bridgedb.rdb/src/org/bridgedb/rdb/SimpleGdbImplCommon.java (modified) (2 diffs)
-
org.bridgedb.webservice.biomart/src/org/bridgedb/webservice/biomart/IDMapperBiomart.java (modified) (1 diff)
-
org.bridgedb.webservice.bridgerest/src/org/bridgedb/webservice/bridgerest/BridgeRest.java (modified) (1 diff)
-
org.bridgedb.webservice.picr/src/org/bridgedb/webservice/picr/IDMapperPicr.java (modified) (1 diff)
-
org.bridgedb/src/org/bridgedb/AttributeMapper.java (modified) (2 diffs)
-
org.bridgedb/src/org/bridgedb/IDMapperStack.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/SimpleGdbImplCommon.java
r459 r473 17 17 import org.bridgedb.IDMapperException; 18 18 import org.bridgedb.Xref; 19 import org.bridgedb.impl.InternalUtils; 19 20 20 21 /** … … 321 322 } 322 323 } 324 325 public Map<Xref, Set<String>> freeAttributeSearchEx (String query, String attrType, int limit) throws IDMapperException 326 { 327 Map<Xref, Set<String>> result = new HashMap<Xref, Set<String>>(); 328 final QueryLifeCycle pst = (MATCH_ID.equals (attrType)) ? 329 qIdSearchWithAttributes : qAttributeSearch; 330 synchronized (pst) { 331 try { 332 pst.init(limit); 333 pst.setString(1, attrType); 334 pst.setString(2, "%" + query.toLowerCase() + "%"); 335 ResultSet r = pst.executeQuery(); 336 337 while(r.next()) 338 { 339 String id = r.getString("id"); 340 String code = r.getString("code"); 341 String symbol = r.getString("attrValue"); 342 Xref ref = new Xref (id, DataSource.getBySystemCode(code)); 343 InternalUtils.multiMapPut(result, ref, symbol); 344 } 345 } catch (SQLException e) { 346 throw new IDMapperException (e); 347 } 348 finally { pst.cleanup(); } 349 return result; 350 } 351 } 323 352 324 353 /** {@inheritDoc} */ -
trunk/org.bridgedb.webservice.biomart/src/org/bridgedb/webservice/biomart/IDMapperBiomart.java
r308 r473 388 388 * {@inheritDoc} 389 389 */ 390 public Map<Xref, Set<String>> freeAttributeSearchEx (String query, String attrType, int limit) throws IDMapperException { 391 throw new UnsupportedOperationException("Free attribute search not supported."); 392 } 393 394 /** 395 * {@inheritDoc} 396 */ 390 397 public Set<String> getAttributeSet() throws IDMapperException { 391 398 return stub.availableTgtAttributes(mart, dataset); -
trunk/org.bridgedb.webservice.bridgerest/src/org/bridgedb/webservice/bridgerest/BridgeRest.java
r347 r473 513 513 } 514 514 } 515 516 @Override 517 public Map<Xref, Set<String>> freeAttributeSearchEx(String query, String attrType, int limit) 518 throws IDMapperException 519 { 520 try { 521 Map<Xref, Set<String>> result = new HashMap<Xref, Set<String>>(); 522 523 BufferedReader in = new UrlBuilder("attributeSearch") 524 .ordered (query).named("limit", "" + limit) 525 .named ("attrName", attrType) 526 .openReader(); 527 String line; 528 while ((line = in.readLine()) != null) { 529 String[] cols = line.split("\t", -1); 530 Xref x = new Xref (cols[0], DataSource.getByFullName(cols[1])); 531 String value = cols[2]; 532 InternalUtils.multiMapPut(result, x, value); 533 } 534 in.close(); 535 return result; 536 } catch (IOException ex) { 537 throw new IDMapperException (ex); 538 } 539 } 515 540 516 541 } -
trunk/org.bridgedb.webservice.picr/src/org/bridgedb/webservice/picr/IDMapperPicr.java
r308 r473 272 272 return result; 273 273 } 274 275 @Override 276 public Map<Xref, Set<String>> freeAttributeSearchEx(String query, String attrType, int limit) 277 throws IDMapperException 278 { 279 throw new UnsupportedOperationException(); 280 } 274 281 } -
trunk/org.bridgedb/src/org/bridgedb/AttributeMapper.java
r308 r473 51 51 52 52 /** 53 * free text search for matching symbols.53 * free text search for matching attributes. 54 54 * @return map references and attribute values that match the query 55 55 * @param query The text to search for … … 61 61 public Map<Xref, String> freeAttributeSearch (String query, String attrType, int limit) throws IDMapperException; 62 62 63 /** 64 * Improved version of free text search for matching attributes. 65 * Unlike freeAttributeSearch, this method may return multiple results per xref. 66 * @return map of references and attribute values that match the query 67 * @param query The text to search for 68 * @param attrType the attribute to look for, e.g. 'Symbol' or 'Description'. 69 * If you use the special MATCH_ID constant, it will query the identifier instead. 70 * @param limit The number of results to limit the search to 71 * @throws IDMapperException if the mapping service is (temporarily) unavailable 72 */ 73 public Map<Xref, Set<String>> freeAttributeSearchEx (String query, String attrType, int limit) throws IDMapperException; 74 63 75 /** use this magic constant as the attrType parameter to also search for identifiers. */ 64 76 public static final String MATCH_ID = "org.bridgedb.MATCH_ID"; -
trunk/org.bridgedb/src/org/bridgedb/IDMapperStack.java
r337 r473 386 386 } 387 387 388 public Map<Xref, Set<String>> freeAttributeSearchEx (String query, String attrType, int limit) throws IDMapperException 389 { 390 Map<Xref, Set<String>> result = new HashMap<Xref, Set<String>>(); 391 for (IDMapper child : gdbs) 392 { 393 if (child != null && child instanceof AttributeMapper && child.isConnected() 394 && ((AttributeMapper)child).isFreeAttributeSearchSupported()) 395 { 396 Map<Xref, Set<String>> childResult = 397 ((AttributeMapper)child).freeAttributeSearchEx(query, attrType, limit); 398 if (result == null) 399 result = childResult; 400 else 401 { 402 for (Xref ref : childResult.keySet()) 403 { 404 if (!result.containsKey(ref)) 405 result.put (ref, childResult.get(ref)); 406 } 407 } 408 } 409 } 410 return result; 411 } 412 388 413 /** @return concatenation of toString of each child */ 389 414 @Override public String toString() … … 533 558 return result; 534 559 } 535 536 560 }
