Merge branch 'bug/JAL-2634' into develop
[jalview.git] / src / jalview / ws / rest / RestJobThread.java
index 5f8eb03..0592426 100644 (file)
@@ -1,20 +1,23 @@
-/*******************************************************************************
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.
- *
+ * 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/>.
- *******************************************************************************/
+ * 
+ * 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.ws.rest;
 
 import jalview.bin.Cache;
@@ -23,7 +26,7 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
@@ -33,6 +36,7 @@ import jalview.gui.WebserviceInfo;
 import jalview.io.NewickFile;
 import jalview.io.packed.JalviewDataset;
 import jalview.io.packed.JalviewDataset.AlignmentSet;
+import jalview.util.MessageManager;
 import jalview.ws.AWSThread;
 import jalview.ws.AWsJob;
 
@@ -40,11 +44,9 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map.Entry;
-import java.util.Vector;
 
 import org.apache.axis.transport.http.HTTPConstants;
 import org.apache.http.Header;
@@ -106,8 +108,7 @@ public class RestJobThread extends AWSThread
         jobs = new RestJob[viscontigals.length];
         for (int j = 0; j < jobs.length; j++)
         {
-          int[] visc = new int[]
-          { viscontig[j * 2], viscontig[j * 2 + 1] };
+          int[] visc = new int[] { viscontig[j * 2], viscontig[j * 2 + 1] };
           if (j != 0)
           {
             jobs[j] = new RestJob(j, this, viscontigals[j], visc);
@@ -172,9 +173,13 @@ public class RestJobThread extends AWSThread
   private String getStage(Stage stg)
   {
     if (stg == Stage.SUBMIT)
+    {
       return "submitting ";
+    }
     if (stg == Stage.POLL)
+    {
       return "checking status of ";
+    }
 
     return (" being confused about ");
   }
@@ -608,7 +613,7 @@ public class RestJobThread extends AWSThread
     // total number of distinct alignment sets generated by job set.
     int numAlSets = 0, als = 0;
     List<AlignmentI> destAls = new ArrayList<AlignmentI>();
-    List<jalview.datamodel.ColumnSelection> destColsel = new ArrayList<jalview.datamodel.ColumnSelection>();
+    List<jalview.datamodel.HiddenColumns> destColsel = new ArrayList<jalview.datamodel.HiddenColumns>();
     List<List<NewickFile>> trees = new ArrayList<List<NewickFile>>();
 
     do
@@ -714,7 +719,7 @@ public class RestJobThread extends AWSThread
           RestJob rj = (RestJob) jobs[nrj];
           int contigs[] = input.getVisibleContigs();
           AlignmentI destAl = null;
-          jalview.datamodel.ColumnSelection destCs = null;
+          jalview.datamodel.HiddenColumns destHCs = null;
           // Resolve destAl for this data.
           if (als == 0 && rj.isInputContextModified())
           {
@@ -730,7 +735,7 @@ public class RestJobThread extends AWSThread
               if (!restClient.isAlignmentModified() && merge)
               {
                 destAl = restClient.av.getAlignment();
-                destCs = restClient.av.getColumnSelection();
+                destHCs = restClient.av.getAlignment().getHiddenColumns();
                 resultDest
                         .add(restClient.isShowResultsInNewView() ? AddDataTo.newView
                                 : AddDataTo.currentView);
@@ -741,15 +746,15 @@ public class RestJobThread extends AWSThread
                 newAlignment = true;
                 // recreate the input alignment data
                 Object[] idat = input
-                        .getAlignmentAndColumnSelection(gapCharacter);
+                        .getAlignmentAndHiddenColumns(gapCharacter);
                 destAl = new Alignment((SequenceI[]) idat[0]);
-                destCs = (ColumnSelection) idat[1];
+                destHCs = (HiddenColumns) idat[1];
                 resultDest.add(AddDataTo.newAlignment);
                 // but do not add to the alignment panel list - since we need to
                 // create a whole new alignFrame set.
               }
               destAls.add(destAl);
-              destColsel.add(destCs);
+              destColsel.add(destHCs);
             }
           }
           else
@@ -768,7 +773,7 @@ public class RestJobThread extends AWSThread
               // recover reference to last alignment created for this rest frame
               // ready for extension
               destAl = destAls.get(als);
-              destCs = destColsel.get(als);
+              destHCs = destColsel.get(als);
             }
             else
             {
@@ -797,14 +802,17 @@ public class RestJobThread extends AWSThread
                 newview = input.getUpdatedView(rseqs, orders, gapCharacter);
               }
               destAl = new Alignment((SequenceI[]) newview[0]);
-              destCs = (ColumnSelection) newview[1];
+              destHCs = (HiddenColumns) newview[1];
               newAlignment = true;
               // TODO create alignment from result data with propagated
               // references.
               destAls.add(destAl);
-              destColsel.add(destCs);
+              destColsel.add(destHCs);
               resultDest.add(AddDataTo.newAlignment);
-              throw new Error("Impl. Error! TODO: ");
+              throw new Error(
+                      MessageManager
+                              .getString("error.implementation_error")
+                              + "TODO: ");
             }
           }
           /**
@@ -860,7 +868,7 @@ public class RestJobThread extends AWSThread
                 // TODO: cope with recovering hidden sequences from
                 // resultContext
                 {
-                  for (SequenceI oseq:sg.getSequences(null))
+                  for (SequenceI oseq : sg.getSequences(null))
                   {
                     SequenceI nseq = getNewSeq(oseq, rseqs[nrj],
                             ordermap[nrj], destAl);
@@ -1039,10 +1047,11 @@ public class RestJobThread extends AWSThread
     for (AddDataTo action : resultDest)
     {
       AlignmentI destal;
-      ColumnSelection destcs;
-      String alTitle = restClient.service.details.Action + " using "
-              + restClient.service.details.Name + " on "
-              + restClient.viewTitle;
+      HiddenColumns destcs;
+      String alTitle = MessageManager.formatMessage(
+              "label.webservice_job_title_on", new String[] {
+                  restClient.service.details.Action,
+                  restClient.service.details.Name, restClient.viewTitle });
       switch (action)
       {
       case newAlignment: