random bits and pieces whilst in hamburg - beginnings of file handliongimpmementation.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 7 Oct 2005 15:14:53 +0000 (15:14 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 7 Oct 2005 15:14:53 +0000 (15:14 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@55 be28352e-c001-0410-b1a7-c7978e42abec

13 files changed:
src/org/vamsas/client/ClientHandle.java
src/org/vamsas/client/Events.java
src/org/vamsas/client/SimpleClient.java
src/org/vamsas/client/object.java
src/org/vamsas/client/simpleclient/ClientsFile.java [new file with mode: 0644]
src/org/vamsas/client/simpleclient/FileWatcher.java [new file with mode: 0644]
src/org/vamsas/client/simpleclient/documentHandler.java
src/org/vamsas/objects/core/Alignment.java
src/org/vamsas/objects/core/AlignmentDescriptor.java
src/org/vamsas/objects/core/DataSet.java
src/org/vamsas/objects/core/DataSetAnnotationsDescriptor.java
src/org/vamsas/objects/core/DataSetDescriptor.java
src/org/vamsas/objects/core/ProvenanceDescriptor.java

index 031469a..5f3a77e 100644 (file)
@@ -2,11 +2,14 @@
  */
 package org.vamsas.client;
 
+import java.io.Serializable;
+
 /**
  * Uniquely describes a vamsas client application.
  * @author jimp 
  */
-public class ClientHandle {
+public class ClientHandle implements Serializable {
+  static final long serialVersionUID = 0;
   /**
    * @param clientName
    * @param version
index f03d042..bf35fa0 100644 (file)
@@ -11,8 +11,9 @@ public class Events {
    */
   public static final String DOCUMENT_UPDATE="org.vamsas.client.events.documentUpdateEvent";
   /**
-   * Generated when a new vamsas document is created 
-   * so an application may do its own data space initialization
+   * Generated when a new vamsas document is created (perhaps from some existing Vamsas data)
+   * so an application may do its own data space initialization.
+   * TODO: decide if this is called when an app is connected to a stored session...
    */
   public static final String DOCUMENT_CREATE="org.vamsas.client.events.documentCreateEvent";
   /**
@@ -21,7 +22,7 @@ public class Events {
    */
   public static final String CLIENT_CREATION="org.vamsas.client.events.clientCreateEvent";
   /**
-   * Generated when a vamsas client leaves a session (Handle is passed).
+   * Generated when a vamsas client leaves a session (Handle is passed to all others).
    */
   public static final String CLIENT_FINALIZATION="org.vamsas.client.events.clientFinalizationEvent";
   /**
index 90e394f..472e3dd 100644 (file)
@@ -37,7 +37,7 @@ public class SimpleClient implements IClient {
   SessionHandle session = null;
 
   ClientHandle client = null;
-
+  
   /*
    * (non-Javadoc)
    * 
@@ -123,7 +123,11 @@ public class SimpleClient implements IClient {
    * @see org.vamsas.client.IClient#finalizeClient()
    */
   public void finalizeClient() {
-    // TODO: raise events
+    // TODO: determine if this is last client in session
+    // TODO: raise events like : ((lst_client && document.request.to.close), (client_finalization), (
+    
+    // if (handlers.containsKey(Events.))
+    // if (handlers.containsKey(Events.CLIENT_FINALIZATION))
     // deregister listeners.
     // mark this instance as finalized
   }
index fc13b4f..040222a 100644 (file)
@@ -60,25 +60,27 @@ public abstract class object {
    */
   protected void setInstanceIdField() {
     if (registerable) {
-      if (vorbaId!=null) 
+      if (vorbaId != null)
         try {
           java.lang.reflect.Field fd = this.getClass().getField("id");
           fd.set((Object) this, (Object) new String(vorbaId.id));
         } catch (IllegalAccessException e) {
-          System.err.println("SourceGeneration of "+this.getClass().toString()
-              +"\n has resulted in an inaccessible 'id' field!\nCannot set ID from the vorbaId object.")
-              e.printStackTrace(System.err);
-        }
-        catch (SecurityException e) {
+          System.err
+              .println("SourceGeneration of "
+                  + this.getClass().toString()
+                  + "\n has resulted in an inaccessible 'id' field!\nCannot set ID from the vorbaId object.");
+          e.printStackTrace(System.err);
+        } catch (SecurityException e) {
           e.printStackTrace(System.err);
         } catch (NoSuchFieldException e) {
           this.setRegisterable(false);
         }
     } else {
       System.err.println("Client error. Trying to setInstanceIdField on a "
-          +this.getClass().toString()+" (which cannot be given a vorbaId)");
+          + this.getClass().toString() + " (which cannot be given a vorbaId)");
     }
   }
+
   /**
    * calculate a hash for the object with all housekeeping fields at standard
    * values. (isRegisterable is an immutable attribute property)
@@ -97,6 +99,19 @@ public abstract class object {
   }
 
   /**
+   * TODO: combine two versions of the same collection object to resolve
+   * asynchronous updates to the same vamsas object Merges two vamsas objects,
+   * one of which is a later version of the earlier (ie they have the same
+   * vorbaId but one is a later version recently read from the vamsasDocument
+   * collection.
+   * 
+   * @return
+   */
+  protected boolean merge(object laterCopy) {
+    return true;
+  }
+
+  /**
    * 
    * @return true if object is registered
    */
diff --git a/src/org/vamsas/client/simpleclient/ClientsFile.java b/src/org/vamsas/client/simpleclient/ClientsFile.java
new file mode 100644 (file)
index 0000000..132280e
--- /dev/null
@@ -0,0 +1,86 @@
+package org.vamsas.client.simpleclient;
+import org.vamsas.client.*;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Vector;
+
+/**
+ * @author jim
+ * Handler for the clientsFile within a vamsas session.
+ */
+public class ClientsFile {
+  private File filelist;
+  /**
+   * number of my client in list 
+   * (not known at start but used when known to make lock)
+   */
+  private int syncnum=1;
+  
+  ClientsFile(File filelist) {
+    this.filelist=filelist;
+  }
+  public ClientHandle[] retrieveClientList() {
+    if (filelist!=null) {
+      if (filelist.exists()) {
+        Lock listlock;
+        do {
+          listlock  = new Lock(filelist); // TODO: wait around if we can't get the lock.
+        } while (!listlock.isLocked());
+        try {
+          ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(new java.io.FileInputStream(filelist)));
+          ClientHandle[] clients;
+          clients = (ClientHandle[]) ((Vector) is.readObject()).toArray();
+          return clients;
+        }
+        catch (FileNotFoundException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+      // else return null.
+    } else {
+      throw new Error("Tried to retrieve a clientList without specifying client list filename");
+    }
+    return null;
+       
+  }
+  public boolean putClientList(ClientHandle[] clients) {
+    if (filelist!=null) {
+      if (filelist.exists()) {
+        Lock listlock;
+        do {
+          listlock  = new Lock(filelist); // TODO: wait around if we can't get the lock?  should return and make client wait until write has finished so it can read new client info...
+        } while (!listlock.isLocked());
+        try {
+          File templist=File.createTempFile(filelist.getName(),".temp",filelist);
+          ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(templist)));
+          os.writeObject(clients);
+          os.close();
+        }
+        catch (FileNotFoundException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+      }
+      // else return null.
+    } else {
+      throw new Error("Tried to retrieve a clientList without specifying client list filename");
+    }
+    return false;
+  }
+}
diff --git a/src/org/vamsas/client/simpleclient/FileWatcher.java b/src/org/vamsas/client/simpleclient/FileWatcher.java
new file mode 100644 (file)
index 0000000..f486360
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * 
+ */
+package org.vamsas.client.simpleclient;
+
+import java.io.File;
+
+/**
+ * @author jim
+ * Watches a particular file for its creation, deletion, or modification.
+ */
+public class FileWatcher {
+  private File subject=null;
+  private long lastStat;
+  boolean exists=false;
+  /**
+   * Make a watcher for a particular file.
+   * If the file doesn't exist, the watcher will watch
+   * for its creation (and indicate a change of state)
+   * @param subject
+   */
+  private boolean check() {
+    if (subject!=null) {
+      if (!subject.exists()) {
+        if (exists) {
+        exists=false;
+        return true;
+      } 
+      return false;
+    } else {
+      long newStat=subject.lastModified();
+      if (exists && lastStat==newStat) {
+        return false;
+      }
+      lastStat=newStat;
+      exists=true;
+      return true;
+    }
+  }
+    return false;
+  }
+  
+  
+  public FileWatcher(File subject) {
+    // TODO Auto-generated constructor stub
+    this.subject = subject;
+    check();
+  }
+  public boolean hasChanged() {
+    return check();
+  }
+}
index 433fef1..d584121 100644 (file)
@@ -24,10 +24,23 @@ import org.vamsas.objects.core.LockFileDescriptor;
  */
 public class documentHandler {
   /**
+   * Vamsas client is intialised with a path to create live session directories. 
+   * This path may contain a vamsas.properties file 
+   * that sets additional parameters (otherwise client 
+   * just uses the one on the classpath).
+   * 
+   * A vamsas session consists of :
+   *  SessionDir - translates to urn of a live session.
+   *  Contains: Vamsas Document (as a jar), Session client list file, 
+   *  both of which may be locked, and additional 
+   *  temporary versions of these files when write 
+   *  operations are taking place.
+   * 
    * Zip file entries
    *  - vamsasdocument.xml : core info
    *  one or more:
    *  - <applicationname>.version.sessionnumber.raw (string given in vamsasdocument.xml applicationData entry)
+   *  
    * Lockfile
    *  - filename given in the vamsasdocument.xml. Should be checked for validity by any client and rewritten if necessary. 
    *    The lockfile can point to the jar itself.
index 68cf78b..be0f142 100644 (file)
@@ -58,9 +58,9 @@ implements java.io.Serializable
     private java.lang.String _id;
 
     /**
-     * Field _alignmentAnnotations
+     * Field _alignmentAnnotationsList
      */
-    private org.vamsas.objects.core.AlignmentAnnotations _alignmentAnnotations;
+    private java.util.Vector _alignmentAnnotationsList;
 
     /**
      * Field _treeList
@@ -85,6 +85,7 @@ implements java.io.Serializable
     public Alignment() 
      {
         super();
+        _alignmentAnnotationsList = new Vector();
         _treeList = new Vector();
         _alignmentSequenceList = new Vector();
     } //-- org.vamsas.objects.core.Alignment()
@@ -95,6 +96,33 @@ implements java.io.Serializable
     //-----------/
 
     /**
+     * Method addAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @param vAlignmentAnnotations
+     */
+    public void addAlignmentAnnotations(org.vamsas.objects.core.AlignmentAnnotations vAlignmentAnnotations)
+        throws java.lang.IndexOutOfBoundsException
+    {
+        _alignmentAnnotationsList.addElement(vAlignmentAnnotations);
+    } //-- void addAlignmentAnnotations(org.vamsas.objects.core.AlignmentAnnotations) 
+
+    /**
+     * Method addAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @param index
+     * @param vAlignmentAnnotations
+     */
+    public void addAlignmentAnnotations(int index, org.vamsas.objects.core.AlignmentAnnotations vAlignmentAnnotations)
+        throws java.lang.IndexOutOfBoundsException
+    {
+        _alignmentAnnotationsList.insertElementAt(vAlignmentAnnotations, index);
+    } //-- void addAlignmentAnnotations(int, org.vamsas.objects.core.AlignmentAnnotations) 
+
+    /**
      * Method addAlignmentSequence
      * 
      * 
@@ -158,6 +186,18 @@ implements java.io.Serializable
     } //-- void deleteAligned() 
 
     /**
+     * Method enumerateAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @return Enumeration
+     */
+    public java.util.Enumeration enumerateAlignmentAnnotations()
+    {
+        return _alignmentAnnotationsList.elements();
+    } //-- java.util.Enumeration enumerateAlignmentAnnotations() 
+
+    /**
      * Method enumerateAlignmentSequence
      * 
      * 
@@ -216,12 +256,12 @@ implements java.io.Serializable
             }
             else if (temp._id != null)
                 return false;
-            if (this._alignmentAnnotations != null) {
-                if (temp._alignmentAnnotations == null) return false;
-                else if (!(this._alignmentAnnotations.equals(temp._alignmentAnnotations))) 
+            if (this._alignmentAnnotationsList != null) {
+                if (temp._alignmentAnnotationsList == null) return false;
+                else if (!(this._alignmentAnnotationsList.equals(temp._alignmentAnnotationsList))) 
                     return false;
             }
-            else if (temp._alignmentAnnotations != null)
+            else if (temp._alignmentAnnotationsList != null)
                 return false;
             if (this._treeList != null) {
                 if (temp._treeList == null) return false;
@@ -261,15 +301,52 @@ implements java.io.Serializable
     } //-- boolean getAligned() 
 
     /**
-     * Returns the value of field 'alignmentAnnotations'.
+     * Method getAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @param index
+     * @return AlignmentAnnotations
+     */
+    public org.vamsas.objects.core.AlignmentAnnotations getAlignmentAnnotations(int index)
+        throws java.lang.IndexOutOfBoundsException
+    {
+        //-- check bounds for index
+        if ((index < 0) || (index > _alignmentAnnotationsList.size())) {
+            throw new IndexOutOfBoundsException("getAlignmentAnnotations: Index value '"+index+"' not in range [0.."+_alignmentAnnotationsList.size()+ "]");
+        }
+        
+        return (org.vamsas.objects.core.AlignmentAnnotations) _alignmentAnnotationsList.elementAt(index);
+    } //-- org.vamsas.objects.core.AlignmentAnnotations getAlignmentAnnotations(int) 
+
+    /**
+     * Method getAlignmentAnnotations
+     * 
+     * 
      * 
      * @return AlignmentAnnotations
-     * @return the value of field 'alignmentAnnotations'.
      */
-    public org.vamsas.objects.core.AlignmentAnnotations getAlignmentAnnotations()
+    public org.vamsas.objects.core.AlignmentAnnotations[] getAlignmentAnnotations()
     {
-        return this._alignmentAnnotations;
-    } //-- org.vamsas.objects.core.AlignmentAnnotations getAlignmentAnnotations() 
+        int size = _alignmentAnnotationsList.size();
+        org.vamsas.objects.core.AlignmentAnnotations[] mArray = new org.vamsas.objects.core.AlignmentAnnotations[size];
+        for (int index = 0; index < size; index++) {
+            mArray[index] = (org.vamsas.objects.core.AlignmentAnnotations) _alignmentAnnotationsList.elementAt(index);
+        }
+        return mArray;
+    } //-- org.vamsas.objects.core.AlignmentAnnotations[] getAlignmentAnnotations() 
+
+    /**
+     * Method getAlignmentAnnotationsCount
+     * 
+     * 
+     * 
+     * @return int
+     */
+    public int getAlignmentAnnotationsCount()
+    {
+        return _alignmentAnnotationsList.size();
+    } //-- int getAlignmentAnnotationsCount() 
 
     /**
      * Method getAlignmentSequence
@@ -459,6 +536,21 @@ implements java.io.Serializable
     } //-- void marshal(org.xml.sax.ContentHandler) 
 
     /**
+     * Method removeAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @param index
+     * @return AlignmentAnnotations
+     */
+    public org.vamsas.objects.core.AlignmentAnnotations removeAlignmentAnnotations(int index)
+    {
+        java.lang.Object obj = _alignmentAnnotationsList.elementAt(index);
+        _alignmentAnnotationsList.removeElementAt(index);
+        return (org.vamsas.objects.core.AlignmentAnnotations) obj;
+    } //-- org.vamsas.objects.core.AlignmentAnnotations removeAlignmentAnnotations(int) 
+
+    /**
      * Method removeAlignmentSequence
      * 
      * 
@@ -474,6 +566,15 @@ implements java.io.Serializable
     } //-- org.vamsas.objects.core.AlignmentSequence removeAlignmentSequence(int) 
 
     /**
+     * Method removeAllAlignmentAnnotations
+     * 
+     */
+    public void removeAllAlignmentAnnotations()
+    {
+        _alignmentAnnotationsList.removeAllElements();
+    } //-- void removeAllAlignmentAnnotations() 
+
+    /**
      * Method removeAllAlignmentSequence
      * 
      */
@@ -518,14 +619,37 @@ implements java.io.Serializable
     } //-- void setAligned(boolean) 
 
     /**
-     * Sets the value of field 'alignmentAnnotations'.
+     * Method setAlignmentAnnotations
+     * 
+     * 
+     * 
+     * @param index
+     * @param vAlignmentAnnotations
+     */
+    public void setAlignmentAnnotations(int index, org.vamsas.objects.core.AlignmentAnnotations vAlignmentAnnotations)
+        throws java.lang.IndexOutOfBoundsException
+    {
+        //-- check bounds for index
+        if ((index < 0) || (index > _alignmentAnnotationsList.size())) {
+            throw new IndexOutOfBoundsException("setAlignmentAnnotations: Index value '"+index+"' not in range [0.."+_alignmentAnnotationsList.size()+ "]");
+        }
+        _alignmentAnnotationsList.setElementAt(vAlignmentAnnotations, index);
+    } //-- void setAlignmentAnnotations(int, org.vamsas.objects.core.AlignmentAnnotations) 
+
+    /**
+     * Method setAlignmentAnnotations
+     * 
+     * 
      * 
-     * @param alignmentAnnotations the value of field
-     * 'alignmentAnnotations'.
+     * @param alignmentAnnotationsArray
      */
-    public void setAlignmentAnnotations(org.vamsas.objects.core.AlignmentAnnotations alignmentAnnotations)
+    public void setAlignmentAnnotations(org.vamsas.objects.core.AlignmentAnnotations[] alignmentAnnotationsArray)
     {
-        this._alignmentAnnotations = alignmentAnnotations;
+        //-- copy array
+        _alignmentAnnotationsList.removeAllElements();
+        for (int i = 0; i < alignmentAnnotationsArray.length; i++) {
+            _alignmentAnnotationsList.addElement(alignmentAnnotationsArray[i]);
+        }
     } //-- void setAlignmentAnnotations(org.vamsas.objects.core.AlignmentAnnotations) 
 
     /**
index b5292e3..5030b0c 100644 (file)
@@ -183,8 +183,8 @@ public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDesc
         desc.setValidator(fieldValidator);
         //-- initialize element descriptors
         
-        //-- _alignmentAnnotations
-        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AlignmentAnnotations.class, "_alignmentAnnotations", "AlignmentAnnotations", org.exolab.castor.xml.NodeType.Element);
+        //-- _alignmentAnnotationsList
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AlignmentAnnotations.class, "_alignmentAnnotationsList", "AlignmentAnnotations", org.exolab.castor.xml.NodeType.Element);
         handler = new org.exolab.castor.xml.XMLFieldHandler() {
             public java.lang.Object getValue( java.lang.Object object ) 
                 throws IllegalStateException
@@ -197,7 +197,7 @@ public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDesc
             {
                 try {
                     Alignment target = (Alignment) object;
-                    target.setAlignmentAnnotations( (org.vamsas.objects.core.AlignmentAnnotations) value);
+                    target.addAlignmentAnnotations( (org.vamsas.objects.core.AlignmentAnnotations) value);
                 }
                 catch (java.lang.Exception ex) {
                     throw new IllegalStateException(ex.toString());
@@ -209,11 +209,12 @@ public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDesc
         };
         desc.setHandler(handler);
         desc.setNameSpaceURI("http://www.vamsas.org");
-        desc.setMultivalued(false);
+        desc.setMultivalued(true);
         addFieldDescriptor(desc);
         
-        //-- validation code for: _alignmentAnnotations
+        //-- validation code for: _alignmentAnnotationsList
         fieldValidator = new org.exolab.castor.xml.FieldValidator();
+        fieldValidator.setMinOccurs(0);
         { //-- local scope
         }
         desc.setValidator(fieldValidator);
@@ -284,7 +285,7 @@ public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDesc
         
         //-- validation code for: _alignmentSequenceList
         fieldValidator = new org.exolab.castor.xml.FieldValidator();
-        fieldValidator.setMinOccurs(2);
+        fieldValidator.setMinOccurs(1);
         { //-- local scope
         }
         desc.setValidator(fieldValidator);
index 176ebc5..d53dc4f 100644 (file)
@@ -63,9 +63,9 @@ implements java.io.Serializable
     private java.util.Vector _treeList;
 
     /**
-     * Field _provenanceList
+     * Field _provenance
      */
-    private java.util.Vector _provenanceList;
+    private org.vamsas.objects.core.Provenance _provenance;
 
 
       //----------------/
@@ -79,7 +79,6 @@ implements java.io.Serializable
         _dataSetAnnotationsList = new Vector();
         _alignmentList = new Vector();
         _treeList = new Vector();
-        _provenanceList = new Vector();
     } //-- org.vamsas.objects.core.DataSet()
 
 
@@ -142,33 +141,6 @@ implements java.io.Serializable
     } //-- void addDataSetAnnotations(int, org.vamsas.objects.core.DataSetAnnotations) 
 
     /**
-     * Method addProvenance
-     * 
-     * 
-     * 
-     * @param vProvenance
-     */
-    public void addProvenance(org.vamsas.objects.core.Provenance vProvenance)
-        throws java.lang.IndexOutOfBoundsException
-    {
-        _provenanceList.addElement(vProvenance);
-    } //-- void addProvenance(org.vamsas.objects.core.Provenance) 
-
-    /**
-     * Method addProvenance
-     * 
-     * 
-     * 
-     * @param index
-     * @param vProvenance
-     */
-    public void addProvenance(int index, org.vamsas.objects.core.Provenance vProvenance)
-        throws java.lang.IndexOutOfBoundsException
-    {
-        _provenanceList.insertElementAt(vProvenance, index);
-    } //-- void addProvenance(int, org.vamsas.objects.core.Provenance) 
-
-    /**
      * Method addSequence
      * 
      * 
@@ -247,18 +219,6 @@ implements java.io.Serializable
     } //-- java.util.Enumeration enumerateDataSetAnnotations() 
 
     /**
-     * Method enumerateProvenance
-     * 
-     * 
-     * 
-     * @return Enumeration
-     */
-    public java.util.Enumeration enumerateProvenance()
-    {
-        return _provenanceList.elements();
-    } //-- java.util.Enumeration enumerateProvenance() 
-
-    /**
      * Method enumerateSequence
      * 
      * 
@@ -334,12 +294,12 @@ implements java.io.Serializable
             }
             else if (temp._treeList != null)
                 return false;
-            if (this._provenanceList != null) {
-                if (temp._provenanceList == null) return false;
-                else if (!(this._provenanceList.equals(temp._provenanceList))) 
+            if (this._provenance != null) {
+                if (temp._provenance == null) return false;
+                else if (!(this._provenance.equals(temp._provenance))) 
                     return false;
             }
-            else if (temp._provenanceList != null)
+            else if (temp._provenance != null)
                 return false;
             return true;
         }
@@ -454,52 +414,15 @@ implements java.io.Serializable
     } //-- java.lang.String getId() 
 
     /**
-     * Method getProvenance
-     * 
-     * 
-     * 
-     * @param index
-     * @return Provenance
-     */
-    public org.vamsas.objects.core.Provenance getProvenance(int index)
-        throws java.lang.IndexOutOfBoundsException
-    {
-        //-- check bounds for index
-        if ((index < 0) || (index > _provenanceList.size())) {
-            throw new IndexOutOfBoundsException("getProvenance: Index value '"+index+"' not in range [0.."+_provenanceList.size()+ "]");
-        }
-        
-        return (org.vamsas.objects.core.Provenance) _provenanceList.elementAt(index);
-    } //-- org.vamsas.objects.core.Provenance getProvenance(int) 
-
-    /**
-     * Method getProvenance
-     * 
-     * 
+     * Returns the value of field 'provenance'.
      * 
      * @return Provenance
+     * @return the value of field 'provenance'.
      */
-    public org.vamsas.objects.core.Provenance[] getProvenance()
+    public org.vamsas.objects.core.Provenance getProvenance()
     {
-        int size = _provenanceList.size();
-        org.vamsas.objects.core.Provenance[] mArray = new org.vamsas.objects.core.Provenance[size];
-        for (int index = 0; index < size; index++) {
-            mArray[index] = (org.vamsas.objects.core.Provenance) _provenanceList.elementAt(index);
-        }
-        return mArray;
-    } //-- org.vamsas.objects.core.Provenance[] getProvenance() 
-
-    /**
-     * Method getProvenanceCount
-     * 
-     * 
-     * 
-     * @return int
-     */
-    public int getProvenanceCount()
-    {
-        return _provenanceList.size();
-    } //-- int getProvenanceCount() 
+        return this._provenance;
+    } //-- org.vamsas.objects.core.Provenance getProvenance() 
 
     /**
      * Method getSequence
@@ -677,15 +600,6 @@ implements java.io.Serializable
     } //-- void removeAllDataSetAnnotations() 
 
     /**
-     * Method removeAllProvenance
-     * 
-     */
-    public void removeAllProvenance()
-    {
-        _provenanceList.removeAllElements();
-    } //-- void removeAllProvenance() 
-
-    /**
      * Method removeAllSequence
      * 
      */
