Changeset 298

Show
Ignore:
Timestamp:
02/05/10 22:24:19 (2 years ago)
Author:
jgao
Message:

BridgeRest?: cache supportedSrc/TgtDataSources and attributeSet; support spaces in organism name.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/corelib/src/org/bridgedb/webservice/bridgerest/BridgeRest.java

    r288 r298  
    5555                /** {@inheritDoc} */ 
    5656                public IDMapper connect(String location) throws IDMapperException  { 
    57                         return new BridgeRest(location); 
     57                        // replace all spaces by "%20" to access organisms such as "Arabidopsis theliana" 
     58                        return new BridgeRest(location.replaceAll(" ", "%20")); 
    5859                } 
    5960        } 
     
    143144                        throws IDMapperException  
    144145                { 
    145                         return loadDataSources("sourceDataSources"); 
     146                        if (supportedSrcDataSources==null) { 
     147                                supportedSrcDataSources = loadDataSources("sourceDataSources"); 
     148                        } 
     149                        return supportedSrcDataSources; 
    146150                } 
    147151 
     
    150154                        throws IDMapperException  
    151155                { 
    152                         return loadDataSources("targetDataSources"); 
     156                        if (supportedTgtDataSources==null) { 
     157                                supportedTgtDataSources = loadDataSources("targetDataSources"); 
     158                        } 
     159                        return supportedTgtDataSources; 
    153160                } 
    154161 
     
    180187 
    181188        private final IDMapperCapabilities capabilities; 
     189 
     190        private Set<DataSource> supportedSrcDataSources = null; 
     191        private Set<DataSource> supportedTgtDataSources = null; 
     192        private Set<String> attributeSet = null; 
    182193 
    183194        /** 
     
    446457        /** {@inheritDoc} */ 
    447458        public Set<String> getAttributeSet() throws IDMapperException { 
    448                 try { 
    449                         Set<String> results = new HashSet<String>(); 
    450  
    451                         BufferedReader in = new UrlBuilder ("attributeSet") 
    452                                 .openReader(); 
    453                         String line; 
    454                         while ((line = in.readLine()) != null) { 
    455                                 results.add(line); 
    456                         } 
    457                         in.close(); 
    458                         return results; 
    459                 } catch (IOException ex) { 
    460                         throw new IDMapperException (ex); 
    461                 }  
     459                if (attributeSet==null) { 
     460                        try { 
     461                                Set<String> results = new HashSet<String>(); 
     462 
     463                                BufferedReader in = new UrlBuilder ("attributeSet") 
     464                                        .openReader(); 
     465                                String line; 
     466                                while ((line = in.readLine()) != null) { 
     467                                        results.add(line); 
     468                                } 
     469                                in.close(); 
     470                                attributeSet = results; 
     471                        } catch (IOException ex) { 
     472                                throw new IDMapperException (ex); 
     473                        } 
     474                } 
     475 
     476                return attributeSet; 
    462477        } 
    463478