[MOBY-guts] biomoby commit
Gary Schlitz
gss at pub.open-bio.org
Fri Jun 18 21:42:34 UTC 2004
gss
Fri Jun 18 17:42:34 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/server/src/org/smoby/ref/servlets
In directory pub.open-bio.org:/tmp/cvs-serv30042/src/org/smoby/ref/servlets
Modified Files:
DiscoveryServlet.java
Log Message:
Changes to utilize single model
moby-live/S-MOBY/ref-impl/server/src/org/smoby/ref/servlets DiscoveryServlet.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/server/src/org/smoby/ref/servlets/DiscoveryServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/server/src/org/smoby/ref/servlets/DiscoveryServlet.java 2004/06/14 20:59:36 1.3
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/server/src/org/smoby/ref/servlets/DiscoveryServlet.java 2004/06/18 21:42:34 1.4
@@ -2,8 +2,7 @@
import org.smoby.servlet.*;
import org.smoby.graph.*;
-import org.smoby.parser.NonCanonicalException;
-import org.smoby.parser.Parser;
+import org.smoby.parser.*;
import org.smoby.ref.tools.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdql.*;
@@ -17,11 +16,15 @@
* search the metadata repository for graphs that unify with a query graph
* in the Prolog sense. The query graph should be sent via HTTP POST in a
* parameter named "query-graph"; a set of matching graphs is returned in
- * the response body in either human-readable text format (the default),
- * or in an efficient, machine-readable binary format. To receive the
- * response in this binary format, the client should send a parameter
- * named "binary-return" in the request, with any value. The client can
- * obtain a Java object suitable for parsing either binary or text format
+ * the response body. The statements to be included in each matching graph
+ * is controlled by sending a parameter named "statements". If the value
+ * of the parameter is "minimal", then only a small set of statements is
+ * returned, namely the statements that encode the name, one line
+ * description, and URI of the provider. If the value of the parameter is
+ * "reachable", then all statements reachable from the provider node are
+ * returned for each matching provider.
+ *
+ * The client can obtain a Java object suitable for parsing the graph
* into an array of ProviderDescriptionGraph objects, by calling the
* GraphListTransceiverFactory.newReceiver() factory method.
*/
@@ -42,14 +45,30 @@
//
Parser parser = Parser.forString(graphString, Parser.LANGUAGE_RDF_XML);
MOBYProvider provider = parser.parseProvider();
+
+ // Find which statements the user wishes to have returned
+ //
+ String statements = ParamReader.getParameter(
+ "statements", request, false, new String[] {
+ "minimal", "query", "reachable"
+ });
// Retrieve an array of provider description graphs that unify with
// the query graph.
//
- DiscoveryQuery q = new DiscoveryQuery(provider, DiscoveryQuery.ALL_STMTS);
- MOBYCollection matching = q.findMatchingGraphs();
+ DiscoveryQuery q = null;
+
+ if (statements.equalsIgnoreCase("minimal")) {
+ q = DiscoveryQuery.newMinimalStmtsQuery(provider);
+ } else if (statements.equalsIgnoreCase("query")) {
+ q = DiscoveryQuery.newQueryStmtsQuery(provider);
+ } else {
+ q = DiscoveryQuery.newReachableStmtsQuery(provider);
+ }
+
+ MOBYProviderSet matching = q.findMatchingGraphs();
- if ((matching.size() == 0))
+ if ((matching == null) || (matching.size() == 0))
{
// The client doesn't want the graphs sent in a binary
// format, so show a text message indicating that there
@@ -59,20 +78,10 @@
}
else
{
- for (Iterator it = matching.iterator(); it.hasNext();) {
- MOBYProvider p = (MOBYProvider) it.next();
- p.serialize(out);
- }
+ matching.serialize(out);
}
}
-// catch (NonCanonicalException e)
-// {
-// // The query graph did not have the required canonical form
-// //
-// response.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE,
-// "Query graph is not canonical:\n" + e);
-// }
catch (ParameterException e)
{
// The graph parameter was missing
More information about the MOBY-guts
mailing list