@@ -719,21 +633,6 @@ implements java.io.Serializable
     } //-- org.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotations(int) 
 
     /**
-     * Method removeProvenance
-     * 
-     * 
-     * 
-     * @param index
-     * @return Provenance
-     */
-    public org.vamsas.objects.core.Provenance removeProvenance(int index)
-    {
-        java.lang.Object obj = _provenanceList.elementAt(index);
-        _provenanceList.removeElementAt(index);
-        return (org.vamsas.objects.core.Provenance) obj;
-    } //-- org.vamsas.objects.core.Provenance removeProvenance(int) 
-
-    /**
      * Method removeSequence
      * 
      * 
@@ -842,37 +741,13 @@ implements java.io.Serializable
     } //-- void setId(java.lang.String) 
 
     /**
-     * Method setProvenance
-     * 
-     * 
-     * 
-     * @param index
-     * @param vProvenance
-     */
-    public void setProvenance(int index, org.vamsas.objects.core.Provenance vProvenance)
-        throws java.lang.IndexOutOfBoundsException
-    {
-        //-- check bounds for index
-        if ((index < 0) || (index > _provenanceList.size())) {
-            throw new IndexOutOfBoundsException("setProvenance: Index value '"+index+"' not in range [0.."+_provenanceList.size()+ "]");
-        }
-        _provenanceList.setElementAt(vProvenance, index);
-    } //-- void setProvenance(int, org.vamsas.objects.core.Provenance) 
-
-    /**
-     * Method setProvenance
-     * 
-     * 
+     * Sets the value of field 'provenance'.
      * 
-     * @param provenanceArray
+     * @param provenance the value of field 'provenance'.
      */
