JAL-4059 Tidy getting the namespace, and save the namespace in the Jalview instance...
[jalview.git] / src / jalview / ws / DBRefFetcher.java
index d8858a9..d4e34e7 100644 (file)
  */
 package jalview.ws;
 
-import java.util.Locale;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
-import java.util.StringTokenizer;
 import java.util.Vector;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -49,6 +47,8 @@ import jalview.gui.FeatureSettings;
 import jalview.gui.IProgressIndicator;
 import jalview.gui.OOMWarning;
 import jalview.util.DBRefUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
 import jalview.util.MessageManager;
 import jalview.ws.seqfetcher.DbSourceProxy;
 import uk.ac.ebi.picr.model.UPEntry;
@@ -286,12 +286,12 @@ public class DBRefFetcher implements Runnable
       throw new Error(MessageManager
               .getString("error.implementation_error_must_init_dbsources"));
     }
-    long startTime = System.currentTimeMillis();
+    long progressId = IdUtils.newId(IdType.PROGRESS);
     if (progressWindow != null)
     {
       progressWindow.setProgressBar(
               MessageManager.getString("status.fetching_db_refs"),
-              startTime);
+              progressId);
     }
     try
     {
@@ -302,7 +302,8 @@ public class DBRefFetcher implements Runnable
       }
     } catch (Exception e)
     {
-      System.err.println("Couldn't locate PICR service instance.\n");
+      jalview.bin.Console
+              .errPrintln("Couldn't locate PICR service instance.\n");
       e.printStackTrace();
     }
 
@@ -316,7 +317,8 @@ public class DBRefFetcher implements Runnable
     while (sdataset.size() > 0 && db < dbSources.length)
     {
       int maxqlen = 1; // default number of queries made at one time
-      System.out.println("Verifying against " + dbSources[db].getDbName());
+      jalview.bin.Console
+              .outPrintln("Verifying against " + dbSources[db].getDbName());
 
       // iterate through db for each remaining un-verified sequence
       SequenceI[] currSeqs = new SequenceI[sdataset.size()];
@@ -425,7 +427,7 @@ public class DBRefFetcher implements Runnable
                             true);
                   } catch (Exception e)
                   {
-                    System.err.println(
+                    jalview.bin.Console.errPrintln(
                             "Exception with Picr for '" + token + "'\n");
                     e.printStackTrace();
                   }
@@ -438,7 +440,7 @@ public class DBRefFetcher implements Runnable
                     // present, and do a transferReferences
                     // otherwise transfer non sequence x-references directly.
                   }
-                  System.out.println(
+                  jalview.bin.Console.outPrintln(
                           "Validated ID against PICR... (for what its worth):"
                                   + token);
                   addSeqId(sequence, token);
@@ -447,7 +449,7 @@ public class DBRefFetcher implements Runnable
                 else
                 {
                   // if ()
-                  // System.out.println("Not querying source with
+                  // jalview.bin.Console.outPrintln("Not querying source with
                   // token="+token+"\n");
                   addSeqId(sequence, token);
                   queries.addElement(token.toUpperCase(Locale.ROOT));
@@ -482,7 +484,7 @@ public class DBRefFetcher implements Runnable
     {
       progressWindow.setProgressBar(
               MessageManager.getString("label.dbref_search_completed"),
-              startTime);
+              progressId);
     }
 
     for (FetchFinishedListenerI listener : listeners)
@@ -512,7 +514,7 @@ public class DBRefFetcher implements Runnable
           DbSourceProxy dbSourceProxy, AlignmentI retrievedAl,
           boolean trimDatasetSeqs, List<String> warningMessages)
   {
-    // System.out.println("trimming ? " + trimDatasetSeqs);
+    // jalview.bin.Console.outPrintln("trimming ? " + trimDatasetSeqs);
     if (retrievedAl == null || retrievedAl.getHeight() == 0)
     {
       return false;
@@ -678,8 +680,8 @@ public class DBRefFetcher implements Runnable
           }
         }
 
-        System.out.println("Adding dbrefs to " + sequence.getName()
-                + " from " + dbSource + " sequence : "
+        jalview.bin.Console.outPrintln("Adding dbrefs to "
+                + sequence.getName() + " from " + dbSource + " sequence : "
                 + retrievedSeq.getName());
         sequence.transferAnnotation(retrievedSeq, mp);