JAL-1432 updated copyright notices
[jalview.git] / src / jalview / io / VamsasAppDatastore.java
index 8228239..34c61d9 100644 (file)
@@ -1,30 +1,27 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.io;
 
 import jalview.bin.Cache;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.AlignmentView;
-import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.GraphLine;
-import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
@@ -34,14 +31,13 @@ import jalview.io.vamsas.Datasetsequence;
 import jalview.io.vamsas.DatastoreItem;
 import jalview.io.vamsas.DatastoreRegistry;
 import jalview.io.vamsas.Rangetype;
-import jalview.util.UrlLink;
-
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Vector;
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
@@ -51,14 +47,14 @@ import uk.ac.vamsas.objects.core.*;
 import uk.ac.vamsas.objects.utils.Properties;
 
 /*
- * 
+ *
  * static {
  * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty(
  * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); }
- * 
+ *
  */
 /*
- * TODO: check/verify consistency for vamsas sync with group associated alignment annotation  
+ * TODO: check/verify consistency for vamsas sync with group associated alignment annotation
  */
 public class VamsasAppDatastore
 {
@@ -546,12 +542,8 @@ public class VamsasAppDatastore
             else
             {
               // first find the alignment sequence to associate this with.
-              SequenceI jvalsq = null;
-              Enumeration jval = av.getAlignment().getSequences()
-                      .elements();
-              while (jval.hasMoreElements())
+              for (SequenceI jvalsq : av.getAlignment().getSequences())
               {
-                jvalsq = (SequenceI) jval.nextElement();
                 // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence)
                 // sref, aa[i]);
                 if (jvalsq.getDatasetSequence() == aa[i].sequenceRef)
@@ -884,7 +876,7 @@ public class VamsasAppDatastore
    * creates/syncs the jvalsq from the alignment sequence
    */
   private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
-          char valGapchar, char gapChar, Vector dsseqs)
+          char valGapchar, char gapChar, List<SequenceI> dsseqs)
 
   {
     boolean modal = false;
@@ -1260,7 +1252,7 @@ public class VamsasAppDatastore
   /**
    * list of alignment views created when updating Jalview from document.
    */
-  private Vector newAlignmentViews = new Vector();
+  private final Vector newAlignmentViews = new Vector();
 
   /**
    * update local jalview view settings from the stored appdata (if any)
@@ -1292,6 +1284,7 @@ public class VamsasAppDatastore
             jalview.util.jarInputStreamProvider jprovider = new jalview.util.jarInputStreamProvider()
             {
 
+              @Override
               public String getFilename()
               {
 
@@ -1299,6 +1292,7 @@ public class VamsasAppDatastore
                 return "Jalview Vamsas Document Client Data";
               }
 
+              @Override
               public JarInputStream getJarInputStream() throws IOException
               {
                 jalview.bin.Cache.log
@@ -1338,6 +1332,7 @@ public class VamsasAppDatastore
           jalview.util.jarInputStreamProvider jarstream = new jalview.util.jarInputStreamProvider()
           {
 
+            @Override
             public String getFilename()
             {
 
@@ -1345,6 +1340,7 @@ public class VamsasAppDatastore
               return "Jalview Vamsas Document User Data";
             }
 
+            @Override
             public JarInputStream getJarInputStream() throws IOException
             {
               jalview.bin.Cache.log
@@ -1443,7 +1439,8 @@ public class VamsasAppDatastore
           if (mappings != null && mappings.length > 0)
           {
             jalview.structure.StructureSelectionManager
-                    .getStructureSelectionManager(Desktop.instance).addMappings(mappings);
+                    .getStructureSelectionManager(Desktop.instance)
+                    .addMappings(mappings);
           }
         }
       }
@@ -1472,6 +1469,8 @@ public class VamsasAppDatastore
     Object vobject = jv2vobj.remove(oldjvobject);
     if (vobject == null)
     {
+      // NOTE: this happens if user deletes object in one session then updates
+      // from another client
       throw new Error(
               "IMPLEMENTATION ERROR: old jalview object is not bound ! ("
                       + oldjvobject + ")");
@@ -1573,7 +1572,7 @@ public class VamsasAppDatastore
         // ///LOAD DATASET
         DataSet dataset = root.getDataSet(_ds);
         int i, iSize = dataset.getSequenceCount();
-        Vector dsseqs;
+        List<SequenceI> dsseqs;
         jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(dataset);
         int jremain = 0;
         if (jdataset == null)
@@ -1620,8 +1619,8 @@ public class VamsasAppDatastore
           SequenceI[] seqs = new SequenceI[dsseqs.size()];
           for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
           {
-            seqs[i] = (SequenceI) dsseqs.elementAt(i);
-            dsseqs.setElementAt(null, i);
+            seqs[i] = dsseqs.get(i);
+            dsseqs.set(i, null);
           }
           jdataset = new jalview.datamodel.Alignment(seqs);
           Cache.log.debug("New vamsas dataset imported into jalview.");
@@ -1782,8 +1781,8 @@ public class VamsasAppDatastore
               SequenceI[] seqs = new SequenceI[dsseqs.size()];
               for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
               {
-                seqs[i] = (SequenceI) dsseqs.elementAt(i);
-                dsseqs.setElementAt(null, i);
+                seqs[i] = dsseqs.get(i);
+                dsseqs.set(i, null);
               }
               jal = new jalview.datamodel.Alignment(seqs);
               Cache.log.debug("New vamsas alignment imported into jalview "