[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Oct 30 02:33:25 UTC 2008


gordonp
Wed Oct 29 22:33:25 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory dev.open-bio.org:/tmp/cvs-serv10500/src/main/org/biomoby/shared

Modified Files:
	Central.java MobyDataType.java MobyNamespace.java 
Log Message:
Updates related to SAWSDL wrapping Web Service implementation
moby-live/Java/src/main/org/biomoby/shared Central.java,1.16,1.17 MobyDataType.java,1.25,1.26 MobyNamespace.java,1.12,1.13
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java	2006/11/21 13:04:15	1.16
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java	2008/10/30 02:33:25	1.17
@@ -203,6 +203,9 @@
     MobyDataType getDataType (String dataTypeName)
  	throws MobyException, NoSuccessException;
 
+    MobyDataType[] getDataTypes ()
+ 	throws MobyException, NoSuccessException;
+
     /**************************************************************************
      * Get all relationships of the given 'dataTypeName'.
      *<p>

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java	2008/02/22 09:37:39	1.25
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java	2008/10/30 02:33:25	1.26
@@ -9,11 +9,10 @@
 
 import java.net.URL;
 import java.util.*;
+import java.util.logging.*;
 
 import org.biomoby.client.CentralImpl;
 import org.biomoby.registry.meta.Registry;
-import org.biomoby.registry.meta.RegistryCache;
-import org.biomoby.shared.extended.DataTypeParser;
 
 /**
  * A container representing a data type used in the Moby registry (in
@@ -55,8 +54,8 @@
     protected String lsid = null;
     protected Registry registry = null;  // with which registry was the data type registered?
 
-    private static Map<String,MobyDataType[]> datatypesMapBySynonym = new HashMap<String,MobyDataType[]>();
-    private static Map<URL,MobyDataType[]> datatypesMapByURL = new HashMap<URL,MobyDataType[]>();
+    private static Logger logger = Logger.getLogger("org.biomoby.shared.MobyDataType");
+    private static Map<String,MobyDataType[]> datatypesMapByURL = new HashMap<String,MobyDataType[]>();
 
     /**************************************************************************
      * Default constructor.
@@ -87,27 +86,6 @@
 	return registry;
     }
 
-    /**
-     * Particularly useful for loading data types from cached file, or
-     * refreshing an in-memory cache.
-     */
-    public static void loadDataTypes(URL dataDefURL, Registry reg) throws Exception{
-	synchronized(datatypesMapBySynonym){
-	    if(reg == null){
-		reg = RegistryCache.getDefaultRegistry();
-	    }
-	    
-	    MobyDataType[] datatypes;
-	    DataTypeParser p = new DataTypeParser(dataDefURL);
-	    datatypes = p.getMobyDataTypesFromRDF();
-	    for(MobyDataType dataType: datatypes){
-		dataType.setRegistry(reg);
-	    }
-	    datatypesMapBySynonym.put(reg.getSynonym(), datatypes);
-	    datatypesMapByURL.put(dataDefURL, datatypes);  
-	}
-    }
-
     public static MobyDataType getDataType(String className){
 	return getDataType(className, null);
     }
@@ -120,40 +98,34 @@
 	    return null;
 	}
 
-	if(reg == null){
-	    reg = RegistryCache.getDefaultRegistry();
-	}
-	if(reg == null){
-	    return null;
-	}
 	MobyDataType[] datatypes = null;
-	// sync makes sure we don't fetch it if it's currently being loaded by loadDataTypes
-	synchronized(datatypesMapBySynonym){
-	    datatypes = datatypesMapBySynonym.get(reg.getSynonym());
-	}
 
-	// This method has not been called yet in the JVM, populate the datatypes 
+	// This method has not been called yet in the JVM, populate the namespaces, 
+	// ensuring concurrent calls don't collide
 	synchronized(datatypesMapByURL){
+	    datatypes = datatypesMapByURL.get(reg == null ? "" : reg.getEndpoint());
 	    if(datatypes == null){
+		Central central = null;
 		try{
-		    URL dataDefURL = Registry.findResourceURL(reg, Central.DATA_TYPES_RESOURCE_NAME);
-		    datatypes = datatypesMapByURL.get(dataDefURL);		    
-		    if(datatypes == null){
-			System.err.println("Fetching data type ontology from " + dataDefURL);
-			loadDataTypes(dataDefURL, reg);
-			System.err.println(" ... done");
-			datatypes = datatypesMapByURL.get(dataDefURL);
-		    }
-		    
+		    central = CentralImpl.getDefaultCentral(reg);
+		} catch(MobyException e){
+		    logger.log(Level.WARNING,
+			       "Cannot find a default Moby Central implementation",
+			       e);
+		    return null;
+		}
+		try{
+		    datatypes = central.getDataTypes();
+		    datatypesMapByURL.put(reg == null ? "" : reg.getEndpoint(), datatypes);
 		}
 		catch(Exception e){
-		    System.err.println("Cannot parse MOBY Data Type Ontology: " + e);
+		    logger.log(Level.WARNING,
+			       "Cannot parse MOBY Datatype Ontology: " + e);
 		    e.printStackTrace();
 		    return null;
 		}
 	    }
 	}
-
 	// Perform a linear search for the corresponding datatype to the given name or LSID.
 	for(int i = 0; i < datatypes.length; i++){
 	    String dt_name = datatypes[i].getName();
@@ -165,7 +137,6 @@
 	}
 
 	// Wasn't found if we got to here
-	//(new Exception("Couldn't find data type for '"+className+"'")).printStackTrace();
 	return null;
     }
 

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java	2008/07/16 20:34:07	1.12
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java	2008/10/30 02:33:25	1.13
@@ -9,8 +9,6 @@
 
 import org.biomoby.client.CentralImpl;
 import org.biomoby.registry.meta.Registry;
-import org.biomoby.registry.meta.RegistryCache;
-import org.biomoby.shared.extended.NamespaceParser;
 
 import java.util.*;
 import java.util.logging.*;
@@ -84,9 +82,12 @@
 		}
 		try{
 		    namespaces = central.getFullNamespaces();
+		    namespacesMapByURL.put(reg == null ? "" : reg.getEndpoint(), 
+					   namespaces);
 		}
 		catch(Exception e){
-		    System.err.println("Cannot parse MOBY Namespace Ontology: " + e);
+		    logger.log(Level.WARNING,
+			       "Cannot parse MOBY Namespace Ontology: " + e);
 		    e.printStackTrace();
 		    return null;
 		}




More information about the MOBY-guts mailing list