[MOBY-guts] biomoby commit
Eddie Kawas
kawas at pub.open-bio.org
Tue Mar 14 16:11:44 UTC 2006
kawas
Tue Mar 14 11:11:43 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-serv25707/org/biomoby/registry/definitions/types
Modified Files:
JNamespacesSqlImpl.java
Log Message:
new method to retrieve full namespace information, like lsid, contact_email, authority, etc for use (in the RDF) by clients
moby-live/Java/src/main/org/biomoby/registry/definitions/types JNamespacesSqlImpl.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespacesSqlImpl.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/JNamespacesSqlImpl.java 2005/08/29 20:19:20 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespacesSqlImpl.java 2006/03/14 16:11:43 1.2
@@ -22,6 +22,8 @@
*/
public final class JNamespacesSqlImpl implements JNamespaceI{
private static final String sql = "SELECT namespace_type, description FROM namespace ORDER BY namespace_type asc";
+
+ private static final String sql_all = "SELECT namespace_type, description, namespace_lsid, authority, contact_email FROM namespace ORDER BY namespace_type asc";
private final String newline = System.getProperty("line.separator");
@@ -119,7 +121,44 @@
return array;
}
+ /**
+ * Get all the data in the db regrading namespaces.
+ * @return
+ */
+ public String[][] getFullNamespacesAsArray() {
+ /*ensure that the connection isnt null*/
+ if (connection == null)
+ return null;
+
+ ArrayList sb = new ArrayList();
+ 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), rs.getString(5)});
+ }
+ } catch (SQLException e) {
+ return null;
+ }
+ String[][] array = new String[sb.size()][];
+ sb.toArray(array);
+ return array;
+ }
+
public static void main(String[] args) throws MobyException {
- System.out.println(new JNamespacesSqlImpl().getNamespacesAsArray());
+ String[][] namespaces =new JNamespacesSqlImpl().getFullNamespacesAsArray();
+ for (int i = 0; i < namespaces.length; i++) {
+ String[] namespace = namespaces[i];
+ for (int j = 0; j < namespace.length; j++) {
+ System.out.print(namespace[j] + " ");
+ }
+ System.out.println();
+ }
}
}
More information about the MOBY-guts
mailing list