From bded98c37a83dcd79a8445e4272fb83fc28a26c5 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 17 Sep 2021 11:45:37 +0100 Subject: [PATCH] JAL-3829 belt and braces check to make sure there is a pdbe response available to join records from --- .../ThreeDBStructureChooserQuerySource.java | 26 ++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java index ff414dd..4229b72 100644 --- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java @@ -466,11 +466,14 @@ public class ThreeDBStructureChooserQuerySource public FTSRestResponse joinResponses(FTSRestResponse upResponse, FTSRestResponse pdbResponse) { + boolean hasPdbResp = lastPdbRequest != null; + int idx_provider = getLastFTSRequest().getFieldIndex("Provider"); // join on int idx_modelId = getLastFTSRequest().getFieldIndex("Model id"); - int pdbIdx = lastPdbRequest.getFieldIndex("PDB Id"); - int pdbTitle_idx = lastPdbRequest.getFieldIndex("Title"); + int pdbIdx = hasPdbResp ? lastPdbRequest.getFieldIndex("PDB Id") : -1; + int pdbTitle_idx = hasPdbResp ? lastPdbRequest.getFieldIndex("Title") + : -1; int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title"); List joinedRows = new ArrayList(); @@ -480,15 +483,24 @@ public class ThreeDBStructureChooserQuerySource String provider = (String) row.getSummaryData()[idx_provider]; if ("PDBe".equalsIgnoreCase(provider)) { - for (final FTSData pdbrow : pdbResponse.getSearchSummary()) + if (!hasPdbResp) + { + System.out.println( + "Warning: seems like we couldn't get to the PDBe search interface."); + } + else { - String pdbid = (String) pdbrow.getSummaryData()[pdbIdx]; - if (id.equalsIgnoreCase(pdbid)) + for (final FTSData pdbrow : pdbResponse.getSearchSummary()) { - row.getSummaryData()[tdbTitle_idx] = pdbrow - .getSummaryData()[pdbTitle_idx]; + String pdbid = (String) pdbrow.getSummaryData()[pdbIdx]; + if (id.equalsIgnoreCase(pdbid)) + { + row.getSummaryData()[tdbTitle_idx] = pdbrow + .getSummaryData()[pdbTitle_idx]; + } } } + } else { -- 1.7.10.2