[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Wed Mar 15 16:22:38 UTC 2006


kawas
Wed Mar 15 11:22:37 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types
In directory pub.open-bio.org:/tmp/cvs-serv32102/org/biomoby/registry/definitions/types

Modified Files:
	JServicesSqlImpl.java JObjectsSqlImpl.java 
	JNamespacesSqlImpl.java 
Log Message:
updated RDF generators and clients so that LSIDs with versioining information is used. This is only preliminary. More updates to come

moby-live/Java/src/main/org/biomoby/registry/definitions/types JServicesSqlImpl.java,1.2,1.3 JObjectsSqlImpl.java,1.1,1.2 JNamespacesSqlImpl.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServicesSqlImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServicesSqlImpl.java	2006/03/14 16:23:06	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServicesSqlImpl.java	2006/03/15 16:22:37	1.3
@@ -25,7 +25,7 @@
 			+ "FROM service as ot1, service_term2term as rt, service as ot2 "
 			+ "WHERE ot1.service_id = rt.service1_id and ot2.service_id = rt.service2_id order by ot1.service_type";
 
-	private static final String sql_all = "SELECT ot1.service_type, rt.relationship_type, ot2.service_type, ot1.description, ot1.service_lsid, ot1.authority, ot1.contact_email "
+	private static final String sql_all = "SELECT ot1.service_type, rt.relationship_type, ot2.service_type, ot1.description, ot1.service_lsid, ot1.authority, ot1.contact_email, ot2.service_lsid "
 			+ "FROM service as ot1, service_term2term as rt, service as ot2 "
 			+ "WHERE ot1.service_id = rt.service1_id and ot2.service_id = rt.service2_id order by ot1.service_type";
 
@@ -48,12 +48,12 @@
 			Map map = MobyCentralConfig.getMobyService();
 			// Create a connection to the database
 			String serverName = map.get("url") + ":" + map.get("port");// localhost:3306";
-																		// //TODO
-																		// -
-																		// make
-																		// this
-																		// a
-																		// property
+			// //TODO
+			// -
+			// make
+			// this
+			// a
+			// property
 			String mydatabase = (String) map.get("dbname");// "mobyobject";
 			String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
 			String username = (String) map.get("username");// "moby_external";
@@ -143,9 +143,11 @@
 
 	/**
 	 * Get all the data in the db regrading service types.
+	 * 
 	 * @return an array of String[] objects. The String[] consists of
-	 *         {service_type, relationship_type, to_service_type, description, service_lsid, authority,
-	 *         contact_email}. <em>Note that relationship_type is the relationship that service_type has
+	 *         {service_type, relationship_type, to_service_type, description,
+	 *         service_lsid, authority, contact_email, to_service_type_lsid}.
+	 *         <em>Note that relationship_type is the relationship that service_type has
 	 *         with to_service_type.</em>
 	 */
 	public String[][] getFullServicesAsArray() {
@@ -166,7 +168,7 @@
 			while (rs.next()) {
 				// Get the data from the row using the column index
 				sb.add(new String[] { rs.getString(1), rs.getString(2), rs.getString(3),
-						rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7) });
+						rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8) });
 			}
 		} catch (SQLException e) {
 			// TODO - throw exception - Database access error

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjectsSqlImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjectsSqlImpl.java	2005/08/29 20:19:20	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjectsSqlImpl.java	2006/03/15 16:22:37	1.2
@@ -21,179 +21,221 @@
  *         email me at edward.kawas at gmail.com
  */
 public final class JObjectsSqlImpl implements JObjectsI {
-    private static final String sql = "SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description "
-            + "FROM object as ot1, object_term2term as rt, object as ot2 "
-            + "WHERE  ot1.object_id = rt.object1_id and ot2.object_id = rt.object2_id "
-            + "ORDER BY ot1.object_type";
-
-    private final String newline = System.getProperty("line.separator");
-
-    private Connection connection = null;
-
-    /**
-     * 
-     * @throws MobyException
-     *             if database driver cannot be found or there is an database
-     *             access error.
-     */
-    public JObjectsSqlImpl() throws MobyException {
-        try {
-            // Load the JDBC driver
-            String driverName = "com.mysql.jdbc.Driver";
-            Class.forName(driverName);
-            //  get certain properties from mobycentral.config
-            Map map = MobyCentralConfig.getMobyObject();
-            // Create a connection to the database
-            String serverName = map.get("url") + ":" + map.get("port");//localhost:3306";
-                                                                       // //TODO
-                                                                       // - make
-                                                                       // this a
-                                                                       // property
-            String mydatabase = (String) map.get("dbname");//"mobyobject";
-            String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
-            String username = (String) map.get("username");//"moby_external";
-            String password = (String) map.get("password");//"";
-
-            /*
-             * String serverName = "mobycentral.icapture.ubc.ca:3306"; String
-             * mydatabase = "mobyobject"; String url = "jdbc:mysql://" +
-             * serverName + "/" + mydatabase; String username = "moby_external";
-             * String password = "";
-             */
-            this.connection = DriverManager.getConnection(url, username,
-                    password);
-        } catch (ClassNotFoundException e) {
-            throw new MobyException(
-                    "Could not find database driver. Please ensure that you have the right libraries present");
-        } catch (SQLException e) {
-            e.printStackTrace();
-            throw new MobyException("Database access error: " + e.getSQLState());
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.biomoby.registry.definitions.types.JObjectsI#getObjects()
-     */
-    public final String getObjects() {
-        StringBuffer sb = new StringBuffer();
-        /* ensure connection is not null */
-        if (connection == null)
-            return "";
-
-        ResultSet rs = null;
-        try {
-            Statement stmt = connection.createStatement();
-            rs = stmt.executeQuery(sql);
-        } catch (SQLException ex) {
-            // TODO - throw exception - Error in sql
-            return ex.getMessage();
-        }
-        try {
-            while (rs.next()) {
-                // Get the data from the row using the column index
-                sb.append(rs.getString(1)
-                        + "\t"
-                        + rs.getString(2)
-                        + "\t"
-                        + rs.getString(3)
-                        + ((rs.getString(4) == null || rs.getString(4).equals(
-                                "")) ? "\t" : "(" + rs.getString(4) + ")\t")
-                        + rs.getString(5) + newline);
-            }
-        } catch (SQLException e) {
-            // TODO - throw exception - Database access error
-            return e.getMessage();
-        }
-        return sb.toString();
-    }
-
-    /**
-     * 
-     * @param name
-     *            the name of the object to get information on
-     * @return a tab delimited string containing object, object relationship,
-     *         object type that this relationship is with, the articlename (if
-     *         it exists), and description
-     */
-    public final String getObject(String name) {
-        String _SQL = "SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description "
-                + "FROM object as ot1, object_term2term as rt, object as ot2 "
-                + "WHERE  ot1.object_id = rt.object1_id and ot2.object_id = rt.object2_id and ot1.object_type = '"
-                + name + "' " + "ORDER BY ot1.object_type";
-        StringBuffer sb = new StringBuffer();
-        /* ensure connection is not null */
-        if (connection == null)
-            return "";
-
-        ResultSet rs = null;
-        try {
-            Statement stmt = connection.createStatement();
-            rs = stmt.executeQuery(_SQL);
-        } catch (SQLException ex) {
-            // TODO - throw exception - Error in sql
-            return ex.getMessage();
-        }
-        try {
-            while (rs.next()) {
-                // Get the data from the row using the column index
-                sb.append(rs.getString(1)
-                        + "\t"
-                        + rs.getString(2)
-                        + "\t"
-                        + rs.getString(3)
-                        + ((rs.getString(4) == null || rs.getString(4).equals(
-                                "")) ? "\t" : "(" + rs.getString(4) + ")\t")
-                        + rs.getString(5) + newline);
-            }
-        } catch (SQLException e) {
-            // TODO - throw exception - Database access error
-            return e.getMessage();
-        }
-        return sb.toString();
-    }
-
-    public static void main(String[] args) throws MobyException {
-        System.out.println(new JObjectsSqlImpl().getObjectsAsArray());
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.biomoby.registry.definitions.types.JObjectsI#getObjectsAsArray()
-     */
-    public String[][] getObjectsAsArray() {
-        ArrayList sb = new ArrayList();
-        /* ensure connection is not null */
-        if (connection == null)
-            return null;
-
-        ResultSet rs = null;
-        try {
-            Statement stmt = connection.createStatement();
-            rs = stmt.executeQuery(sql);
-        } catch (SQLException ex) {
-            return null;
-        }
-        try {
-            while (rs.next()) {
-                // Get the data from the row using the column index
-                sb
-                        .add(new String[] {
-                                rs.getString(1),
-                                rs.getString(2),
-                                rs.getString(3),
-                                ((rs.getString(4) == null || 
-                                        rs.getString(4).equals("")) ? 
-                                                "" : "(" + rs.getString(4) + ")"),
-                                rs.getString(5) });
-            }
-        } catch (SQLException e) {
-            return null;
-        }
-        String[][] array = new String[sb.size()][];
-        sb.toArray(array);
-        return array;
-    }
+	private static final String sql = "SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description "
+			+ "FROM object as ot1, object_term2term as rt, object as ot2 "
+			+ "WHERE  ot1.object_id = rt.object1_id and ot2.object_id = rt.object2_id "
+			+ "ORDER BY ot1.object_type";
+
+	private static final String sql_all = "SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description,"
+			+ " ot1.object_lsid, ot1.authority, ot1.contact_email, ot2.object_lsid "
+			+ "FROM object as ot1, object_term2term as rt, object as ot2 "
+			+ "WHERE  ot1.object_id = rt.object1_id and ot2.object_id = rt.object2_id "
+			+ "ORDER BY ot1.object_type";
+
+	private final String newline = System.getProperty("line.separator");
+
+	private Connection connection = null;
+
+	/**
+	 * 
+	 * @throws MobyException
+	 *             if database driver cannot be found or there is an database
+	 *             access error.
+	 */
+	public JObjectsSqlImpl() throws MobyException {
+		try {
+			// Load the JDBC driver
+			String driverName = "com.mysql.jdbc.Driver";
+			Class.forName(driverName);
+			// get certain properties from mobycentral.config
+			Map map = MobyCentralConfig.getMobyObject();
+			// Create a connection to the database
+			String serverName = map.get("url") + ":" + map.get("port");// localhost:3306";
+			// //TODO
+			// - make
+			// this a
+			// property
+			String mydatabase = (String) map.get("dbname");// "mobyobject";
+			String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
+			String username = (String) map.get("username");// "moby_external";
+			String password = (String) map.get("password");// "";
+
+			/*
+			 * String serverName = "mobycentral.icapture.ubc.ca:3306"; String
+			 * mydatabase = "mobyobject"; String url = "jdbc:mysql://" +
+			 * serverName + "/" + mydatabase; String username = "moby_external";
+			 * String password = "";
+			 */
+			this.connection = DriverManager.getConnection(url, username, password);
+		} catch (ClassNotFoundException e) {
+			throw new MobyException(
+					"Could not find database driver. Please ensure that you have the right libraries present");
+		} catch (SQLException e) {
+			e.printStackTrace();
+			throw new MobyException("Database access error: " + e.getSQLState());
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.biomoby.registry.definitions.types.JObjectsI#getObjects()
+	 */
+	public final String getObjects() {
+		StringBuffer sb = new StringBuffer();
+		/* ensure connection is not null */
+		if (connection == null)
+			return "";
+
+		ResultSet rs = null;
+		try {
+			Statement stmt = connection.createStatement();
+			rs = stmt.executeQuery(sql);
+		} catch (SQLException ex) {
+			// TODO - throw exception - Error in sql
+			return ex.getMessage();
+		}
+		try {
+			while (rs.next()) {
+				// Get the data from the row using the column index
+				sb.append(rs.getString(1)
+						+ "\t"
+						+ rs.getString(2)
+						+ "\t"
+						+ rs.getString(3)
+						+ ((rs.getString(4) == null || rs.getString(4).equals("")) ? "\t" : "("
+								+ rs.getString(4) + ")\t") + rs.getString(5) + newline);
+			}
+		} catch (SQLException e) {
+			// TODO - throw exception - Database access error
+			return e.getMessage();
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * 
+	 * @param name
+	 *            the name of the object to get information on
+	 * @return a tab delimited string containing object, object relationship,
+	 *         object type that this relationship is with, the articlename (if
+	 *         it exists), and description
+	 */
+	public final String getObject(String name) {
+		String _SQL = "SELECT ot1.object_type, rt.relationship_type, ot2.object_type, rt.object2_articlename, ot1.description "
+				+ "FROM object as ot1, object_term2term as rt, object as ot2 "
+				+ "WHERE  ot1.object_id = rt.object1_id and ot2.object_id = rt.object2_id and ot1.object_type = '"
+				+ name + "' " + "ORDER BY ot1.object_type";
+		StringBuffer sb = new StringBuffer();
+		/* ensure connection is not null */
+		if (connection == null)
+			return "";
+
+		ResultSet rs = null;
+		try {
+			Statement stmt = connection.createStatement();
+			rs = stmt.executeQuery(_SQL);
+		} catch (SQLException ex) {
+			// TODO - throw exception - Error in sql
+			return ex.getMessage();
+		}
+		try {
+			while (rs.next()) {
+				// Get the data from the row using the column index
+				sb.append(rs.getString(1)
+						+ "\t"
+						+ rs.getString(2)
+						+ "\t"
+						+ rs.getString(3)
+						+ ((rs.getString(4) == null || rs.getString(4).equals("")) ? "\t" : "("
+								+ rs.getString(4) + ")\t") + rs.getString(5) + newline);
+			}
+		} catch (SQLException e) {
+			// TODO - throw exception - Database access error
+			return e.getMessage();
+		}
+		return sb.toString();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.biomoby.registry.definitions.types.JObjectsI#getObjectsAsArray()
+	 */
+	public String[][] getObjectsAsArray() {
+		ArrayList sb = new ArrayList();
+		/* ensure connection is not null */
+		if (connection == null)
+			return null;
+
+		ResultSet rs = null;
+		try {
+			Statement stmt = connection.createStatement();
+			rs = stmt.executeQuery(sql);
+		} catch (SQLException ex) {
+			return null;
+		}
+		try {
+			while (rs.next()) {
+				// Get the data from the row using the column index
+				sb.add(new String[] {
+						rs.getString(1),
+						rs.getString(2),
+						rs.getString(3),
+						((rs.getString(4) == null || rs.getString(4).equals("")) ? "" : "("
+								+ rs.getString(4) + ")"), rs.getString(5) });
+			}
+		} catch (SQLException e) {
+			return null;
+		}
+		String[][] array = new String[sb.size()][];
+		sb.toArray(array);
+		return array;
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	public String[][] getFullObjectsAsArray() {
+		ArrayList sb = new ArrayList();
+		/* ensure connection is not null */
+		if (connection == null)
+			return null;
+
+		ResultSet rs = null;
+		try {
+			Statement stmt = connection.createStatement();
+			rs = stmt.executeQuery(sql_all);
+		} catch (SQLException ex) {
+			return null;
+		}
+		try {
+			while (rs.next()) {
+				// Get the data from the row using the column index
+				sb.add(new String[] {
+						rs.getString(1),
+						rs.getString(2),
+						rs.getString(3),
+						((rs.getString(4) == null || rs.getString(4).equals("")) ? "" : "("
+								+ rs.getString(4) + ")"), rs.getString(5), rs.getString(6),
+						rs.getString(7), rs.getString(8), rs.getString(9) });
+			}
+		} catch (SQLException e) {
+			return null;
+		}
+		String[][] array = new String[sb.size()][];
+		sb.toArray(array);
+		return array;
+	}
+	public static void main(String[] args) throws MobyException {
+		String[][] datatypes = new JObjectsSqlImpl().getFullObjectsAsArray();
+		for (int i = 0; i < datatypes.length; i++) {
+			String[] datatype = datatypes[i];
+			for (int j = 0; j < datatype.length; j++) {
+				System.out.print(datatype[j] + " ");
+			}
+			System.out.println();
+		}
+	}
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespacesSqlImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespacesSqlImpl.java	2006/03/14 16:23:06	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespacesSqlImpl.java	2006/03/15 16:22:37	1.4
@@ -43,24 +43,12 @@
 			// get certain properties from mobycentral.config
 			Map map = MobyCentralConfig.getMobyNamespace();
 			// Create a connection to the database
-			String serverName = map.get("url") + ":" + map.get("port");// localhost:3306";
-																		// //TODO
-																		// -
-																		// make
-																		// this
-																		// a
-																		// property
-			String mydatabase = (String) map.get("dbname");// "mobyobject";
+			String serverName = map.get("url") + ":" + map.get("port");
+			String mydatabase = (String) map.get("dbname"); 
 			String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
-			String username = (String) map.get("username");// "moby_external";
-			String password = (String) map.get("password");// "";
+			String username = (String) map.get("username"); 
+			String password = (String) map.get("password");
 
-			/*
-			 * String serverName = "mobycentral.icapture.ubc.ca:3306"; String
-			 * mydatabase = "mobynamespace"; String url = "jdbc:mysql://" +
-			 * serverName + "/" + mydatabase; String username = "moby_external";
-			 * String password = "";
-			 */
 			this.connection = DriverManager.getConnection(url, username, password);
 		} catch (ClassNotFoundException e) {
 			throw new MobyException(




More information about the MOBY-guts mailing list