[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Sun Mar 2 12:45:25 UTC 2008


senger
Sun Mar  2 07:45:25 EST 2008
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory dev.open-bio.org:/tmp/cvs-serv32345/src/Clients

Modified Files:
	CacheRegistryClient.java MobyDigestClient.java 
	TestingCentral.java 
Log Message:
Too Many Changes - see docs/ChangeLog

moby-live/Java/src/Clients CacheRegistryClient.java,1.9,1.10 MobyDigestClient.java,1.8,1.9 TestingCentral.java,1.10,1.11
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2008/02/23 13:58:32	1.9
+++ /home/repository/moby/moby-live/Java/src/Clients/CacheRegistryClient.java	2008/03/02 12:45:25	1.10
@@ -16,8 +16,7 @@
 import org.biomoby.shared.event.Notifier;
 
 import org.tulsoft.tools.BaseCmdLine;
-import org.tulsoft.shared.FileUtils;
-import org.tulsoft.shared.GException;
+import org.apache.commons.lang.time.DurationFormatUtils;
 
 /**
  * This is a command-line client creating (and removing) a cache of a
@@ -65,53 +64,91 @@
 	    if (! cmd.hasOption ("-q"))
 		worker.addNotificationListener (new LogListener());
 
+	    long started, elapsed, total = 0;
+
 	    //
 	    // [re-]fill the cache
 	    //
+	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-n")) {
+		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
+		decoration ("Retrieving namespaces...    ");
+		started = System.currentTimeMillis();
+		worker.getFullNamespaces();
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
+	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-d")) {
 		worker.removeFromCache (CentralCached.CACHE_PART_DATATYPES);
-		decorationLn ("Retrieving data types...");
+		decoration ("Retrieving data types...    ");
+		started = System.currentTimeMillis();
 		worker.getDataTypes();
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-s")) {
 		worker.removeFromCache (CentralCached.CACHE_PART_SERVICES);
-		decorationLn ("Retrieving services...");
+		decoration ("Retrieving services...      ");
+		started = System.currentTimeMillis();
 		worker.getServices();
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-t")) {
 		worker.removeFromCache (CentralCached.CACHE_PART_SERVICETYPES);
-		decorationLn ("Retrieving service types...");
+		decoration ("Retrieving service types... ");
+		started = System.currentTimeMillis();
 		worker.getFullServiceTypes();
-	    }
-	    if (cmd.hasOption ("-fill") || cmd.hasOption ("-fill-n")) {
-		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
-		decorationLn ("Retrieving namespaces...");
-		worker.getFullNamespaces();
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 
 	    //
 	    // update the cache
 	    //
+	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-n")) {
+		decoration ("Updating namespaces...      ");
+		started = System.currentTimeMillis();
+		worker.updateCache (CentralCached.CACHE_PART_NAMESPACES);
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
+	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-d")) {
-		decorationLn ("Updating data types...");
+		decoration ("Updating data types...      ");
+		started = System.currentTimeMillis();
 		worker.updateCache (CentralCached.CACHE_PART_DATATYPES);
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-s")) {
-		decorationLn ("Updating services...");
+		decoration ("Updating services...        ");
+		started = System.currentTimeMillis();
 		worker.updateCache (CentralCached.CACHE_PART_SERVICES);
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-t")) {
-		decorationLn ("Updating service types...");
+		decoration ("Updating service types...   ");
+		started = System.currentTimeMillis();
 		worker.updateCache (CentralCached.CACHE_PART_SERVICETYPES);
-	    }
-	    if (cmd.hasOption ("-update") || cmd.hasOption ("-update-n")) {
-		decorationLn ("Updating namespaces...");
-		worker.updateCache (CentralCached.CACHE_PART_NAMESPACES);
+		elapsed = System.currentTimeMillis() - started;
+		total += elapsed;
+		decorationLn (DurationFormatUtils.formatDurationHMS (elapsed));
 	    }
 
 	    //
 	    // remove the cache
 	    //
+	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-n")) {
+		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
+		decorationLn ("Cache for namespaces removed.");
+	    }
 	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-d")) {
 		worker.removeFromCache (CentralCached.CACHE_PART_DATATYPES);
 		decorationLn ("Cache for data types removed.");
@@ -124,14 +161,15 @@
 		worker.removeFromCache (CentralCached.CACHE_PART_SERVICETYPES);
 		decorationLn ("Cache for service types removed.");
 	    }
-	    if (cmd.hasOption ("-remove") || cmd.hasOption ("-remove-n")) {
-		worker.removeFromCache (CentralCached.CACHE_PART_NAMESPACES);
-		decorationLn ("Cache for namespaces removed.");
-	    }
 
 	    //
 	    // cache info
 	    //
+	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-n")) {
+		decorationLn ("Cache for namespaces...");
+		msgln
+		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_NAMESPACES));
+	    }
 	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-d")) {
 		decorationLn ("Cache for data types...");
 		msgln
@@ -147,11 +185,11 @@
 		msgln
 		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_SERVICETYPES));
 	    }
-	    if (cmd.hasOption ("-info") || cmd.hasOption ("-info-n")) {
-		decorationLn ("Cache for namespaces...");
-		msgln
-		    (worker.getCacheInfoFormatted (CentralCached.CACHE_PART_NAMESPACES));
-	    }
+
+
+	    decorationLn ("Total spent time:           " +
+			  DurationFormatUtils.formatDurationHMS (total));
+
 
 	} catch (Throwable e) {
 	    processErrorAndExit (e);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java	2006/02/08 17:24:13	1.8
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyDigestClient.java	2008/03/02 12:45:25	1.9
@@ -6,16 +6,21 @@
 // Copyright Martin Senger (martin.senger at gmail.com).
 //
 
-import org.biomoby.shared.*;
+import org.biomoby.client.CmdLineHelper;
+import org.biomoby.shared.CentralCached;
+import org.biomoby.shared.MobyDataType;
+import org.biomoby.shared.MobyNamespace;
+import org.biomoby.shared.MobyService;
+import org.biomoby.shared.MobyServiceType;
+import org.biomoby.shared.MobyData;
+import org.biomoby.shared.MobySecondaryData;
+import org.biomoby.shared.MobyPrimaryDataSet;
 import org.biomoby.shared.event.SimpleListener;
-import org.biomoby.shared.event.Notifier;
-import org.biomoby.client.*;
 
 import org.tulsoft.tools.BaseCmdLine;
-import org.tulsoft.shared.FileUtils;
-import org.tulsoft.shared.GException;
 
 import java.util.Map;
+import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
 
@@ -28,22 +33,8 @@
  * @version $Id$
  */
 
-public class MobyDigestClient {
-
-    /*************************************************************************
-     * Return a help text how to use this client.
-     *************************************************************************/
-    public static String getUsage() {
-	String helpFile = "help/MobyDigest_usage.txt";
-	try {
-	    return new String (FileUtils.findAndGetBinaryFile (helpFile));
-	} catch (GException e) {
-	    return
-		"Sorry but an error occured.\n" +
-		"I cannot find the help file '" + helpFile + "'.\n" +
-		e.getMessage();
-	}
-    }
+public class MobyDigestClient
+    extends CmdLineHelper {
 
     /*************************************************************************
      *
@@ -53,38 +44,31 @@
     public static void main (String [] args) {
 	try {
 
-	    BaseCmdLine cmd = new BaseCmdLine (args, true);
-	    if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
-		System.out.print (MobyDigestClient.getUsage());
-		System.exit (0);
-	    }
+	    BaseCmdLine cmd = getCmdLine (args, MobyDigestClient.class);
 
 	    // where is a Moby registry
-	    CentralAll worker =
-		new CentralDigestCachedImpl (cmd.getParam ("-e"),
-					     cmd.getParam ("-uri"),
-					     cmd.getParam ("-cachedir"));
+	    CentralCached worker = getCachableRegistryWorker (cmd);
 
 	    // how much to show
 	    boolean details = cmd.hasOption ("-details");
 	    boolean summary = cmd.hasOption ("-summary");
 	    boolean verbose = (cmd.hasOption ("-v") || cmd.hasOption ("-verbose"));
 	    if (verbose)
-		((Notifier)worker).addNotificationListener (new SimpleListener());
+		worker.addNotificationListener (new SimpleListener());
 
 	    // read (sometimes all) data types and their relationships
 	    if (cmd.hasOption ("-d")) {
 		if (details) {
 		    MobyDataType[] dataTypes = worker.getDataTypes();
 		    for (int i = 0; i < dataTypes.length; i++) {
-			System.out.println (dataTypes[i].toString());
-			System.out.println ("---");
+			msgln (dataTypes[i].toString());
+			msgln ("---");
 		    }
 		} 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());
+			msgln (entry.getKey());
 		    }
 		}
 	    }
@@ -94,9 +78,9 @@
 		MobyServiceType[] serviceTypes = worker.getFullServiceTypes();
 		for (int i = 0; i < serviceTypes.length; i++) {
 		    if (details)
-			System.out.println (serviceTypes[i]);
+			msgln (serviceTypes[i]);
 		    else
-			System.out.println (serviceTypes[i].getName());
+			msgln (serviceTypes[i].getName());
 		}
 	    }
 
@@ -106,21 +90,21 @@
 		    MobyService[] services = worker.getServices();
 		    if (details) {
 			for (int i = 0; i < services.length; i++) {
-			    System.out.println (services[i]);
-			    System.out.println ("---");
+			    msgln (services[i]);
+			    msgln ("---");
 			}
 		    } else {  // summary
-			System.out.println
+			msgln
 			    ("#Prim\t#Sec\tSType\t#Out\tInColl\tOutColl\tService\tAuthority");
 			for (int i = 0; i < services.length; i++) {
 			    MobyService service = services[i];
 			    MobyData[] pInputs = service.getPrimaryInputs();
 			    MobyData[] sInputs = service.getSecondaryInputs();
 			    MobyData[] outputs = service.getPrimaryOutputs();
-			    System.out.print (pInputs.length + "\t");
-			    System.out.print (sInputs.length + "\t");
+			    msg (pInputs.length + "\t");
+			    msg (sInputs.length + "\t");
 			    StringBuffer buf = new StringBuffer();
-			    HashSet set = new HashSet();
+			    Set<String> set = new HashSet<String>();
 			    for (int j = 0; j < sInputs.length; j++) {
 				String abbrev =
 				    ( ((MobySecondaryData)sInputs[j]).getDataType()
@@ -130,8 +114,8 @@
 				    set.add (abbrev);
 				}
 			    }
-			    System.out.print (buf + "\t");
-			    System.out.print (outputs.length + "\t");
+			    msg (buf + "\t");
+			    msg (outputs.length + "\t");
 			    boolean found = false;
 			    for (int j = 0; j < pInputs.length; j++) {
 				if (pInputs[j] instanceof MobyPrimaryDataSet) {
@@ -139,7 +123,7 @@
 				    break;
 				}
 			    }
-			    System.out.print (found + "\t");
+			    msg (found + "\t");
 			    found = false;
 			    for (int j = 0; j < outputs.length; j++) {
 				if (outputs[j] instanceof MobyPrimaryDataSet) {
@@ -147,10 +131,9 @@
 				    break;
 				}
 			    }
-			    System.out.print (found + "\t");
-			    System.out.print (service.getName() + "\t");
- 			    System.out.print (service.getAuthority());
-			    System.out.println();
+			    msg (found + "\t");
+			    msg (service.getName() + "\t");
+ 			    msgln (service.getAuthority());
 			}
 		    }
 		} else {
@@ -160,7 +143,7 @@
 			String authority = (String)entry.getKey();
 			String[] names = (String[])entry.getValue();
 			for (int i = 0; i < names.length; i++) {
-			    System.out.println (names[i] + " (" + authority + ")");
+			    msgln (names[i] + " (" + authority + ")");
 			}
 		    }
 		}
@@ -171,16 +154,14 @@
 		MobyNamespace[] namespaces = worker.getFullNamespaces();
 		for (int i = 0; i < namespaces.length; i++) {
 		    if (details)
-			System.out.println (namespaces[i]);
+			msgln (namespaces[i]);
 		    else
-			System.out.println (namespaces[i].getName());
+			msgln (namespaces[i].getName());
 		}
 	    }
 
-	} catch (Exception e) {
-	    System.err.println ("===ERROR===");
-	    e.printStackTrace();
-	    System.err.println ("===========");
+	} catch (Throwable e) {
+	    processErrorAndExit (e);
 	}
     }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java	2006/12/07 18:41:00	1.10
+++ /home/repository/moby/moby-live/Java/src/Clients/TestingCentral.java	2008/03/02 12:45:25	1.11
@@ -94,8 +94,8 @@
         }
 	if (type.equalsIgnoreCase ("Integer")) {
 	    data.setDefaultValue ("123");
-	    data.setMaximumValue (234);
-	    data.setMinimumValue (23);
+	    data.setMaxValue     ("234");
+	    data.setMinValue     ("23");
 	    data.addAllowedValue ("30");
 	    data.addAllowedValue ("40");
 	    data.addAllowedValue ("50");




More information about the MOBY-guts mailing list