[MOBY-guts] biomoby commit
Gary Schlitz
gss at pub.open-bio.org
Wed May 19 23:33:05 UTC 2004
gss
Wed May 19 19:33:05 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/example-providers/acmepubs.com/src/com/acmepubs/servlets
In directory pub.open-bio.org:/tmp/cvs-serv2250/src/com/acmepubs/servlets
Modified Files:
CitationSearchServlet.java
Log Message:
Incorporation of new parser
moby-live/S-MOBY/ref-impl/example-providers/acmepubs.com/src/com/acmepubs/servlets CitationSearchServlet.java,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/example-providers/acmepubs.com/src/com/acmepubs/servlets/CitationSearchServlet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/example-providers/acmepubs.com/src/com/acmepubs/servlets/CitationSearchServlet.java 2004/05/19 18:26:52 1.8
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/example-providers/acmepubs.com/src/com/acmepubs/servlets/CitationSearchServlet.java 2004/05/19 23:33:05 1.9
@@ -7,6 +7,7 @@
import org.go.vocabulary.*;
import org.smoby.servlet.*;
import org.smoby.graph.*;
+import org.smoby.graph.impl.MOBYObjectFactory;
import org.smoby.vocabulary.*;
import com.acmepubs.vocabulary.*;
@@ -35,47 +36,54 @@
* a gene symbol and returning a URL for querying the
* SGD database for literature pertaining to that URL.
*/
- protected void handleRequest(MOBYProvider graph)
+ protected void handleRequest(MOBYProvider provider)
{
- // Retrieve the subject of the moby:operatesOn statement (there is only
- // one operatesOn statement in a valid MOBY graph)
- //
-// Resource mobyGraphSubject = (Resource) graph.getOperatesOnStmt().getObject();
-//
-// // There may be multiple moby:hasMapping statements. For each one,
-// // map its geneSymbol to a literatureGuideURL
-// //
-// StmtIterator it = graph.getModel().listStatements(
-// mobyGraphSubject, MOBY.hasMapping, (RDFNode) null);
-//
-// while (it.hasNext())
-// {
-// try
-// {
-// Statement hasMappingStmt = it.nextStatement();
-// Resource mobySubject = (Resource) hasMappingStmt.getObject();
-//
-// Statement geneSymbolStmt =
-// getFirstStatement(graph, mobySubject, AcmePubs.geneSymbol, null);
-//
-// String geneSymbol = geneSymbolStmt.getString();
-//
-// Statement mapsToStmt =
-// getFirstStatement(graph, mobySubject, MOBY.mapsTo, null);
-//
-// Resource mobyObject = (Resource) mapsToStmt.getObject();
-//
-// Statement literatureGuideURLStmt =
-// getFirstStatement(graph, mobyObject, AcmePubs.literatureGuideURL, null);
-//
-// String baseURI = "http://db.yeastgenome.org/cgi-bin/SGD/reference/geneinfo.pl?locus=";
-// literatureGuideURLStmt.changeObject(baseURI + geneSymbol);
-// }
-// catch (Throwable t)
-// {
-// // Something went wrong, so proceed to next hasMapping statement
-// }
-// }
+ try
+ {
+ // There should be only one operatesOn subgraph, which should be
+ // a collection of MOBYGraph objects.
+ //
+ MOBYCollection coll = (MOBYCollection)
+ provider.getOperatesOn().iterator().next();
+
+ // Iterate over the MOBYGraph objects
+ //
+ Iterator it = coll.iterator();
+ while (it.hasNext())
+ {
+ MOBYGraph graph = (MOBYGraph) it.next();
+
+ // The subject of the graph should be a MOBYSubject
+ //
+ MOBYSubject subject = (MOBYSubject) graph.gethasMapping();
+
+ // That object should have a single subproperty of moby:Property,
+ // namely geneSymbol; its value should be a literal
+ //
+ MOBYPropertyValueStatement stmt = (MOBYPropertyValueStatement)
+ subject.getPropertyValueStatements().iterator().next();
+ MOBYLiteral literal = (MOBYLiteral) stmt.getValue();
+ String geneSymbol = literal.getStringValue();
+
+ // The object of the MOBYSubject should be a MOBYObject. That
+ // object should have a single subproperty of moby:Property,
+ // namely literatureGuideURL
+ //
+ MOBYObject object = (MOBYObject)
+ subject.getDirectMappings().iterator().next();
+ stmt = (MOBYPropertyValueStatement)
+ object.getPropertyValueStatements().iterator().next();
+
+ // Set the value of the literatureGuideURL to a literal value
+ // based on a base URI string and the geneSymbol that was passed
+ //
+ String baseURI = "http://db.yeastgenome.org/cgi-bin/SGD/reference/geneinfo.pl?locus=";
+ literal = MOBYObjectFactory.newLiteralValue(
+ baseURI + geneSymbol);
+ stmt.setPropertyValue(literal);
+ }
+ }
+ catch (Throwable t) {System.out.println(t);} // No feedback on failure...
}
/**
More information about the MOBY-guts
mailing list