[MOBY-guts] biomoby commit
Gary Schlitz
gss at pub.open-bio.org
Wed Jul 21 22:01:20 UTC 2004
gss
Wed Jul 21 18:01:20 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db
In directory pub.open-bio.org:/tmp/cvs-serv12905/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db
Modified Files:
StorageManager.java
Log Message:
Many changes prior to BOSC
moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db StorageManager.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db/StorageManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db/StorageManager.java 2004/07/15 20:27:17 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/semanticmoby.org/src/org/smoby/ref/tools/db/StorageManager.java 2004/07/21 22:01:20 1.2
@@ -9,6 +9,8 @@
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.shared.*;
import com.hp.hpl.jena.vocabulary.*;
+import java.sql.Connection;
+import java.sql.SQLException;
import java.util.*;
/**
@@ -60,7 +62,7 @@
{
Model model = ((MOBYProviderImpl) provider).getUnderlying();
Model dbModel = null;
- String uriString = provider.getURI();
+ String uriString = provider.getResource().getURI();
Resource uri = model.createResource(uriString);
try
@@ -100,6 +102,12 @@
dbModel.add(uri, MOBY.lastModifiedDate, lastModifiedDate.getTime());
}
+ // Add keywords associated with the provider
+ //
+ KeywordFinder finder = new KeywordFinder(provider, model);
+ addKeywords(provider.getResource().getURI(),
+ finder.getKeywords(), dbModel);
+
// Commit the transaction on the database model
//
dbModel.commit();
@@ -116,6 +124,73 @@
}
}
}
+
+ private void addKeywords(String providerURI, KeywordList list, Model model)
+ throws StorageException
+ {
+ try
+ {
+ ModelRDB dbModel = (ModelRDB) model;
+ Connection conn = dbModel.getConnection().getConnection();
+
+ java.sql.Statement sql = conn.createStatement();
+
+ doAddKeywords(providerURI, list.getProviderKeywords(), "P", sql);
+ doAddKeywords(providerURI, list.getSubjectKeywords(), "S", sql);
+ doAddKeywords(providerURI, list.getObjectKeywords(), "O", sql);
+
+ }
+ catch (Throwable t)
+ {
+ throw new StorageException(t);
+ }
+ }
+
+ private void doAddKeywords(String providerURI, Iterator it,
+ String appliesTo, java.sql.Statement sql)
+ throws SQLException
+ {
+ while (it.hasNext())
+ {
+ String keyword = it.next().toString();
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("INSERT INTO MOBY_KEYWORD\n");
+ sb.append(" (keyword, provider_uri, applies_to)\n");
+ sb.append("values ('");
+ sb.append(keyword.toLowerCase().trim());
+ sb.append("', '");
+ sb.append(providerURI);
+ sb.append("', '");
+ sb.append(appliesTo);
+ sb.append("')");
+
+ String queryString = sb.toString();
+
+ sql.execute(queryString);
+ }
+ }
+
+ private void removeKeywords(String providerURI, Model model)
+ throws StorageException
+ {
+ try
+ {
+ ModelRDB dbModel = (ModelRDB) model;
+ Connection conn = dbModel.getConnection().getConnection();
+
+ java.sql.Statement sql = conn.createStatement();
+
+ sql.execute("DELETE FROM MOBY_KEYWORD WHERE provider_uri = '"
+ + providerURI + "'");
+
+ }
+ catch (Throwable t)
+ {
+ throw new StorageException(t);
+ }
+ }
/**
* Remove all the statements registered by a given provider URI
@@ -143,6 +218,10 @@
//
ProviderRemover.remove(dbModel, providerURI);
+ // Remove keywords associated with the provider URI
+ //
+ removeKeywords(providerURI, dbModel);
+
// Commit the transaction on the database
//
dbModel.commit();
More information about the MOBY-guts
mailing list