[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Sat Apr 19 19:11:18 UTC 2008


senger
Sat Apr 19 15:11:18 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory dev.open-bio.org:/tmp/cvs-serv10271/src/Clients

Modified Files:
	CreateMobyInput.java 
Log Message:

moby-live/Java/src/Clients CreateMobyInput.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/CreateMobyInput.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/Clients/CreateMobyInput.java	2007/05/29 03:51:46	1.9
+++ /home/repository/moby/moby-live/Java/src/Clients/CreateMobyInput.java	2008/04/19 19:11:18	1.10
@@ -6,7 +6,7 @@
 // Copyright Martin Senger (martin.senger at gmail.com).
 //
 
-import org.biomoby.shared.CentralAll;
+import org.biomoby.shared.CentralCached;
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.MobyService;
 import org.biomoby.shared.event.LogListener;
@@ -14,6 +14,7 @@
 import org.biomoby.service.dashboard.data.DataTypeTreeTable;
 import org.biomoby.service.dashboard.data.ServiceInputPanel;
 import org.biomoby.client.CentralDigestCachedImpl;
+import org.biomoby.client.CmdLineHelper;
 
 import org.tulsoft.tools.BaseCmdLine;
 import org.tulsoft.shared.FileUtils;
@@ -44,24 +45,8 @@
  * @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
  * @version $Id$
  */
-public class CreateMobyInput {
-
-    static boolean verbose;
-
-    /*************************************************************************
-     * Return a help text how to use this client.
-     *************************************************************************/
-    public static String getUsage() {
-	String helpFile = "help/CreateMobyInput_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 CreateMobyInput
+    extends CmdLineHelper {
 
     /*************************************************************************
      * Create a GUI for a single data type.
@@ -128,7 +113,7 @@
 	if (doc != null) {
 	    XMLOutputter xo = new XMLOutputter();
 	    xo.setFormat (Format.getPrettyFormat());
-	    System.out.println (xo.outputString (doc));
+	    msgln (xo.outputString (doc));
 	}
     }
 
@@ -137,7 +122,7 @@
      * an XML document representing complete input for a service.
      *************************************************************************/
     protected void onPrint (ServiceInputPanel inputs) {
-	System.out.println (inputs.toXML());
+	msgln (inputs.toXML());
     }
 
     /*************************************************************************
@@ -149,40 +134,31 @@
 
 	try {
 
-	    BaseCmdLine cmd = new BaseCmdLine (args, true);
-	    if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
-		System.out.print (CreateMobyInput.getUsage());
-		System.exit (0);
-	    }
+	    BaseCmdLine cmd = getCmdLine (args, CreateMobyInput.class);
 
 	    // there is not much to do without -data or -service
 	    String dataType = cmd.getParam ("-data");
 	    String service = cmd.getParam ("-service");
 	    if (dataType == null && service == null) {
-		System.err.println
+		emsgln
 		    ("Either '-data <data-type>' or '-service <service>' must be specified.");
-		System.exit (1);
+		exit (1);
 	    }
 
 	    // where is a Moby registry
-	    String cachedir = cmd.getParam ("-cachedir");
-	    if (cachedir == null)
-		System.err.println ("WARNING: parameter -cachedir not given => no cache used.");
-	    CentralAll worker =
-		new CentralDigestCachedImpl (cmd.getParam ("-e"),
-					     cmd.getParam ("-uri"),
-					     cachedir);
-	    CentralDigestCachedImpl castWorker = (CentralDigestCachedImpl)worker;
-	
-	    // how much to show
-	    verbose = cmd.hasOption ("-v");
-	    if (! cmd.hasOption ("-q"))
-		((Notifier)castWorker).addNotificationListener (new LogListener());
+	    CentralCached worker = getCachableRegistryWorker (cmd);
 
-	    if (cmd.hasOption ("-debug")) {
-		worker.setDebug (true);
+	    // there is not much to do without -cachedir
+	    String cacheDir = cmd.getParam ("-cachedir");
+	    if (cacheDir == null) {
+		emsgln ("Parameter -cachedir must be specified.");
+		exit (1);
 	    }
 
+	    // how much to show
+	    if (! cmd.hasOption ("-q"))
+		worker.addNotificationListener (new LogListener());
+
 	    // load all data types
 	    MobyDataType[] dataTypes = worker.getDataTypes();
 
@@ -196,7 +172,7 @@
 		    }
 		}
 		if (rootType == null) {
-		    System.err.println ("Parameter -data specifies a non-existing data type.");
+		    emsgln ("Parameter -data specifies a non-existing data type.");
 		} else {
 		    new CreateMobyInput (rootType, dataTypes);
 		}
@@ -205,32 +181,22 @@
 	    // load a service and show it in a table
 	    if (service != null) {
 		MobyService mobyService = null;
-		if (cachedir == null) {
-		    MobyService pattern = new MobyService (service);
-		    pattern.setCategory ("");
-		    MobyService[] services = worker.findService (pattern);
-		    if (services.length > 0)
-			mobyService = services[0];
-		} else {
-		    MobyService[] services = worker.getServices();
-		    for (int i = 0; i < services.length; i++) {
-			if (service.equals (services[i].getName())) {
-			    mobyService = services[i];
-			    break;
-			}
+		MobyService[] services = worker.getServices();
+		for (int i = 0; i < services.length; i++) {
+		    if (service.equals (services[i].getName())) {
+			mobyService = services[i];
+			break;
 		    }
 		}
 		if (mobyService == null) {
-		    System.err.println ("Parameter -service specifies a non-existing service.");
+		    emsgln ("Parameter -service specifies a non-existing service.");
 		} else {
 		    new CreateMobyInput (mobyService, dataTypes);
 		}
 	    }
 
-	} catch (Exception e) {
-	    System.err.println ("===ERROR===");
-	    e.printStackTrace();
-	    System.err.println ("===========");
+	} catch (Throwable e) {
+	    processErrorAndExit (e);
 	}
     }
 




More information about the MOBY-guts mailing list