Update of /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14365
Modified Files:
ChadoAdapter.java ChadoAdapterGUI.java ChadoDatabase.java
Log Message:
Changed chado adapter files to use 2-space indenting.
Index: ChadoAdapter.java
===================================================================
RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/ChadoAdapter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ChadoAdapter.java 23 Apr 2004 20:12:23 -0000 1.3
--- ChadoAdapter.java 27 Apr 2004 14:42:05 -0000 1.4
***************
*** 102,126 ****
public class ChadoAdapter extends AbstractApolloAdapter {
! // These constants are used by the GUI to communicate connection info using <code>setStateInformation</code>.
! public static String DRIVER_CLASS = "DRIVER_CLASS";
! public static String JDBC_URL = "JDBC_URL";
! public static String CHADO_DB = "CHADO_DB";
! public static String USERNAME = "USERNAME";
! public static String PASSWORD = "PASSWORD";
! public static String SEQUENCE_TYPE = "SEQUENCE_TYPE";
! public static String SEQUENCE_ID = "SEQUENCE_ID";
! public static String ORGANISM_LIKE = "ORGANISM_LIKE";
! /**
! * The current driver properties set by the GUI in the most recent call to <code>setStateInformation</code>.
! */
! protected Properties stateInfo = new Properties();
! /**
! * List of predefined Chado databases read from an adapter-specific configuration file and presented
! * to the user in the GUI. The user may also input connection parameters for a database not in
! * this list.
! */
! protected ChadoDatabase[] databases;
/** if true print debugging statements */
--- 102,126 ----
public class ChadoAdapter extends AbstractApolloAdapter {
! // These constants are used by the GUI to communicate connection info using <code>setStateInformation</code>.
! public static String DRIVER_CLASS = "DRIVER_CLASS";
! public static String JDBC_URL = "JDBC_URL";
! public static String CHADO_DB = "CHADO_DB";
! public static String USERNAME = "USERNAME";
! public static String PASSWORD = "PASSWORD";
! public static String SEQUENCE_TYPE = "SEQUENCE_TYPE";
! public static String SEQUENCE_ID = "SEQUENCE_ID";
! public static String ORGANISM_LIKE = "ORGANISM_LIKE";
! /**
! * The current driver properties set by the GUI in the most recent call to <code>setStateInformation</code>.
! */
! protected Properties stateInfo = new Properties();
! /**
! * List of predefined Chado databases read from an adapter-specific configuration file and presented
! * to the user in the GUI. The user may also input connection parameters for a database not in
! * this list.
! */
! protected ChadoDatabase[] databases;
/** if true print debugging statements */
***************
*** 128,425 ****
private boolean DEBUG = false;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! public ChadoAdapter() {
! this.databases = readConfigFile();
! }
! // -----------------------------------------------------------------------
! // AbstractApolloAdapter
! // -----------------------------------------------------------------------
! public Properties getStateInformation() {
! return (this.stateInfo == null) ? null : (Properties)(this.stateInfo.clone());
! }
! // JC: It's not clear why there isn't a strongly-typed interface for passing configuration
! // info. between the GUI and the data adapter class. But that's the way it is.
! public void setStateInformation(Properties p) {
! this.stateInfo = p;
! }
! // Read annotation and/or analysis results from the database
! public CurationSet getCurationSet() throws DataAdapterException {
! // Superclass method
! clearOldData();
! // Properties that specify which Chdado sequence to retrieve
! // (e.g. seqType might be 'assembly' and seqId 'apr_1234_assembly')
! String seqType = this.stateInfo.getProperty(SEQUENCE_TYPE);
! String seqId = this.stateInfo.getProperty(SEQUENCE_ID);
! // Create a JdbcChadoAdapter; all the actual database communication is delegated to this
! // object, allowing us to create subclasses for different Chado implementations (e.g.
! // Sybase, MySQL, PostgreSQL)
! JdbcChadoAdapter chadoAdapter = this.getJdbcChadoAdapter();
! // Superclass method that displays a progress graph
! fireProgressEvent(new ProgressEvent(this, new Double(50.0), "Connecting to chado database"));
! // Check that we can connect to the database and find the requested sequence
! // Throws DataAdapterException if conn or seq invalid
! chadoAdapter.validateConnectionAndSequence(seqType, seqId);
! fireProgressEvent(new ProgressEvent(this, new Double(100.0), "Connecting to chado database"));
! // Retrieve annotation and accompanying sequence
! CurationSet cset = chadoAdapter.getCurationSet(this, seqType, seqId);
! // NOTE - apollo.gui.menus.FileMenu will throw an exception if this method is not called.
! super.setInputType(DataInputType.SEQUENCE);
! // Superclass method
! notifyLoadingDone();
! return cset;
! }
! // Not yet implemented in this adapter
! public Boolean addToCurationSet()
! throws DataAdapterException {
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(String id) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence id=" + id);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(DbXref dbxref) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxref=" + dbxref);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(DbXref dbxref, int start, int end)
! throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxref=" + dbxref + " start=" + start + " end=" + end);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public Vector getSequences(DbXref[] dbxref) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxrefs=" + dbxref);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public Vector getSequences(DbXref[] dbxref, int[] start, int[] end)
! throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxrefs=" + dbxref + " starts=" + start + " ends=" + end);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public String getRawAnalysisResults(String id)
! throws apollo.dataadapter.DataAdapterException {
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public void commitChanges(CurationSet curation)
! throws DataAdapterException {
! throw new NotImplementedException();
! }
! // -----------------------------------------------------------------------
! // org.bdgp.io.AbstractDataAdapter
! // -----------------------------------------------------------------------
! /**
! * Array containing the list of IO operations supported by this adapter; currently the
! * adapter supports read-only access to a Chado database.
! */
! protected IOOperation[] SUPPORTED_OPS = {
! ApolloDataAdapterI.OP_READ_DATA,
! // Add these lines back in when the corresponding support is added:
! // ApolloDataAdapterI.OP_READ_SEQUENCE,
! // ApolloDataAdapterI.OP_WRITE_DATA,
! // ApolloDataAdapterI.OP_APPEND_DATA,
! };
! // Adapter name to be shown in the drop-down menu that appears when the user chooses to read or write data.
! public String getName() { return "Chado"; }
! // JC: not sure where this is used
! public String getType() { return "Chado Adapter"; }
! // Return the list of ops that can be passed to the constructor of this class
! public IOOperation [] getSupportedOperations() { return this.SUPPORTED_OPS; }
! // "Called when adapter is created and added to the registry (see org.bdgp.io.DataAdapterChooser)"
! // Nothing needs to be done here right now.
! public void init() {}
! // Factory method that creates a new UI (i.e., an instance of the corresponding GUI class)
! // for a specified data adapter operation. Creates a new object on every call.
! public DataAdapterUI getUI(IOOperation op) {
! return new ChadoAdapterGUI(op, this.databases);
! }
! // -----------------------------------------------------------------------
! // ChadoAdapter - protected methods
! // -----------------------------------------------------------------------
! /**
! * Factory method that returns an instance of JdbcChadoAdapter, or one of its subclasses;
! * which subclass is used is determined by the GUI. The data adapter configuration file read
! * by <code>readConfigFile</code> allows the GUI to present the user with a list of available
! * Chado databases, each of which will have an associated JdbcChadoAdapter subclass.
! *
! * @return A JdbcChadoAdapter instance capable of communicating with the Chado database
! * instance currently selected by the user in the GUI.
! */
! protected JdbcChadoAdapter getJdbcChadoAdapter() throws DataAdapterException {
!
! // Properties needed to connect to Chado database; these are set by ChadoAdapterGUI
! // via <code>setStateInformation()</code>.
! String driverClass = this.stateInfo.getProperty(DRIVER_CLASS);
! String jdbcUrl = this.stateInfo.getProperty(JDBC_URL);
! String chadoDb = this.stateInfo.getProperty(CHADO_DB);
! String username = this.stateInfo.getProperty(USERNAME);
! String password = this.stateInfo.getProperty(PASSWORD);
! String organismLike = this.stateInfo.getProperty(ORGANISM_LIKE);
! // driverClass specifies which subclass of apollo.dataadapter.chado.jdbc.JdbcChadoAdapter
! // should be used to communicate with this particular type of Chado database
! Class dc = null;
! try {
! dc = Class.forName(driverClass);
! } catch (ClassNotFoundException cnfe) {
! throw new DataAdapterException("Unable to find Chado driver class " + driverClass);
! }
! // Attempt to instantiate an object of the appropriate class; by convention any subclass
! // of JdbcChadoAdapter will have a JavaBean-style 0-argument constructor.
! JdbcChadoAdapter chadoAdapter = null;
! try {
! chadoAdapter = (JdbcChadoAdapter)(dc.newInstance());
! }
! catch (Throwable t) {
! System.err.println(this.getClass() + ": error creating instance of Chado driver class " + driverClass);
! t.printStackTrace(System.err);
! }
! // Pass some essential connection information along to the adapter object.
! chadoAdapter.init(jdbcUrl, chadoDb, username, password, DEBUG, organismLike);
! return chadoAdapter;
}
! /**
! * Read a list of available Chado databases from an adapter-specific configuration file.
! * The Chado adapter will look for a configuration file named "chado-adapter.cfg" in all of
! * the locations that Apollo usually looks for configuration files. It expects to find it
! * in the "conf" subdirectory but will also look in the parent directory (in all the
! * standard locations.) Each line of the configuration file (that is not a blank line or
! * part of a comment) is expected to look like this:<br>
! * <br>
! * <pre>
! * "Chado Cryptococcus database" "apollo.dataadapter.chado.jdbc.SybaseChadoAdapter" "jdbc:sybase:Tds:dbserver.yourcompany.com:2025" "cryptdb" "Cryptococcus%"
! * </pre>
! * <br>
! * The fields do not have to be quoted unless they contain whitespace. The fields are whitespace
! * -delimited and should be interpreted as follows:
! * <ol>
! * <li>A human-readable descriptor that uniquely identifies a single chado database</li>
! * <li>The name of a subclass of apollo.dataadapter.chado.jdbc.JdbcChadoAdapter (or that class itself)</li>
! * <li>A JDBC connection URL for the server on which the database resides</li>
! * <li>The name of the database/schema; the interpretation of this field may be DBMS-specific</li>
! * <li>A string to be used in a 'like' query to restrict which sequences are presented to the user (optional)</li>
! * </ol>
! *
! * @see apollo.util.IOUtil.findFile
! * @return An array of chado database descriptors.
! **/
! protected ChadoDatabase[] readConfigFile() {
! // JC: since apollo.gui.Config does not provide generic routines for parsing
! // configuration files, some of the code found below was copied verbatim from there.
! Vector databases = new Vector();
! String configFileName = apollo.util.IOUtil.findFile("conf/chado-adapter.cfg");
! if (configFileName == null) {
! configFileName = apollo.util.IOUtil.findFile("chado-adapter.cfg");
! }
! if (configFileName == null) {
! System.err.println(this.getClass() + ": warning - unable to find chado-adapter.cfg");
! } else {
! File configFile = new File(configFileName);
! try {
! StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new FileReader(configFile)));
! tokenizer.eolIsSignificant(true);
! tokenizer.slashStarComments(true);
! boolean done = false;
! int tokType = 0;
! Vector fields = new Vector();
!
! while (!done) {
! int lineno = tokenizer.lineno();
! // EOF
! if ((tokType = tokenizer.nextToken()) == StreamTokenizer.TT_EOF) {
! done = true;
! }
! // Another token
! else if (tokType != StreamTokenizer.TT_EOL) {
! fields.addElement(tokenizer.sval);
! }
! // End of line
! else {
! if (fields.size() == 0) {
! // This is OK; can happen on a comment or blank line
! }
! else if (fields.size() > 5) {
! System.err.println(this.getClass() + ": warning - unable to parse line " + lineno + " of " + configFileName +
! " with " + fields.size() + " fields");
! } else {
! String name = (String)(fields.elementAt(0));
! String className = (String)(fields.elementAt(1));
! String url = (String)(fields.elementAt(2));
! String dbName = (String)(fields.elementAt(3));
! // The "like" argument is optional
! String organismLike = (fields.size() >= 5) ? (String)fields.elementAt(4) : null;
! databases.addElement(new ChadoDatabase(name, className, url, dbName, organismLike));
! }
! fields.removeAllElements();
! }
! }
! } catch (Exception e) {
! System.err.println(this.getClass() + ": warning - failed to read " + configFileName);
}
}
! ChadoDatabase result[] = new ChadoDatabase[databases.size()];
! databases.copyInto(result);
! return result;
}
! /**
! * Read a list of sequence IDs and descriptions into two parallel Vectors. The sequence IDs must be
! * values from the chado column feature.uniquename, but the descriptions can be any unique human-readable
! * string that adequately describes the corresponding sequence.
! *
! * @param featType The type of sequence to retrive from the feature table (e.g., 'assembly', 'super-contig')
! * @param uniquenames Vector that will hold the sequence IDs (values from the chado column feature.uniquename)
! * @param descriptions Vector that will hold the human-readable descriptions for the sequences named in <code>uniquenames</code>
! */
! protected void getSequenceList(String featType, Vector uniquenames, Vector descriptions) throws DataAdapterException {
! JdbcChadoAdapter chadoAdapter = this.getJdbcChadoAdapter();
! chadoAdapter.getAllChadoSequencesByType(featType, uniquenames, descriptions);
! }
}
--- 128,425 ----
private boolean DEBUG = false;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! public ChadoAdapter() {
! this.databases = readConfigFile();
! }
! // -----------------------------------------------------------------------
! // AbstractApolloAdapter
! // -----------------------------------------------------------------------
! public Properties getStateInformation() {
! return (this.stateInfo == null) ? null : (Properties)(this.stateInfo.clone());
! }
! // JC: It's not clear why there isn't a strongly-typed interface for passing configuration
! // info. between the GUI and the data adapter class. But that's the way it is.
! public void setStateInformation(Properties p) {
! this.stateInfo = p;
! }
! // Read annotation and/or analysis results from the database
! public CurationSet getCurationSet() throws DataAdapterException {
! // Superclass method
! clearOldData();
! // Properties that specify which Chdado sequence to retrieve
! // (e.g. seqType might be 'assembly' and seqId 'apr_1234_assembly')
! String seqType = this.stateInfo.getProperty(SEQUENCE_TYPE);
! String seqId = this.stateInfo.getProperty(SEQUENCE_ID);
! // Create a JdbcChadoAdapter; all the actual database communication is delegated to this
! // object, allowing us to create subclasses for different Chado implementations (e.g.
! // Sybase, MySQL, PostgreSQL)
! JdbcChadoAdapter chadoAdapter = this.getJdbcChadoAdapter();
! // Superclass method that displays a progress graph
! fireProgressEvent(new ProgressEvent(this, new Double(50.0), "Connecting to chado database"));
! // Check that we can connect to the database and find the requested sequence
! // Throws DataAdapterException if conn or seq invalid
! chadoAdapter.validateConnectionAndSequence(seqType, seqId);
! fireProgressEvent(new ProgressEvent(this, new Double(100.0), "Connecting to chado database"));
! // Retrieve annotation and accompanying sequence
! CurationSet cset = chadoAdapter.getCurationSet(this, seqType, seqId);
! // NOTE - apollo.gui.menus.FileMenu will throw an exception if this method is not called.
! super.setInputType(DataInputType.SEQUENCE);
! // Superclass method
! notifyLoadingDone();
! return cset;
! }
! // Not yet implemented in this adapter
! public Boolean addToCurationSet()
! throws DataAdapterException {
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(String id) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence id=" + id);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(DbXref dbxref) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxref=" + dbxref);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public SequenceI getSequence(DbXref dbxref, int start, int end)
! throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxref=" + dbxref + " start=" + start + " end=" + end);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public Vector getSequences(DbXref[] dbxref) throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxrefs=" + dbxref);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public Vector getSequences(DbXref[] dbxref, int[] start, int[] end)
! throws DataAdapterException {
! System.err.println(this.getClass() + ": getSequence dbxrefs=" + dbxref + " starts=" + start + " ends=" + end);
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public String getRawAnalysisResults(String id)
! throws apollo.dataadapter.DataAdapterException {
! throw new NotImplementedException();
! }
! // Not yet implemented in this adapter
! public void commitChanges(CurationSet curation)
! throws DataAdapterException {
! throw new NotImplementedException();
! }
! // -----------------------------------------------------------------------
! // org.bdgp.io.AbstractDataAdapter
! // -----------------------------------------------------------------------
! /**
! * Array containing the list of IO operations supported by this adapter; currently the
! * adapter supports read-only access to a Chado database.
! */
! protected IOOperation[] SUPPORTED_OPS = {
! ApolloDataAdapterI.OP_READ_DATA,
! // Add these lines back in when the corresponding support is added:
! // ApolloDataAdapterI.OP_READ_SEQUENCE,
! // ApolloDataAdapterI.OP_WRITE_DATA,
! // ApolloDataAdapterI.OP_APPEND_DATA,
! };
! // Adapter name to be shown in the drop-down menu that appears when the user chooses to read or write data.
! public String getName() { return "Chado"; }
! // JC: not sure where this is used
! public String getType() { return "Chado Adapter"; }
! // Return the list of ops that can be passed to the constructor of this class
! public IOOperation [] getSupportedOperations() { return this.SUPPORTED_OPS; }
! // "Called when adapter is created and added to the registry (see org.bdgp.io.DataAdapterChooser)"
! // Nothing needs to be done here right now.
! public void init() {}
! // Factory method that creates a new UI (i.e., an instance of the corresponding GUI class)
! // for a specified data adapter operation. Creates a new object on every call.
! public DataAdapterUI getUI(IOOperation op) {
! return new ChadoAdapterGUI(op, this.databases);
! }
! // -----------------------------------------------------------------------
! // ChadoAdapter - protected methods
! // -----------------------------------------------------------------------
! /**
! * Factory method that returns an instance of JdbcChadoAdapter, or one of its subclasses;
! * which subclass is used is determined by the GUI. The data adapter configuration file read
! * by <code>readConfigFile</code> allows the GUI to present the user with a list of available
! * Chado databases, each of which will have an associated JdbcChadoAdapter subclass.
! *
! * @return A JdbcChadoAdapter instance capable of communicating with the Chado database
! * instance currently selected by the user in the GUI.
! */
! protected JdbcChadoAdapter getJdbcChadoAdapter() throws DataAdapterException {
! // Properties needed to connect to Chado database; these are set by ChadoAdapterGUI
! // via <code>setStateInformation()</code>.
! String driverClass = this.stateInfo.getProperty(DRIVER_CLASS);
! String jdbcUrl = this.stateInfo.getProperty(JDBC_URL);
! String chadoDb = this.stateInfo.getProperty(CHADO_DB);
! String username = this.stateInfo.getProperty(USERNAME);
! String password = this.stateInfo.getProperty(PASSWORD);
! String organismLike = this.stateInfo.getProperty(ORGANISM_LIKE);
! // driverClass specifies which subclass of apollo.dataadapter.chado.jdbc.JdbcChadoAdapter
! // should be used to communicate with this particular type of Chado database
! Class dc = null;
! try {
! dc = Class.forName(driverClass);
! } catch (ClassNotFoundException cnfe) {
! throw new DataAdapterException("Unable to find Chado driver class " + driverClass);
! }
! // Attempt to instantiate an object of the appropriate class; by convention any subclass
! // of JdbcChadoAdapter will have a JavaBean-style 0-argument constructor.
! JdbcChadoAdapter chadoAdapter = null;
! try {
! chadoAdapter = (JdbcChadoAdapter)(dc.newInstance());
! }
! catch (Throwable t) {
! System.err.println(this.getClass() + ": error creating instance of Chado driver class " + driverClass);
! t.printStackTrace(System.err);
}
! // Pass some essential connection information along to the adapter object.
! chadoAdapter.init(jdbcUrl, chadoDb, username, password, DEBUG, organismLike);
! return chadoAdapter;
! }
! /**
! * Read a list of available Chado databases from an adapter-specific configuration file.
! * The Chado adapter will look for a configuration file named "chado-adapter.cfg" in all of
! * the locations that Apollo usually looks for configuration files. It expects to find it
! * in the "conf" subdirectory but will also look in the parent directory (in all the
! * standard locations.) Each line of the configuration file (that is not a blank line or
! * part of a comment) is expected to look like this:<br>
! * <br>
! * <pre>
! * "Chado Cryptococcus database" "apollo.dataadapter.chado.jdbc.SybaseChadoAdapter" "jdbc:sybase:Tds:dbserver.yourcompany.com:2025" "cryptdb" "Cryptococcus%"
! * </pre>
! * <br>
! * The fields do not have to be quoted unless they contain whitespace. The fields are whitespace
! * -delimited and should be interpreted as follows:
! * <ol>
! * <li>A human-readable descriptor that uniquely identifies a single chado database</li>
! * <li>The name of a subclass of apollo.dataadapter.chado.jdbc.JdbcChadoAdapter (or that class itself)</li>
! * <li>A JDBC connection URL for the server on which the database resides</li>
! * <li>The name of the database/schema; the interpretation of this field may be DBMS-specific</li>
! * <li>A string to be used in a 'like' query to restrict which sequences are presented to the user (optional)</li>
! * </ol>
! *
! * @see apollo.util.IOUtil.findFile
! * @return An array of chado database descriptors.
! **/
! protected ChadoDatabase[] readConfigFile() {
! // JC: since apollo.gui.Config does not provide generic routines for parsing
! // configuration files, some of the code found below was copied verbatim from there.
! Vector databases = new Vector();
! String configFileName = apollo.util.IOUtil.findFile("conf/chado-adapter.cfg");
! if (configFileName == null) {
! configFileName = apollo.util.IOUtil.findFile("chado-adapter.cfg");
! }
! if (configFileName == null) {
! System.err.println(this.getClass() + ": warning - unable to find chado-adapter.cfg");
! } else {
! File configFile = new File(configFileName);
! try {
! StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new FileReader(configFile)));
! tokenizer.eolIsSignificant(true);
! tokenizer.slashStarComments(true);
! boolean done = false;
! int tokType = 0;
! Vector fields = new Vector();
!
! while (!done) {
! int lineno = tokenizer.lineno();
! // EOF
! if ((tokType = tokenizer.nextToken()) == StreamTokenizer.TT_EOF) {
! done = true;
! }
! // Another token
! else if (tokType != StreamTokenizer.TT_EOL) {
! fields.addElement(tokenizer.sval);
! }
! // End of line
! else {
! if (fields.size() == 0) {
! // This is OK; can happen on a comment or blank line
! }
! else if (fields.size() > 5) {
! System.err.println(this.getClass() + ": warning - unable to parse line " + lineno + " of " + configFileName +
! " with " + fields.size() + " fields");
! } else {
! String name = (String)(fields.elementAt(0));
! String className = (String)(fields.elementAt(1));
! String url = (String)(fields.elementAt(2));
! String dbName = (String)(fields.elementAt(3));
! // The "like" argument is optional
! String organismLike = (fields.size() >= 5) ? (String)fields.elementAt(4) : null;
! databases.addElement(new ChadoDatabase(name, className, url, dbName, organismLike));
}
+ fields.removeAllElements();
+ }
}
! } catch (Exception e) {
! System.err.println(this.getClass() + ": warning - failed to read " + configFileName);
! }
}
! ChadoDatabase result[] = new ChadoDatabase[databases.size()];
! databases.copyInto(result);
! return result;
! }
!
! /**
! * Read a list of sequence IDs and descriptions into two parallel Vectors. The sequence IDs must be
! * values from the chado column feature.uniquename, but the descriptions can be any unique human-readable
! * string that adequately describes the corresponding sequence.
! *
! * @param featType The type of sequence to retrive from the feature table (e.g., 'assembly', 'super-contig')
! * @param uniquenames Vector that will hold the sequence IDs (values from the chado column feature.uniquename)
! * @param descriptions Vector that will hold the human-readable descriptions for the sequences named in <code>uniquenames</code>
! */
! protected void getSequenceList(String featType, Vector uniquenames, Vector descriptions) throws DataAdapterException {
! JdbcChadoAdapter chadoAdapter = this.getJdbcChadoAdapter();
! chadoAdapter.getAllChadoSequencesByType(featType, uniquenames, descriptions);
! }
}
Index: ChadoAdapterGUI.java
===================================================================
RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/ChadoAdapterGUI.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ChadoAdapterGUI.java 22 Apr 2004 15:07:03 -0000 1.3
--- ChadoAdapterGUI.java 27 Apr 2004 14:42:05 -0000 1.4
***************
*** 41,534 ****
public class ChadoAdapterGUI extends AbstractDataAdapterUI implements ActionListener, ItemListener {
! // -----------------------------------------------------------------------
! // Static variables
! // -----------------------------------------------------------------------
! /**
! * NOTE - subclasses of JdbcChadoAdapter must be explicitly added to this list in order to be
! * usable in the Chado adapter. This is a limitation that could be removed if necessary.
! Yes - this should come from config.
! */
! protected static String DRIVER_CLASSES[] = new String[] {
! "apollo.dataadapter.chado.jdbc.PostgresChadoAdapter",
! "apollo.dataadapter.chado.jdbc.SybaseChadoAdapter"
! };
! /**
! * Prompt for the pull-down menu that allows the user to select a Chado database from
! * among those read from the Chado adapter's configuration file.
! */
! protected static String CUSTOM_DB_PROMPT = "Enter database info. below or select from list";
! /**
! * Prompt for the area in which the user can enter the ID of the sequence he/she wishes
! * to load.
! */
! protected static String CUSTOM_SEQ_PROMPT = "Enter a sequence ID below:";
! // -----------------------------------------------------------------------
! // Instance variables
! // -----------------------------------------------------------------------
! /**
! * The IOOperation (e.g. reading/writing) that this object was created to support.
! */
! protected IOOperation op;
! /**
! * List of Chado databases read by the ChadoAdapter from its configuration file.
! *
! * @see ChadoAdapter.readConfigFile
! */
! protected ChadoDatabase[] chado_dbs;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! /**
! * @param op The IOOperation that this GUI was invoked to perform.
! * @param chado_dbs A list of Chado database descriptors from which the user may choose.
! */
! public ChadoAdapterGUI(IOOperation op, ChadoDatabase chado_dbs[]) {
! this.op = op;
! this.chado_dbs = chado_dbs;
! this.makeUI();
! }
! // -----------------------------------------------------------------------
! // AbstractDataAdapterUI
! // -----------------------------------------------------------------------
! // NOTE - Not yet implemented. The sample adapter uses this information to extract
! // the user's previous choices from the Apollo history file.
! public void setProperties(Properties props) {}
! // The properties returned by this method are written to the Apollo history file.
! public Properties getProperties() {
! return new Properties(); // not yet implemented
! }
! // The main method supported by the GUI; called when the user clicks on "OK" to read annotation,
! // write sequence, or do whatever operation is appropriate (so long as it is supported by the
! // adapter.)
! public Object doOperation(Object values) throws DataAdapterException {
! ChadoAdapter adapter = getAndInitAdapter();
! IOOperation op = this.getOperation();
! // This is the only operation supported so far.
! if (op.equals(ApolloDataAdapterI.OP_READ_DATA)) {
! return adapter.getCurationSet();
! }
! else if (op.equals(ApolloDataAdapterI.OP_WRITE_DATA)) {
! System.err.println(this.getClass() + ".doOperation: OP_WRITE_DATA unsupported");
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
! }
! else if (op.equals(ApolloDataAdapterI.OP_READ_SEQUENCE)) {
! System.err.println(this.getClass() + ".doOperation: OP_READ_SEQUENCE unsupported");
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
! }
! else if (op.equals(ApolloDataAdapterI.OP_READ_RAW_ANALYSIS)) {
! System.err.println(this.getClass() + ".doOperation: OP_READ_RAW_ANALYSIS unsupported");
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
! }
! else if (op.equals(ApolloDataAdapterI.OP_APPEND_DATA)) {
! System.err.println(this.getClass() + ".doOperation: OP_APPEND_DATA unsupported");
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
! }
! else {
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
! }
}
! // -----------------------------------------------------------------------
! // ActionListener
! // -----------------------------------------------------------------------
!
! /**
! * A list of chado feature.uniquenames read from the current database by the ChadoAdapter.
! */
! String sequenceUniquenames[];
! public void actionPerformed(ActionEvent e) {
! // seqChoiceButton
! if (e.getSource() == seqChoiceButton) {
! // If we have valid connection info. tell the adaptor to query the database for a list of sequences
! try {
! ChadoAdapter adapter = getAndInitAdapter();
! Vector uniquenames = new Vector();
! Vector descriptions = new Vector();
! adapter.getSequenceList(getSequenceType(), uniquenames, descriptions);
! int nn = uniquenames.size();
! // Populate the seqChoiceComboBox with the retrieved sequence descriptions
! this.clearSeqChoiceComboBox();
! for (int i = 0;i < nn;++i) {
! String descr = (String)(descriptions.elementAt(i));
! this.seqChoiceComboBox.addItem(descr);
! }
! if (nn > 0) { this.seqChoiceComboBox.setEnabled(true); }
! this.sequenceUniquenames = new String[nn];
! uniquenames.copyInto(sequenceUniquenames);
! } catch (DataAdapterException dae) {
! // TO DO - generate a popup with an informative error message
! }
}
}
! // -----------------------------------------------------------------------
! // ItemListener
! // -----------------------------------------------------------------------
! public void itemStateChanged(ItemEvent e) {
! // seqChoiceComboBox - allows the user to choose a sequence
! if (e.getItemSelectable() == seqChoiceComboBox) {
! if (e.getStateChange() == e.SELECTED) {
! Object selections[] = seqChoiceComboBox.getSelectedObjects();
! int selection = seqChoiceComboBox.getSelectedIndex();
! // CUSTOM_SEQ_PROMPT is always index 0
! if (selection == 0) {
! // Make the sequence ID entry box editable
! this.seqIdTextField.setEditable(true);
! }
! // User has chosen a sequence from the list (read from the db.);
! // place its ID in the ID entry box and make it non-editable.
! else if (selection > 0) {
! String newval = this.sequenceUniquenames[selection - 1];
! this.seqIdTextField.setEditable(false);
! this.seqIdTextField.setText(newval);
! }
! }
}
! // seqTypeComboBox - allows the user to choose a Chado sequence type (e.g. 'assembly', 'super-contig'
! else if (e.getItemSelectable() == seqTypeComboBox) {
! this.clearSeqChoiceComboBox();
! // When the sequence type changes, so must the button used to retrieve all sequences of that type.
! Object selections[] = seqTypeComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! this.seqChoiceButton.setText("Get " + newval + " list");
! }
! }
! // databaseComboBox - allows the user to choose a chado database
! else if (e.getItemSelectable() == databaseComboBox) {
! if (e.getStateChange() == e.SELECTED) {
! Object selections[] = databaseComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! // "Custom" database selected; allow the user to edit the connection info. fields
! if (newval.equals(CUSTOM_DB_PROMPT)) {
! this.driverClassComboBox.setEnabled(true);
! this.jdbcUrlTextField.setEditable(true);
! this.chadoDbTextField.setEditable(true);
! }
! else {
! ChadoDatabase db = getChadoDatabaseByName(newval);
! // A database from the config. file has been chosen; set the connection info. fields
! // and make them non-editable.
! if (db != null) {
! this.driverClassComboBox.setEnabled(false);
! this.jdbcUrlTextField.setEditable(false);
! this.chadoDbTextField.setEditable(false);
! this.driverClassComboBox.setSelectedItem(db.getAdapterClassName());
! this.jdbcUrlTextField.setText(db.getJdbcUrl());
! this.chadoDbTextField.setText(db.getChadoDb());
! }
! }
! }
}
}
}
! // -----------------------------------------------------------------------
! // ChadoAdapterGUI - protected methods
! // -----------------------------------------------------------------------
! /**
! * Retrieve one of the objects in <code>this.chado_dbs</code> by name.
! *
! * @param name The human-readable name of one of the databases in <code>chado_dbs</code>
! * @return The named Chado database descriptor.
! */
! protected ChadoDatabase getChadoDatabaseByName(String name) {
! if (this.chado_dbs != null) {
! int nc = this.chado_dbs.length;
! for (int i = 0;i < nc;++i) {
! if (this.chado_dbs[i].getName().equals(name)) return this.chado_dbs[i];
! }
! }
! return null;
}
! /**
! * Retrieve the corresponding ChadoAdapter object (stored by the superclass), coerce it
! * to the correct type, and initialize its properties based on the user's current
! * selections.
! *
! * @return An initialized instance of ChadoAdapter.
! */
! protected ChadoAdapter getAndInitAdapter() throws DataAdapterException {
! ChadoAdapter adapter = null;
! Properties params = new Properties();
!
! // Sanity check - we're forced to accept any adapter in setAdapter() but the
! // Apollo data adapter spec. suggests that each GUI will work only with the
! // corresponding adapter class.
! if (this.driver instanceof ChadoAdapter) {
! adapter = ((ChadoAdapter)this.driver);
! } else {
! throw new apollo.dataadapter.DataAdapterException("ChadoAdapterGUI not compatible with adapter " + this.driver);
! }
! params.setProperty(ChadoAdapter.DRIVER_CLASS, getDriverClass());
! params.setProperty(ChadoAdapter.JDBC_URL, getJdbcUrl());
! params.setProperty(ChadoAdapter.CHADO_DB, getChadoDb());
! params.setProperty(ChadoAdapter.USERNAME, getUsername());
! params.setProperty(ChadoAdapter.PASSWORD, getPassword());
! params.setProperty(ChadoAdapter.SEQUENCE_TYPE, getSequenceType());
! params.setProperty(ChadoAdapter.SEQUENCE_ID, getSequenceId());
! ChadoDatabase cdb = getSelectedDatabase();
! if (cdb != null) {
! String orgLike = cdb.getOrganismLike();
! // The ORGANISM_LIKE property is optional
! if (orgLike != null) params.setProperty(ChadoAdapter.ORGANISM_LIKE, orgLike);
! }
! adapter.setStateInformation(params);
! return adapter;
}
! /**
! * Create the UI appropriate for <code>this.op</code>.
! */
! protected void makeUI() {
! // Pull-down menu for predefined database choices
! int nc = 1 + this.chado_dbs.length;
! String[] databaseChoices = new String[nc];
! // CUSTOM_DB_PROMPT has to be 1st at the moment as CAGUI doesnt set up with other dbs
! // if they initially show up in chooser 1st
! databaseChoices[0] = CUSTOM_DB_PROMPT;
! // just doing this so my db comes up for my debugging ease - ok im lazy -
! // we can switch this back at some point
! // config primary choice? - also may not want generic CUSTOM_DB_PROMPT?
! //databaseChoices[nc-1] = CUSTOM_DB_PROMPT;
! for (int i = 0;i < chado_dbs.length;++i) {
! databaseChoices[i+1] = chado_dbs[i].getName();
! //databaseChoices[i] = chado_dbs[i].getName();
! }
! this.databaseComboBox = new JComboBox(databaseChoices);
! // Pull-down menu for sequences (if the user retrieves a list of sequences from the db.)
! this.seqChoiceComboBox = new JComboBox();
! this.clearSeqChoiceComboBox();
! // OP_READ_DATA
! if (getOperation().equals(ApolloDataAdapterI.OP_READ_DATA)) {
! makeReadDataUI();
! }
! // Nothing else supported yet
! else {
! System.err.println(this.getClass() + ": makeUI() called with unsupported operation " + this.op);
! }
}
! // Instance variables to hold the various Swing/AWT UI components
! // Chado database
! protected JLabel databaseChoicePrompt = new JLabel("Chado Database", SwingConstants.RIGHT);
! protected JComboBox databaseComboBox = null;
! // Name of JdbcChadoAdapter subclass used to connect
! protected JLabel driverClassPrompt = new JLabel("Chado driver class: ", SwingConstants.RIGHT);
! protected JComboBox driverClassComboBox = new JComboBox(DRIVER_CLASSES);
! // JDBC URL
! protected JLabel jdbcUrlPrompt = new JLabel("JDBC URL: ", SwingConstants.RIGHT);
! protected JTextField jdbcUrlTextField = new JTextField(30);
! // Database/schema name
! protected JLabel chadoDbPrompt = new JLabel("Database/schema: ", SwingConstants.RIGHT);
! protected JTextField chadoDbTextField = new JTextField(30);
! // Database login
! protected JLabel usernamePrompt = new JLabel(" Login: ", SwingConstants.RIGHT);
! protected JTextField usernameTextField = new JTextField(30);
! // Database password
! protected JLabel passwordPrompt = new JLabel(" Password: ", SwingConstants.RIGHT);
! protected JPasswordField passwordTextField = new JPasswordField(30);
! // TO DO - the list of sequence types would ideally be read from the database's cvterm table
! // (but this might require hierarchical cvterms in order to identify all sequence-related types)
// for now we should config these. assembly and supercontig are tigr,
// golden_path_region is fly scaffolds
! // Sequence type
! protected String seqTypes[] = new String[] {"golden_path_region", "assembly", "supercontig"};
! protected JLabel seqTypePrompt = new JLabel("Sequence type: ", SwingConstants.RIGHT);
! protected JComboBox seqTypeComboBox = new JComboBox(seqTypes);
! // List of sequences and the button that refreshes it
! protected JLabel seqChoicePrompt = new JLabel("Sequence: ", SwingConstants.RIGHT);
! protected JComboBox seqChoiceComboBox = null;
! protected JButton seqChoiceButton = new JButton("Get " + seqTypes[0] + " list");
! // Sequence id
! protected JLabel seqIdPrompt = new JLabel("Sequence ID: ", SwingConstants.RIGHT);
! protected JTextField seqIdTextField = new JTextField(30);
! /**
! * Creates the user interface for OP_READ_DATA.
! */
! protected void makeReadDataUI() {
! // The various Swing UI components are added as children of the current object,
! // which itself subclasses the appropriate top-level Swing component (probably
! // JFrame or JPanel)
! Insets i0 = new Insets(0,0,0,0);
! Insets ir4 = new Insets(0,0,0,4);
! int y = 0;
! Border lineborder = BorderFactory.createLineBorder(Color.gray);
! // ----------------------------------------------
! // Database panel - choose a Chado database
! // ----------------------------------------------
! JPanel dbPanel = new JPanel();
! dbPanel.setLayout(new GridBagLayout());
! Border dbTitle = BorderFactory.createTitledBorder(lineborder, "Chado database");
! dbPanel.setBorder(dbTitle);
! dbPanel.add(databaseChoicePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(databaseComboBox, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! dbPanel.add(driverClassPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(driverClassComboBox, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! dbPanel.add(jdbcUrlPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(jdbcUrlTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Database/schema name (interpretation may vary by platform; in Sybase this is the database name)
! dbPanel.add(chadoDbPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(chadoDbTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Login panel - enter login and password
! // ----------------------------------------------
! y = 0;
! JPanel userPanel = new JPanel();
! userPanel.setLayout(new GridBagLayout());
! Border userTitle = BorderFactory.createTitledBorder(lineborder, "Username and password");
! userPanel.setBorder(userTitle);
! // Username
! userPanel.add(usernamePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! userPanel.add(usernameTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Password
! userPanel.add(passwordPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! userPanel.add(passwordTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Sequence panel - enter/choose sequence
! // ----------------------------------------------
! // TO DO
! // -add support for retrieving/viewing a subsequence of the specified sequence in Apollo
! // -add support for retrieving data on demand
! y = 0;
! JPanel seqPanel = new JPanel();
! seqPanel.setLayout(new GridBagLayout());
! Border seqTitle = BorderFactory.createTitledBorder(lineborder, "Select a sequence to display");
! seqPanel.setBorder(seqTitle);
! // Sequence type (currently "assembly" is the only option)
! seqPanel.add(seqTypePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqTypeComboBox, new GridBagConstraints(1,y,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! seqPanel.add(seqChoiceButton, new GridBagConstraints(2,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! seqPanel.add(seqChoicePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqChoiceComboBox, new GridBagConstraints(1,y++,2,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Sequence ID
! seqPanel.add(seqIdPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqIdTextField, new GridBagConstraints(1,y++,2,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Event handling
! // ----------------------------------------------
! databaseComboBox.addItemListener(this);
! seqTypeComboBox.addItemListener(this);
! seqChoiceComboBox.addItemListener(this);
! seqChoiceButton.addActionListener(this);
! // ----------------------------------------------
! // Main GUI layout
! // ----------------------------------------------
! y = 0;
! this.setLayout(new GridBagLayout());
! this.add(dbPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! this.add(userPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! this.add(seqPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! }
! /**
! * @return The IOOperation this UI was instantiated to perform.
! */
! protected IOOperation getOperation() { return this.op; }
! /**
! * Method that extracts the currently-selected value of a JComboBox.
! *
! * @param cb The aforementioned JComboBox
! * @return The currently-selected String, or null if there is not a unique String-valued current selection.
! */
! protected String getComboBoxValue(JComboBox cb) {
! Object sel = cb.getSelectedItem();
! return ((sel != null) && (sel instanceof String)) ? (String)sel : null;
! }
! /**
! * Reset the seqChoiceComboBox to its original state; called when the current database changes.
! */
! protected void clearSeqChoiceComboBox() {
! this.seqChoiceComboBox.removeAllItems();
! this.seqChoiceComboBox.addItem(CUSTOM_SEQ_PROMPT);
! this.seqIdTextField.setEditable(true);
! this.seqChoiceComboBox.setEnabled(false);
! }
! // Retrieve current user input from UI components
! protected String getDriverClass() { return getComboBoxValue(this.driverClassComboBox); }
! protected String getJdbcUrl() { return this.jdbcUrlTextField.getText(); }
! protected String getChadoDb() { return this.chadoDbTextField.getText(); }
! protected String getUsername() { return this.usernameTextField.getText(); }
! protected String getPassword() { return new String(this.passwordTextField.getPassword()); }
! protected String getSequenceType() { return getComboBoxValue(this.seqTypeComboBox); }
! protected String getSequenceId() { return this.seqIdTextField.getText(); }
! protected ChadoDatabase getSelectedDatabase() {
! Object selections[] = databaseComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! if (!newval.equals(CUSTOM_DB_PROMPT)) {
! return getChadoDatabaseByName(newval);
! }
! }
! return null;
}
}
--- 41,534 ----
public class ChadoAdapterGUI extends AbstractDataAdapterUI implements ActionListener, ItemListener {
! // -----------------------------------------------------------------------
! // Static variables
! // -----------------------------------------------------------------------
! /**
! * NOTE - subclasses of JdbcChadoAdapter must be explicitly added to this list in order to be
! * usable in the Chado adapter. This is a limitation that could be removed if necessary.
! Yes - this should come from config.
! */
! protected static String DRIVER_CLASSES[] = new String[] {
! "apollo.dataadapter.chado.jdbc.PostgresChadoAdapter",
! "apollo.dataadapter.chado.jdbc.SybaseChadoAdapter"
! };
! /**
! * Prompt for the pull-down menu that allows the user to select a Chado database from
! * among those read from the Chado adapter's configuration file.
! */
! protected static String CUSTOM_DB_PROMPT = "Enter database info. below or select from list";
! /**
! * Prompt for the area in which the user can enter the ID of the sequence he/she wishes
! * to load.
! */
! protected static String CUSTOM_SEQ_PROMPT = "Enter a sequence ID below:";
! // -----------------------------------------------------------------------
! // Instance variables
! // -----------------------------------------------------------------------
! /**
! * The IOOperation (e.g. reading/writing) that this object was created to support.
! */
! protected IOOperation op;
! /**
! * List of Chado databases read by the ChadoAdapter from its configuration file.
! *
! * @see ChadoAdapter.readConfigFile
! */
! protected ChadoDatabase[] chado_dbs;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! /**
! * @param op The IOOperation that this GUI was invoked to perform.
! * @param chado_dbs A list of Chado database descriptors from which the user may choose.
! */
! public ChadoAdapterGUI(IOOperation op, ChadoDatabase chado_dbs[]) {
! this.op = op;
! this.chado_dbs = chado_dbs;
! this.makeUI();
! }
! // -----------------------------------------------------------------------
! // AbstractDataAdapterUI
! // -----------------------------------------------------------------------
! // NOTE - Not yet implemented. The sample adapter uses this information to extract
! // the user's previous choices from the Apollo history file.
! public void setProperties(Properties props) {}
! // The properties returned by this method are written to the Apollo history file.
! public Properties getProperties() {
! return new Properties(); // not yet implemented
! }
! // The main method supported by the GUI; called when the user clicks on "OK" to read annotation,
! // write sequence, or do whatever operation is appropriate (so long as it is supported by the
! // adapter.)
! public Object doOperation(Object values) throws DataAdapterException {
! ChadoAdapter adapter = getAndInitAdapter();
! IOOperation op = this.getOperation();
! // This is the only operation supported so far.
! if (op.equals(ApolloDataAdapterI.OP_READ_DATA)) {
! return adapter.getCurationSet();
! }
! else if (op.equals(ApolloDataAdapterI.OP_WRITE_DATA)) {
! System.err.println(this.getClass() + ".doOperation: OP_WRITE_DATA unsupported");
! throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
}
+ else if (op.equals(ApolloDataAdapterI.OP_READ_SEQUENCE)) {
+ System.err.println(this.getClass() + ".doOperation: OP_READ_SEQUENCE unsupported");
+ throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
+ }
+ else if (op.equals(ApolloDataAdapterI.OP_READ_RAW_ANALYSIS)) {
+ System.err.println(this.getClass() + ".doOperation: OP_READ_RAW_ANALYSIS unsupported");
+ throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
+ }
+ else if (op.equals(ApolloDataAdapterI.OP_APPEND_DATA)) {
+ System.err.println(this.getClass() + ".doOperation: OP_APPEND_DATA unsupported");
+ throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
+ }
+ else {
+ throw new apollo.dataadapter.DataAdapterException("Unsupported operation");
+ }
+ }
! // -----------------------------------------------------------------------
! // ActionListener
! // -----------------------------------------------------------------------
! /**
! * A list of chado feature.uniquenames read from the current database by the ChadoAdapter.
! */
! String sequenceUniquenames[];
! public void actionPerformed(ActionEvent e) {
! // seqChoiceButton
! if (e.getSource() == seqChoiceButton) {
! // If we have valid connection info. tell the adaptor to query the database for a list of sequences
! try {
! ChadoAdapter adapter = getAndInitAdapter();
! Vector uniquenames = new Vector();
! Vector descriptions = new Vector();
! adapter.getSequenceList(getSequenceType(), uniquenames, descriptions);
! int nn = uniquenames.size();
! // Populate the seqChoiceComboBox with the retrieved sequence descriptions
! this.clearSeqChoiceComboBox();
! for (int i = 0;i < nn;++i) {
! String descr = (String)(descriptions.elementAt(i));
! this.seqChoiceComboBox.addItem(descr);
}
+ if (nn > 0) { this.seqChoiceComboBox.setEnabled(true); }
+
+ this.sequenceUniquenames = new String[nn];
+ uniquenames.copyInto(sequenceUniquenames);
+ } catch (DataAdapterException dae) {
+ // TO DO - generate a popup with an informative error message
+ }
}
+ }
! // -----------------------------------------------------------------------
! // ItemListener
! // -----------------------------------------------------------------------
! public void itemStateChanged(ItemEvent e) {
! // seqChoiceComboBox - allows the user to choose a sequence
! if (e.getItemSelectable() == seqChoiceComboBox) {
! if (e.getStateChange() == e.SELECTED) {
! Object selections[] = seqChoiceComboBox.getSelectedObjects();
! int selection = seqChoiceComboBox.getSelectedIndex();
! // CUSTOM_SEQ_PROMPT is always index 0
! if (selection == 0) {
! // Make the sequence ID entry box editable
! this.seqIdTextField.setEditable(true);
! }
! // User has chosen a sequence from the list (read from the db.);
! // place its ID in the ID entry box and make it non-editable.
! else if (selection > 0) {
! String newval = this.sequenceUniquenames[selection - 1];
! this.seqIdTextField.setEditable(false);
! this.seqIdTextField.setText(newval);
}
! }
! }
! // seqTypeComboBox - allows the user to choose a Chado sequence type (e.g. 'assembly', 'super-contig'
! else if (e.getItemSelectable() == seqTypeComboBox) {
! this.clearSeqChoiceComboBox();
! // When the sequence type changes, so must the button used to retrieve all sequences of that type.
! Object selections[] = seqTypeComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! this.seqChoiceButton.setText("Get " + newval + " list");
! }
! }
! // databaseComboBox - allows the user to choose a chado database
! else if (e.getItemSelectable() == databaseComboBox) {
! if (e.getStateChange() == e.SELECTED) {
! Object selections[] = databaseComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! // "Custom" database selected; allow the user to edit the connection info. fields
! if (newval.equals(CUSTOM_DB_PROMPT)) {
! this.driverClassComboBox.setEnabled(true);
! this.jdbcUrlTextField.setEditable(true);
! this.chadoDbTextField.setEditable(true);
! }
! else {
! ChadoDatabase db = getChadoDatabaseByName(newval);
! // A database from the config. file has been chosen; set the connection info. fields
! // and make them non-editable.
! if (db != null) {
! this.driverClassComboBox.setEnabled(false);
! this.jdbcUrlTextField.setEditable(false);
! this.chadoDbTextField.setEditable(false);
! this.driverClassComboBox.setSelectedItem(db.getAdapterClassName());
! this.jdbcUrlTextField.setText(db.getJdbcUrl());
! this.chadoDbTextField.setText(db.getChadoDb());
}
+ }
}
+ }
}
+ }
! // -----------------------------------------------------------------------
! // ChadoAdapterGUI - protected methods
! // -----------------------------------------------------------------------
! /**
! * Retrieve one of the objects in <code>this.chado_dbs</code> by name.
! *
! * @param name The human-readable name of one of the databases in <code>chado_dbs</code>
! * @return The named Chado database descriptor.
! */
! protected ChadoDatabase getChadoDatabaseByName(String name) {
! if (this.chado_dbs != null) {
! int nc = this.chado_dbs.length;
! for (int i = 0;i < nc;++i) {
! if (this.chado_dbs[i].getName().equals(name)) return this.chado_dbs[i];
! }
}
+ return null;
+ }
! /**
! * Retrieve the corresponding ChadoAdapter object (stored by the superclass), coerce it
! * to the correct type, and initialize its properties based on the user's current
! * selections.
! *
! * @return An initialized instance of ChadoAdapter.
! */
! protected ChadoAdapter getAndInitAdapter() throws DataAdapterException {
! ChadoAdapter adapter = null;
! Properties params = new Properties();
! // Sanity check - we're forced to accept any adapter in setAdapter() but the
! // Apollo data adapter spec. suggests that each GUI will work only with the
! // corresponding adapter class.
! if (this.driver instanceof ChadoAdapter) {
! adapter = ((ChadoAdapter)this.driver);
! } else {
! throw new apollo.dataadapter.DataAdapterException("ChadoAdapterGUI not compatible with adapter " + this.driver);
! }
! params.setProperty(ChadoAdapter.DRIVER_CLASS, getDriverClass());
! params.setProperty(ChadoAdapter.JDBC_URL, getJdbcUrl());
! params.setProperty(ChadoAdapter.CHADO_DB, getChadoDb());
! params.setProperty(ChadoAdapter.USERNAME, getUsername());
! params.setProperty(ChadoAdapter.PASSWORD, getPassword());
! params.setProperty(ChadoAdapter.SEQUENCE_TYPE, getSequenceType());
! params.setProperty(ChadoAdapter.SEQUENCE_ID, getSequenceId());
! ChadoDatabase cdb = getSelectedDatabase();
! if (cdb != null) {
! String orgLike = cdb.getOrganismLike();
! // The ORGANISM_LIKE property is optional
! if (orgLike != null) params.setProperty(ChadoAdapter.ORGANISM_LIKE, orgLike);
}
! adapter.setStateInformation(params);
! return adapter;
! }
! /**
! * Create the UI appropriate for <code>this.op</code>.
! */
! protected void makeUI() {
! // Pull-down menu for predefined database choices
! int nc = 1 + this.chado_dbs.length;
! String[] databaseChoices = new String[nc];
! // CUSTOM_DB_PROMPT has to be 1st at the moment as CAGUI doesnt set up with other dbs
! // if they initially show up in chooser 1st
! databaseChoices[0] = CUSTOM_DB_PROMPT;
! // just doing this so my db comes up for my debugging ease - ok im lazy -
! // we can switch this back at some point
! // config primary choice? - also may not want generic CUSTOM_DB_PROMPT?
! //databaseChoices[nc-1] = CUSTOM_DB_PROMPT;
! for (int i = 0;i < chado_dbs.length;++i) {
! databaseChoices[i+1] = chado_dbs[i].getName();
! //databaseChoices[i] = chado_dbs[i].getName();
! }
! this.databaseComboBox = new JComboBox(databaseChoices);
! // Pull-down menu for sequences (if the user retrieves a list of sequences from the db.)
! this.seqChoiceComboBox = new JComboBox();
! this.clearSeqChoiceComboBox();
!
! // OP_READ_DATA
! if (getOperation().equals(ApolloDataAdapterI.OP_READ_DATA)) {
! makeReadDataUI();
}
+ // Nothing else supported yet
+ else {
+ System.err.println(this.getClass() + ": makeUI() called with unsupported operation " + this.op);
+ }
+ }
! // Instance variables to hold the various Swing/AWT UI components
! // Chado database
! protected JLabel databaseChoicePrompt = new JLabel("Chado Database", SwingConstants.RIGHT);
! protected JComboBox databaseComboBox = null;
! // Name of JdbcChadoAdapter subclass used to connect
! protected JLabel driverClassPrompt = new JLabel("Chado driver class: ", SwingConstants.RIGHT);
! protected JComboBox driverClassComboBox = new JComboBox(DRIVER_CLASSES);
! // JDBC URL
! protected JLabel jdbcUrlPrompt = new JLabel("JDBC URL: ", SwingConstants.RIGHT);
! protected JTextField jdbcUrlTextField = new JTextField(30);
! // Database/schema name
! protected JLabel chadoDbPrompt = new JLabel("Database/schema: ", SwingConstants.RIGHT);
! protected JTextField chadoDbTextField = new JTextField(30);
! // Database login
! protected JLabel usernamePrompt = new JLabel(" Login: ", SwingConstants.RIGHT);
! protected JTextField usernameTextField = new JTextField(30);
! // Database password
! protected JLabel passwordPrompt = new JLabel(" Password: ", SwingConstants.RIGHT);
! protected JPasswordField passwordTextField = new JPasswordField(30);
! // TO DO - the list of sequence types would ideally be read from the database's cvterm table
! // (but this might require hierarchical cvterms in order to identify all sequence-related types)
// for now we should config these. assembly and supercontig are tigr,
// golden_path_region is fly scaffolds
! // Sequence type
! protected String seqTypes[] = new String[] {"golden_path_region", "assembly", "supercontig"};
! protected JLabel seqTypePrompt = new JLabel("Sequence type: ", SwingConstants.RIGHT);
! protected JComboBox seqTypeComboBox = new JComboBox(seqTypes);
! // List of sequences and the button that refreshes it
! protected JLabel seqChoicePrompt = new JLabel("Sequence: ", SwingConstants.RIGHT);
! protected JComboBox seqChoiceComboBox = null;
! protected JButton seqChoiceButton = new JButton("Get " + seqTypes[0] + " list");
! // Sequence id
! protected JLabel seqIdPrompt = new JLabel("Sequence ID: ", SwingConstants.RIGHT);
! protected JTextField seqIdTextField = new JTextField(30);
! /**
! * Creates the user interface for OP_READ_DATA.
! */
! protected void makeReadDataUI() {
! // The various Swing UI components are added as children of the current object,
! // which itself subclasses the appropriate top-level Swing component (probably
! // JFrame or JPanel)
! Insets i0 = new Insets(0,0,0,0);
! Insets ir4 = new Insets(0,0,0,4);
! int y = 0;
! Border lineborder = BorderFactory.createLineBorder(Color.gray);
! // ----------------------------------------------
! // Database panel - choose a Chado database
! // ----------------------------------------------
! JPanel dbPanel = new JPanel();
! dbPanel.setLayout(new GridBagLayout());
! Border dbTitle = BorderFactory.createTitledBorder(lineborder, "Chado database");
! dbPanel.setBorder(dbTitle);
! dbPanel.add(databaseChoicePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(databaseComboBox, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! dbPanel.add(driverClassPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(driverClassComboBox, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! dbPanel.add(jdbcUrlPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(jdbcUrlTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Database/schema name (interpretation may vary by platform; in Sybase this is the database name)
! dbPanel.add(chadoDbPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! dbPanel.add(chadoDbTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Login panel - enter login and password
! // ----------------------------------------------
! y = 0;
! JPanel userPanel = new JPanel();
! userPanel.setLayout(new GridBagLayout());
! Border userTitle = BorderFactory.createTitledBorder(lineborder, "Username and password");
! userPanel.setBorder(userTitle);
! // Username
! userPanel.add(usernamePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! userPanel.add(usernameTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Password
! userPanel.add(passwordPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! userPanel.add(passwordTextField, new GridBagConstraints(1,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Sequence panel - enter/choose sequence
! // ----------------------------------------------
! // TO DO
! // -add support for retrieving/viewing a subsequence of the specified sequence in Apollo
! // -add support for retrieving data on demand
! y = 0;
! JPanel seqPanel = new JPanel();
! seqPanel.setLayout(new GridBagLayout());
! Border seqTitle = BorderFactory.createTitledBorder(lineborder, "Select a sequence to display");
! seqPanel.setBorder(seqTitle);
! // Sequence type (currently "assembly" is the only option)
! seqPanel.add(seqTypePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqTypeComboBox, new GridBagConstraints(1,y,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! seqPanel.add(seqChoiceButton, new GridBagConstraints(2,y++,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! seqPanel.add(seqChoicePrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqChoiceComboBox, new GridBagConstraints(1,y++,2,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // Sequence ID
! seqPanel.add(seqIdPrompt, new GridBagConstraints(0,y,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,ir4,0,0));
! seqPanel.add(seqIdTextField, new GridBagConstraints(1,y++,2,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,i0,0,0));
! // ----------------------------------------------
! // Event handling
! // ----------------------------------------------
! databaseComboBox.addItemListener(this);
! seqTypeComboBox.addItemListener(this);
! seqChoiceComboBox.addItemListener(this);
! seqChoiceButton.addActionListener(this);
! // ----------------------------------------------
! // Main GUI layout
! // ----------------------------------------------
! y = 0;
! this.setLayout(new GridBagLayout());
! this.add(dbPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! this.add(userPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! this.add(seqPanel, new GridBagConstraints(0,y++,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.HORIZONTAL,ir4,0,0));
! }
! /**
! * @return The IOOperation this UI was instantiated to perform.
! */
! protected IOOperation getOperation() { return this.op; }
! /**
! * Method that extracts the currently-selected value of a JComboBox.
! *
! * @param cb The aforementioned JComboBox
! * @return The currently-selected String, or null if there is not a unique String-valued current selection.
! */
! protected String getComboBoxValue(JComboBox cb) {
! Object sel = cb.getSelectedItem();
! return ((sel != null) && (sel instanceof String)) ? (String)sel : null;
! }
! /**
! * Reset the seqChoiceComboBox to its original state; called when the current database changes.
! */
! protected void clearSeqChoiceComboBox() {
! this.seqChoiceComboBox.removeAllItems();
! this.seqChoiceComboBox.addItem(CUSTOM_SEQ_PROMPT);
! this.seqIdTextField.setEditable(true);
! this.seqChoiceComboBox.setEnabled(false);
! }
! // Retrieve current user input from UI components
! protected String getDriverClass() { return getComboBoxValue(this.driverClassComboBox); }
! protected String getJdbcUrl() { return this.jdbcUrlTextField.getText(); }
! protected String getChadoDb() { return this.chadoDbTextField.getText(); }
! protected String getUsername() { return this.usernameTextField.getText(); }
! protected String getPassword() { return new String(this.passwordTextField.getPassword()); }
! protected String getSequenceType() { return getComboBoxValue(this.seqTypeComboBox); }
! protected String getSequenceId() { return this.seqIdTextField.getText(); }
! protected ChadoDatabase getSelectedDatabase() {
! Object selections[] = databaseComboBox.getSelectedObjects();
! if ((selections != null) && (selections.length == 1)) {
! String newval = selections[0].toString();
! if (!newval.equals(CUSTOM_DB_PROMPT)) {
! return getChadoDatabaseByName(newval);
! }
}
+ return null;
+ }
}
Index: ChadoDatabase.java
===================================================================
RCS file: /cvsroot/gmod/apollo/src/java/apollo/dataadapter/chado/ChadoDatabase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ChadoDatabase.java 19 Apr 2004 16:52:20 -0000 1.1
--- ChadoDatabase.java 27 Apr 2004 14:42:05 -0000 1.2
***************
*** 9,72 ****
public class ChadoDatabase {
! /**
! * Short (and preferably unique) user-readable identifier for the database.
! */
! protected String name;
! /**
! * Fully-qualified name of a Java class that extends apollo.dataadapter.chado.jdbc.JdbcChadoAdapter;
! * used to implement DBMS-specific features or optimizations.
! */
! protected String adapterClassName;
! /**
! * JDBC connection URL
! */
! protected String jdbcUrl;
! /**
! * Name of the specific Chado database instance/schema on the database server. The
! * interpretation of this value may vary slightly depending on the DBMS. In Oracle,
! * for example, this will most likely be a "schema" (i.e., username), whereas in Sybase
! * or MySQL it will more likely be a database name.
! */
! protected String chadoDb;
! /**
! * String used to limit the sequences listed in the pull-down menu presented by the
! * data adapter. Implemented via a 'like' query on organism.common_name using
! * this string.
! */
! protected String organismLike;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! /**
! * @param name Short (and preferably unique) user-readable identifier for the database.
! * @param adapterClassName Name of a Java class that extends apollo.dataadapter.chado.jdbc.JdbcChadoAdapter.
! * @param jdbcUrl JDBC connection URL.
! * @param chadoDb Name of the specific Chado database instance/schema on the database server.
! * @param organismLike String used to limit the sequences listed in the pull-down menu, via a 'like' query on organism.common_name.
! */
! public ChadoDatabase(String name, String adapterClassName, String jdbcUrl, String chadoDb, String organismLike) {
! this.name = name;
! this.adapterClassName = adapterClassName;
! this.jdbcUrl = jdbcUrl;
! this.chadoDb = chadoDb;
! this.organismLike = organismLike;
! }
! // -----------------------------------------------------------------------
! // ChadoDatabase
! // -----------------------------------------------------------------------
! // accessor methods
! public String getName() { return this.name; }
! public String getAdapterClassName() { return this.adapterClassName; }
! public String getJdbcUrl() { return this.jdbcUrl; }
! public String getChadoDb() { return this.chadoDb; }
! public String getOrganismLike() { return this.organismLike; }
}
--- 9,72 ----
public class ChadoDatabase {
! /**
! * Short (and preferably unique) user-readable identifier for the database.
! */
! protected String name;
! /**
! * Fully-qualified name of a Java class that extends apollo.dataadapter.chado.jdbc.JdbcChadoAdapter;
! * used to implement DBMS-specific features or optimizations.
! */
! protected String adapterClassName;
! /**
! * JDBC connection URL
! */
! protected String jdbcUrl;
! /**
! * Name of the specific Chado database instance/schema on the database server. The
! * interpretation of this value may vary slightly depending on the DBMS. In Oracle,
! * for example, this will most likely be a "schema" (i.e., username), whereas in Sybase
! * or MySQL it will more likely be a database name.
! */
! protected String chadoDb;
! /**
! * String used to limit the sequences listed in the pull-down menu presented by the
! * data adapter. Implemented via a 'like' query on organism.common_name using
! * this string.
! */
! protected String organismLike;
! // -----------------------------------------------------------------------
! // Constructor
! // -----------------------------------------------------------------------
! /**
! * @param name Short (and preferably unique) user-readable identifier for the database.
! * @param adapterClassName Name of a Java class that extends apollo.dataadapter.chado.jdbc.JdbcChadoAdapter.
! * @param jdbcUrl JDBC connection URL.
! * @param chadoDb Name of the specific Chado database instance/schema on the database server.
! * @param organismLike String used to limit the sequences listed in the pull-down menu, via a 'like' query on organism.common_name.
! */
! public ChadoDatabase(String name, String adapterClassName, String jdbcUrl, String chadoDb, String organismLike) {
! this.name = name;
! this.adapterClassName = adapterClassName;
! this.jdbcUrl = jdbcUrl;
! this.chadoDb = chadoDb;
! this.organismLike = organismLike;
! }
! // -----------------------------------------------------------------------
! // ChadoDatabase
! // -----------------------------------------------------------------------
! // accessor methods
! public String getName() { return this.name; }
! public String getAdapterClassName() { return this.adapterClassName; }
! public String getJdbcUrl() { return this.jdbcUrl; }
! public String getChadoDb() { return this.chadoDb; }
! public String getOrganismLike() { return this.organismLike; }
}
|