[MOBY-guts] biomoby commit

senger@ebi.ac.uk senger at pub.open-bio.org
Fri Jun 20 11:06:22 UTC 2003


senger
Fri Jun 20 07:06:22 EDT 2003
Update of /home/repository/moby/moby-live/Java/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv16795/org/biomoby/client

Modified Files:
	CentralImpl.java 
Log Message:
retrieveObjectDefinition added

moby-live/Java/org/biomoby/client CentralImpl.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java	2003/06/15 15:21:56	1.4
+++ /home/repository/moby/moby-live/Java/org/biomoby/client/CentralImpl.java	2003/06/20 11:06:22	1.5
@@ -623,6 +623,91 @@
 
 
     /**************************************************************************
+     * The 'retrieveObjectDefinition' method returns something like this;
+     *
+     * <registerObjectClass>
+     *   <objectType>urn:lsid:biomoby.org:objectclass:go_term</objectType>
+     *   <Description><![CDATA[A very lightweight object holding a GO term name and its definition]]></Description>
+     *   <authURI>http://www.illuminae.com</authURI>
+     *   <contactEmail>markw at illuminae.com</contactEmail>
+     *   <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'>
+     *      <objectType articleName=''>urn:lsid:biomoby.org:objectclass:object</objectType>
+     *   </Relationship>
+     *   <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:hasa'>
+     *      <objectType articleName='Term'>urn:lsid:biomoby.org:objectclass:string</objectType>
+     *      <objectType articleName='Definition'>urn:lsid:biomoby.org:objectclass:string</objectType>
+     *   </Relationship>
+     * </registerObjectClass>
+     *
+     *************************************************************************/
+    public MobyDataType getDataType (String dataTypeName)
+	throws MobyException, NoSuccessException {
+	String result =
+	    (String)doCall ("retrieveObjectDefinition",
+			    new Object[] {
+				"<retrieveObjectDefinition>" +
+				  "<objectType>" + dataTypeName + "</objectType>" +
+				"</retrieveObjectDefinition>"
+			    });
+
+	// parse returned XML
+	Document document = parser.parse (new StringReader (result));
+	NodeList list = document.getElementsByTagName ("registerObjectClass");
+	if (list == null || list.getLength() == 0)
+ 	    throw new NoSuccessException ("Data Type name was not founnd.",
+					  dataTypeName);
+	MobyDataType data = null;
+	Element elem = (Element)list.item (0);
+	NodeList children = elem.getChildNodes();
+
+	// first find the "real" data type name
+	for (int j = 0; j < children.getLength(); j++) {
+	    String nodeName = children.item (j).getNodeName();
+	    if (nodeName.equals ("objectType")) {
+		data = new MobyDataType (children.item (j).getFirstChild().getNodeValue());
+		break;
+	    }
+	}
+
+	// if not found (unprobable) use the name given by the caller
+	if (data == null)
+	    data = new MobyDataType (dataTypeName);
+
+	// now fill the data type object with the rest of attributes
+	for (int j = 0; j < children.getLength(); j++) {
+	    String nodeName = children.item (j).getNodeName();
+	    if (nodeName.equals ("Description")) {
+		data.setDescription (children.item (j).getFirstChild().getNodeValue());
+	    } else if (nodeName.equals ("authURI")) {
+		data.setAuthority (children.item (j).getFirstChild().getNodeValue());
+	    } else if (nodeName.equals ("contactEmail")) {
+		data.setEmailContact (children.item (j).getFirstChild().getNodeValue());
+	    } else if (nodeName.equals ("Relationship")) {
+		String relationshipType = ((Element)children.item (j)).getAttribute ("relationshipType");
+		if (relationshipType.endsWith ("isa")) {
+
+		    NodeList parents = children.item (j).getChildNodes();
+		    for (int k = 0; k < parents.getLength(); k++) {
+			if (parents.item (k).getNodeName().equals ("objectType")) {
+			    data.addParentName (parents.item (k).getFirstChild().getNodeValue());
+			}
+		    }
+		} else if (relationshipType.endsWith ("hasa")) {
+
+		    NodeList belows = children.item (j).getChildNodes();
+		    for (int k = 0; k < belows.getLength(); k++) {
+			if (belows.item (k).getNodeName().equals ("objectType")) {
+			    data.addChild ( ((Element)belows.item (k)).getAttribute ("articleName"),
+					    belows.item (k).getFirstChild().getNodeValue() );
+			}
+		    }
+		}
+	    }
+	}
+	return data;
+    }
+
+    /**************************************************************************
      * B
      *  <Objects>
      *     <Object name="ObjectOntologyTerm">
@@ -718,11 +803,11 @@
 	Hashtable children = dataType.getChildren();
 	StringBuffer buf2 = new StringBuffer();
 	for (Enumeration en = children.keys(); en.hasMoreElements(); ) {
-	    String typeName = (String)en.nextElement();
+	    String name = (String)en.nextElement();
 	    buf2.append ("<objectType articleName=\"");
-	    buf2.append (children.get (typeName));
+	    buf2.append (name);
 	    buf2.append ("\">");
-	    buf2.append (typeName);
+	    buf2.append (children.get (name));
 	    buf2.append ("</objectType>");
 	}
 




More information about the MOBY-guts mailing list