[MOBY-guts] biomoby commit

senger@ebi.ac.uk senger at pub.open-bio.org
Mon Nov 24 18:45:25 UTC 2003


senger
Mon Nov 24 13:45:25 EST 2003
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv16028/src/main/org/biomoby/client

Modified Files:
	CentralImpl.java 
Log Message:
added relationships methods to Central.java

moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/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/src/main/org/biomoby/client/CentralImpl.java	2003/11/20 17:08:47	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2003/11/24 18:45:25	1.5
@@ -628,7 +628,7 @@
     /**************************************************************************
      * The 'retrieveObjectDefinition' method returns something like this;
      *
-     * <registerObjectDefinition>
+     * <retrieveObjectDefinition>
      *   <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>
@@ -640,7 +640,7 @@
      *      <objectType articleName='Term'>urn:lsid:biomoby.org:objectclass:string</objectType>
      *      <objectType articleName='Definition'>urn:lsid:biomoby.org:objectclass:string</objectType>
      *   </Relationship>
-     * </registerObjectDefinition>
+     * </retrieveObjectDefinition>
      *
      *************************************************************************/
     public MobyDataType getDataType (String dataTypeName)
@@ -1083,4 +1083,139 @@
 	this.debug = debug;
     }
 
+    /**************************************************************************
+     * The 'Relationships' method returns something like this;
+     *
+     * <Relationships>
+     *   <Relationship relationshipType='urn:lsid:biomoby.org:servicerelation:isa'>
+     *     <serviceType>urn:lsid:biomoby.org:servicetype:analysis</serviceType>
+     *     <serviceType>urn:lsid:biomoby.org:servicetype:service</serviceType>
+     *   </Relationship>
+     * </Relationships>
+     *************************************************************************/
+    public String[] getServiceTypeRelationships (String serviceTypeName)
+	throws MobyException {
+	String result =
+	    (String)doCall ("Relationships",
+			    new Object[] {
+				"<Relationship>" +
+				"<serviceType>" + serviceTypeName + "</serviceType>" +
+				"<relationshipType>" + Central.ISA + "</relationshipType>" +
+				"<expandRelationship>1</expandRelationship>" +
+				"</Relationship>"
+			    });
+
+	// parse returned XML
+	Vector v = new Vector();
+	Document document = parser.parse (new StringReader (result));
+	NodeList list = document.getElementsByTagName ("Relationship");
+	for (int i = 0; i < list.getLength(); i++) {
+	    Element elem = (Element)list.item (i);
+	    NodeList children = elem.getChildNodes();
+	    for (int j = 0; j < children.getLength(); j++) {
+		if (children.item (j).getNodeName().equals ("serviceType")) {
+		    v.addElement (children.item (j).getFirstChild().getNodeValue());
+		}
+	    }
+	}
+	String[] results = new String [v.size()];
+	v.copyInto (results);
+	return results;
+    }
+
+    /**************************************************************************
+     * The 'Relationships' method returns something like this;
+     *
+     *<Relationships>
+     *  <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:virtualsequence</objectType>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:object</objectType>
+     *  </Relationship>
+     *  <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:hasa'>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:string</objectType>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:integer</objectType>
+     *  </Relationship>
+     *</Relationships>
+     *
+     *************************************************************************/
+    public Map getDataTypeRelationships (String dataTypeName)
+	throws MobyException {
+	String result =
+	    (String)doCall ("Relationships",
+			    new Object[] {
+				"<Relationship>" +
+				"<objectType>" + dataTypeName + "</objectType>" +
+				"<relationshipType>" + Central.ISA + "</relationshipType>" +
+				"<relationshipType>" + Central.HASA + "</relationshipType>" +
+				"<relationshipType>" + Central.HAS + "</relationshipType>" +
+				"<expandRelationship>1</expandRelationship>" +
+				"</Relationship>"
+			    });
+
+	// parse returned XML
+	Map results = new HashMap();
+	Document document = parser.parse (new StringReader (result));
+	NodeList list = document.getElementsByTagName ("Relationship");
+
+	for (int i = 0; i < list.getLength(); i++) {
+	    Element elem = (Element)list.item (i);
+	    String relType = elem.getAttribute ("relationshipType");
+	    NodeList children = elem.getChildNodes();
+	    Vector v = new Vector();
+	    for (int j = 0; j < children.getLength(); j++) {
+		if (children.item (j).getNodeName().equals ("objectType")) {
+		    v.addElement (children.item (j).getFirstChild().getNodeValue());
+		}
+	    }
+	    String[] names = new String [v.size()];
+	    v.copyInto (names);
+	    results.put (relType, names);
+	}
+	return results;
+    }
+
+    /**************************************************************************
+     * The 'Relationships' method returns something like this;
+     *
+     *<Relationships>
+     *  <Relationship relationshipType='urn:lsid:biomoby.org:objectrelation:isa'>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:virtualsequence</objectType>
+     *    <objectType>urn:lsid:biomoby.org:objectclass:object</objectType>
+     *  </Relationship>
+     *</Relationships>
+     *
+     *************************************************************************/
+    public String[] getDataTypeRelationships (String dataTypeName,
+					      String relationshipType)
+	throws MobyException {
+	String result =
+	    (String)doCall ("Relationships",
+			    new Object[] {
+				"<Relationship>" +
+				"<objectType>" + dataTypeName + "</objectType>" +
+				"<relationshipType>" + relationshipType + "</relationshipType>" +
+				"<expandRelationship>1</expandRelationship>" +
+				"</Relationship>"
+			    });
+
+	// parse returned XML
+	Vector v = new Vector();
+	Document document = parser.parse (new StringReader (result));
+	NodeList list = document.getElementsByTagName ("Relationship");
+
+	// it should always be just one element in this list
+	for (int i = 0; i < list.getLength(); i++) {
+	    Element elem = (Element)list.item (i);
+	    NodeList children = elem.getChildNodes();
+	    for (int j = 0; j < children.getLength(); j++) {
+		if (children.item (j).getNodeName().equals ("objectType")) {
+		    v.addElement (children.item (j).getFirstChild().getNodeValue());
+		}
+	    }
+	}
+	String[] results = new String [v.size()];
+	v.copyInto (results);
+	return results;
+    }
+
 }




More information about the MOBY-guts mailing list