[MOBY-guts] biomoby commit
senger@ebi.ac.uk
senger at pub.open-bio.org
Fri May 9 15:51:10 UTC 2003
senger
Fri May 9 11:51:10 EDT 2003
Update of /home/repository/moby/moby-live/Java/Clients
In directory pub.open-bio.org:/tmp/cvs-serv9113/Clients
Modified Files:
MobyCmdLineClient.java
Log Message:
changes reflecting the main API change in BioMoby
moby-live/Java/Clients MobyCmdLineClient.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/Clients/MobyCmdLineClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/Clients/MobyCmdLineClient.java 2003/03/02 20:48:24 1.1
+++ /home/repository/moby/moby-live/Java/Clients/MobyCmdLineClient.java 2003/05/09 15:51:10 1.2
@@ -85,6 +85,10 @@
cmd.getParam ("-uri"));
String param;
+ if (cmd.hasOption ("-debug")) {
+ worker.setDebug (true);
+ }
+
//
// simple retrieval of various sets
//
@@ -149,11 +153,11 @@
//
// retrieval of more complex entities
//
- if ((param = cmd.getParam ("-d")) != null ) {
- decorationLn ("Data type '" + param + "':");
- decorationLn ("---------");
- System.out.println (worker.getDataType (param));
- }
+// if ((param = cmd.getParam ("-d")) != null ) {
+// decorationLn ("Data type '" + param + "':");
+// decorationLn ("---------");
+// System.out.println (worker.getDataType (param));
+// }
if ((param = cmd.getParam ("-wsdl")) != null ) {
decorationLn ("WSDL for service '" + param + "':");
@@ -177,16 +181,25 @@
MobyDataType data = new MobyDataType (param);
data.setDescription (cmd.getParam ("-rd-desc"));
data.setAuthority (cmd.getParam ("-rd-auth"));
- if ((param = cmd.getParam ("-rd-xsd")) != null) {
- if (new File (param).exists())
- param = FileUtils.getFile (param);
- data.setXSD (param);
- }
+ data.setEmailContact (cmd.getParam ("-rd-email"));
if ((param = cmd.getParam ("-rd-isa")) != null ) {
String[] isas = StringUtils.split (param, ",");
for (int i = 0; i < isas.length; i++)
data.addParentName (isas [i]);
}
+ if ((param = cmd.getParam ("-rd-hasa")) != null ) {
+ String[] hasas = StringUtils.split (param, ",");
+ for (int i = 0; i < hasas.length; i++) {
+ int pos = hasas[i].indexOf (":");
+ if (pos == -1) {
+ data.addChild (null, hasas [i]);
+ } else if (pos == hasas[i].length() - 1) {
+ data.addChild (null, hasas [i].substring (0, pos));
+ } else {
+ data.addChild (hasas[i].substring (0, pos), hasas[i].substring (pos+1));
+ }
+ }
+ }
worker.registerDataType (data);
decorationLn (data.toString());
}
@@ -196,6 +209,8 @@
decorationLn ("---------------------");
MobyServiceType stype = new MobyServiceType (param);
stype.setDescription (cmd.getParam ("-rt-desc"));
+ stype.setAuthority (cmd.getParam ("-rt-auth"));
+ stype.setEmailContact (cmd.getParam ("-rt-email"));
if ((param = cmd.getParam ("-rt-isa")) != null ) {
String[] isas = StringUtils.split (param, ",");
for (int i = 0; i < isas.length; i++)
@@ -211,6 +226,7 @@
MobyNamespace namespace = new MobyNamespace (param);
namespace.setDescription (cmd.getParam ("-rn-desc"));
namespace.setAuthority (cmd.getParam ("-rn-auth"));
+ namespace.setEmailContact (cmd.getParam ("-rn-email"));
worker.registerNamespace (namespace);
decorationLn (namespace.toString());
}
@@ -223,21 +239,118 @@
service.setType (cmd.getParam ("-rs-type"));
service.setCategory (cmd.getParam ("-rs-categ"));
service.setAuthority (cmd.getParam ("-rs-auth"));
+ service.setEmailContact (cmd.getParam ("-rs-email"));
+ if ((param = cmd.getParam ("-rs-main")) != null) {
+ service.setAuthoritative (param.equals ("1") ? true : false);
+ }
service.setURL (cmd.getParam ("-rs-url"));
if ((param = cmd.getParam ("-rs-in")) != null ) {
String[] inputs = StringUtils.split (param, ",");
for (int i = 0; i < inputs.length; i++) {
String[] parts = StringUtils.split (inputs[i], "=");
- if (parts.length >= 2)
- service.addInput (parts[0], parts[1]);
- else
- service.addInput (parts[0], "");
+ if (parts.length >= 2) {
+ MobyPrimaryDataSimple data = new MobyPrimaryDataSimple ("dummy");
+ data.setDataType (new MobyDataType (parts[0]));
+ data.addNamespace (new MobyNamespace (parts[1]));
+ service.addInput (data);
+ } else {
+ MobyPrimaryDataSimple data = new MobyPrimaryDataSimple ("dummy");
+ data.setDataType (new MobyDataType (parts[0]));
+ service.addInput (data);
+ }
+ }
+ }
+ if ((param = cmd.getParam ("-rs-ifile")) != null ) {
+ String[] files = StringUtils.split (param, ",");
+ for (int i = 0; i < files.length; i++) {
+ Properties props = new Properties();
+ try {
+ props.load (new FileInputStream (files[i]));
+ if (props.containsKey ("secondary")) {
+ // for 'secondary'
+ String value = props.getProperty ("name", "un-named");
+ MobySecondaryData data = new MobySecondaryData (value);
+ if ((value = props.getProperty ("datatype")) != null)
+ data.setDataType (value);
+ if ((value = props.getProperty ("default")) != null)
+ data.setDefaultValue (value);
+ if ((value = props.getProperty ("max")) != null) {
+ try {
+ data.setMaximumValue (Integer.valueOf (value).intValue());
+ } catch (java.lang.NumberFormatException e) { }
+ }
+ if ((value = props.getProperty ("min")) != null) {
+ try {
+ data.setMinimumValue (Integer.valueOf (value).intValue());
+ } catch (java.lang.NumberFormatException e) { }
+ }
+ for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {
+ String propName = (String)en.nextElement();
+ if (propName.startsWith ("enum"))
+ data.addAllowedValue (props.getProperty (propName));
+ }
+ service.addInput (data);
+
+ } else if (props.containsKey ("collection")) {
+ // for 'collection'
+ String value = props.getProperty ("name", "un-named");
+ MobyPrimaryDataSet data = new MobyPrimaryDataSet (value);
+ for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {
+ String propName = (String)en.nextElement();
+ if (propName.startsWith ("file")) {
+ data.addElement (createSimple (props.getProperty (propName)));
+ }
+ }
+ service.addInput (data);
+
+ } else {
+ // for 'simple'
+ MobyPrimaryDataSimple data = createSimple (files[i]);
+ if (data != null)
+ service.addInput (data);
+ }
+ } catch (IOException e) {
+ System.err.println ("ERROR: Failed to read " + files[i] + " (" + e.toString() + ").");
+ }
}
}
if ((param = cmd.getParam ("-rs-out")) != null ) {
String[] outs = StringUtils.split (param, ",");
- for (int i = 0; i < outs.length; i++)
- service.addOutputType (outs [i]);
+ for (int i = 0; i < outs.length; i++) {
+ service.addOutput (new MobyPrimaryDataSimple (outs[i]));
+ }
+ }
+ if ((param = cmd.getParam ("-rs-ofile")) != null ) {
+ String[] files = StringUtils.split (param, ",");
+ for (int i = 0; i < files.length; i++) {
+ Properties props = new Properties();
+ try {
+ props.load (new FileInputStream (files[i]));
+ if (props.containsKey ("secondary")) {
+ // ignore 'secondary'
+
+ } else if (props.containsKey ("collection")) {
+ // for 'collection'
+ String value = props.getProperty ("name", "un-named");
+ MobyPrimaryDataSet data = new MobyPrimaryDataSet (value);
+ for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {
+ String propName = (String)en.nextElement();
+ if (propName.startsWith ("file")) {
+ data.addElement (createSimple (props.getProperty (propName)));
+ }
+ }
+ service.addOutput (data);
+
+ } else {
+ // for 'simple'
+ MobyPrimaryDataSimple data = createSimple (files[i]);
+ if (data != null)
+ service.addOutput (data);
+ }
+ } catch (IOException e) {
+ System.err.println ("ERROR: Failed to read " + files[i] + " (" + e.toString() + ").");
+ }
+ }
}
worker.registerService (service);
decorationLn (service.toString());
@@ -249,8 +362,7 @@
if ((param = cmd.getParam ("-ud")) != null ) {
decorationLn ("Unregister data type '" + param + "':");
decorationLn ("--------------------");
- MobyDataType data = new MobyDataType ("dummy");
- data.setId (param);
+ MobyDataType data = new MobyDataType (param);
worker.unregisterDataType (data);
decorationLn (data.toString());
}
@@ -258,8 +370,7 @@
if ((param = cmd.getParam ("-ut")) != null ) {
decorationLn ("Unregister service type '" + param + "':");
decorationLn ("-----------------------");
- MobyServiceType stype = new MobyServiceType ("dummy");
- stype.setId (param);
+ MobyServiceType stype = new MobyServiceType (param);
worker.unregisterServiceType (stype);
decorationLn (stype.toString());
}
@@ -267,8 +378,7 @@
if ((param = cmd.getParam ("-un")) != null ) {
decorationLn ("Unregister namespace '" + param + "':");
decorationLn ("--------------------");
- MobyNamespace namespace = new MobyNamespace ("dummy");
- namespace.setId (param);
+ MobyNamespace namespace = new MobyNamespace (param);
worker.unregisterNamespace (namespace);
decorationLn (namespace.toString());
}
@@ -276,15 +386,39 @@
if ((param = cmd.getParam ("-us")) != null ) {
decorationLn ("Unregister service '" + param + "':");
decorationLn ("--------------------");
- MobyService service = new MobyService ("dummy");
- service.setId (param);
- worker.unregisterService (service);
- decorationLn (service.toString());
+ int pos = param.indexOf (",");
+ if (pos == -1 || pos == param.length() - 1)
+ System.err.println ("ERROR: an authority must be specified");
+ else {
+ MobyService service = new MobyService (param.substring (0, pos));
+ service.setAuthority (param.substring (pos+1));
+ worker.unregisterService (service);
+ decorationLn (service.toString());
+ }
}
//
// look-up services
//
+ if ((param = cmd.getParam ("-fn")) != null ) {
+ decorationLn ("Looking for services '" + param + "':");
+ decorationLn ("--------------------");
+ int pos = param.indexOf (",");
+ MobyService[] services;
+ if (pos == -1)
+ services = worker.findService (new MobyService (param));
+ else if (pos == param.length() - 1)
+ services = worker.findService (new MobyService (param.substring (0, pos)));
+ else {
+ MobyService pattern = new MobyService (param.substring (0, pos));
+ pattern.setAuthority (param.substring (pos+1));
+ services = worker.findService (pattern);
+ }
+ if (services != null) {
+ for (int i = 0; i < services.length; i++)
+ System.out.println (services[i]);
+ }
+ }
if ((param = cmd.getParam ("-f")) != null ) {
decorationLn ("Looking for services related to: '" + param + "':");
decorationLn ("--------------------------------");
@@ -311,16 +445,18 @@
String[] inputs = StringUtils.split (param, ",");
for (int i = 0; i < inputs.length; i++) {
String[] parts = StringUtils.split (inputs[i], "=");
- if (parts.length >= 2)
- pattern.addInput (parts[0], parts[1]);
- else
- pattern.addInput (parts[0], "");
+ if (parts.length >= 2) {
+// pattern.addInput (parts[0], parts[1]);
+ } else {
+// pattern.addInput (parts[0], "");
+ }
}
}
if ((param = cmd.getParam ("-fs-out")) != null ) {
String[] outs = StringUtils.split (param, ",");
- for (int i = 0; i < outs.length; i++)
- pattern.addOutputType (outs [i]);
+ for (int i = 0; i < outs.length; i++) {
+// pattern.addOutputType (outs [i]);
+ }
}
decoration (pattern.toString());
decorationLn ("-----------------------------------------------");
@@ -348,6 +484,11 @@
}
}
+ } catch (PendingCurationException e) {
+ System.err.println ("===ERROR===");
+ System.err.println ("Pending Curation");
+ System.err.println ("===========");
+
} catch (NoSuccessException e) {
System.err.println ("===ERROR===");
System.err.println (e.getMessage());
@@ -370,4 +511,24 @@
if (verbose) System.out.println (msg);
}
+ static MobyPrimaryDataSimple createSimple (String fname) {
+ Properties props = new Properties();
+ try {
+ props.load (new FileInputStream (fname));
+ String value = props.getProperty ("name", "un-named");
+ MobyPrimaryDataSimple data = new MobyPrimaryDataSimple (value);
+ if ((value = props.getProperty ("datatype")) != null)
+ data.setDataType (new MobyDataType (value));
+ for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {
+ String propName = (String)en.nextElement();
+ if (propName.startsWith ("namespace"))
+ data.addNamespace (new MobyNamespace (props.getProperty (propName)));
+ }
+ return data;
+ } catch (IOException e) {
+ System.err.println ("ERROR: Failed to read " + fname + " (" + e.toString() + ").");
+ return null;
+ }
+ }
+
}
More information about the MOBY-guts
mailing list