From d64daffb893f7efbf8e424e41f3ddb22f04ab121 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 3 Sep 2021 17:01:04 +0100 Subject: [PATCH] JAL-3865 isolate PDB and TDB clients and last query records in their query objects --- .../PDBStructureChooserQuerySource.java | 11 +++++++++ .../StructureChooserQuerySource.java | 7 +++--- .../ThreeDBStructureChooserQuerySource.java | 26 ++++++++++++++------ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java index 4dede2e..3d1b982 100644 --- a/src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/PDBStructureChooserQuerySource.java @@ -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 diff --git a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java index 4faa2de..96b67e4 100644 --- a/src/jalview/gui/structurechooser/StructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/StructureChooserQuerySource.java @@ -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 discoveredStructuresSet) { - return FTSRestResponse.getTableModel(lastPdbRequest, + return FTSRestResponse.getTableModel(getLastFTSRequest(), discoveredStructuresSet); } + protected abstract FTSRestRequest getLastFTSRequest(); + public abstract PDBEntry[] collectSelectedRows(JTable restable, int[] selectedRows, List selectedSeqsToView); diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java index e188b23..0bf9fdb 100644 --- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java @@ -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 -- 1.7.10.2