Changeset 504 for trunk

Show
Ignore:
Timestamp:
03/03/11 18:26:55 (15 months ago)
Author:
martijn
Message:

Add transitive option to GdbProvider? and REST server,
GdbProvider? now uses IDMapperStack internally,
Changed command line option handling in REST server.

Location:
trunk
Files:
1 added
20 modified

Legend:

Unmodified
Added
Removed
  • trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/GdbProvider.java

    r322 r504  
    3030import org.bridgedb.IDMapper; 
    3131import org.bridgedb.IDMapperException; 
     32import org.bridgedb.IDMapperStack; 
    3233import org.bridgedb.bio.Organism; 
    3334 
     
    4142 */ 
    4243public class GdbProvider { 
    43         Map<Organism, List<IDMapper>> organism2gdb = new HashMap<Organism, List<IDMapper>>(); 
     44        Map<Organism, IDMapperStack> organism2gdb = new HashMap<Organism, IDMapperStack>(); 
    4445        List<IDMapper> globalGdbs = new ArrayList<IDMapper>(); 
    4546         
     
    5051         
    5152        public void addOrganismGdb(Organism organism, IDMapper gdb) { 
    52                 List<IDMapper> l = organism2gdb.get(organism); 
     53                IDMapperStack l = organism2gdb.get(organism); 
    5354                if(l == null) { 
    54                         organism2gdb.put(organism, l = new ArrayList<IDMapper>()); 
     55                        organism2gdb.put(organism, l = new IDMapperStack()); 
     56                        l.setTransitive(transitive); 
    5557                } 
    56                 if(!l.contains(gdb)) { 
    57                         l.add(gdb); 
    58                 } 
     58                l.addIDMapper(gdb); 
    5959        } 
    6060         
    6161        public void removeOrganismGdb(Organism organism, IDMapperRdb gdb) { 
    62                 List<IDMapper> l = organism2gdb.get(organism); 
     62                IDMapperStack l = organism2gdb.get(organism); 
    6363                if(l != null) { 
    64                         l.remove(gdb); 
     64                        l.removeIDMapper(gdb); 
    6565                } 
    6666        } 
     
    7474        } 
    7575         
    76         public List<IDMapper> getGdbs(Organism organism) { 
    77                 List<IDMapper> gdbs = organism2gdb.get(organism); 
     76        public IDMapperStack getGdbs(Organism organism) { 
     77                IDMapperStack gdbs = organism2gdb.get(organism); 
    7878                if(gdbs == null) { 
    79                         gdbs = new ArrayList<IDMapper>(); 
     79                        gdbs = new IDMapperStack(); 
     80                        gdbs.setTransitive(transitive); 
    8081                } 
    81                 gdbs.addAll(globalGdbs); 
     82                for (IDMapper globalGdb : globalGdbs) 
     83                { 
     84                        gdbs.addIDMapper(globalGdb); 
     85                } 
    8286                return gdbs; 
    8387        } 
     
    8589        static final String DB_GLOBAL = "*"; 
    8690         
    87         public static GdbProvider fromConfigFile(File f) throws IDMapperException, IOException, ClassNotFoundException { 
     91        private final boolean transitive; 
     92        GdbProvider() { this(false); } 
     93        GdbProvider(boolean transitive) 
     94        { 
     95                this.transitive = transitive; 
     96        } 
     97         
     98        public static GdbProvider fromConfigFile(File f, boolean transitive) throws IDMapperException, IOException, ClassNotFoundException { 
    8899                System.out.println("Parsing gene database configuration: " + f.getAbsolutePath()); 
    89                 GdbProvider gdbs = new GdbProvider(); 
     100                GdbProvider gdbs = new GdbProvider(transitive); 
    90101                BufferedReader in = new BufferedReader(new FileReader(f)); 
    91102                String line = in.readLine(); 
  • trunk/org.bridgedb.server/.classpath

    r477 r504  
    77        <classpathentry kind="lib" path="lib/restlet-2.0m6/org.restlet.jar"/> 
    88        <classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-5.1.7-bin.jar"/> 
     9        <classpathentry kind="lib" path="lib/commons-cli-1.2.jar"/> 
    910        <classpathentry combineaccessrules="false" kind="src" path="/org.bridgedb.rdb"/> 
    1011        <classpathentry kind="output" path="bin"/> 
  • trunk/org.bridgedb.server/build.xml

    r390 r504  
    1818                <pathelement location="../dist/org.bridgedb.rdb.jar"/> 
    1919                <pathelement location="lib/restlet-2.0m6/org.restlet.jar"/> 
     20                <pathelement location="lib/commons-cli-1.2.jar"/> 
    2021        </path> 
    2122         
     
    4243  <target name="dist" depends="jar"> 
    4344        <copy toDir="${dist.dir}" file="lib/restlet-2.0m6/org.restlet.jar"/> 
     45        <copy toDir="${dist.dir}" file="lib/commons-cli-1.2.jar"/> 
    4446  </target> 
    4547 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/AttributeSearch.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashMap; 
    2019import java.util.Map; 
    2120 
    22 import org.bridgedb.AttributeMapper; 
    23 import org.bridgedb.IDMapper; 
     21import org.bridgedb.IDMapperStack; 
    2422import org.bridgedb.Xref; 
    2523import org.restlet.data.Status; 
     
    5654                try  
    5755                { 
    58                         Map<Xref, String> results = new HashMap<Xref, String>(); 
    59  
    60                         for(IDMapper mapper : getIDMappers() ) { 
    61                                 if(mapper instanceof AttributeMapper) { 
    62                                         results.putAll(((AttributeMapper)mapper).freeAttributeSearch(searchStr, attribute, limit)); 
    63                                 } 
    64                         } 
     56                        IDMapperStack mapper = getIDMappers(); 
     57                        Map<Xref, String> results = mapper.freeAttributeSearch(searchStr, attribute, limit); 
    6558 
    6659                        StringBuilder result = new StringBuilder(); 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/AttributeSet.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashSet; 
    2019import java.util.Set; 
    2120 
    22 import org.bridgedb.AttributeMapper; 
    23 import org.bridgedb.IDMapper; 
     21import org.bridgedb.IDMapperStack; 
    2422import org.restlet.data.Status; 
    2523import org.restlet.resource.Get; 
     
    3230                try 
    3331                { 
    34                         Set<String> attributes = new HashSet<String>(); 
    35                          
    36                     for(IDMapper mapper : getIDMappers())  
    37                     { 
    38                         if(mapper instanceof AttributeMapper) { 
    39                                 attributes.addAll(((AttributeMapper)mapper).getAttributeSet()); 
    40                         } 
    41                     } 
     32                    IDMapperStack mapper = getIDMappers();  
     33                        Set<String> attributes = mapper.getAttributeSet(); 
    4234                    StringBuilder result = new StringBuilder(); 
    4335                    for(String a : attributes) { 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Attributes.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashMap; 
    20 import java.util.HashSet; 
    2119import java.util.Map; 
    2220import java.util.Set; 
    2321 
    24 import org.bridgedb.AttributeMapper; 
    2522import org.bridgedb.DataSource; 
    26 import org.bridgedb.IDMapper; 
    2723import org.bridgedb.IDMapperException; 
     24import org.bridgedb.IDMapperStack; 
    2825import org.bridgedb.Xref; 
    2926import org.restlet.data.Status; 
     
    7269         
    7370        private String getAttributesWithType() throws IDMapperException { 
    74                 Set<String> values = new HashSet<String>(); 
    75                  
    76                 for(IDMapper mapper : getIDMappers()) { 
    77                         if(mapper instanceof AttributeMapper) { 
    78                                 values.addAll(((AttributeMapper)mapper).getAttributes(xref, attrType)); 
    79                         } 
    80                 } 
     71                IDMapperStack mapper = getIDMappers(); 
     72                Set<String> values = mapper.getAttributes(xref, attrType); 
    8173                StringBuilder str = new StringBuilder(); 
    8274                for(String v : values) { 
     
    8880         
    8981        private String getAttributesWithoutType() throws IDMapperException { 
    90                 Map<String, Set<String>> values = new HashMap<String, Set<String>>(); 
    91                  
    92                 for(IDMapper mapper : getIDMappers()) { 
    93                         if(mapper instanceof AttributeMapper) { 
    94                                 values.putAll(((AttributeMapper)mapper).getAttributes(xref)); 
    95                         } 
    96                 } 
     82                IDMapperStack mapper = getIDMappers(); 
     83                Map<String, Set<String>> values = mapper.getAttributes(xref); 
    9784                StringBuilder str = new StringBuilder(); 
    9885                for(String attr : values.keySet()) { 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/BackPageText.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashSet; 
    2019import java.util.Set; 
    2120 
    22 import org.bridgedb.AttributeMapper; 
    2321import org.bridgedb.DataSource; 
    24 import org.bridgedb.IDMapper; 
     22import org.bridgedb.IDMapperStack; 
    2523import org.bridgedb.Xref; 
    2624import org.restlet.data.Status; 
     
    5957        public String getBackPageText()  
    6058        { 
    61           System.out.println( "Xrefs.getBackPageText() start" ); 
    62           try  
    63           { 
    64             //The result set 
    65             Set<String> bpInfoSym = new HashSet<String>(); 
    66             Set<String> bpInfoDes = new HashSet<String>(); 
    67             Set<String> bpInfoTyp = new HashSet<String>(); 
    68             Set<String> bpInfoChr = new HashSet<String>(); 
    69             Set<String> bpInfoSyn = new HashSet<String>(); 
    70              
    71             for(IDMapper mapper : getIDMappers())  
    72             { 
    73                 if (mapper instanceof AttributeMapper) 
    74                 { 
    75                         AttributeMapper attr = (AttributeMapper)mapper; 
    76                                 bpInfoSym.addAll(attr.getAttributes( xref, "Symbol")); 
    77                                 bpInfoDes.addAll(attr.getAttributes( xref, "Description")); 
    78                                 bpInfoTyp.addAll(attr.getAttributes( xref, "Type")); 
    79                                 bpInfoChr.addAll(attr.getAttributes( xref, "Chromosome")); 
    80                                 bpInfoSyn.addAll(attr.getAttributes( xref, "Synonyms")); 
    81                 } 
    82             } 
    83              
    84             StringBuilder result = new StringBuilder(); 
    85             result.append("<html><body><table>"); 
    86             for( String x : bpInfoSym ) { 
    87               result.append("<tr><td>Symbol</td><td>" + x + "</td></tr>" ); 
    88             } 
    89             for( String x : bpInfoDes ) { 
    90               result.append("<tr><td>Description</td><td>" + x + "</td></tr>" ); 
    91             } 
    92             for( String x : bpInfoTyp ) { 
    93               result.append("<tr><td>Type</td><td>" + x + "</td></tr>" ); 
    94             } 
    95             for( String x : bpInfoChr ) { 
    96               result.append("<tr><td>Chromosome</td><td>" + x + "</td></tr>" ); 
    97             } 
    98             for( String x : bpInfoSyn ) { 
    99               result.append("<tr><td>Synonyms</td><td>" + x + "</td></tr>" ); 
    100             } 
    101             result.append("</table></body></html>"); 
    102             return( result.toString() ); 
    103           } catch( Exception e ) { 
    104             e.printStackTrace(); 
    105             setStatus( Status.SERVER_ERROR_INTERNAL ); 
    106             return e.getMessage(); 
    107           } 
     59                System.out.println( "Xrefs.getBackPageText() start" ); 
     60                try  
     61                { 
     62                        IDMapperStack mapper = getIDMappers(); 
     63 
     64                        //The result set 
     65                        Set<String> bpInfoSym = mapper.getAttributes( xref, "Symbol"); 
     66                        Set<String> bpInfoDes = mapper.getAttributes( xref, "Description"); 
     67                        Set<String> bpInfoTyp = mapper.getAttributes( xref, "Type"); 
     68                        Set<String> bpInfoChr = mapper.getAttributes( xref, "Chromosome"); 
     69                        Set<String> bpInfoSyn = mapper.getAttributes( xref, "Synonyms"); 
     70 
     71                        StringBuilder result = new StringBuilder(); 
     72                        result.append("<html><body><table>"); 
     73                        for( String x : bpInfoSym ) { 
     74                                result.append("<tr><td>Symbol</td><td>" + x + "</td></tr>" ); 
     75                        } 
     76                        for( String x : bpInfoDes ) { 
     77                                result.append("<tr><td>Description</td><td>" + x + "</td></tr>" ); 
     78                        } 
     79                        for( String x : bpInfoTyp ) { 
     80                                result.append("<tr><td>Type</td><td>" + x + "</td></tr>" ); 
     81                        } 
     82                        for( String x : bpInfoChr ) { 
     83                                result.append("<tr><td>Chromosome</td><td>" + x + "</td></tr>" ); 
     84                        } 
     85                        for( String x : bpInfoSyn ) { 
     86                                result.append("<tr><td>Synonyms</td><td>" + x + "</td></tr>" ); 
     87                        } 
     88                        result.append("</table></body></html>"); 
     89                        return( result.toString() ); 
     90                } catch( Exception e ) { 
     91                        e.printStackTrace(); 
     92                        setStatus( Status.SERVER_ERROR_INTERNAL ); 
     93                        return e.getMessage(); 
     94                } 
    10895        } 
    10996 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Config.java

    r322 r504  
    44 
    55import org.bridgedb.BridgeDb; 
    6 import org.bridgedb.rdb.GdbProvider; 
    7 import org.bridgedb.bio.Organism; 
    86import org.restlet.data.Status; 
    97import org.restlet.resource.Get; 
     
    3331        } 
    3432         
    35         private GdbProvider getGdbProvider() { 
    36                 return ((IDMapperService)getApplication()).getGdbProvider(); 
    37         }        
    3833} 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Contents.java

    r322 r504  
    11package org.bridgedb.server; 
    22 
    3 import java.util.Properties; 
    4  
    5 import org.bridgedb.BridgeDb; 
    63import org.bridgedb.rdb.GdbProvider; 
    74import org.bridgedb.bio.Organism; 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/FreeSearch.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashSet; 
    2019import java.util.Set; 
    2120 
     
    5352                try  
    5453                { 
    55                         Set<Xref> results = new HashSet<Xref>(); 
    56  
    57                         for(IDMapper mapper : getIDMappers() ) { 
    58                                 if(mapper.getCapabilities().isFreeSearchSupported()) { 
    59                                         results.addAll(mapper.freeSearch(searchStr, limit)); 
    60                                 } 
    61                         } 
     54                        IDMapper mapper = getIDMappers(); 
     55                        Set<Xref> results = mapper.freeSearch(searchStr, limit); 
    6256 
    6357                        StringBuilder result = new StringBuilder(); 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/IDMapperResource.java

    r308 r504  
    1919import java.io.UnsupportedEncodingException; 
    2020import java.net.URLDecoder; 
    21 import java.util.ArrayList; 
    22 import java.util.List; 
    2321 
    2422import org.bridgedb.DataSource; 
    25 import org.bridgedb.IDMapper; 
     23import org.bridgedb.IDMapperStack; 
    2624import org.bridgedb.bio.Organism; 
    2725import org.bridgedb.rdb.GdbProvider; 
     
    3432 */ 
    3533public class IDMapperResource extends ServerResource { 
    36         private List<IDMapper> mappers; 
     34        private IDMapperStack mappers; 
    3735        private String orgName; 
    3836         
     
    7977                        throw new IllegalArgumentException("Unknown organism: " + orgName + "<p><font size='+1'><i>Double check the spelling. We are expecting an entry like: Human</i></font></p>"); 
    8078                } 
    81                 mappers = new ArrayList<IDMapper>(getGdbProvider().getGdbs(org)); 
    82                 if (mappers.isEmpty()){ 
     79                mappers = getGdbProvider().getGdbs(org); 
     80                if (mappers.getSize() == 0) 
     81                { 
    8382                        throw new IllegalArgumentException("No database found for: " + orgName +"<p><font size='+1'><i>Verify that the database is supported and properly referenced in gdb.config.</i></font></p>"); 
    8483                } 
    8584        } 
    86         protected List<IDMapper> getIDMappers() { 
     85        protected IDMapperStack getIDMappers() { 
    8786                return mappers; 
    8887        } 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/IDMapperService.java

    r322 r504  
    4848 
    4949        public final File configFile; 
    50  
    51         public IDMapperService(File aConfigFile) 
     50        private boolean transitive; 
     51 
     52        public IDMapperService(File aConfigFile, boolean transitive) 
    5253        { 
     54                this.transitive = transitive; 
    5355                if (aConfigFile == null) 
    5456                { 
     
    299301                        gdbFile = new File(gdbconf[0]); 
    300302                } 
    301                 gdbProvider = GdbProvider.fromConfigFile(gdbFile); 
     303                gdbProvider = GdbProvider.fromConfigFile(gdbFile, transitive); 
    302304        } 
    303305} 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/IsFreeSearchSupported.java

    r308 r504  
    2828                try 
    2929                { 
    30                         boolean isSupported = false; 
    31                     for(IDMapper mapper : getIDMappers())  
    32                     { 
    33                         if(mapper.getCapabilities().isFreeSearchSupported()) { 
    34                                 isSupported = true; 
    35                                 break; 
    36                         } 
    37                     } 
     30                        IDMapper mapper = getIDMappers(); 
     31                        boolean isSupported = mapper.getCapabilities().isFreeSearchSupported(); 
    3832                    return "" + isSupported; 
    3933                }  
  • trunk/org.bridgedb.server/src/org/bridgedb/server/IsMappingSupported.java

    r308 r504  
    5050        public String isMappingSupported() { 
    5151                try { 
    52                         boolean supported = false; 
    53                         for(IDMapper m : getIDMappers()) { 
    54                                 if(m.getCapabilities().isMappingSupported(srcDs, destDs)) { 
    55                                         supported = true; 
    56                                         break; 
    57                                 } 
    58                         } 
     52                         
     53                        IDMapper m = getIDMappers(); 
     54                        boolean supported = m.getCapabilities().isMappingSupported(srcDs, destDs); 
    5955                        return "" + supported; 
    6056                } catch(Exception e) { 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Properties.java

    r308 r504  
    1818 
    1919import org.bridgedb.IDMapper; 
     20import org.bridgedb.IDMapperStack; 
    2021import org.restlet.data.Status; 
    2122import org.restlet.resource.Get; 
     
    2930                { 
    3031                StringBuilder result = new StringBuilder(); 
    31                     for(IDMapper mapper : getIDMappers())  
     32                IDMapperStack stack = getIDMappers(); 
     33                    for(int i = 0; i < stack.getSize(); ++i)  
    3234                    { 
     35                        IDMapper mapper = stack.getIDMapperAt(i); 
    3336                        for (String key : mapper.getCapabilities().getKeys()) 
    3437                        { 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Server.java

    r474 r504  
    1919import java.io.File; 
    2020 
     21import org.apache.commons.cli.CommandLine; 
     22import org.apache.commons.cli.CommandLineParser; 
     23import org.apache.commons.cli.HelpFormatter; 
     24import org.apache.commons.cli.Option; 
     25import org.apache.commons.cli.OptionBuilder; 
     26import org.apache.commons.cli.Options; 
     27import org.apache.commons.cli.ParseException; 
     28import org.apache.commons.cli.PosixParser; 
    2129import org.restlet.Component; 
    2230import org.restlet.data.Protocol; 
     
    2634        private Component component; 
    2735 
    28         public void run(int port, File configFile) 
     36        public void run(int port, File configFile, boolean transitive) 
    2937        { 
    3038                component = new Component(); 
    3139                component.getServers().add(Protocol.HTTP, port); 
    32                 component.getDefaultHost().attach(new IDMapperService(configFile));              
     40                component.getDefaultHost().attach(new IDMapperService(configFile, transitive));          
    3341                try { 
    3442                        System.out.println ("Starting server on port " + port); 
     
    5159        public static void main(String[] args)  
    5260        { 
    53                 Server server = new Server(); 
    54                  
    5561                int port = 8183; // default port 
    56                 if ( args.length > 0 ) 
    57                 { 
    58                   port = new Integer( args[0] ).intValue(); 
    59                 } 
    60          
     62                boolean transitive = false; 
    6163                File configFile = null; 
    6264                 
    63                 if (args.length > 1) 
     65                Options options = new Options(); 
     66                options.addOption(OptionBuilder.withArgName("port") 
     67                                .hasArg() 
     68                                .withDescription("Port to use (default: 8183)") 
     69                                .create("p")); 
     70                options.addOption("t", false, "Enable transitive mode (default: false)"); 
     71                options.addOption(OptionBuilder.withArgName("file") 
     72                                .hasArg() 
     73                                .withDescription("Override configuration file (default: gdb.config)") 
     74                                .create("f")); 
     75                options.addOption("h", false, "Print help and quit"); 
     76                CommandLineParser parser = new PosixParser(); 
     77                try 
    6478                { 
    65                         configFile = new File(args[1]); 
     79                        CommandLine line = parser.parse (options, args); 
     80                        if (line.getArgs().length > 0) throw new ParseException("Unknown options: " + line.getArgList()); 
     81                        if (line.hasOption("h")) 
     82                        { 
     83                                HelpFormatter formatter = new HelpFormatter(); 
     84                                formatter.printHelp( "startserver.sh", options ); 
     85                                System.exit(0); 
     86                        } 
     87                         
     88                        if (line.hasOption("p")) port = Integer.parseInt(line.getOptionValue("p")); 
     89                        if (line.hasOption("f")) configFile = new File (line.getOptionValue("f")); 
     90                        if (line.hasOption("t")) transitive = true;  
     91                                 
     92                } 
     93                catch (Exception e) 
     94                { 
     95                        System.err.println ("Did not understand command line options. Reason: " + e.getClass().getName() + " " + e.getMessage()); 
     96                        HelpFormatter formatter = new HelpFormatter(); 
     97                        formatter.printHelp( "startserver.sh", options ); 
     98                        System.exit(-1); 
    6699                } 
    67100                 
    68                 if (args.length > 2) 
    69                 { 
    70                         System.err.println ("Expected max 2 arguments"); 
    71                         System.exit(1); 
    72                 } 
    73                  
    74                 server.run (port, configFile); 
     101                Server server = new Server(); 
     102                                 
     103                server.run (port, configFile, transitive); 
    75104        } 
    76105} 
  • trunk/org.bridgedb.server/src/org/bridgedb/server/SupportedSourceDataSources.java

    r308 r504  
    3030                { 
    3131                StringBuilder result = new StringBuilder(); 
    32                     for(IDMapper mapper : getIDMappers())  
    33                     { 
    34                         for (DataSource ds : mapper.getCapabilities().getSupportedSrcDataSources()) 
    35                         { 
    36                                 result.append(ds.getFullName()); 
    37                                 result.append ("\n"); 
    38                         } 
    39                     } 
     32                IDMapper mapper = getIDMappers(); 
     33                for (DataSource ds : mapper.getCapabilities().getSupportedSrcDataSources()) 
     34                { 
     35                        result.append(ds.getFullName()); 
     36                        result.append ("\n"); 
     37                } 
    4038                    return result.toString(); 
    4139                }  
  • trunk/org.bridgedb.server/src/org/bridgedb/server/SupportedTargetDataSources.java

    r308 r504  
    3030                { 
    3131                StringBuilder result = new StringBuilder(); 
    32                     for(IDMapper mapper : getIDMappers())  
    33                     { 
    34                         for (DataSource ds : mapper.getCapabilities().getSupportedTgtDataSources()) 
    35                         { 
    36                                 result.append(ds.getFullName()); 
    37                                 result.append ("\n"); 
    38                         } 
    39                     } 
     32                    IDMapper mapper = getIDMappers();  
     33                for (DataSource ds : mapper.getCapabilities().getSupportedTgtDataSources()) 
     34                { 
     35                        result.append(ds.getFullName()); 
     36                        result.append ("\n"); 
     37                } 
    4038                    return result.toString(); 
    4139                }  
  • trunk/org.bridgedb.server/src/org/bridgedb/server/XrefExists.java

    r308 r504  
    4949                try 
    5050                { 
    51                         boolean exists = false; 
    52                     for(IDMapper mapper : getIDMappers())  
    53                     { 
    54                         if(mapper.xrefExists(xref)) { 
    55                                 exists = true; 
    56                                 break; 
    57                         } 
    58                     } 
    59                     return "" + exists; 
     51                    IDMapper mapper = getIDMappers();  
     52                    return "" + mapper.xrefExists(xref); 
    6053                }  
    6154                catch( Exception e )  
  • trunk/org.bridgedb.server/src/org/bridgedb/server/Xrefs.java

    r308 r504  
    1717package org.bridgedb.server; 
    1818 
    19 import java.util.HashSet; 
    2019import java.util.Set; 
    2120 
     
    6362                        //The result set 
    6463 
    65                         IDMapper mapper = getIDMappers().get(0); 
    66                         Set<Xref> xrefs = (targetDs == null) ? mapper.mapID(xref) : mapper.mapID(xref, targetDs); 
    67  
    68                         for (int i = 1; i < getIDMappers().size(); ++i) 
    69                         { 
    70                                 mapper = getIDMappers().get(i); 
    71                                 xrefs.addAll ((targetDs == null) ? mapper.mapID(xref) : mapper.mapID(xref, targetDs)); 
    72                         } 
    73                                          
     64                        IDMapper mapper = getIDMappers(); 
     65                        Set<Xref> xrefs; 
     66                        if (targetDs == null) 
     67                                xrefs = mapper.mapID(xref); 
     68                        else 
     69                                xrefs = mapper.mapID(xref, targetDs); 
     70                         
    7471                        StringBuilder result = new StringBuilder(); 
    7572                        for(Xref x : xrefs) {