[MOBY-guts] biomoby commit

senger@ebi.ac.uk senger at pub.open-bio.org
Wed Sep 22 21:11:17 UTC 2004


senger
Wed Sep 22 17:11:17 EDT 2004
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory pub.open-bio.org:/tmp/cvs-serv15476/src/main/org/biomoby/shared

Modified Files:
	MobyDataType.java MobyPrimaryDataSimple.java MobyService.java 
Added Files:
	MobyRelationship.java 
Log Message:
new registration procedure, etc.

moby-live/Java/src/main/org/biomoby/shared MobyRelationship.java,NONE,1.1 MobyDataType.java,1.2,1.3 MobyPrimaryDataSimple.java,1.1,1.2 MobyService.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java	2004/03/09 00:20:13	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java	2004/09/22 21:11:17	1.3
@@ -11,15 +11,14 @@
 
 
 /**
- * A container representing a data type used in the Moby registry.
- * The Moby data types are used to specify what types of inputs and
- * outputs are needed or produced by Moby services.
- *<p>
+ * A container representing a data type used in the Moby registry (in
+ * the BioMoby speak it is called "Object Class"). The Moby data
+ * types are used to specify what types of inputs and outputs are
+ * needed or produced by Moby services. <p>
  *
- * This container is used mainly to register a new data type in a
+ * This container is used mainly to register a new data type into a
  * Moby registry, and to find services with this particular input or
- * output data type.
- *<p>
+ * output data type. <p>
  *
  * @author <A HREF="mailto:senger at ebi.ac.uk">Martin Senger</A>
  * @version $Id$
@@ -32,12 +31,18 @@
     protected String emailContact = "";
     protected String description = "";
     protected String[] parentNames = new String[] { };
-    protected Hashtable children = new Hashtable();
+    protected MobyRelationship[] children = new MobyRelationship[] { };
     protected String id = null;
 
     /**************************************************************************
-     * Default constructor. Other characteristics are empty - which is usually
-     * wrong - therefore use 'set' method to fill them.
+     * Default constructor. Other characteristics are empty - which is
+     * usually wrong - you should use 'set' methods to fill them
+     * before using this instance. <p>
+     *
+     * @param name of this data type (e.g. GenericSequence, or
+     * String). The name can be either a simple string (e.g. Object),
+     * or a full-blown LSID
+     * (e.g. urn:lsid:biomoby.org:objectclass:Object).
      *************************************************************************/
     public MobyDataType (String name) {
 	this.name = name;
@@ -47,34 +52,76 @@
 	return name;
     }
 
+    /**
+     * Return an ID that is given to this data type during its
+     * registration. The ID seems to be used only for de-registration
+     * of this data type; you are not supposed to fill it when you
+     * create an instance of this object.
+     */
     public String getId() {
 	return id;
     }
+
+    /**
+     * @see #getId
+     */
     public void setId (String value) {
 	id = value;
     }
 
+    /**
+     * Return an authority for this data type. The authority is an URI
+     * of this data type provider. Very often empty.
+     */
     public String getAuthority() {
 	return authority;
     }
+    /**
+     * @see #getAuthority
+     */
     public void setAuthority (String value) {
 	authority = (value == null ? "" : value);
     }
 
+    /**
+     * Return a contact email. The purpose of this field is still a
+     * bit obscure - but I think that the intention is to use it in
+     * the process of de-registration of this data type.
+     */
     public String getEmailContact() {
 	return emailContact;
     }
+    /**
+     * @see #getEmailContact
+     */
     public void setEmailContact (String value) {
 	emailContact = (value == null ? "" : value);
     }
 
+    /**
+     * Return a (usually) human readable description of this data
+     * type.
+     */
     public String getDescription() {
 	return description;
     }
+    /**
+     * @see #getDescription
+     */
     public void setDescription (String value) {
 	description = (value == null ? "" : value);
     }
 
