[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Mon Aug 29 21:09:22 UTC 2005


kawas
Mon Aug 29 17:09:21 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources
In directory pub.open-bio.org:/tmp/cvs-serv15466/org/biomoby/client/ui/graphical/servlet/jresources

Modified Files:
	RESOURCE.java 
Log Message:
fixed the bug in the resources script that occured when a description for an object was longer than a single line.
eddie

moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java	2005/07/20 20:33:22	1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java	2005/08/29 21:09:21	1.9
@@ -1,6 +1,7 @@
 package org.biomoby.client.ui.graphical.servlet.jresources;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
@@ -19,9 +20,9 @@
 import org.biomoby.client.CentralDigestImpl;
 import org.biomoby.client.rdf.vocabulary.Predicates;
 import org.biomoby.client.rdf.vocabulary.XMLTypes;
-import org.biomoby.registry.definitions.types.JNamespaces;
-import org.biomoby.registry.definitions.types.JObjects;
-import org.biomoby.registry.definitions.types.JServices;
+import org.biomoby.registry.definitions.types.JNamespacesSqlImpl;
+import org.biomoby.registry.definitions.types.JObjectsSqlImpl;
+import org.biomoby.registry.definitions.types.JServicesSqlImpl;
 import org.biomoby.registry.properties.MobyProperties;
 import org.biomoby.shared.CentralDigest;
 import org.biomoby.shared.MobyData;
@@ -38,6 +39,7 @@
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFReader;
 import com.hp.hpl.jena.rdf.model.RDFWriter;
 import com.hp.hpl.jena.rdf.model.Resource;
 import com.hp.hpl.jena.vocabulary.DC;
@@ -144,25 +146,15 @@
 
     private static Properties properties = MobyProperties.PROPERTIES();;
 
-    private static final String OBJ = "http://"
-            + properties.getProperty("resources_script_domain")
-            + "/RESOURCES/MOBY-S/Objects#";
-
-    private static final String SRV = "http://"
-            + properties.getProperty("resources_script_domain")
-            + "/RESOURCES/MOBY-S/Services#";
-
-    private static final String NS = "http://"
-            + properties.getProperty("resources_script_domain")
-            + "/RESOURCES/MOBY-S/Namespaces#";
-
-    private static final String MP = "http://"
-            + properties.getProperty("resources_script_domain")
-            + "/RESOURCES/MOBY-S/Predicates#";
-
-    private static final String SI = "http://"
-            + properties.getProperty("resources_script_domain")
-            + "/RESOURCES/MOBY-S/ServiceInstances#";
+    private static final String OBJ = "http://biomoby.org/RESOURCES/MOBY-S/Objects#";
+
+    private static final String SRV = "http://biomoby.org/RESOURCES/MOBY-S/Services#";
+
+    private static final String NS = "http://biomoby.org/RESOURCES/MOBY-S/Namespaces#";
+
+    private static final String MP = "http://biomoby.org/RESOURCES/MOBY-S/Predicates#";
+
+    private static final String SI = "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#";
 
     private static boolean RUN_MAIN = false;
 
@@ -279,15 +271,13 @@
                     writer.write(model, out, null);
                     return;
                 } else if (ontology.equals("Predicates")) {
-                    //TODO - create the predicates RDF/XML document describing
-                    // the Predicates.
-
+                    String s = getPredicates();
+                    
                     response.setContentType("application/rdf+xml");
                     response.setHeader("Content-Disposition",
                             "attachment;filename=Namespaces");
-                    RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
-                    writer.setProperty("showXmlDeclaration", "true");
-                    writer.write(model, out, null);
+                    out.write(s);
+                    out.close();
                     return;
                 } else if (ontology.equals("FULL")) {
                     try {
@@ -329,11 +319,13 @@
      * @return
      * @throws MobyException
      */
-    private final Model getAll(Model model) throws Exception {
+    public final Model getAll(Model model) throws Exception {
         model = getObjects(model);
         model = getServices(model);
         model = getNamespaces(model);
-        //TODO - add the predicates to the model.
+        // add the predicates to the model
+        RDFReader reader = model.getReader();
+        reader.read(model, new ByteArrayInputStream(getPredicates().getBytes()), null);
         try {
             model = getServiceInstances(model);
         } catch (ModelException e) {
@@ -360,6 +352,7 @@
         CentralDigest central = null;
         MobyService[] services = null;
         try {
+            // TODO should i make this more general by adding a parameter for the endpoint?
             central = new CentralDigestImpl();
             services = central.getServices();
         } catch (MobyException e) {
@@ -458,7 +451,6 @@
                             }
                         }
                         if (innerBag != null && innerBag.size() > 0) {
-                            // TODO
                             consumeBag.add(innerBag);
                         }
                         // iterate through items adding them to the bag
@@ -616,19 +608,18 @@
      */
     private final Model getServices(Model model) throws MobyException {
 
-        String str = getTypes("Services");
+        String[][] str = getTypes("Services");
         if (str.equals("")) {
             return null;
         }
         if (RUN_MAIN) {
             createNsMap(model);
         }
-        String[] objects = str.split("\n");
         Resource subject = _addClassResource(model, SRV, "Service",
                 "a base Service class, never instantiated");
         model.add(model.createStatement(subject, RDF.type, RDFS.Class));
-        for (int i = 0; i < objects.length; i++) {
-            String[] _line = objects[i].split("\t");
+        for (int i = 0; i < str.length; i++) {
+            String[] _line = str[i];
             String sub = _line[0];
             String pred = _line[1];
             String obj = _line[2];
@@ -655,19 +646,18 @@
      * @throws MobyException
      */
     private final Model getNamespaces(Model model) throws MobyException {
-        String str = getTypes("Namespaces");
-        if (str.equals("")) {
+        String[][] str = getTypes("Namespaces");
+        if (str == null) {
             return null;
         }
         if (RUN_MAIN) {
             createNsMap(model);
         }
-        String[] objects = str.split("\n");
         Resource subject = _addClassResource(model, NS, "Namespace",
                 "a base Namespace identifier, never instantiated");
         model.add(model.createStatement(subject, RDF.type, RDFS.Class));
-        for (int x = 0; x < objects.length; x++) {
-            String[] _line = objects[x].split("\t");
+        for (int x = 0; x < str.length; x++) {
+            String[] _line = str[x];
             String sub = _line[0];
             String def = "";
             if (_line.length > 1)
@@ -688,11 +678,10 @@
      * @throws MobyException
      */
     private final Model getObjects(Model model) throws MobyException {
-        String str = getTypes("Objects");
-        if (str.equals("")) {
+        String[][] str = getTypes("Objects");
+        if (str == null) {
             return null;
         }
-        String[] objects = str.split("\n");
         // add mobyPred prefix to model
         if (RUN_MAIN) {
             createNsMap(model);
@@ -704,22 +693,19 @@
                 .createLiteral("www.illuminae.com", "en")));
         model.add(model.createStatement(subject, DC.creator, model
                 .createLiteral("markw at illuminae.com", "en")));
-        model.add(model.createStatement(subject, RDF.type, RDFS.Class));
-        for (int x = 0; x < objects.length; x++) {
-            String[] _line = objects[x].split("\t");
+        
+        model.add(model.createStatement(subject, RDFS.subClassOf, Predicates.DataComponent));
+        for (int x = 0; x < str.length; x++) {
+            String[] _line = str[x];
             String sub, pred, obj, def, articlename = "";
             sub = _line[0];
             pred = _line[1];
             obj = _line[2];
-            def = "";
-            if (_line.length == 4)
-                def = _line[3];
-            if (obj.indexOf("(") >= 0)
-                articlename = obj.substring(obj.indexOf("(") + 1, obj
-                        .indexOf(")"));
+            articlename = _line[3];
+            def = _line[4];
             Matcher m;
-            if (obj.indexOf("(") >= 0)
-                obj = obj.substring(0, obj.indexOf("("));
+            if (articlename.indexOf("(") >= 0)
+                articlename = articlename.substring(articlename.indexOf("(")+1, articlename.indexOf(")"));
 
             Resource _subject = _addClassResource(model, OBJ, sub, def);
 
@@ -753,7 +739,7 @@
 
     private final void createNsMap(Model model) {
         Map map = model.getNsPrefixMap();
-        map.put("mobyPred", Predicates.getURI());
+        map.put("moby", Predicates.getURI());
         map.put("mobyObject", OBJ);
         map.put("serviceInstances", SI);
         map.put("mobyNamespace", NS);
@@ -830,8 +816,6 @@
         Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$");
         Matcher m = p.matcher(thing);
         String label = (m.matches() ? m.group(1) : thing);
-        //TODO - add the ofType property if thing is String, Float, Integer,
-        // DataTime.
         Resource resource = model.createResource(ns + thing);
         addOfTypeProperty(model, resource, thing);
         model.add(model.createStatement(resource, RDF.type, RDFS.Class));
@@ -869,33 +853,27 @@
         }
     }
 
-    private final String getTypes(String type) throws MobyException {
+    private final String[][] getTypes(String type) throws MobyException {
         if (type.equalsIgnoreCase("objects")) {
             try {
-                return new JObjects().getObjects();
+                return new JObjectsSqlImpl().getObjectsAsArray();
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            // resort to a secondary method for retrieval of JObjects
-            return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Objects");
         } else if (type.equalsIgnoreCase("services")) {
             try {
-                return new JServices().getServices();
+                return new JServicesSqlImpl().getServicesAsArray();
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            // resort to a secondary method for retrieval of JServices
-            return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Services");
         } else if (type.equalsIgnoreCase("namespaces")) {
             try {
-                return new JNamespaces().getNamespaces();
+                return new JNamespacesSqlImpl().getNamespacesAsArray();
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            // resort to a secondary method for retrieval of JNamespaces
-            return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Namespaces");
         }
-        return "";
+        return null;
     }
 
     /*
@@ -1014,7 +992,9 @@
         StringBuffer buffer = new StringBuffer();
         buffer.append(
                 "<rdf:RDF\r\n" + 
-        		"   xmlns:mobyPred=\"http://biomoby.org/RESOURCES/MOBY-S/Predicates#\"\r\n" + 
+        		"   xmlns:moby=\"http://biomoby.org/RESOURCES/MOBY-S/Predicates#\"\r\n" + 
+        		"   xmlns:mobyObject=\"http://biomoby.org/RESOURCES/MOBY-S/Objects#\"\r\n" +
+        		"   xmlns:serviceInstances=\"http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#\"\r\n" +
         		"   xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\r\n" + 
         		"   xmlns:xs=\"http://www.w3.org/2001/XMLSchema#\"\r\n" + 
         		"   xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\r\n" + 
@@ -1022,91 +1002,97 @@
         		"   xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\r\n");
         // add the predicates here
         buffer.append(createOntologyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
-                "The BioMoby Predicates Vocabulary (mobyPred)",
-                "This is the RDF Schema for the BioMoby Predicate vocabulary defined in the mobyPred namespace."));
+                "The BioMoby Predicates Vocabulary (moby)",
+                "This is the RDF Schema for the BioMoby Predicate vocabulary defined in the moby namespace."));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#hasa",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "hasa","The subject contains exactly one object.",
-                "http://www.w3.org/2000/01/rdf-schema#Property",
-                "http://www.w3.org/2000/01/rdf-schema#Class"));
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object",
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#has",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "has","The subject contains one or more object.",
-                "http://www.w3.org/2000/01/rdf-schema#Property",
-                "http://www.w3.org/2000/01/rdf-schema#Class"));
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object",
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#articleName",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
-                "articleName","The subject is known to be named object while in a relationship.",
-                "http://www.w3.org/2000/01/rdf-schema#Property",
+                "articleName","Uses a non-controlled vocabulary to describe the intended semantic relationship between the Subject node, and the node in which the Subject is associated through a HAS or HASA relationship.",
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object",
+                "http://www.w3.org/2000/01/rdf-schema#Literal"));
+        
+        buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#componentName",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
+                "componentName","The subject is known to be named object.",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#namespace_type",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "namespace_type","The subject resource is applicable under the object namespace.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://www.w3.org/2000/01/rdf-schema#Class", //TODO - namespace?
                 "http://www.w3.org/2000/01/rdf-schema#Resource"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#object_type",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "object_type","The subject resource is a resource object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Objects#Object",
                 "http://www.w3.org/2000/01/rdf-schema#Resource"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#consumes",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "consumes","The subject container takes as input object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent",
                 "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#produces",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "produces","The subject container produces as output object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent",
                 "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#performs_task",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "performs_task","The subject performs the task of the object resource.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://www.w3.org/2000/01/rdf-schema#Class", //TODO servicetype?
                 "http://www.w3.org/2000/01/rdf-schema#Resource"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#default_value",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "default_value","The subject has a default value of object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#min",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "min","The subject has a minimum value of object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#max",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "max","The subject has a maximum value of object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#enum",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "enum","The subject may assume the value of object.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#datatype",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "datatype","Idiomatic property used for structured values.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://www.w3.org/2001/XMLSchema#type",
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#signatureURL",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "signatureURL","Object is a URL that contains information on the subject.",
-                "http://www.w3.org/2000/01/rdf-schema#Class",
+                "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#", //TODO
                 "http://www.w3.org/2000/01/rdf-schema#Literal"));
         
         buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#authoritative",
@@ -1142,34 +1128,37 @@
         buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Simple",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "Simple","A class representing a simple input or output.",
-                "http://www.w3.org/2000/01/rdf-schema#Class"));
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent"));
         
         buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "Secondary","A class representing a secondary input.",
-                "http://www.w3.org/2000/01/rdf-schema#Class"));
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent"));
         
         buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Collection",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
                 "Collection","A container for objects representing Simples.",
-                "http://www.w3.org/2000/01/rdf-schema#Container"));
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent"));
         
-        buffer.append(createEscapedComment("Not sure about the next 3 classes. I dont think that they are actually used anywhere. They represent the articleName of simples, collections and secondaries."));
+        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#MobyThing",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
+                "mobyThing","NOT SURE",
+                "http://www.w3.org/2000/01/rdf-schema#Class"));
         
-        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SimpleArticle",
+        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#MobyMessageComponent",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
-                "SimpleArticle","NOT SURE",
-                "http://www.w3.org/2000/01/rdf-schema#Container"));
+                "MobyMessageComponent","NOT SURE",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#MobyThing"));
         
-        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#CollectionArticle",
+        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#DataComponent",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
-                "CollectionArticle","NOT SURE",
-                "http://www.w3.org/2000/01/rdf-schema#Container"));
+                "DataComponent","NOT SURE",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#MobyMessageComponent"));
         
-        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SecondaryArticle",
+        buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#StructuralComponent",
                 "http://biomoby.org/RESOURCES/MOBY-S/Predicates#",
-                "SecondaryArticle","NOT SURE",
-                "http://www.w3.org/2000/01/rdf-schema#Container"));
+                "StructuralComponent","NOT SURE",
+                "http://biomoby.org/RESOURCES/MOBY-S/Predicates#MobyMessageComponent"));
         
         
         // end the addition of predicates here
@@ -1230,8 +1219,8 @@
         return s;
     }
 
-    public static void main(String[] args) throws MobyException {
-        System.out.println(new RESOURCE().getRESOURCES("Predicates"));
+    public static void main(String[] args) throws Exception {
+        System.out.println(new RESOURCE().getRESOURCES("Namespaces"));
     }
 
 }
\ No newline at end of file




More information about the MOBY-guts mailing list