[MOBY-guts] biomoby commit

Gary Schlitz gss at pub.open-bio.org
Fri Jun 18 21:38:27 UTC 2004


gss
Fri Jun 18 17:38:27 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/parser
In directory pub.open-bio.org:/tmp/cvs-serv29813/src/org/smoby/parser

Modified Files:
	Parser.java 
Log Message:
Minor small fixes

moby-live/S-MOBY/ref-impl/core/src/org/smoby/parser Parser.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/parser/Parser.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/core/src/org/smoby/parser/Parser.java	2004/06/17 17:35:01	1.3
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/parser/Parser.java	2004/06/18 21:38:27	1.4
@@ -6,6 +6,7 @@
 import org.smoby.graph.*;
 import org.smoby.graph.impl.*;
 import org.smoby.parser.*;
+import org.smoby.tools.Util;
 import org.smoby.vocabulary.*;
 import com.hp.hpl.jena.rdf.model.*;
 import com.hp.hpl.jena.vocabulary.*;
@@ -100,7 +101,7 @@
     public static Parser forInputStream(InputStream is, String language)
 		throws UnparsableGraphException
     {
-        Model model = ModelFactory.createDefaultModel();
+        Model model = Util.newJenaModel();
         try {
             model.read(is, "", language);
         } catch (Throwable t) {
@@ -131,45 +132,14 @@
         while (it.hasNext())
         {
         	Statement stmt = it.nextStatement();
-        	Model subModel = ModelFactory.createDefaultModel();
+        	Model subModel = Util.newJenaModel();
         	subModel.setNsPrefixes(model.getNsPrefixMap());
         	Resource subject = stmt.getSubject();
-        	addReachableStmts(subModel, subject, subject.getURI());
+        	Util.addReachableStmts(model, subModel, subject, subject.getURI());
         	inferenceModels.put(subModel,
         		ModelFactory.createRDFSModel(subModel));
         }
     }
-    
-	private void addReachableStmts(Model model, Resource subject, String uri)
-	{
-		// For each statement whose subject is the given resource
-		//
-		StmtIterator it = subject.getModel().listStatements(
-			subject, null, (RDFNode) null);
-		
-		while (it.hasNext())
-		{
-			Statement stmt = it.nextStatement();
-			
-			// The statement itself should be added
-			//
-			model.add(model.createStatement(
-				stmt.getSubject(), stmt.getPredicate(), stmt.getObject()));
-			
-			// If the object of the statement is a blank node or a
-			// resource whose URI starts with the provider URI, then
-			// recursively add the statements that are reachable
-			// from the object
-			//
-			if (stmt.getObject().canAs(Resource.class))
-			{
-				Resource object = (Resource) stmt.getObject().as(Resource.class);
-				if (object.isAnon() || object.getURI().startsWith(uri)) {
-					addReachableStmts(model, object, uri);
-				}
-			}
-		}
-	}
 
     /**
      * Parse a provider from the model. If the model contains
@@ -196,14 +166,9 @@
     {
         ArrayList providers = new ArrayList();
         
-        // Find the statements that say something is of type Provider
-        //
-//        StmtIterator it = underlying.listStatements(null, RDF.type, MOBY.Provider);
-        
-        Iterator it = inferenceModels.keySet().iterator();
-        
         // Parse each provider
         //
+        Iterator it = inferenceModels.keySet().iterator();
         while (it.hasNext())
         {
         	Model model = (Model) it.next();




More information about the MOBY-guts mailing list