[MOBY-guts] biomoby commit

senger@ebi.ac.uk senger at pub.open-bio.org
Sat Jun 21 19:27:41 UTC 2003


senger
Sat Jun 21 15:27:41 EDT 2003
Update of /home/repository/moby/moby-live/Java/Clients
In directory pub.open-bio.org:/tmp/cvs-serv22032/Clients

Modified Files:
	TestingCentral.java 
Log Message:


moby-live/Java/Clients TestingCentral.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/Clients/TestingCentral.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/Clients/TestingCentral.java	2003/06/15 15:21:56	1.6
+++ /home/repository/moby/moby-live/Java/Clients/TestingCentral.java	2003/06/21 19:27:41	1.7
@@ -70,6 +70,41 @@
     }
 
     /*************************************************************************
+     * Create a Service object
+     *************************************************************************/
+    protected MobyService createService (String serviceName) {
+	MobyService service = new MobyService (serviceName);
+	service.setDescription ("description for service " + serviceName);
+	service.setAuthority ("testing.org");
+	service.setEmailContact (emailContact);
+	service.setAuthoritative (true);
+	service.setURL ("http://www.testing.org");
+	return service;
+    }
+
+    /*************************************************************************
+     * Create a SecondaryData object
+     *************************************************************************/
+    protected MobySecondaryData createSecondaryData (String objectName, String type) {
+	MobySecondaryData data = new MobySecondaryData (objectName);
+	data.setDataType (type);
+	if (type.equalsIgnoreCase ("Integer")) {
+	    data.setDefaultValue ("123");
+	    data.setMaximumValue (234);
+	    data.setMinimumValue (23);
+	    data.addAllowedValue ("30");
+	    data.addAllowedValue ("40");
+	    data.addAllowedValue ("50");
+	} else if (type.equalsIgnoreCase ("String")) {
+	    data.setDefaultValue ("nice default");
+	    data.addAllowedValue ("Mark");
+	    data.addAllowedValue ("Jason");
+	    data.addAllowedValue ("Martin");
+	}
+	return data;
+    }
+
+    /*************************************************************************
      *
      * Entry point...
      *
@@ -116,6 +151,7 @@
 	    String result;
 
 
+	    // retrieve things
 	    try {
 		start ("retrieveServiceNames");
 		Map serviceNames = worker.getServiceNames();
@@ -146,6 +182,7 @@
 		ok();
 	    } catch (MobyException e) {	error (e); }
 
+	    // register service type
 	    String uniqueName = "MyTestingServiceType_" + new Date().getTime();
 	    MobyServiceType stype = helper.createServiceType (uniqueName);
  	    try {
@@ -155,29 +192,23 @@
 	    } catch (MobyException e)      { error (e);
 	    } catch (NoSuccessException e) { error (e); }
 
+	    // register namespace(s)
+	    MobyNamespace namespace1 = helper.createNamespace ("MyTestingNamespace_" + new Date().getTime() + 1);
+	    MobyNamespace namespace2 = helper.createNamespace ("MyTestingNamespace_" + new Date().getTime() + 2);
  	    try {
-		start ("deregisterServiceType");
-		worker.unregisterServiceType (stype);
+		start ("registerNamespace - 1");
+		worker.registerNamespace (namespace1);
 		ok();
 	    } catch (MobyException e)      { error (e);
 	    } catch (NoSuccessException e) { error (e); }
-
-	    uniqueName = "MyTestingNamespace_" + new Date().getTime();
-	    MobyNamespace namespace = helper.createNamespace (uniqueName);
  	    try {
-		start ("registerNamespace");
-		worker.registerNamespace (namespace);
-		ok();
-	    } catch (MobyException e)      { error (e);
-	    } catch (NoSuccessException e) { error (e); }
-
- 	    try {
-		start ("deregisterNamespace");
-		worker.unregisterNamespace (namespace);
+		start ("registerNamespace - 2");
+		worker.registerNamespace (namespace2);
 		ok();
 	    } catch (MobyException e)      { error (e);
 	    } catch (NoSuccessException e) { error (e); }
 
+	    // register data type(s)
 	    String name1 = "MyTestingDataType_" + new Date().getTime() + 1;
 	    String name2 = "MyTestingDataType_" + new Date().getTime() + 2;
 	    String name3 = "MyTestingDataType_" + new Date().getTime() + 3;
@@ -208,6 +239,63 @@
 	    } catch (NoSuccessException e) { error (e); }
 
  	    try {
+		start ("getDataTypeDefinition - 2");
+		worker.getDataType (data2.getName());
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
+
+	    // register a service
+	    MobyPrimaryDataSimple simpleData = new MobyPrimaryDataSimple ("Simpla_A");
+	    simpleData.setDataType (data2);
+	    simpleData.addNamespace (namespace1);
+	    simpleData.addNamespace (namespace2);
+
+	    MobyPrimaryDataSimple simpleData1 = new MobyPrimaryDataSimple ("Simple_B");
+	    simpleData1.setDataType (data1);
+	    simpleData.addNamespace (namespace1);
+	    MobyPrimaryDataSimple simpleData2 = new MobyPrimaryDataSimple ("Simple_C");
+	    simpleData2.setDataType (data2);
+	    simpleData.addNamespace (namespace1);
+	    MobyPrimaryDataSimple simpleData3 = new MobyPrimaryDataSimple ("Simple_D");
+	    simpleData3.setDataType (data3);
+	    simpleData.addNamespace (namespace1);
+	    MobyPrimaryDataSet collection = new MobyPrimaryDataSet ("Collection_A");
+	    collection.addElement (simpleData1);
+	    collection.addElement (simpleData2);
+	    collection.addElement (simpleData3);
+
+	    MobySecondaryData secData1 = helper.createSecondaryData ("Secondary_A", "Integer");
+	    MobySecondaryData secData2 = helper.createSecondaryData ("Secondary_B", "String");
+	    MobySecondaryData secData3 = helper.createSecondaryData ("Secondary_C", name3);
+
+	    MobyService service = helper.createService ("MyTestingService_" + new Date().getTime());
+	    service.setType (stype.getName());
+	    service.addInput (simpleData);
+	    service.addInput (collection);
+	    service.addInput (secData1);
+	    service.addInput (secData2);
+	    service.addInput (secData3);
+
+ 	    try {
+		start ("registerService");
+		worker.registerService (service);
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
+
+	    // TBD: find service
+	    // ..
+
+	    // deregister everything
+ 	    try {
+		start ("deregisterService");
+		worker.unregisterService (service);
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
+
+ 	    try {
 		start ("deregisterDataType - 3");
 		worker.unregisterDataType (data3);
 		ok();
@@ -226,146 +314,27 @@
 	    } catch (MobyException e)      { error (e);
 	    } catch (NoSuccessException e) { error (e); }
 
+ 	    try {
+		start ("deregisterNamespace - 2");
+		worker.unregisterNamespace (namespace2);
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
+ 	    try {
+		start ("deregisterNamespace - 1");
+		worker.unregisterNamespace (namespace1);
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
+
+ 	    try {
+		start ("deregisterServiceType");
+		worker.unregisterServiceType (stype);
+		ok();
+	    } catch (MobyException e)      { error (e);
+	    } catch (NoSuccessException e) { error (e); }
 
-// 	    if (testService) {
-// 		String serviceName = "TestingService_" + new Date().getTime();
-// 		String serviceType = "TestingServiceType_" + new Date().getTime();
-// 		String objectType1 = "TestingObjectType1_" + new Date().getTime();
-// 		String namespace1  = "TestingNamespace1_" + new Date().getTime();
-// 		String objectType2 = "TestingObjectType2_" + new Date().getTime();
-// 		String namespace2  = "TestingNamespace2_" + new Date().getTime();
-// 		String objectType3 = "TestingObjectType3_" + new Date().getTime();
-// 		String objectType4 = "TestingObjectType4_" + new Date().getTime();
-// 		String authURI = "org.embl.ebi.senger";
-
-// 		result = client.registerServiceType (serviceType);
-// 		String serviceTypeId = client.extractId (result);
-// 		result = client.registerNamespace (namespace1);
-// 		String namespaceId1 = client.extractId (result);
-// 		result = client.registerNamespace (namespace2);
-// 		String namespaceId2 = client.extractId (result);
-// 		result = client.registerObject (objectType1, "<blank/>");
-// 		String objectId1 = client.extractId (result);
-// 		result = client.registerObject (objectType2, "<blank/>");
-// 		String objectId2 = client.extractId (result);
-// 		result = client.registerObject (objectType3, "<blank/>");
-// 		String objectId3 = client.extractId (result);
-// 		result = client.registerObject (objectType4, "<blank/>");
-// 		String objectId4 = client.extractId (result);
-
-// 		// 1. register a service
-// 		System.out.println ("METHOD: registerService '" + serviceName + "'");
-// 		result = (String)client.doCall ("registerService",
-// 						new Object[] {
-// 						    "<registerService>" +
-// 						      "<Category>moby</Category>" +
-// 						      "<serviceName>" + serviceName + "</serviceName>" +
-// 						      "<serviceType>" + serviceType + "</serviceType>" +
-// 						      "<authURI>" + authURI + "</authURI>" +
-// 						      "<inputObjects>" +
-// 						        "<Input>" +
-// 						          "<objectType>" + objectType1 + "</objectType>" +
-// 						           "<namespaceType>" + namespace1 + "</namespaceType>" +
-// 						        "</Input>" +
-// 						        "<Input>" +
-// 						          "<objectType>" + objectType2 + "</objectType>" +
-// 						          "<namespaceType>" + namespace2 + "</namespaceType>" +
-// 						        "</Input>" +
-// 						      "</inputObjects>" +
-// 						      "<outputObjects>" +
-// 						        "<objectType>" + objectType3 + "</objectType>" +
-// 						        "<objectType>" + objectType4 + "</objectType>" +
-// 						      "</outputObjects>" +
-// 						      "<URL>http://not.existing.server/not.existing.service</URL>" +
-// 						      "<Description><![CDATA[" +
-// 						        "This is ONLY A TESTING service." +
-// 						        "]]>" +
-// 						      "</Description>" +
-// 						    "</registerService>"
-// 						});
-// 		System.out.println ("----------------------------\n" + result);
-// 		String serviceId = client.extractId (result);
-
-// 		// 2. locate service byte service type
-// 		System.out.println ("METHOD: locateServiceByType '" + serviceType + "'");
-// 		result = (String)client.doCall ("locateServiceByType",
-// 						new Object[] {
-// 						    "<locateServiceByType>" +
-// 						      "<serviceType>" + serviceType + "</serviceType>" +
-// 						      "<fullServices>1</fullServices>" +
-// 						    "</locateServiceByType>"
-// 						});
-// 		System.out.println ("---------------------------\n" + result);
-
-// 		// 3. locate service by input type
-// 		System.out.println ("METHOD: locateServiceByInput");
-// 		result = (String)client.doCall ("locateServiceByInput",
-// 						new Object[] { 
-// 						    "<locateServiceByInput>" +
-// 						      "<inputObjects>" +
-// 						        "<Input>" +
-// 						          "<objectType>" + objectType1 + "</objectType>" +
-// 						          "<namespaceType>" + namespace1 + "</namespaceType>" +
-// 						        "</Input>" +
-// 						        "<Input>" +
-// 						          "<objectType>" + objectType2 + "</objectType>" +
-// 						          "<namespaceType>" + namespace2 + "</namespaceType>" +
-// 						        "</Input>" +
-// 						      "</inputObjects>" +
-// 						      "<serviceType>" + serviceType + "</serviceType>" +
-// 						      "<authURI>" + authURI + "</authURI>" +
-// 						      "<fullObjects>1</fullObjects>" +
-// 						      "<fullServices>1</fullServices>" +
-// 						    "</locateServiceByInput>"
-// 						});
-//  		System.out.println ("--------------------------------\n" + result);
-
-// 		// 4. locate service by output type
-// 		System.out.println ("METHOD: locateServiceByOutput");
-// 		result = (String)client.doCall ("locateServiceByOutput",
-// 						new Object[] { 
-// 						    "<locateServiceByOutput>" +
-// 						      "<objectType>" + objectType4 + "</objectType>" +
-// 						      "<serviceType>" + serviceType + "</serviceType>" +
-// 						      "<authURI>" + authURI + "</authURI>" +
-// 						      "<fullObjects>1</fullObjects>" +
-// 						      "<fullServices>1</fullServices>" +
-// 						    "</locateServiceByOutput>"
-// 						});
-// 		System.out.println ("---------------------------------\n" + result);
-
-// 		// 5. retrieve service (by service name)
-// 		System.out.println ("METHOD: retrieveService");
-// 		result = (String)client.doCall ("retrieveService",
-// 						new Object[] {
-// 						    "<retrieveService>" +
-// 						      "<authURI>" + authURI + "</authURI>" +
-// 						      "<serviceName>" + serviceName + "</serviceName>" +
-// 						    "</retrieveService>"
-// 						});
-// 		System.out.println ("-----------------------\n" + result);
-
-// 		// 6. deregister service
-// 		System.out.println ("METHOD: deregisterService \"" + serviceTypeId + "\"");
-// 		result = (String)client.doCall ("deregisterService",
-// 						new Object[] {
-// 						    "<deregisterService>" +
-// 						      "<serviceID>" + serviceId + "</serviceID>" +
-// 						    "</deregisterService>"
-
-// 						});
-// 		System.out.println ("---------------------------\n" + result);
-
-// 		// 7. deregister the rest
-// 		result = client.deregisterServiceType (serviceTypeId);
-// 		result = client.deregisterObject (objectId1);
-// 		result = client.deregisterObject (objectId2);
-// 		result = client.deregisterObject (objectId3);
-// 		result = client.deregisterObject (objectId4);
-// 		result = client.deregisterNamespace (namespaceId1);
-// 		result = client.deregisterNamespace (namespaceId2);
 
-// 	    }
 
 	} catch (Exception e) {
 	    System.err.println ("===ERROR===");




More information about the MOBY-guts mailing list