[MOBY-guts] biomoby commit
Gary Schiltz
gss at pub.open-bio.org
Tue Nov 1 16:28:12 UTC 2005
gss
Tue Nov 1 11:28:11 EST 2005
Update of /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools
In directory pub.open-bio.org:/tmp/cvs-serv9543/src/org/semanticmoby/ref/tools
Modified Files:
InvocationBroker.java KeywordFinder.java KeywordList.java
URIInvestigator.java KeywordQuery.java DiscoveryQuery.java
Log Message:
Changes to reflect change of name from Service to Resource
s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools InvocationBroker.java,1.5,1.6 KeywordFinder.java,1.6,1.7 KeywordList.java,1.3,1.4 URIInvestigator.java,1.6,1.7 KeywordQuery.java,1.6,1.7 DiscoveryQuery.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/InvocationBroker.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/InvocationBroker.java 2005/10/09 01:11:21 1.5
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/InvocationBroker.java 2005/11/01 16:28:11 1.6
@@ -9,8 +9,6 @@
import org.semanticmoby.http.*;
-import org.semanticmoby.parser.*;
-
import org.semanticmoby.vocabulary.MOBY;
import java.io.*;
@@ -23,7 +21,7 @@
/**
* This class is used to invoke and display the results of Semantic
- * MOBY services.
+ * MOBY resources.
*/
public class InvocationBroker {
@@ -54,49 +52,49 @@
this.response = response;
}
- private String rdfxmlString(MOBYService service) {
+ private String rdfxmlString(MOBYResource resource) {
StringWriter writer = new StringWriter();
- service.getJenaModel().write(writer);
+ resource.getJenaModel().write(writer);
return writer.toString();
}
- private String n3String(MOBYService service) {
+ private String n3String(MOBYResource resource) {
StringWriter writer = new StringWriter();
- service.getJenaModel().write(writer, "N3");
+ resource.getJenaModel().write(writer, "N3");
return writer.toString();
}
/**
- * Handle a request to invoke a service at a given URI.
- * If the service requires inputs, and the service has
+ * Handle a request to invoke a resource at a given URI.
+ * If the resource requires inputs, and the resource has
* a valid inputURI property, redirect to the URI that is
- * the value of the property. If the service requires input
+ * the value of the property. If the resource requires input
* and has no inputURI property, then build a simple input
* GUI from scratch.
* <br><br>
- * If the service doesn't require any inputs, then do an HTTP
- * POST to the service URI, passing the graph as a parameter.
+ * If the resource doesn't require any inputs, then do an HTTP
+ * POST to the resource URI, passing the graph as a parameter.
*/
- public void invokeURI(String serviceURI) {
+ public void invokeURI(String resourceURI) {
- // Try to retrieve and parse a service graph from the URI;
+ // Try to retrieve and parse a resource graph from the URI;
// on failure, print a message and return.
//
- MOBYService service = null;
+ MOBYResource resource = null;
try {
Model model = ModelFactory.createDefaultModel();
- model.read(serviceURI);
+ model.read(resourceURI);
Parser parser = new Parser(model);
- service = parser.parseService();
+ resource = parser.parseResource();
} catch (Throwable t) {
t.printStackTrace();
@@ -104,18 +102,18 @@
return;
}
- if (requiresInputs(service)) {
+ if (requiresInputs(resource)) {
- // Since the service requires input, either redirect to its
+ // Since the resource requires input, either redirect to its
// inputURI (if it has one) or build a simple GUI for it.
//
try {
- String inputURI = getInputURI(service);
+ String inputURI = getInputURI(resource);
if (inputURI == null) {
- buildInputGUI(service);
+ buildInputGUI(resource);
} else {
// Do an HTTP HEAD request to find out if the
@@ -131,24 +129,24 @@
response.sendRedirect(inputURI);
} else {
- buildInputGUI(service);
+ buildInputGUI(resource);
}
}
} catch (Throwable t) {
t.printStackTrace();
- buildInputGUI(service);
+ buildInputGUI(resource);
}
} else // No input required
{
try {
- // Invoke the service
+ // Invoke the resource
//
- HTTPRequest rqst = HTTPRequest.newPostRequest(service.getURI());
+ HTTPRequest rqst = HTTPRequest.newPostRequest(resource.getURI());
rqst.addParameter(MOBY.GRAPH_PARAMETER_NAME,
- rdfxmlString(service));
+ rdfxmlString(resource));
HTTPResponse resp = rqst.send();
@@ -165,16 +163,16 @@
model.read(resp.getBodyAsStream(), "");
Parser parser = new Parser(model);
- MOBYService resultsService = parser.parseService();
+ MOBYResource resultsResource = parser.parseResource();
- String outputURI = getOutputURI(resultsService);
+ String outputURI = getOutputURI(resultsResource);
if (outputURI == null) {
// No output URI was specified, so build a generic
// display of the results
//
- buildOutputGUI(resultsService);
+ buildOutputGUI(resultsResource);
} else {
// There is an output URI. Conceptually, what we want
@@ -193,7 +191,7 @@
//
rqst = HTTPRequest.newPostRequest(outputURI);
- String graphString = rdfxmlString(resultsService);
+ String graphString = rdfxmlString(resultsResource);
rqst.addParameter(MOBY.GRAPH_PARAMETER_NAME,
graphString);
resp = rqst.send();
@@ -210,12 +208,12 @@
// The output URI returned a status other than
// 200 OK, so fall back to a default output GUI
//
- buildOutputGUI(resultsService);
+ buildOutputGUI(resultsResource);
}
} catch (Throwable t) {
t.printStackTrace();
- buildOutputGUI(resultsService);
+ buildOutputGUI(resultsResource);
}
}
} else {
@@ -252,13 +250,13 @@
}
- private String getInputURI(MOBYService service) {
+ private String getInputURI(MOBYResource resource) {
try {
- Model model = service.getJenaModel();
+ Model model = resource.getJenaModel();
Statement stmt =
- model.getProperty(service.getResource(), MOBY.inputURI);
+ model.getProperty(resource.getResource(), MOBY.inputURI);
if (stmt != null) {
@@ -276,13 +274,13 @@
}
- private String getOutputURI(MOBYService service) {
+ private String getOutputURI(MOBYResource resource) {
try {
- Model model = service.getJenaModel();
+ Model model = resource.getJenaModel();
Statement stmt =
- model.getProperty(service.getResource(), MOBY.outputURI);
+ model.getProperty(resource.getResource(), MOBY.outputURI);
return stmt.getString();
} catch (Throwable t) {
@@ -294,30 +292,30 @@
}
- public void buildInputGUI(MOBYService service) {
+ public void buildInputGUI(MOBYResource resource) {
// error message
}
- public void buildOutputGUI(MOBYService service)
+ public void buildOutputGUI(MOBYResource resource)
throws IOException, ServletException {
HttpSession session = request.getSession(true);
session.setAttribute("n3Graph",
- n3String(service).replaceAll("<", "<")
+ n3String(resource).replaceAll("<", "<")
.replaceAll(">", ">").replaceAll("\"",
"""));
session.setAttribute("rdfxmlGraph",
- rdfxmlString(service).replaceAll("<", "<")
+ rdfxmlString(resource).replaceAll("<", "<")
.replaceAll(">", ">").replaceAll("\"",
"""));
redirectToPage("/jsp/display.jsp");
}
- private boolean requiresInputs(MOBYService service) {
+ private boolean requiresInputs(MOBYResource resource) {
- return getInputURI(service) != null;
+ return getInputURI(resource) != null;
}
}
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordFinder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordFinder.java 2005/10/28 04:12:27 1.6
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordFinder.java 2005/11/01 16:28:11 1.7
@@ -6,8 +6,6 @@
import org.semanticmoby.graph.*;
-import org.semanticmoby.parser.*;
-
import org.semanticmoby.vocabulary.MOBY;
import java.util.*;
@@ -16,15 +14,15 @@
public class KeywordFinder {
/**
- * The MOBY service for which to find keywords
+ * The MOBY resource for which to find keywords
*/
- private MOBYService service;
+ private MOBYResource resource;
/**
- * The underlying Jena model on which the MOBY service
+ * The underlying Jena model on which the MOBY resource
* is based
*/
- private Model serviceModel;
+ private Model resourceModel;
/**
* A keyword list object to hold the keywords that are
@@ -33,17 +31,17 @@
private KeywordList keywords = null;
/**
- * Construct an instance for the given service and model
+ * Construct an instance for the given resource and model
*/
- public KeywordFinder(MOBYService service) {
+ public KeywordFinder(MOBYResource resource) {
- this.service = service;
- this.serviceModel = service.getJenaModel();
+ this.resource = resource;
+ this.resourceModel = resource.getJenaModel();
}
/**
* Retrieve, if necessary, and return the keywords associated
- * with the service.
+ * with the resource.
*/
public KeywordList getKeywords() throws Exception {
@@ -58,20 +56,20 @@
/**
- * Collect keywords for the service
+ * Collect keywords for the resource
*/
- private void collectKeywords() { // Add keywords from classes that the service is asserted to
+ private void collectKeywords() { // Add keywords from classes that the resource is asserted to
- // be an instance of (i.e. service rdf:type <some type>)
+ // be an instance of (i.e. resource rdf:type <some type>)
//
- Resource res = service.getResource();
+ Resource res = resource.getResource();
- keywords.addServiceKeywords(getKeywordsFor(res));
+ keywords.addResourceKeywords(getKeywordsFor(res));
// Add keywords from subjects and objects of each
// operatesOn subgraph
//
- for (Iterator it = service.getOperatesOn(); it.hasNext();) {
+ for (Iterator it = resource.getOperatesOn(); it.hasNext();) {
MOBYGraphNode node = (MOBYGraphNode) it.next();
@@ -176,7 +174,7 @@
// Iterate over the resource's rdf:type properties
//
StmtIterator it =
- serviceModel.listStatements(res, RDF.type, (RDFNode) null);
+ resourceModel.listStatements(res, RDF.type, (RDFNode) null);
while (it.hasNext()) {
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordList.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordList.java 2005/10/09 01:11:21 1.3
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordList.java 2005/11/01 16:28:11 1.4
@@ -7,25 +7,25 @@
public class KeywordList {
- private Set serviceKeywords = new HashSet();
+ private Set resourceKeywords = new HashSet();
private Set subjectKeywords = new HashSet();
private Set objectKeywords = new HashSet();
- public void addServiceKeyword(String keyword) {
+ public void addResourceKeyword(String keyword) {
- serviceKeywords.add(keyword);
+ resourceKeywords.add(keyword);
}
- public void addServiceKeywords(List keywords) {
+ public void addResourceKeywords(List keywords) {
- serviceKeywords.addAll(keywords);
+ resourceKeywords.addAll(keywords);
}
- public Iterator getServiceKeywords() {
+ public Iterator getResourceKeywords() {
- return serviceKeywords.iterator();
+ return resourceKeywords.iterator();
}
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java 2005/10/28 04:12:27 1.6
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/URIInvestigator.java 2005/11/01 16:28:11 1.7
@@ -9,8 +9,6 @@
import org.semanticmoby.http.*;
-import org.semanticmoby.parser.*;
-
import org.semanticmoby.ref.tools.db.*;
import org.semanticmoby.tools.*;
@@ -46,15 +44,15 @@
* The URL that is to be investigated for possible inclusion in the
* metadata repository.
*/
- private String serviceURL;
+ private String resourceURL;
/**
* Create an instance for investingating the given resource URL
* @param resourceURL the URL to investigate
*/
- private URIInvestigator(String serviceURL) {
+ private URIInvestigator(String resourceURL) {
- this.serviceURL = serviceURL;
+ this.resourceURL = resourceURL;
}
/**
@@ -64,19 +62,19 @@
* investigated, then this call is a NO-OP.
* @param resourceURL the URL to investigate
*/
- public synchronized static void investigate(String serviceURL) {
+ public synchronized static void investigate(String resourceURL) {
synchronized (instances) {
- if (instances.get(serviceURL) != null) {
+ if (instances.get(resourceURL) != null) {
- syncLog.warn("Already investigating " + serviceURL);
+ syncLog.warn("Already investigating " + resourceURL);
return;
}
- URIInvestigator investigator = new URIInvestigator(serviceURL);
- instances.put(serviceURL, investigator);
+ URIInvestigator investigator = new URIInvestigator(resourceURL);
+ instances.put(resourceURL, investigator);
investigator.start();
}
}
@@ -121,7 +119,7 @@
//
synchronized (instances) {
- instances.remove(serviceURL);
+ instances.remove(resourceURL);
}
}
}
@@ -152,13 +150,13 @@
try {
- lastModifiedDate = manager.getLastModifiedDate(serviceURL);
+ lastModifiedDate = manager.getLastModifiedDate(resourceURL);
alreadyRegistered = (lastModifiedDate != null);
} catch (StorageException e) {
e.printStackTrace();
syncLog.error("Couldn't check for last modified date of resource URL " +
- serviceURL, e);
+ resourceURL, e);
e.printStackTrace();
return;
@@ -166,7 +164,7 @@
// Helper class for making the HTTP GET call
//
- HTTPRequest request = HTTPRequest.newGetRequest(serviceURL);
+ HTTPRequest request = HTTPRequest.newGetRequest(resourceURL);
// If there was a last modified date, then request that the graph only
// be sent if it has been modified since that date
@@ -190,7 +188,7 @@
} catch (HTTPException e) {
e.printStackTrace();
- syncLog.warn("Couldn't reach suggested resource " + serviceURL);
+ syncLog.warn("Couldn't reach suggested resource " + resourceURL);
return;
}
@@ -202,7 +200,7 @@
// The resource has not been modified since it was
// registered, so there is nothing to do but log a message.
//
- syncLog.info("IN-SYNC : " + serviceURL);
+ syncLog.info("IN-SYNC : " + resourceURL);
break;
@@ -214,10 +212,10 @@
if (alreadyRegistered) {
deregisterResource(manager, true);
- syncLog.info("ALREADY REGISTERED : " + serviceURL);
+ syncLog.info("ALREADY REGISTERED : " + resourceURL);
} else {
- syncLog.info("IGNORED : " + serviceURL + " doesn't exist");
+ syncLog.info("IGNORED : " + resourceURL + " doesn't exist");
}
break;
@@ -245,7 +243,7 @@
//
e.printStackTrace();
syncLog.warn("Unable to get Last-Modified date for " +
- serviceURL + "; using current date");
+ resourceURL + "; using current date");
lastModifiedDate = new Date();
} catch (Throwable t) {
@@ -254,7 +252,7 @@
//
t.printStackTrace();
syncLog.warn("Unparsable Last-Modified date " + "(\"" +
- dateString + "\") for " + serviceURL +
+ dateString + "\") for " + resourceURL +
"; ignoring");
}
@@ -270,48 +268,48 @@
} catch (HTTPException e) {
e.printStackTrace();
- syncLog.error("Couldn't retrieve graph from " + serviceURL);
+ syncLog.error("Couldn't retrieve graph from " + resourceURL);
return;
}
- MOBYService service = null;
+ MOBYResource resource = null;
try {
Parser parser =
Parser.forInputStream(in, Parser.LANGUAGE_RDF_XML);
- service = parser.parseService();
+ resource = parser.parseResource();
} catch (Throwable t) {
t.printStackTrace();
System.err.println("Parse error: " + t);
}
- if (service == null) {
+ if (resource == null) {
// De-register the resource, printing a removal message if
- // a service couldn't be parsed
- deregisterResource(manager, service == null);
- syncLog.error("Couldn't parse a resource from graph at " + serviceURL);
+ // a resource couldn't be parsed
+ deregisterResource(manager, resource == null);
+ syncLog.error("Couldn't parse a resource from graph at " + resourceURL);
- // If a service was parsed, then register it
+ // If a resource was parsed, then register it
} else {
try {
- manager.registerResource(service, lastModifiedDate);
+ manager.registerResource(resource, lastModifiedDate);
// Log a message about successfully registering the graph:
//
syncLog.info((
alreadyRegistered ? "UPDATED : "
: "ADDED : "
- ) + serviceURL);
+ ) + resourceURL);
} catch (Exception e) {
e.printStackTrace();
- syncLog.error("Error storing graph for " + serviceURL, e);
+ syncLog.error("Error storing graph for " + resourceURL, e);
}
}
@@ -322,7 +320,7 @@
// Log a message about the failed attempt to contact the URL
//
syncLog.error("Status " + status + " received while trying " +
- "to contact resource " + serviceURL);
+ "to contact resource " + resourceURL);
break;
}
@@ -333,16 +331,16 @@
try {
- manager.deregisterResource(serviceURL);
+ manager.deregisterResource(resourceURL);
if (removing) {
- syncLog.info("REMOVED : " + serviceURL);
+ syncLog.info("REMOVED : " + resourceURL);
}
} catch (StorageException e) {
e.printStackTrace();
- syncLog.error("Unable to de-register resource " + serviceURL, e);
+ syncLog.error("Unable to de-register resource " + resourceURL, e);
}
}
}
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordQuery.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordQuery.java 2005/10/28 04:12:27 1.6
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/KeywordQuery.java 2005/11/01 16:28:11 1.7
@@ -5,8 +5,6 @@
import org.semanticmoby.graph.*;
-import org.semanticmoby.parser.Parser;
-
import org.semanticmoby.ref.tools.db.*;
import org.semanticmoby.tools.Util;
@@ -50,7 +48,7 @@
while (rs.next()) {
String uri = rs.getString("resource_uri");
- MOBYService resource = serviceAt(uri, model);
+ MOBYResource resource = resourceAt(uri, model);
if (resource != null) {
@@ -75,7 +73,7 @@
}
- private MOBYService serviceAt(String uri, Model model) {
+ private MOBYResource resourceAt(String uri, Model model) {
Model resourceModel = ModelFactory.createDefaultModel();
Resource resource = resourceModel.createResource(uri);
@@ -86,7 +84,7 @@
Parser parser = new Parser(resourceModel);
- return parser.parseService();
+ return parser.parseResource();
} catch (Throwable t) {
t.printStackTrace();
===================================================================
RCS file: /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/DiscoveryQuery.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/DiscoveryQuery.java 2005/10/28 04:12:27 1.6
+++ /home/repository/moby/s-moby/ref-impl/semanticmoby.org/src/org/semanticmoby/ref/tools/DiscoveryQuery.java 2005/11/01 16:28:11 1.7
@@ -10,8 +10,6 @@
import org.semanticmoby.graph.*;
-import org.semanticmoby.parser.*;
-
import org.semanticmoby.ref.tools.db.*;
import org.semanticmoby.tools.Util;
@@ -53,7 +51,7 @@
/**
* The graph that serves as a template for resources that match.
*/
- private MOBYService queryResource;
+ private MOBYResource queryResource;
/**
* Flag indicating which statements should be returned: URI_ONLY,
@@ -79,25 +77,25 @@
* @param statementsToReturn which statements should be returned: URI_ONLY,
* QUERY_STMTS_ONLY, or ALL_STMTS (use the static constants on this class).
*/
- private DiscoveryQuery(MOBYService queryResource, int statementsToReturn) {
+ private DiscoveryQuery(MOBYResource queryResource, int statementsToReturn) {
this.queryResource = queryResource;
this.statementsToReturn = statementsToReturn;
}
- public static DiscoveryQuery newMinimalStmtsQuery(MOBYService resource) {
+ public static DiscoveryQuery newMinimalStmtsQuery(MOBYResource resource) {
return new DiscoveryQuery(resource, MINIMAL_STMTS);
}
- public static DiscoveryQuery newQueryStmtsQuery(MOBYService resource) {
+ public static DiscoveryQuery newQueryStmtsQuery(MOBYResource resource) {
return new DiscoveryQuery(resource, QUERY_STMTS);
}
- public static DiscoveryQuery newReachableStmtsQuery(MOBYService resource) {
+ public static DiscoveryQuery newReachableStmtsQuery(MOBYResource resource) {
return new DiscoveryQuery(resource, REACHABLE_STMTS);
}
@@ -114,7 +112,7 @@
}
- public MOBYServiceSet findMatchingGraphs() {
+ public MOBYResourceSet findMatchingGraphs() {
init();
@@ -123,7 +121,7 @@
try {
Model queryModel =
- ((MOBYService) queryResource).getJenaModel();
+ ((MOBYResource) queryResource).getJenaModel();
String queryString = buildQueryString(queryModel);
StorageManager manager = new StorageManager();
dbModel = manager.openDBModel();
@@ -142,14 +140,14 @@
results.close();
- MOBYServiceSet returnSet = new MOBYServiceSet();
+ MOBYResourceSet returnSet = new MOBYResourceSet();
for (Iterator it = matching.iterator(); it.hasNext();) {
Object next = it.next();
- MOBYService mp =
+ MOBYResource mp =
buildGraphModel(dbModel, queryModel, (ResultBinding) next);
- returnSet.addService(mp);
+ returnSet.addResource(mp);
}
return returnSet;
@@ -273,7 +271,7 @@
* @param binding bindings for variables
* @return
*/
- private MOBYService buildGraphModel(Model dbModel, Model queryModel,
+ private MOBYResource buildGraphModel(Model dbModel, Model queryModel,
ResultBinding binding)
throws NonCanonicalException {
@@ -313,7 +311,7 @@
//
Parser parser = new Parser(adjusted);
- return parser.parseService();
+ return parser.parseResource();
}
@@ -361,7 +359,7 @@
try {
Statement resourceTypeStmt =
- original.listStatements(null, RDF.type, MOBY.Service)
+ original.listStatements(null, RDF.type, MOBY.Resource)
.nextStatement();
minimal.add(resourceTypeStmt);
@@ -433,7 +431,7 @@
try {
Statement resourceTypeStmt =
- original.listStatements(null, RDF.type, MOBY.Service)
+ original.listStatements(null, RDF.type, MOBY.Resource)
.nextStatement();
Resource subject = resourceTypeStmt.getSubject();
Util.addReachableStmts(dbModel, reachable, subject, subject.getURI());
More information about the MOBY-guts
mailing list