JAL-3865 isolate PDB and TDB clients and last query records in their query objects
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 16:01:04 +0000 (17:01 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 16:01:04 +0000 (17:01 +0100)
src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java
src/jalview/gui/structurechooser/StructureChooserQuerySource.java
src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java

index 4dede2e..3d1b982 100644 (file)
@@ -37,6 +37,10 @@ public class PDBStructureChooserQuerySource
 
   private static int MAX_QLENGTH = 7820;
 
+  protected FTSRestRequest lastPdbRequest;
+
+  protected FTSRestClientI pdbRestClient;
+
   public PDBStructureChooserQuerySource()
   {
     pdbRestClient = PDBFTSRestClient.getInstance();
@@ -344,4 +348,11 @@ public class PDBStructureChooserQuerySource
     return pdbEntriesToView;
   }
 
+
+  @Override
+  protected FTSRestRequest getLastFTSRequest()
+  {
+    return lastPdbRequest;
+  }
+
 }
\ No newline at end of file
index 4faa2de..96b67e4 100644 (file)
@@ -28,9 +28,6 @@ import jalview.jbgui.FilterOption;
  */
 public abstract class StructureChooserQuerySource
 {
-  protected FTSRestRequest lastPdbRequest;
-
-  protected FTSRestClientI pdbRestClient;
 
   protected FTSDataColumnPreferences docFieldPrefs;
 
@@ -191,10 +188,12 @@ public abstract class StructureChooserQuerySource
   public TableModel getTableModel(
           Collection<FTSData> discoveredStructuresSet)
   {
-    return FTSRestResponse.getTableModel(lastPdbRequest,
+    return FTSRestResponse.getTableModel(getLastFTSRequest(),
             discoveredStructuresSet);
   }
 
+  protected abstract FTSRestRequest getLastFTSRequest();
+
   public abstract PDBEntry[] collectSelectedRows(JTable restable,
           int[] selectedRows, List<SequenceI> selectedSeqsToView);
 
index e188b23..0bf9fdb 100644 (file)
@@ -14,6 +14,7 @@ import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.api.FTSRestClientI;
 import jalview.fts.core.FTSDataColumnPreferences;
 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
 import jalview.fts.core.FTSRestRequest;
@@ -23,7 +24,7 @@ import jalview.jbgui.FilterOption;
 import jalview.util.MessageManager;
 
 /**
- * logic for querying the PDBe API for structures of sequences
+ * logic for querying the 3DBeacons API for structures of sequences
  * 
  * @author jprocter
  */
@@ -33,9 +34,13 @@ public class ThreeDBStructureChooserQuerySource
 
   private static int MAX_QLENGTH = 7820;
 
+  protected FTSRestRequest lastTdbRequest;
+
+  protected FTSRestClientI tdbRestClient;
+
   public ThreeDBStructureChooserQuerySource()
   {
-    pdbRestClient = TDBeaconsFTSRestClient.getInstance();
+    tdbRestClient = TDBeaconsFTSRestClient.getInstance();
     docFieldPrefs = new FTSDataColumnPreferences(
             PreferenceSource.STRUCTURE_CHOOSER,
             TDBeaconsFTSRestClient.getInstance());
@@ -143,10 +148,10 @@ public class ThreeDBStructureChooserQuerySource
           FilterOption selectedFilterOpt, boolean b) throws Exception
   {
     FTSRestResponse resultList;
-    FTSRestRequest pdbRequest = getTDBeaconsRequest(seq, wantedFields);
-    resultList = pdbRestClient.executeRequest(pdbRequest);
+    FTSRestRequest tdbRequest = getTDBeaconsRequest(seq, wantedFields);
+    resultList = tdbRestClient.executeRequest(tdbRequest);
 
-    lastPdbRequest = pdbRequest;
+    lastTdbRequest = tdbRequest;
     return resultList;
   }
   
@@ -214,11 +219,11 @@ public class ThreeDBStructureChooserQuerySource
       return null;
     }
     pdbRequest.setResponseSize(1);
-    resultList = pdbRestClient.executeRequest(pdbRequest);
+    resultList = tdbRestClient.executeRequest(pdbRequest);
     
     // TODO: client side filtering - sort results and pick top one (or N)
 
-    lastPdbRequest = pdbRequest;
+    lastTdbRequest = pdbRequest;
     return resultList;
   }
 
@@ -271,4 +276,11 @@ public class ThreeDBStructureChooserQuerySource
     }
     return pdbEntriesToView;
   }
+
+
+  @Override
+  protected FTSRestRequest getLastFTSRequest()
+  {
+    return lastTdbRequest;
+  }
 }
\ No newline at end of file