001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq.db.biosql;
023
024import java.util.Map;
025
026import org.biojava.bio.BioException;
027import org.biojava.bio.seq.db.SequenceDBLite;
028import org.biojava.directory.RegistryException;
029import org.biojava.directory.SequenceDBProvider;
030
031/**
032 * @author Thomas Down
033 * @deprecated Use hibernate and org.biojavax.bio.db.*
034 */
035public class BioSQLSequenceDBProvider implements SequenceDBProvider {
036    public String getName() {
037        return "biosql";
038    }
039
040    public SequenceDBLite getSequenceDB(Map config)
041        throws RegistryException, BioException
042    {
043        String location = (String) config.get("location");
044        if (location == null) {
045            throw new RegistryException("BioSQL provider requires"
046                                    + " a 'location' parameter");
047        }
048
049        String dbName = (String) config.get("dbname");
050        if (dbName == null) {
051            throw new RegistryException("BioSQL provider requires"
052                                    + " a 'dbname' parameter");
053        }
054
055        String biodatabase = (String) config.get("biodbname");
056        if (biodatabase == null) {
057            throw new RegistryException("BioSQL provider requires"
058                                    + " a 'biodbname' parameter");
059        }
060
061        String userName = (String) config.get("user");
062        if (userName == null) {
063            throw new RegistryException("BioSQL provider requires"
064                                    + " a 'user' parameter");
065        }
066
067        String password = (String) config.get("passwd");
068        if (password == null) {
069            throw new RegistryException("BioSQL provider requires"
070                                    + " a 'passwd' parameter");
071        }
072
073        String driver = (String) config.get("driver");
074        if (driver== null) {
075            throw new RegistryException("BioSQL provider requires"
076                                    + " a 'driver' parameter");
077        }
078
079        return new BioSQLSequenceDB(driver,
080                                                                                                                                location,
081                                userName,
082                                password,
083                                biodatabase,
084                                false);
085    }
086}