-    public void setProvenance(org.vamsas.objects.core.Provenance[] provenanceArray)
+    public void setProvenance(org.vamsas.objects.core.Provenance provenance)
     {
-        //-- copy array
-        _provenanceList.removeAllElements();
-        for (int i = 0; i < provenanceArray.length; i++) {
-            _provenanceList.addElement(provenanceArray[i]);
-        }
+        this._provenance = provenance;
     } //-- void setProvenance(org.vamsas.objects.core.Provenance) 
 
     /**
index 09af6d9..064823f 100644 (file)
@@ -392,12 +392,13 @@ public class DataSetAnnotationsDescriptor extends org.exolab.castor.xml.util.XML
         };
         desc.setHandler(handler);
         desc.setNameSpaceURI("http://www.vamsas.org");
+        desc.setRequired(true);
         desc.setMultivalued(true);
         addFieldDescriptor(desc);
         
         //-- validation code for: _provenanceList
         fieldValidator = new org.exolab.castor.xml.FieldValidator();
-        fieldValidator.setMinOccurs(0);
+        fieldValidator.setMinOccurs(1);
         { //-- local scope
         }
         desc.setValidator(fieldValidator);
index 05f9f20..7e342bc 100644 (file)
@@ -243,8 +243,8 @@ public class DataSetDescriptor extends org.exolab.castor.xml.util.XMLClassDescri
         { //-- local scope
         }
         desc.setValidator(fieldValidator);
-        //-- _provenanceList
-        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenanceList", "Provenance", org.exolab.castor.xml.NodeType.Element);
+        //-- _provenance
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element);
         handler = new org.exolab.castor.xml.XMLFieldHandler() {
             public java.lang.Object getValue( java.lang.Object object ) 
                 throws IllegalStateException
@@ -257,7 +257,7 @@ public class DataSetDescriptor extends org.exolab.castor.xml.util.XMLClassDescri
             {
                 try {
                     DataSet target = (DataSet) object;
-                    target.addProvenance( (org.vamsas.objects.core.Provenance) value);
+                    target.setProvenance( (org.vamsas.objects.core.Provenance) value);
                 }
                 catch (java.lang.Exception ex) {
                     throw new IllegalStateException(ex.toString());
@@ -270,10 +270,10 @@ public class DataSetDescriptor extends org.exolab.castor.xml.util.XMLClassDescri
         desc.setHandler(handler);
         desc.setNameSpaceURI("http://www.vamsas.org");
         desc.setRequired(true);
-        desc.setMultivalued(true);
+        desc.setMultivalued(false);
         addFieldDescriptor(desc);
         
-        //-- validation code for: _provenanceList
+        //-- validation code for: _provenance
         fieldValidator = new org.exolab.castor.xml.FieldValidator();
         fieldValidator.setMinOccurs(1);
         { //-- local scope
index 23b355d..a76c8ab 100644 (file)
@@ -94,12 +94,13 @@ public class ProvenanceDescriptor extends org.exolab.castor.xml.util.XMLClassDes
         };
         desc.setHandler(handler);
         desc.setNameSpaceURI("http://www.vamsas.org");
+        desc.setRequired(true);
         desc.setMultivalued(true);
         addFieldDescriptor(desc);
         
         //-- validation code for: _entryList
         fieldValidator = new org.exolab.castor.xml.FieldValidator();
-        fieldValidator.setMinOccurs(0);
+        fieldValidator.setMinOccurs(1);
         { //-- local scope
         }
         desc.setValidator(fieldValidator);