[MOBY-guts] biomoby commit

senger@ebi.ac.uk senger at pub.open-bio.org
Fri May 9 15:51:11 UTC 2003


senger
Fri May  9 11:51:11 EDT 2003
Update of /home/repository/moby/moby-live/Java/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv9113/org/biomoby/client

Modified Files:
	CentralImpl.java 
Log Message:
changes reflecting the main API change in BioMoby
moby-live/Java/org/biomoby/client CentralImpl.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java	2003/03/02 20:48:26	1.2
+++ /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java	2003/05/09 15:51:11	1.3
@@ -65,6 +65,7 @@
     private URL endpoint;
     private String uri;
     private ParserWrapper parser;
+    private boolean debug = false;
 
     /** Default location (endpoint) of a Moby registry. */
     public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl";
@@ -132,7 +133,26 @@
 	    Service service = new Service();
 	    call = (Call) service.createCall();
 	    call.setTargetEndpointAddress (endpoint);
-	    return call.invoke (uri, method, parameters);
+	    if (debug) {
+		System.err.println ("METHOD CALL: " + method);
+		System.err.println ("------------");
+		if (parameters.length > 0)
+		    System.err.println (parameters[0] + "\n");
+		System.err.println ("------------\n");
+
+		Object result = call.invoke (uri, method, parameters);
+
+		System.err.println ("METHOD RETURN:");
+		System.err.println ("------------");
+		if (result != null)
+		    System.err.println (result + "\n");
+		System.err.println ("------------\n");
+
+		return result;
+
+	    } else {
+		return call.invoke (uri, method, parameters);
+	    }
 
 	} catch (AxisFault e) {
 	    throw new MobyException (Utils.formatFault (e, endpoint.toString(),
@@ -151,15 +171,20 @@
      * and with the message from the tag 'message'.
      *
      * This is how the XML is supposed to look:
-     *   <MOBYRegistration>
-     *	   <id>000057</id>
-     *	   <success>1</success>
-     * 	   <message><![CDATA[]]></message>
-     *	 </MOBYRegistration>
+     *     <MOBYRegistration>
+     *        <success> <!-- 1 | 0 | -1 --> </success>
+     *        <id> <!-- some id number for your registration --> </id>  
+     *        <message> <![CDATA[message here]]> </message>
+     *     </MOBYRegistration>
+     *
+     * Success takes the value "1" to indicate success, "0" to
+     * indicate failure, and "-1" to indicate "Pending Curation".
      *
+     * I keep 'id' in but it does not seem to be used anymore by the current
+     * Moby Central.
      *************************************************************************/
     protected String checkRegistration (String xml, Object culprit)
-	throws MobyException, NoSuccessException {
+	throws MobyException, NoSuccessException, PendingCurationException {
 
 	String id = "", success = "0", message = "";
 
@@ -185,79 +210,189 @@
 
 	if (success.equals ("0"))
 	    throw new NoSuccessException (message, culprit);
+	else if (success.equals ("-1"))
+	    throw new PendingCurationException();
 	return id;
     }
 
     /**************************************************************************
-     * Return a piece of XML created from the definitions of input data types
-     * of the given service. The returned XML looks like this:
-     *
-     * <Input>
-     *   <objectType>objectType1</objectType>
-     *   <namespaceType>namespace1</namespaceType>
-     * </Input>
-     * <Input>
-     *	 <objectType>objectType2</objectType>
-     *   <namespaceType>namespace2</namespaceType>
-     * </Input>
-     *
+     * Return a piece of XML created from the definitions representing input
+     * data types and their usage in the given service. Only data considered
+     * primary are included. Note that the main job of converting to XML is
+     * done by instances of MobyPrimaryData.
+     *
+     * The returned XML looks like this:
+     *    <Input>
+     *       <!-- zero or more Primary (Simple and/or Complex) articles -->
+     *    </Input>
      *************************************************************************/
-    protected String buildInputTag (MobyService service) {
+    protected String buildPrimaryInputTag (MobyService service) {
 	StringBuffer buf = new StringBuffer();
-	synchronized (service) {  // because of two arrays: inputs and namespaces
-	    String[] inputs = service.getInputTypes();
-	    String[] namespaces = service.getInputNamespaces();
-	    for (int i = 0; i < inputs.length; i++) {
-		buf.append ("<Input>");
-		buf.append ("<objectType>");
-		buf.append (inputs[i]);
-		buf.append ("</objectType>");
-		buf.append ("<namespaceType>");
-		buf.append (namespaces[i]);
-		buf.append ("</namespaceType>");
-		buf.append ("</Input>");
-	    }
+	MobyData[] primaryInputs = service.getPrimaryInputs();
+	buf.append ("<Input>\n");
+	for (int i = 0; i < primaryInputs.length; i++)
+	    buf.append (primaryInputs[i].toXML());
+	buf.append ("</Input>\n");
+	return new String (buf);
+    }
+
+    /**************************************************************************
+     * Return a piece of XML created from the definitions representing input
+     * data types and their usage in the given service. Only data considered
+     * secondary are included. Note that the main job of converting to XML is
+     * done by instances of MobySecondaryData.
+     *
+     * The returned XML looks like this:
+     *    <secondaryArticles>
+     *       <!-- zero or more INPUT Secondary articles -->
+     *    </secondaryArticles>
+     *************************************************************************/
+    protected String buildSecondaryInputTag (MobyService service) {
+	StringBuffer buf = new StringBuffer();
+	MobyData[] secInputs = service.getSecondaryInputs();
+	buf.append ("<secondaryArticles>\n");
+	for (int i = 0; i < secInputs.length; i++) {
+	    buf.append (secInputs[i].toXML());
 	}
+	buf.append ("</secondaryArticles>\n");
 	return new String (buf);
     }
 
     /**************************************************************************
-     * Return a piece of XML created from the definitions of output data types
-     * of the given service. The returned XML looks like this:
-     *
-     * <objectType>objectType1</objectType>
-     * <objectType>objectType2</objectType>
+     * Return a piece of XML created from the definitions representing output
+     * data types and their usage in the given service. Only data considered
+     * primary are included. Note that the main job of converting to XML is
+     * done by instances of MobyPrimaryData.
+     *
+     * The returned XML looks like this:
+     *    <Output>
+     *       <!-- zero or more Primary (Simple and/or Complex) articles --> 
+     *    </Output>
      *
      *************************************************************************/
     protected String buildOutputTag (MobyService service) {
 	StringBuffer buf = new StringBuffer();
-	String[] outputs = service.getOutputTypes();
-	for (int i = 0; i < outputs.length; i++) {
-	    buf.append ("<objectType>");
-	    buf.append (outputs[i]);
-	    buf.append ("</objectType>");
-	}
+	MobyData[] primaryOutputs = service.getPrimaryOutputs();
+	buf.append ("<Output>\n");
+	for (int i = 0; i < primaryOutputs.length; i++)
+	    buf.append (primaryOutputs[i].toXML());
+	buf.append ("</Output>\n");
 	return new String (buf);
     }
 
     /**************************************************************************
+     * Return a piece of XML represented a query object (an object used
+     * to find a service).
+     *
+     * The returned XML looks like this:
+     *
+     *    <inputObjects>
+     *      <Input>
+     *           <!-- one or more Simple or Complex Primary articles -->
+     *      </Input>
+     *    </inputObjects>
+     *    <outputObjects>
+     *      <Output>
+     *           <!-- one or more Simple or Complex Primary articles -->
+     *      </Output>
+     *    </outputObjects>
+     *    <serviceType>ServiceTypeTerm</serviceType>
+     *    <serviceName>ServiceName</serviceName>
+     *    <Category>moby</Category>
+     *    <authURI>http://desired.service.provider</authURI>;
+     *    <expandObjects>1|0</expandObjects> 
+     *    <expandServices>1|0</expandServices>
+     *    <authoritative>1|0</authoritative>
+     *    <keywords>
+     *         <keyword>something</keyword>
+     *         ....
+     *         ....
+     *    </keywords>
+     *************************************************************************/
+    protected String buildQueryObject (MobyService service,
+				       String[] keywords,
+				       boolean expandObjects,
+				       boolean expandServices,
+				       boolean authoritative) {
+	if (service == null)
+	    service = new MobyService ("dummy");
+	StringBuffer buf = new StringBuffer();
+
+	buf.append ("<inputObjects>\n<Input>\n");
+	MobyData[] pi = service.getPrimaryInputs();
+	if (pi.length > 0) {
+	    buf.append ("<inputObjects>\n<Input>\n");
+	    for (int i = 0; i < pi.length; i++)
+		buf.append (pi[i].toXML());
+	}
+	buf.append ("</Input>\n</inputObjects>\n");
+
+	buf.append ("<outputObjects>\n<Output>\n");
+	MobyData[] po = service.getPrimaryOutputs();
+	if (po.length > 0) {
+	    for (int i = 0; i < po.length; i++)
+		buf.append (po[i].toXML());
+	}
+	buf.append ("</Output>\n</outputObjects>\n");
+
+	buf.append ("<serviceType>" + service.getType() + "</serviceType>\n");
+
+	String name = service.getName();
+	if (!name.equals ("") && !name.equals ("dummy"))
+	    buf.append ("<serviceName>" + service.getName() + "</serviceName>\n");
+
+	buf.append ("<Category>" + service.getCategory() + "</Category>\n");
+	buf.append ("<authURI>" + service.getAuthority() + "</authURI>\n");
+
+	buf.append ("<expandObjects>");
+	buf.append (expandObjects ? "1" : "0");
+	buf.append ("</expandObjects>\n");
+
+	buf.append ("<expandServices>");
+	buf.append (expandServices ? "1" : "0");
+	buf.append ("</expandServices>\n");
+
+	buf.append ("<authoritative>");
+ 	buf.append (authoritative ? "1" : "0");
+	buf.append ("</authoritative>\n");
+
+	buf.append ("<keywords>\n");
+	if (keywords != null && keywords.length > 0) {
+	    for (int i = 0; i < keywords.length; i++) {
+		buf.append ("<keyword>");
+		buf.append (keywords[i]);
+		buf.append ("</keyword>\n");
+	    }
+	}
+	buf.append ("</keywords>\n");
+
+	return new String (buf);
+    }
+ 
+    /**************************************************************************
      * Extract one or more MobyService objects from the given XML piece.
      * The XML should look like this:
      *
-     * <Services>
-     *   <Service authURI='org.embl.ebi.senger' serviceName='TestingServiceNew'>
-     *     <Category>moby</Category>
-     *     <serviceType>TestingServiceType_1046534014379</serviceType>
-     *     <outputObject>TestingObjectTypeNew</outputObject>
-     *     <Description><![CDATA[Just testing...]]></Description>
-     *   </Service>
-     *   <Service authURI='org.embl.ebi.senger' serviceName='TestingService_1046534014378'>
-     *     <Category>moby</Category>
-     *     <serviceType>TestingServiceType_1046534014379</serviceType>
-     *     <outputObject>TestingObjectType4_1046534014379</outputObject>
-     *     <Description><![CDATA[This is ONLY A TESTING service.]]></Description>
-     *   </Service>
-     * </Services>
+     *  <Services>
+     *    <Service authURI="authority.URI.here" serviceName="MyService">
+     *      <serviceType>Service_Ontology_Term</serviceType>
+     *      <Category>moby</Category> <!-- or 'cgi' or 'soap' -->
+     *      <authoritative>1</authoritative>
+     *      <Input>
+     *           <!-- one or more Simple and/or Complex Primary articles -->
+     *      </Input>
+     *      <Output>
+     *           <!-- one or more Simple and/or Complex Primary articles --> 
+     *      </Output>
+     *      <secondaryArticles>
+     *           <!-- one or more Secondary articles -->
+     *      </secondaryArticles>
+     *      <Description><![CDATA[free text description here]]></Description>
+     *    </Service>
+     *    ...  <!--  one or more Service blocks may be returned -->
+     *    ...
+     *    ...
+     *  </Services>
      *
      * Throws an exception if the XML document is invalid.
      *************************************************************************/
@@ -276,12 +411,60 @@
 		String nodeName = children.item (j).getNodeName();
 		if (nodeName.equals ("Description")) {
 		    service.setDescription (children.item (j).getFirstChild().getNodeValue());
-		} else if (nodeName.equals ("Category") || nodeName.equals ("Catagory")) {
+		} else if (nodeName.equals ("Category")) {
 		    service.setCategory (children.item (j).getFirstChild().getNodeValue());
 		} else if (nodeName.equals ("serviceType")) {
 		    service.setType (children.item (j).getFirstChild().getNodeValue());
-		} else if (nodeName.equals ("outputObject")) {
-		    service.addOutputType (children.item (j).getFirstChild().getNodeValue());
+		} else if (nodeName.equals ("authoritative")) {
+		    String authoritative = children.item (j).getFirstChild().getNodeValue();
+		    service.setAuthoritative (authoritative.equals ("1") ? true : false);
+		} else if (nodeName.equals ("Input")) {
+		    // <Input>
+		    //   <!-- one or more Simple and/or Complex Primary articles -->
+		    //   <Simple articleName="NameOfArticle">
+		    //      ...
+		    //   </Simple>
+		    //   <Collection articleName="NameOfArticle">
+		    //      <Simple>......</Simple>
+		    //      <Simple>......</Simple>
+		    //   </Collection>
+		    // </Input>
+		    NodeList inputs = children.item (j).getChildNodes();
+		    for (int k = 0; k < inputs.getLength(); k++) {
+			if (inputs.item (k).getNodeName().equals ("Simple")) {
+			    MobyPrimaryDataSimple data = new MobyPrimaryDataSimple ((Element)inputs.item (k));
+			    service.addInput (data);
+			} else if (inputs.item (k).getNodeName().equals ("Collection")) {
+			    MobyPrimaryDataSet data = new MobyPrimaryDataSet ((Element)inputs.item (k));
+			    service.addInput (data);
+			}
+		    }
+		} else if (nodeName.equals ("Output")) {
+		    // <Output>
+		    //   <!-- one or more Simple and/or Complex Primary articles --> 
+		    // </Output>
+		    NodeList inputs = children.item (j).getChildNodes();
+		    for (int k = 0; k < inputs.getLength(); k++) {
+			if (inputs.item (k).getNodeName().equals ("Simple")) {
+			    MobyPrimaryDataSimple data = new MobyPrimaryDataSimple ((Element)inputs.item (k));
+			    service.addOutput (data);
+			} else if (inputs.item (k).getNodeName().equals ("Collection")) {
+			    MobyPrimaryDataSet data = new MobyPrimaryDataSet ((Element)inputs.item (k));
+			    service.addOutput (data);
+			}
+		    }
+
+		} else if (nodeName.equals ("secondaryArticles")) {
+		    // <Parameter articleName="NameOfArticle">
+		    //   ...
+		    // </Parameter>
+		    NodeList parameters = children.item (j).getChildNodes();
+		    for (int k = 0; k < parameters.getLength(); k++) {
+			if (parameters.item (k).getNodeName().equals ("Parameter")) {
+			    MobySecondaryData data = new MobySecondaryData ((Element)parameters.item (k));
+			    service.addInput (data);
+			}
+		    }
 		}
 	    }
 	    results [i] = service;
@@ -290,7 +473,12 @@
     }
 
     /**************************************************************************
-     * 
+     * B 
+     *  <serviceNames>
+     *     <serviceName name="serviceName" authURI='authority.info.here'/>
+     *          ...
+     *          ...
+     *  </serviceNames>
      *************************************************************************/
     public Map getServiceNames()
 	throws MobyException {
@@ -310,7 +498,12 @@
     }
 
     /**************************************************************************
-     *
+     * B
+     *  <serviceProviders>
+     *     <serviceProvider name="authority.URI.here"/>
+     *          ...
+     *          ...
+     *  </serviceProviders>
      *************************************************************************/
     public String[] getProviders()
 	throws MobyException {
@@ -327,6 +520,14 @@
     }
 
     /**************************************************************************
+     * B
+     *  <serviceTypes>
+     *     <serviceType name="serviceName">
+     *            <Description><![CDATA[free text description here]]></Description>
+     *     </serviceType>
+     *          ...
+     *          ...
+     *  </serviceTypes>
      *
      *************************************************************************/
     public Map getServiceTypes()
@@ -353,6 +554,14 @@
     }
 
     /**************************************************************************
+     * B
+     *  <Namespaces>
+     *     <Namespace name="namespace">
+     *            <Description><![CDATA[free text description here]]></Description>
+     *     </Namespace>
+     *          ...
+     *          ...
+     *  </Namespaces>
      *
      *************************************************************************/
     public Map getNamespaces()
@@ -379,6 +588,14 @@
     }
 
     /**************************************************************************
+     * B
+     *  <objectNames>
+     *     <Object name="objectName">
+     *            <Description><![CDATA[free text description here]]></Description>
+     *     </Object>
+     *          ...
+     *          ...
+     *  </objectNames>
      *
      *************************************************************************/
     public Map getDataTypeNames()
@@ -406,33 +623,43 @@
 
 
     /**************************************************************************
-     *
-     *************************************************************************/
-    public String getDataType (String dataTypeName)
-	throws MobyException, NoSuccessException {
-	String result =
-	    (String)doCall ("retrieveObject",
-			    new Object[] {
-				"<retrieveObject>" +
-				  "<objectType>" + dataTypeName + "</objectType>" +
-				"</retrieveObject>"
-			    });
-
-	// parse returned XML (hack: taking blindly everything in the Schema tag)
-	String xsd = "";
-	int pos = result.indexOf ("<Schema>");
-	if (pos == 1)
-	    throw new NoSuccessException ("Data Type name was not founnd.",
-					   dataTypeName);
-	int pos2 = result.indexOf ("</Schema>");
-	if (pos2 < pos)
-	    throw new NoSuccessException ("Something wrong with the returned XML.",
-					   result);
-	return result.substring (pos + 8, pos2);
-    }
+     * B
+     *  <Objects>
+     *     <Object name="ObjectOntologyTerm">
+     *            <Schema><![CDATA[
+     *                <XSD schema here>]]>
+     *            </Schema>
+     *     </Object>
+     *          ...
+     *          ...
+     *  </Objects>
+     *
+     *************************************************************************/
+//     public String getDataType (String dataTypeName)
+// 	throws MobyException, NoSuccessException {
+// 	String result =
+// 	    (String)doCall ("retrieveObjectSchema",
+// 			    new Object[] {
+// 				"<retrieveObjectSchema>" +
+// 				  "<objectType>" + dataTypeName + "</objectType>" +
+// 				"</retrieveObjectSchema>"
+// 			    });
+
+// 	// parse returned XML (hack: taking blindly everything in the Schema tag)
+// 	String xsd = "";
+// 	int pos = result.indexOf ("<Schema>");
+// 	if (pos == 1)
+// 	    throw new NoSuccessException ("Data Type name was not founnd.",
+// 					   dataTypeName);
+// 	int pos2 = result.indexOf ("</Schema>");
+// 	if (pos2 < pos)
+// 	    throw new NoSuccessException ("Something wrong with the returned XML.",
+// 					   result);
+// 	return result.substring (pos + 8, pos2);
+//     }
 
     /**************************************************************************
-     *
+     * B
      *************************************************************************/
     public String getServiceWSDL (String serviceName)
 	throws MobyException, NoSuccessException {
@@ -449,7 +676,7 @@
     }
 
     /**************************************************************************
-     *
+     * B
      *************************************************************************/
     public String getServiceWSDL (String serviceName, String authority)
 	throws MobyException, NoSuccessException {
@@ -457,8 +684,7 @@
 	    (String)doCall ("retrieveService",
 			    new Object[] {
 				"<retrieveService>" +
-				  "<authURI>" + authority + "</authURI>" +
-				  "<serviceName>" + serviceName + "</serviceName>" +
+				  "<Service authURI=\"" + authority + "\" serviceName=\"" + serviceName + "\"/>" +
 				"</retrieveService>"
 			    });
 
@@ -467,16 +693,16 @@
 	Element service = document.getDocumentElement();
 	Node wsdl = service.getFirstChild();
 	if (wsdl == null)
-	    throw new NoSuccessException ("Service not found.",
+	    throw new NoSuccessException ("Service not found OR WSDL is not available.",
 					   serviceName + " (" + authority + ")");
 	return wsdl.getNodeValue();
     }
 
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void registerDataType (MobyDataType dataType)
-	throws MobyException, NoSuccessException {
+	throws MobyException, NoSuccessException, PendingCurationException {
 
 	// build the ISA tag (expressing hierarchy of data types)
 	String[] names = dataType.getParentNames();
@@ -488,44 +714,71 @@
 	    buf.append ("\n");
 	}
 
+	// build the HASA tag (expressing hierarchy of data types)
+	Hashtable children = dataType.getChildren();
+	StringBuffer buf2 = new StringBuffer();
+	for (Enumeration en = children.keys(); en.hasMoreElements(); ) {
+	    String typeName = (String)en.nextElement();
+	    buf2.append ("<objectType articleName=\"");
+	    buf2.append (children.get (typeName));
+	    buf2.append ("\">");
+	    buf2.append (typeName);
+	    buf2.append ("</objectType>");
+	}
+
 	String result =
-	    (String)doCall ("registerObject",
+	    (String)doCall ("registerObjectClass",
 			    new Object[] {
-				"<registerObject>" +
+				"<registerObjectClass>" +
 				  "<objectType>" + dataType.getName() + "</objectType>" +
 				  "<Description><![CDATA[" + dataType.getDescription() + "]]>" +
 				  "</Description>" +
 				  "<ISA>" + new String (buf) + "</ISA>" +
+				  "<HASA>" + new String (buf2) + "</HASA>" +
 				  "<authURI>" + dataType.getAuthority() + "</authURI>" +
-				  "<Clobber>2</Clobber>" +
-				  "<xsd>" + dataType.getXSD() + "</xsd>" +
-				"</registerObject>"
+				  "<contactEmail>" + dataType.getEmailContact() + "</contactEmail>" +
+				"</registerObjectClass>"
 			    });
 	dataType.setId (checkRegistration (result, dataType));
     }
 
+//         <registerObjectClass>
+//             <objectType>NewObjectType</objectType>
+//             <Description><![CDATA[
+//                     human readable description
+//                     of data type]]>
+//             </Description>
+//             <Relationship relationshipType="RelationshipOntologyTerm">
+//                <objectType articleName="SomeName">ExistingObjectType</objectType>
+//                ...
+//                ...
+//             </Relationship>
+//             ...
+//             ...
+//             <authURI>Your.URI.here</authURI>
+//             <contactEmail>You at your.address.com</contactEmail>
+//         </registerObjectClass>
+
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void unregisterDataType (MobyDataType dataType)
-	throws MobyException, NoSuccessException {
-	if (dataType.getId() == null)
-	    throw new NoSuccessException ("Can't unregister a data type - unknown ID.", dataType);
+	throws MobyException, NoSuccessException, PendingCurationException {
 	String result =
-	    (String)doCall ("deregisterObject",
+	    (String)doCall ("deregisterObjectClass",
 			    new Object[] {
-				"<deregisterObject>" +
-				  "<objectAcc>" + dataType.getId() + "</objectAcc>" +
-				"</deregisterObject>"
+				"<deregisterObjectClass>" +
+				  "<objectType>" + dataType.getName() + "</objectType>" +
+				"</deregisterObjectClass>"
 			    });
 	checkRegistration (result, dataType);
     }
 
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void registerServiceType (MobyServiceType serviceType)
-	throws MobyException, NoSuccessException {
+	throws MobyException, NoSuccessException, PendingCurationException {
 
 	// build the ISA tag (expressing hierarchy of service types)
 	String[] names = serviceType.getParentNames();
@@ -542,6 +795,8 @@
 			    new Object[] {
 				"<registerServiceType>" +
 				  "<serviceType>" + serviceType.getName() + "</serviceType>" +
+				  "<contactEmail>" + serviceType.getEmailContact() + "</contactEmail>" +
+				  "<authURI>" + serviceType.getAuthority() + "</authURI>" +
 				  "<Description><![CDATA[" + serviceType.getDescription() + "]]>" +
 				  "</Description>" +
 				  "<ISA>" + new String (buf) + "</ISA>" +
@@ -550,65 +805,73 @@
 	serviceType.setId (checkRegistration (result, serviceType));
     }
 
+//         <registerServiceType>
+//          <serviceType>NewServiceType</serviceType>
+//          <contactEmail>your_name at contact.address.com</contactEmail>
+//          <authURI>Your.URI.here</authURI>
+//          <Description>
+//            <![CDATA[ human description of service type here]]>
+//          </Description>
+//          <Relationship relationshipType="RelationshipOntologyTerm">
+//            <serviceType>ExistingServiceType</serviceType>
+//            <serviceType>ExistingServiceType</serviceType>
+//          </Relationship>
+//         </registerServiceType>
+
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void unregisterServiceType (MobyServiceType serviceType)
-	throws MobyException, NoSuccessException {
-	if (serviceType.getId() == null)
-	    throw new NoSuccessException ("Can't unregister a service type - unknown ID.", serviceType);
+	throws MobyException, NoSuccessException, PendingCurationException {
 	String result =
 	    (String)doCall ("deregisterServiceType",
 			    new Object[] {
 				"<deregisterServiceType>" +
-				  "<serviceTypeAcc>" + serviceType.getId() + "</serviceTypeAcc>" +
+				  "<serviceType>" + serviceType.getName() + "</serviceType>" +
 				"</deregisterServiceType>"
 			    });
 	checkRegistration (result, serviceType);
     }
 
-
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void registerNamespace (MobyNamespace namespace)
-	throws MobyException, NoSuccessException {
+	throws MobyException, NoSuccessException, PendingCurationException {
 	String result =
 	    (String)doCall ("registerNamespace",
 			    new Object[] {
 				"<registerNamespace>" +
 				  "<namespaceType>" + namespace.getName() + "</namespaceType>" +
+				  "<contactEmail>" + namespace.getEmailContact() + "</contactEmail>" +
 				  "<authURI>" + namespace.getAuthority() + "</authURI>" +
 				  "<Description><![CDATA[" + namespace.getDescription() + "]]>" +
 				  "</Description>" +
-				  "<Clobber>2</Clobber>" +
 				"</registerNamespace>"
 			    });
 	namespace.setId (checkRegistration (result, namespace));
     }
 
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void unregisterNamespace (MobyNamespace namespace)
-	throws MobyException, NoSuccessException {
-	if (namespace.getId() == null)
-	    throw new NoSuccessException ("Can't unregister a namespace - unknown ID.", namespace);
+	throws MobyException, NoSuccessException, PendingCurationException {
 	String result =
 	    (String)doCall ("deregisterNamespace",
 			    new Object[] {
 				"<deregisterNamespace>" +
-				  "<namespaceAcc>" + namespace.getId() + "</namespaceAcc>" +
+				  "<namespaceType>" + namespace.getName() + "</namespaceType>" +
 				"</deregisterNamespace>"
 			    });
 	checkRegistration (result, namespace);
     }
 
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void registerService (MobyService service)
-	throws MobyException, NoSuccessException {
+	throws MobyException, NoSuccessException, PendingCurationException {
 
 	String result =
 	    (String)doCall ("registerService",
@@ -618,141 +881,83 @@
 				  "<serviceName>" + service.getName() + "</serviceName>" +
 				  "<serviceType>" + service.getType() + "</serviceType>" +
 				  "<authURI>" + service.getAuthority() + "</authURI>" +
-				  "<inputObjects>" + buildInputTag (service) + "</inputObjects>" +
-				  "<outputObjects>" + buildOutputTag (service) + "</outputObjects>" +
 				  "<URL>" + service.getURL() + "</URL>" +
+				  "<contactEmail>" + service.getEmailContact() + "</contactEmail>" +
+				  "<authoritativeService>" + (service.isAuthoritative() ? "1" : "0") + "</authoritativeService>" +
 				  "<Description><![CDATA[" + service.getDescription() + "]]>" +
 				  "</Description>" +
+				  buildPrimaryInputTag (service) + 
+				  buildSecondaryInputTag (service) + 
+				  buildOutputTag (service) + 
 				"</registerService>"
 			    });
 	service.setId (checkRegistration (result, service));
     }
 
     /*************************************************************************
-     *
+     * B
      *************************************************************************/
     public void unregisterService (MobyService service)
-	throws MobyException, NoSuccessException {
-	if (service.getId() == null)
-	    throw new NoSuccessException ("Can't unregister a service - unknown ID.", service);
+	throws MobyException, NoSuccessException, PendingCurationException {
 	String result =
 	    (String)doCall ("deregisterService",
 			    new Object[] {
 				"<deregisterService>" +
-				  "<serviceID>" + service.getId() + "</serviceID>" +
+				  "<authURI>" + service.getAuthority() + "</authURI>" +
+				  "<serviceName>" + service.getName() + "</serviceName>" +
 				"</deregisterService>"
 			    });
 	checkRegistration (result, service);
     }
 
     /**************************************************************************
-     *
+     * B
      *************************************************************************/
     public MobyService[] findService (String serviceType)
 	throws MobyException {
-	String result =
-	    (String)doCall ("locateServiceByType",
-			    new Object[] {
-				"<locateServiceByType>" +
-				  "<serviceType>" + serviceType + "</serviceType>" +
-				  "<fullServices>1</fullServices>" +
-				"</locateServiceByType>"
-			    });
-	return extractServices (result);
+	if (serviceType == null)
+	    return new MobyService[] {};
+	MobyService pattern = new MobyService ("dummy");
+	pattern.setType (serviceType);
+	return findService (pattern, null);
     }
 
     /**************************************************************************
-     *
+     * B
      *************************************************************************/
     public MobyService[] findService (String[] keywords)
 	throws MobyException {
 	if (keywords == null)
 	    return new MobyService[] {};
-
-	StringBuffer buf = new StringBuffer();
-	for (int i = 0; i < keywords.length; i++) {
-	    buf.append ("<keyword>");
-	    buf.append (keywords[i]);
-	    buf.append ("</keyword>");
-	}
-
-	String result =
-	    (String)doCall ("locateServiceByKeywords",
-			    new Object[] {
-				"<locateServiceByKeywords>" +
-				  new String (buf) +
- 				  "<fullServices>1</fullServices>" +
-				"</locateServiceByKeywords>"
-			    });
-	return extractServices (result);
+	return findService (null, keywords);
     }
 
     /**************************************************************************
-     *
+     * B
      *************************************************************************/
     public MobyService[] findService (MobyService pattern)
 	throws MobyException {
 	if (pattern == null)
 	    return new MobyService[] {};
-	int iLen = pattern.getInputTypes().length;
-	int oLen = pattern.getOutputTypes().length;
-	if (iLen == 0 && oLen == 0)
-	    return new MobyService[] {};
-
-	MobyService[] byInput = null;
-	MobyService[] byOutput = null;
+	return findService (pattern, null);
+    }
 
-	// locate service by input types
-	if (iLen > 0) {
-	    String result =
-		(String)doCall ("locateServiceByInput",
-				new Object[] { 
-				    "<locateServiceByInput>" +
-				      "<inputObjects>" + buildInputTag (pattern) + "</inputObjects>" +
-				      "<serviceType>" + pattern.getType() + "</serviceType>" +
-				      "<authURI>" + pattern.getAuthority() + "</authURI>" +
-				      "<fullObjects>1</fullObjects>" +
-				      "<fullServices>1</fullServices>" +
-				    "</locateServiceByInput>"
-				});
-	    byInput = extractServices (result);
-	    if (oLen == 0)
-		return byInput;
-	}
-
-	// locate service by output types
-	if (oLen > 0) {
-	    String result =
-		(String)doCall ("locateServiceByOutput",
-				new Object[] { 
-				    "<locateServiceByOutput>" +
-				      buildOutputTag (pattern) +
-				      "<serviceType>" + pattern.getType() + "</serviceType>" +
-				      "<authURI>" + pattern.getAuthority() + "</authURI>" +
-				      "<fullObjects>1</fullObjects>" +
-				      "<fullServices>1</fullServices>" +
-				    "</locateServiceByOutput>"
-				});
-	    byOutput = extractServices (result);
-	    if (iLen == 0)
-		return byOutput;
-	}
+    /**************************************************************************
+     * B
+     *************************************************************************/
+    public MobyService[] findService (MobyService pattern, String[] keywords)
+	throws MobyException {
+	if (pattern == null)
+	    pattern = new MobyService ("dummy");
 
-	// if we are still here, build an intersection
-	if (byInput == null || byOutput == null)
-	    return new MobyService[] {};
-	Vector v = new Vector();
-	for (int i = 0; i < byInput.length; i++) {
-	    for (int j = 0; j < byOutput.length; j++) {
-		if (byInput[i].equals (byOutput[j])) {
-		    v.addElement (byInput[i]);
-		    break;
-		}
-	    }
-	}
-	MobyService[] results = new MobyService [v.size()];
-	v.copyInto (results);
-	return results;
+	String result =
+	    (String)doCall ("findService",
+			    new Object[] { 
+				"<findService>" +
+				buildQueryObject (pattern, keywords, true, true, false) + 
+				"</findService>"
+			    });
+	return extractServices (result);
     }
 
     /**************************************************************************
@@ -766,4 +971,11 @@
 	    return (String)doCall (methodName, new Object[] { inputXML });
     }
 
+    /**************************************************************************
+     *
+     *************************************************************************/
+    public void setDebug (boolean debug) {
+	this.debug = debug;
+    }
+
 }




More information about the MOBY-guts mailing list