+    /**
+     * Return names of all parental data types (as stored in the
+     * BioMoby class ontology). Note, however, that the current
+     * BioMoby API (0.8) does not expect (probably even does not
+     * allow) multiple-inheritance. <p>
+     *
+     * @return (at the moment) none (for the root data type) or one
+     * name. The name is an LSID
+     * (e.g. urn:lsid:biomoby.org:objectclass:Object).
+     */
     public String[] getParentNames() {
 	synchronized (parentNames) {
 	    String[] names = new String [parentNames.length];
@@ -82,6 +129,12 @@
 	    return names;
 	}
     }
+    /**
+     * @see #getParentNames
+     * @param value is a set of parent names (usually just one name,
+     * however). If it is null all parents set previously are
+     * forgotten.
+     */
     public void setParentNames (String[] value) {
 	synchronized (parentNames) {
 	    if (value == null)
@@ -92,6 +145,13 @@
 	    }
 	}
     }
+    /**
+     * Add one parent of this data type. <p>
+     *
+     * @see #getParentNames
+     * @param value is a name of a parental data type. A null value is
+     * ignored.
+     */
     public void addParentName (String value) {
 	if (value != null) {
 	    synchronized (parentNames) {
@@ -105,53 +165,90 @@
     }
 
     /**
-     * Describes what children this data type has (expressing ontology
-     * term HAS-A). The returned value is a hashtable with:
-     * <ul>
-     *    <li> key is a (unique) name of this child a data type
-     *    <li> value is a name of a data type representing this child
-     * </ul>
+     * Return children of this data type, and the way how they are
+     * ontologically related to this data type. The returned elements
+     * are containers, each of them defining the child data type,
+     * under what name it is used here (the BioMoby API calls this
+     * name an "article name"), and what relationship it has to this
+     * data type (HAS, HASA). <p>
+     *
+     * Note that it does not return children that belong to the parent
+     * types - in other words it does not go up through the whole
+     * ontology tree to find all children. <p>
+     *
+     * @see MobyRelationship.HAS
+     * @see MobyRelationship.HASA
      */
-    public Hashtable getChildren() {
+    public MobyRelationship[] getChildren() {
 	return children;
     }
-    public void setChildren (Hashtable value) {
-	children = (value == null ? new Hashtable() : value);
+    /**
+     * @see #getChildren
+     * @param value is an array of children. If it is null all
+     * children set previously are forgotten.
+     */
+    public void setChildren (MobyRelationship[] value) {
+	children = (value == null ? new MobyRelationship[] {} : value);
     }
     /**
-     * 'name' is a name given to this child (attribute)
-     * 'typeName' is a name of a type represented by this child
+     * @see #getChildren
+     * @param child a new child to be added. If null it is ignored.
      */
-    public void addChild (String name, String typeName) {
+    public void addChild (MobyRelationship child) {
+	if (child != null) {
+	    synchronized (children) {
+		int len = children.length + 1;
+		MobyRelationship[] newChildren = new MobyRelationship [len];
+		System.arraycopy (children, 0, newChildren, 0, len-1);
+		newChildren [len - 1] = child;
+		setChildren (newChildren);
+	    }
+	}
+    }
+    /**
+     * Create a {@link MobyRelationship MobyRelationship} object from
+     * given parameters and add it as a new child. <p>
+     *
+     * @see #getChildren
+     * @param name is a name how the new child is known to this data
+     * type (an "article name" in the BioMoby speak),
+     * e.g. 'length'. Because of the backward compatibility it accepts
+     * also a null or empty string here - but according to the BioMoby
+     * API (0.8) this name should be always given.
+     * @param typeName is a name of the child data type,
+     * e.g. 'Integer'. If null it is ignored.
+     * @param relationshipType is either {@link MobyRelationship.HASA
+     * HASA} or {@link MobyRelationship.HAS HAS}. If it is something
+     * else it is silenty changed to {@link MobyRelationship.HASA
+     * HASA}.
+     */
+    public void addChild (String name, String typeName, int relationshipType) {
 	if (typeName != null) {
-	    if (name == null || name.equals (""))
-		name = typeName;
-// 		children.put (typeName, name);
-		children.put (name, typeName);
+	    if (name == null) name = "";
+	    if (relationshipType != MobyRelationship.HASA &&
+		relationshipType != MobyRelationship.HAS)
+		relationshipType = MobyRelationship.HASA;
+	    addChild (new MobyRelationship (name, typeName, relationshipType));
 	}
     }
 
-
     public String toString() {
 	StringBuffer buf = new StringBuffer();
 	buf.append ("Name:    " + name + "\n");
 	buf.append ("Auth:    " + authority + "\n");
 	buf.append ("Desc:    " + description + "\n");
 	buf.append ("Contact: " + emailContact + "\n");
-	buf.append ("ID:      " + id + "\n");
+	if (id != null) buf.append ("ID:      " + id + "\n");
 	buf.append ("Parents:\n");
 	for (int i = 0 ; i < parentNames.length; i++) {
 	    buf.append (Utils.format (null, 1));
 	    buf.append (parentNames [i]);
 	    buf.append ("\n");
 	}
-	buf.append ("Children:\n");
-	for (Enumeration en = children.keys(); en.hasMoreElements(); ) {
+	buf.append ("Children (only those registered here):\n");
+	for (int i = 0 ; i < children.length; i++) {
 	    buf.append (Utils.format (null, 1));
-	    String key = (String)en.nextElement();
-	    buf.append (key);
-	    buf.append (" => ");
-	    buf.append (children.get (key));
+	    buf.append (children[i].toString());
 	    buf.append ("\n");
 	}
 	return new String (buf);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java	2003/09/24 14:33:37	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java	2004/09/22 21:11:17	1.2
@@ -104,7 +104,7 @@
 	buf.append (name);
 	buf.append ("\">\n");
 	buf.append ("<objectType>");
-	buf.append (dataType.getName());
+	if (dataType != null) buf.append (dataType.getName());
 	buf.append ("</objectType>\n");
 	if (namespaces.size() > 0) {
 	    for (Enumeration en = namespaces.elements(); en.hasMoreElements(); ) {
@@ -121,7 +121,7 @@
     public String toString() {
 	StringBuffer buf = new StringBuffer();
 	buf.append ("Name:    " + name + "\n");
-	buf.append ("ID:      " + id + "\n");
+	if (id != null) buf.append ("ID:      " + id + "\n");
 	if (dataType != null)
 	    buf.append ("Data Type:\n" + dataType.format (1));
 	buf.append ("Namespaces:\n");

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2004/04/01 23:24:27	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2004/09/22 21:11:17	1.3
@@ -10,12 +10,12 @@
 import java.util.*;
 
 /**
- * A container representing a service.
- *<p>
+ * A container representing a service. But do not be too excited -
+ * this is not a real service but only its definition as it appears in
+ * the BioMoby regustry. <p>
  *
  * This container is used mainly to register a new service in a
- * Moby registry, and to find registered services later.
- *<p>
+ * Moby registry, and to find registered services later. <p>
  *
  * @author <A HREF="mailto:senger at ebi.ac.uk">Martin Senger</A>
  * @version $Id$
@@ -30,6 +30,9 @@
     protected String type = "";
     protected String description = "";
     protected String url = "";
+    protected String signatureURL = "";
+    protected String rdf = "";
+    protected String pathToRDF = "";
     protected boolean authoritativeService = true;
     protected String id = null;
 
@@ -39,8 +42,9 @@
     protected Vector primaryOutputs = new Vector();
 
     /**************************************************************************
-     * Default constructor. Other characteristics are empty - which is usually
-     * wrong - therefore use 'set' method to fill them.
+     * Default constructor. Other characteristics are empty - which is
+     * usually wrong - therefore use 'set' methods to fill them before
+     * using this instance.
      *************************************************************************/
     public MobyService (String name) {
 	this.name = name;
@@ -50,9 +54,21 @@
 	return name;
     }
 
+    /**
+     * Return an ID that is given to this service instance during its
+     * registration. The ID is used only for de-registration of this
+     * service instance (you are not supposed to fill it when you
+     * create an instance of this object). But it soon becomes
+     * obsolete anyway because of the new way of registering services
+     * (see {@link #getSignatureURL}). <p>
+     */
     public String getId() {
 	return id;
     }
+    /**
+     * Don't use it.
+     * @see #getId
+     */
     public void setId (String value) {
 	id = value;
     }
@@ -99,13 +115,89 @@
 	type = (value == null ? "" : value);
     }
 
+    /**
+     * Return a URL where this service is being served from. It is a
+     * URL where the clients of this service are going when they want
+     * to use it. <p>
+     *
+     * Note that there is nothing in the BioMoby registry remembering
+     * (registering) a namespace of your service. Therefore, your
+     * service is supposed to use <em>always</em> the namespace
+     * <tt>http://biomoby.org</tt>. <p>
+     */
     public String getURL() {
 	return url;
     }
+    /**
+     * @see #getURL
+     */
     public void setURL (String value) {
 	url = (value == null ? "" : value);
     }
 
+    /**
+     * Return a URL pointing to an RDF document that contains this
+     * service description (signature). Note that this RDF document
+     * can include also other things, such as other service
+     * signatures. <p>
+     *
+     * This is how it works:
+     * <ol>
+     *
+     *   <li> When you register a service (using an instance of this
+     *   class) you put here (by calling {@link #setSignatureURL}) a
+     *   URL pointing to <em>your</em> HTTP space, to an RDF
+     *   document. But this document does not need to exist yet.
+     *
+     *   <li> After a successful registration this instance will have
+     *   an RDF document with this service signature. You can obtain
+     *   it by calling {@link #getRDF}.
+     *
+     *   <li> You are expected to copy this RDF document to the place
+     *   that you had suggested in step 1. Failing to do it will
+     *   result in de-registrating your service automatically
+     *   sometimes later. Therefore, if your service is only a testing
+     *   one, do not copy RDF anywhere and the service will disappear.
+     *
+     *   <li> Some implementations of the {@link Central} interface
+     *   (such as its default implementation {@link
+     *   org.biomoby.client.CentralImpl CentralImpl} can copy the RDF
+     *   document for you if you put here a fully qualified path to
+     *   the file where the RDF document should be put (by calling
+     *   {@link #setPathToRDF}).
+     *
+     * </ol>
+     */
+    public String getSignatureURL() {
+	return signatureURL;
+    }
+    /**
+     * @see #getSignatureURL
+     */
+    public void setSignatureURL (String value) {
+	signatureURL = (value == null ? "" : value);
+    }
+
+    /**
+     * @see #getSignatureURL
+     */
+    public String getPathToRDF() {
+	return pathToRDF;
+    }
+    public void setPathToRDF (String value) {
+	pathToRDF = (value == null ? "" : value);
+    }
+
+    /**
+     * @see #getSignatureURL
+     */
+    public String getRDF() {
+	return rdf;
+    }
+    public void setRDF (String value) {
+	rdf = (value == null ? "" : value);
+    }
+
     public void setInputs (MobyData[] value) {
 	if (value == null) {
 	    primaryInputs.clear();
@@ -176,14 +268,16 @@
 
     public String toString() {
 	StringBuffer buf = new StringBuffer();
-	buf.append ("Name:     " + name + "\n");
-	buf.append ("Type:     " + type + "\n");
-	buf.append ("Category: " + category + "\n");
-	buf.append ("Auth:     " + authority + "\n");
-	buf.append ("Desc:     " + description + "\n");
-	buf.append ("URL:      " + url + "\n");
-	buf.append ("Contact:  " + emailContact + "\n");
-	buf.append ("ID:       " + id + "\n");
+	buf.append ("Name:          " + name + "\n");
+	buf.append ("Type:          " + type + "\n");
+	buf.append ("Category:      " + category + "\n");
+	buf.append ("Auth:          " + authority + "\n");
+	buf.append ("Desc:          " + description + "\n");
+	buf.append ("URL:           " + url + "\n");
+	buf.append ("Contact:       " + emailContact + "\n");
+	buf.append ("Signature URL: " + signatureURL + "\n");
+	buf.append ("Path to RDF:   " + pathToRDF + "\n");
+	if (id != null) buf.append ("ID:            " + id + "\n");
 
 	buf.append ("\nPrimary inputs:\n");
 	for (Enumeration en = primaryInputs.elements(); en.hasMoreElements(); )




More information about the MOBY-guts mailing list