Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / fts / service / uniprot / UniProtFTSRestClient.java
index 88397f5..f2a9265 100644 (file)
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 
-/*
- * 2022-07-20 bsoares
- * See https://issues.jalview.org/browse/JAL-4036
- * The new Uniprot API is not dissimilar to the old one, but has some important changes.
- * Some group names have changed slightly, some old groups have gone and there are quite a few new groups.
- * 
- * Most changes are mappings of old column ids to new field ids. There are a handful of old
- * columns not mapped to new fields, and new fields without an old column.
- * [aside: not all possible columns were listed in the resources/fts/uniprot_data_columns.txt file.
- * These were presumably additions after the file was created]
- * For existing/mapped fields, the same preferences found in the resource file have been migrated to
- * the new file with the new field name, id and group.
- * 
- * The new mapped groups and files are stored and read from resources/fts/uniprot_data_columns-2022.txt.
- * 
- * There is now no "sort" query string parameter.
- * 
- * See https://www.uniprot.org/help/api_queries
- * 
- * SIGNIFICANT CHANGE: Pagination is no longer performed using a record offset, but with a "cursor"
- * query string parameter that is not really a cursor.  The value is an opaque string that is passed (or
- * rather a whole URL is passed) in the "Link" header of the HTTP response of the previous page.
- * Where such a link is passed it is put into the cursors ArrayList.
- * There are @Overridden methods in UniprotFTSPanel.
- */
-
 package jalview.fts.service.uniprot;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import java.lang.invoke.MethodHandles;
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -66,6 +43,7 @@ import jalview.bin.Cache;
 import jalview.bin.Console;
 import jalview.fts.api.FTSData;
 import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
 import jalview.fts.core.FTSRestClient;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.core.FTSRestResponse;
@@ -73,8 +51,39 @@ import jalview.util.ChannelProperties;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
+/*
+ * 2022-07-20 bsoares
+ * See https://issues.jalview.org/browse/JAL-4036
+ * The new Uniprot API is not dissimilar to the old one, but has some important changes.
+ * Some group names have changed slightly, some old groups have gone and there are quite a few new groups.
+ * 
+ * Most changes are mappings of old column ids to new field ids. There are a handful of old
+ * columns not mapped to new fields, and new fields without an old column.
+ * [aside: not all possible columns were listed in the resources/fts/uniprot_data_columns.txt file.
+ * These were presumably additions after the file was created]
+ * For existing/mapped fields, the same preferences found in the resource file have been migrated to
+ * the new file with the new field name, id and group.
+ * 
+ * The new mapped groups and files are stored and read from resources/fts/uniprot_data_columns-2022.txt.
+ * 
+ * There is now no "sort" query string parameter.
+ * 
+ * See https://www.uniprot.org/help/api_queries
+ * 
+ * SIGNIFICANT CHANGE: Pagination is no longer performed using a record offset, but with a "cursor"
+ * query string parameter that is not really a cursor.  The value is an opaque string that is passed (or
+ * rather a whole URL is passed) in the "Link" header of the HTTP response of the previous page.
+ * Where such a link is passed it is put into the cursors ArrayList.
+ * There are @Overridden methods in UniprotFTSPanel.
+ */
 public class UniProtFTSRestClient extends FTSRestClient
+    implements ApplicationSingletonI,FTSRestClientI
+{
+public static UniProtFTSRestClient getInstance()
 {
+return (UniProtFTSRestClient) ApplicationSingletonProvider
+    .getInstance(UniProtFTSRestClient.class);
+}
   private static final String DEFAULT_UNIPROT_DOMAIN = "https://rest.uniprot.org";
 
   private static final String USER_AGENT = ChannelProperties
@@ -87,11 +96,10 @@ public class UniProtFTSRestClient extends FTSRestClient
     Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN);
   }
 
-  private static UniProtFTSRestClient instance = null;
 
   public final String uniprotSearchEndpoint;
 
-  public UniProtFTSRestClient()
+  private UniProtFTSRestClient()
   {
     super();
     this.clearCursors();
@@ -214,7 +222,6 @@ public class UniProtFTSRestClient extends FTSRestClient
           }
         }
       }
-
       String uniProtTabDelimittedResponseString = clientResponse
               .getEntity(String.class);
       // Make redundant objects eligible for garbage collection to conserve
@@ -448,14 +455,6 @@ public class UniProtFTSRestClient extends FTSRestClient
     };
   }
 
-  public static UniProtFTSRestClient getInstance()
-  {
-    if (instance == null)
-    {
-      instance = new UniProtFTSRestClient();
-    }
-    return instance;
-  }
 
   @Override
   public String getColumnDataConfigFileName()
@@ -550,4 +549,4 @@ public class UniProtFTSRestClient extends FTSRestClient
     }
     return null;
   }
-}
\ No newline at end of file
+}