[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Thu Sep 22 16:07:09 UTC 2005


senger
Thu Sep 22 12:07:08 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory pub.open-bio.org:/tmp/cvs-serv17235/src/Clients

Modified Files:
	CacheRegistryClient.java MobyDigestClient.java 
	TestingCentral.java 
Log Message:


moby-live/Java/src/Clients CacheRegistryClient.java,1.3,1.4 MobyDigestClient.java,1.3,1.4 TestingCentral.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2005/09/19 02:24:51	1.3
+++ /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2005/09/22 16:07:08	1.4
@@ -17,14 +17,14 @@
 /**
  * This is a command-line client creating (and removing) a cache of a
  * Moby registry. It allows to store locally (in a file system)
- * objects representing data types and service instances (the service
- * types are ignored, at least for now). <p>
+ * objects representing data types, service instances, namespaces, and
+ * service types. <p>
  *
  * The client is quite simple and its basic functionality is included
  * also in other clients (such as {@link MobyGraphs}. The reason for
  * having this client separately is also to show how to use {@link
  * org.biomoby.client.CentralDigestCachedImpl CentralDigestCachedImpl}
- * - a real caching worker. <p>
+ * - which is a real caching worker. <p>
  *
  * @author <A HREF="mailto:senger at ebi.ac.uk">Martin Senger</A>
  * @version $Id$
@@ -86,40 +86,65 @@
 	    //
 	    // how old is the current cache?
 	    //
-	    if (cmd.hasOption ("-age") || cmd.hasOption ("-rawage")) {
+	    if (cmd.hasOption ("-age") || cmd.hasOption ("-rawage") || cmd.hasOption ("-agediff")) {
 		decorationLn ("Cache age for " + worker.getRegistryEndpoint() + ":");
 		long age = castWorker.getCacheAge();
 		if (age < 0)
-		    decoration ("(cache is empty)");
+		    decorationLn ("(cache is empty)");
 		else {
 		    if (cmd.hasOption ("-age"))
-			System.out.print (new Date (castWorker.getCacheAge()).toString());
-		    else
-			System.out.print (castWorker.getCacheAge());
+			System.out.println (new Date (age).toString());
+		    if (cmd.hasOption ("-agediff"))
+			System.out.println (ms2Human (new Date().getTime() - age));
+		    if (cmd.hasOption ("-ageraw"))
+			System.out.println (age);
 		}
-		decorationLn ("");
 	    }
 
 	    //
 	    // [re-]fill the cache
 	    //
-	    if (cmd.hasOption ("-fill")) {
-		castWorker.removeFromCache (null);
+	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-d")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES);
 		decorationLn ("Retrieving data types...");
 		worker.getDataTypes();
+	    }
+	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-s")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICES);
 		decorationLn ("Retrieving services...");
 		worker.getServices();
 	    }
+	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-t")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+		decorationLn ("Retrieving service types...");
+		worker.getFullServiceTypes();
+	    }
+	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-n")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES);
+		decorationLn ("Retrieving namespaces...");
+		worker.getNamespaces();
+	    }
 
 	    //
 	    // remove the cache
 	    //
-	    if (cmd.hasOption ("-remove")) {
-		castWorker.removeFromCache (null);
-		decorationLn ("Cache removed.");
+	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-d")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES);
+		decorationLn ("Cache for data types removed.");
+	    }
+	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-s")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICES);
+		decorationLn ("Cache for services removed.");
+	    }
+	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-t")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+		decorationLn ("Cache for service types removed.");
+	    }
+	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-n")) {
+		castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES);
+		decorationLn ("Cache for namespaces removed.");
 	    }
 
-
 	} catch (Exception e) {
 	    System.err.println ("===ERROR===");
 	    e.printStackTrace();
@@ -128,6 +153,21 @@
     }
 
     /*************************************************************************
+     * Give me an elapsed time (given in milllis) in a human readable form.
+     *************************************************************************/
+    public static String ms2Human (long millis) {
+	StringBuffer buf = new StringBuffer (100);
+	long seconds = millis / 1000;
+	long minutes = seconds / 60;
+	long hours = minutes / 60;
+	long days = hours / 24;
+	if (days > 0)
+	    buf.append (days + " days and ");
+	buf.append ((hours % 24) + ":" + (minutes % 60) + ":" + (seconds % 60) + "." + (millis % 1000));
+	return new String (buf);
+    }
+
+    /*************************************************************************
      * Print 'msg' but only if in verbose mode
      *************************************************************************/
     static void decoration (String msg) {

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java	2005/09/19 08:08:32	1.3
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java	2005/09/22 16:07:08	1.4
@@ -67,15 +67,19 @@
 	    if (cmd.hasOption ("-verbose"))
 		worker.setDebug (true);
 
-	    // read all data types and their relationships
+	    // read (sometimes all) data types and their relationships
 	    if (cmd.hasOption ("-d")) {
-		MobyDataType[] dataTypes = worker.getDataTypes();
-		for (int i = 0; i < dataTypes.length; i++) {
-		    if (details) {
+		if (details) {
+		    MobyDataType[] dataTypes = worker.getDataTypes();
+		    for (int i = 0; i < dataTypes.length; i++) {
 			System.out.println (dataTypes[i].toString());
 			System.out.println ("---");
-		    } else {
-			System.out.println (dataTypes[i].getName());
+		    }
+		} else {
+		    Map dataTypeNames = worker.getDataTypeNames();
+		    for (Iterator it = dataTypeNames.entrySet().iterator(); it.hasNext(); ) {
+			Map.Entry entry = (Map.Entry)it.next();
+			System.out.println (entry.getKey());
 		    }
 		}
 	    }
@@ -95,13 +99,21 @@
 
 	    // read all services
 	    if (cmd.hasOption ("-s")) {
-		MobyService[] services = worker.getServices();
-		for (int i = 0; i < services.length; i++) {
-		    if (details) {
+		if (details) {
+		    MobyService[] services = worker.getServices();
+		    for (int i = 0; i < services.length; i++) {
 			System.out.println (services[i].toString());
 			System.out.println ("---");
-		    } else {
-			System.out.println (services[i].getName());
+		    }
+		} else {
+		    Map authorities = worker.getServiceNamesByAuthority();
+		    for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) {
+			Map.Entry entry = (Map.Entry)it.next();
+			String authority = (String)entry.getKey();
+			String[] names = (String[])entry.getValue();
+			for (int i = 0; i < names.length; i++) {
+			    System.out.println (names[i] + " (" + authority + ")");
+			}
 		    }
 		}
 	    }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java	2005/09/19 08:08:32	1.6
+++ /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java	2005/09/22 16:07:08	1.7
@@ -162,37 +162,35 @@
 	    worker.setDebug (debug);
 
 	    // ...and call other methods:
-	    String result;
-
-
+	    
 	    // retrieve things
 	    try {
 		start ("retrieveServiceNames");
-		Map serviceNames = worker.getServiceNames();
+		worker.getServiceNamesByAuthority();
 		ok();
 	    } catch (MobyException e) { error (e); }
 
 	    try {
 		start ("retrieveServiceProviders");
-		String[] providers = worker.getProviders();
+		worker.getProviders();
 		ok();
 	    } catch (MobyException e) {	error (e); }
 
 	    try {
 		start ("retrieveServiceTypes");
-		Map serviceTypes = worker.getServiceNames();
+		worker.getServiceTypes();
 		ok();
 	    } catch (MobyException e) {	error (e); }
 
 	    try {
 		start ("retrieveNamespaces");
-		Map namespaces = worker.getNamespaces();
+		worker.getNamespaces();
 		ok();
 	    } catch (MobyException e) {	error (e); }
 
  	    try {
 		start ("retrieveObjectNames");
-		Map typeNames = worker.getDataTypeNames();
+		worker.getDataTypeNames();
 		ok();
 	    } catch (MobyException e) {	error (e); }
 




More information about the MOBY-guts mailing list