Merge branch 'develop' into releases/Release_2_9_1_Branch
authorJim Procter <jprocter@issues.jalview.org>
Tue, 3 May 2016 15:07:47 +0000 (16:07 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 3 May 2016 15:07:47 +0000 (16:07 +0100)
15 files changed:
help/html/releases.html
resources/images/blank_16x16_placeholder.png [new file with mode: 0644]
resources/lang/Messages.properties
src/jalview/fts/api/GFTSPanelI.java
src/jalview/fts/core/FTSRestClient.java
src/jalview/fts/core/GFTSPanel.java
src/jalview/fts/service/pdb/PDBFTSPanel.java
src/jalview/fts/service/pdb/PDBFTSRestClient.java
src/jalview/fts/service/uniprot/UniProtFTSRestClient.java
src/jalview/fts/service/uniprot/UniprotFTSPanel.java
test/jalview/ext/ensembl/EnsemblXrefTest.java
test/jalview/fts/service/pdb/PDBFTSPanelTest.java
test/jalview/fts/service/pdb/PDBFTSRestClientTest.java
test/jalview/ws/dbsources/XfamFetcherTest.java
test/jalview/ws/jabaws/DisorderAnnotExportImport.java

index 23e958c..0bb5fb7 100755 (executable)
     <tr>
       <td width="60" nowrap>
         <div align="center">
-          <strong><a name="Jalview.2.9.0b2">2.9.0b2</a><br />
-            <em>16/10/2015</em></strong>
+          <strong><a name="Jalview.2.9.1">2.9.1</a><br /> <em>1/6/2016</em></strong>
         </div>
       </td>
+      <td><em>General</em>
+        <ul>
+          <li></li>
+        </ul> <em>Application</em>
+        <ul>
+          <li></li>
+        </ul> <em>Applet</em>
+        <ul>
+          <li></li>
+        </ul></td>
       <td>
-      <em>General</em>
-      <ul>
-            <li>Time stamps for signed Jalview application and applet jars</li>
-      </ul>
+        <div align="left">
+          <em>General</em>
+          <ul>
+            <li></li>
+          </ul>
+          <em>Application</em>
+          <ul>
+            <li></li>
+          </ul>
+          <em>Applet</em>
+          <ul>
+            <li></li>
+          </ul>
+        </div>
+      </td>
+    </tr>
+    <tr>
+      <td width="60" nowrap>
+        <div align="center">
+          <strong><a name="Jalview.2.9.0b2">2.9.0b2</a><br />
+            <em>16/10/2015</em></strong>
+        </div>
       </td>
+      <td><em>General</em>
+        <ul>
+          <li>Time stamps for signed Jalview application and applet
+            jars</li>
+        </ul></td>
       <td>
         <div align="left">
-        <em>Application</em><ul>
-          <li>Duplicate group consensus and conservation rows shown when tree is partitioned</li>
-            <li>Erratic behaviour when tree partitions made with multiple cDNA/Protein split views</li>
-            </ul>
+          <em>Application</em>
+          <ul>
+            <li>Duplicate group consensus and conservation rows
+              shown when tree is partitioned</li>
+            <li>Erratic behaviour when tree partitions made with
+              multiple cDNA/Protein split views</li>
+          </ul>
         </div>
       </td>
     </tr>
             <em>8/10/2015</em></strong>
         </div>
       </td>
-      <td>
-      <em>General</em>
+      <td><em>General</em>
+        <ul>
+          <li>Updated Spanish translations of localized text for
+            2.9</li>
+        </ul> <em>Application</em>
       <ul>
-            <li>Updated Spanish translations of localized text for 2.9</li>
-      </ul>
-      <em>Application</em><ul>
-      <!-- <li>cDNA/Protein splitframe window geometry preserved in Jalview projects</li>-->
-      <li>Signed OSX InstallAnywhere installer<br></li>
-      <li>Support for per-sequence based annotations in BioJSON</li></ul>
-        <em>Applet</em>
-        <ul><li>Split frame example added to applet examples page</li>
-            </ul>
-      </td>
+          <!-- <li>cDNA/Protein splitframe window geometry preserved in Jalview projects</li>-->
+          <li>Signed OSX InstallAnywhere installer<br></li>
+          <li>Support for per-sequence based annotations in BioJSON</li>
+        </ul> <em>Applet</em>
+        <ul>
+          <li>Split frame example added to applet examples page</li>
+        </ul></td>
       <td>
         <div align="left">
-        <em>General</em>
+          <em>General</em>
           <ul>
-            <li>Mapping of cDNA to protein in split frames incorrect when sequence start > 1</li>
-            <li>Broken images in filter column by annotation dialog documentation</li>
+            <li>Mapping of cDNA to protein in split frames
+              incorrect when sequence start > 1</li>
+            <li>Broken images in filter column by annotation dialog
+              documentation</li>
             <li>Feature colours not parsed from features file</li>
-            <li>Exceptions and incomplete link URLs recovered when loading a features file containing HTML tags in feature description</li>
-            
+            <li>Exceptions and incomplete link URLs recovered when
+              loading a features file containing HTML tags in feature
+              description</li>
+
           </ul>
-      <em>Application</em><ul>
-            <li>Annotations corrupted after BioJS export and reimport</li>
-            <li>Incorrect sequence limits after Fetch DB References with 'trim retrieved sequences'</li>
-            <li>Incorrect warning about deleting all data when deleting selected columns</li>
-            <li>Patch to build system for shipping properly signed JNLP templates for webstart launch</li>
-            <li>EMBL-PDBe fetcher/viewer dialogs do not offer unreleased structures for download or viewing</li>
-            <li>Tab/space/return keystroke operation of EMBL-PDBe fetcher/viewer dialogs works correctly</li>
-            <li>Disabled 'minimise' button on Jalview windows running on OSX to workaround redraw hang bug</li>
-            <li>Split cDNA/Protein view position and geometry not recovered from jalview project</li>
-            <li>Initial enabled/disabled state of annotation menu sorter 'show autocalculated first/last' corresponds to alignment view</li>
-            <li>Restoring of Clustal, RNA Helices and T-Coffee color schemes from BioJSON</li>
-            </ul>
-      <em>Applet</em><ul>
-            <li>Reorder sequences mirrored in cDNA/Protein split frame</li>
+          <em>Application</em>
+          <ul>
+            <li>Annotations corrupted after BioJS export and
+              reimport</li>
+            <li>Incorrect sequence limits after Fetch DB References
+              with 'trim retrieved sequences'</li>
+            <li>Incorrect warning about deleting all data when
+              deleting selected columns</li>
+            <li>Patch to build system for shipping properly signed
+              JNLP templates for webstart launch</li>
+            <li>EMBL-PDBe fetcher/viewer dialogs do not offer
+              unreleased structures for download or viewing</li>
+            <li>Tab/space/return keystroke operation of EMBL-PDBe
+              fetcher/viewer dialogs works correctly</li>
+            <li>Disabled 'minimise' button on Jalview windows
+              running on OSX to workaround redraw hang bug</li>
+            <li>Split cDNA/Protein view position and geometry not
+              recovered from jalview project</li>
+            <li>Initial enabled/disabled state of annotation menu
+              sorter 'show autocalculated first/last' corresponds to
+              alignment view</li>
+            <li>Restoring of Clustal, RNA Helices and T-Coffee
+              color schemes from BioJSON</li>
+          </ul>
+          <em>Applet</em>
+          <ul>
+            <li>Reorder sequences mirrored in cDNA/Protein split
+              frame</li>
             <li>Applet with Jmol examples not loading correctly</li>
-            </ul>
+          </ul>
         </div>
       </td>
     </tr>
     <tr>
       <td><div align="center">
           <strong><a name="Jalview.2.8.0b1">2.8.0b1</a><br />
-          <em>30/1/2014</em></strong>
+            <em>30/1/2014</em></strong>
         </div></td>
       <td>
         <ul>
         <ul>
           <li>URL links generated from description line for
             regular-expression based URL links (applet and application)
+
           
           <li>Non-positional feature URL links are shown in link
             menu</li>
           <li>Cancel button for DAS Feature Fetching
           <li>PCA and PDB Viewers zoom via mouse roller
           <li>User-defined sub-tree colours and sub-tree selection
+
           
           <li>'New Window' button on the 'Output to Text box'
         </ul>
           <li>Fixed Remove Empty Columns Bug (empty columns at end
             of alignment)
           <li>Slowed DAS Feature Fetching for increased robustness.
+
           
           <li>Made angle brackets in ASCII feature descriptions
             display correctly
           <li>WsDbFetch query/result association resolved
           <li>Tree leaf to sequence mapping improved
           <li>Smooth fonts switch moved to FontChooser dialog box.
+
           
         </ul>
       </td>
diff --git a/resources/images/blank_16x16_placeholder.png b/resources/images/blank_16x16_placeholder.png
new file mode 100644 (file)
index 0000000..885ad87
Binary files /dev/null and b/resources/images/blank_16x16_placeholder.png differ
index b68a358..62c813a 100644 (file)
@@ -1279,10 +1279,10 @@ label.structure_chooser_filter_time = Structure Chooser - Filter time ({0})
 label.structure_chooser_no_of_structures = Structure Chooser - {0} Found ({1})
 info.no_pdb_entry_found_for = No PDB entry found for {0}
 exception.unable_to_detect_internet_connection = Jalview is unable to detect an internet connection
-exception.pdb_rest_service_no_longer_available = PDB rest services no longer available!
+exception.fts_rest_service_no_longer_available = {0} rest services no longer available!
 exception.resource_not_be_found = The requested resource could not be found
-exception.pdb_server_error = There seems to be an error from the PDB server
-exception.pdb_server_unreachable = Jalview is unable to reach the PDBe Solr server. \nPlease ensure that you are connected to the internet and try again.
+exception.fts_server_error = There seems to be an error from the {0} server
+exception.fts_server_unreachable = Jalview is unable to reach the {0} server. \nPlease ensure that you are connected to the internet and try again.
 label.nw_mapping = Needleman & Wunsch Alignment
 label.sifts_mapping = SIFTs Mapping
 label.mapping_method = Sequence \u27f7 Structure mapping method
@@ -1297,4 +1297,8 @@ label.run_groovy_tip = Run the script in the Groovy console over this alignment
 label.couldnt_run_groovy_script = Failed to run Groovy script
 label.uniprot_sequence_fetcher = UniProt Sequence Fetcher
 action.next_page= >> 
-action.prev_page= << 
\ No newline at end of file
+action.prev_page= << 
+label.next_page_tooltop=Next Page
+label.prev_page_tooltop=Previous Page
+exception.bad_request=Bad request. There is a problem with your input.
+exception.service_not_available=Service not available. The server is being updated, try again later.
index 16bf404..ce63576 100644 (file)
@@ -33,8 +33,12 @@ public interface GFTSPanelI
 
   /**
    * Action performed when a text is entered in the search field.
+   * 
+   * @param isFreshSearch
+   *          if true a fresh search is executed else a pagination search is
+   *          executed
    */
-  public void searchAction();
+  public void searchAction(boolean isFreshSearch);
 
   /**
    * Action performed when search results are selected and the 'ok' button is
index 8bf1dc2..2f24a01 100644 (file)
@@ -3,6 +3,7 @@ package jalview.fts.core;
 import jalview.fts.api.FTSDataColumnI;
 import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
 import jalview.fts.api.FTSRestClientI;
+import jalview.util.MessageManager;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -383,6 +384,42 @@ public abstract class FTSRestClient implements FTSRestClientI
     throw new Exception("Couldn't find data column group with id : " + id);
   }
 
+  public String getMessageByHTTPStatusCode(int code, String service)
+  {
+    String message = "";
+    switch (code)
+    {
+    case 400:
+      message = MessageManager
+              .getString("exception.bad_request");
+      break;
+      
+    case 410:
+      message = MessageManager.formatMessage(
+              "exception.fts_rest_service_no_longer_available", service);
+      break;
+    case 403:
+    case 404:
+      message = MessageManager.getString("exception.resource_not_be_found");
+      break;
+    case 408:
+    case 409:
+    case 500:
+    case 501:
+    case 502:
+    case 504:
+    case 505:
+      message = MessageManager.getString("exception.fts_server_error");
+      break;
+    case 503:
+      message = MessageManager.getString("exception.service_not_available");
+      break;
+    default:
+      break;
+    }
+    return message;
+  }
+
   protected String getResourceFile(String fileName)
   {
     String result = "";
index 02a313b..bc68667 100644 (file)
@@ -91,7 +91,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
 
   protected JButton btn_cancel = new JButton();
 
-  protected JTextField txt_search = new JTextField(35);
+  protected JTextField txt_search = new JTextField(30);
 
   protected SequenceFetcher seqFetcher;
 
@@ -103,6 +103,43 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
 
   protected JButton btn_prev_page = new JButton();
 
+  protected StringBuilder errorWarning = new StringBuilder();
+
+  protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
+          "/images/warning.gif"));
+
+  protected ImageIcon loadingImage = new ImageIcon(getClass().getResource(
+          "/images/loading.gif"));
+
+  protected ImageIcon balnkPlaceholderImage = new ImageIcon(getClass()
+          .getResource("/images/blank_16x16_placeholder.png"));
+
+  protected JLabel lbl_warning = new JLabel(warningImage);
+
+  protected JLabel lbl_loading = new JLabel(loadingImage);
+
+  protected JLabel lbl_blank = new JLabel(balnkPlaceholderImage);
+
+  private JTabbedPane tabbedPane = new JTabbedPane();
+
+  private JPanel pnl_actions = new JPanel();
+
+  private JPanel pnl_results = new JPanel(new CardLayout());
+
+  private JPanel pnl_inputs = new JPanel();
+
+  private BorderLayout mainLayout = new BorderLayout();
+
+  protected Object[] previousWantedFields;
+
+  protected int resultSetCount;
+
+  protected int totalResultSetCount;
+
+  protected int offSet;
+
+  protected int pageLimit;
+
   private JTable tbl_summary = new JTable()
   {
     private boolean inLayout;
@@ -178,33 +215,8 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
       return toolTipText;
     }
   };
-
-  protected StringBuilder errorWarning = new StringBuilder();
-
   protected JScrollPane scrl_searchResult = new JScrollPane(tbl_summary);
 
-  protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
-          "/images/warning.gif"));
-
-  protected ImageIcon loadingImage = new ImageIcon(getClass().getResource(
-          "/images/loading.gif"));
-
-  protected JLabel lbl_warning = new JLabel(warningImage);
-
-  protected JLabel lbl_loading = new JLabel(loadingImage);
-
-  private JTabbedPane tabbedPane = new JTabbedPane();
-
-  private JPanel pnl_actions = new JPanel();
-
-  private JPanel pnl_results = new JPanel(new CardLayout());
-
-  private JPanel pnl_inputs = new JPanel();
-
-  private BorderLayout mainLayout = new BorderLayout();
-
-  protected Object[] previousWantedFields;
-
   public GFTSPanel()
   {
     try
@@ -229,6 +241,8 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     lbl_warning.setFont(new java.awt.Font("Verdana", 0, 12));
     lbl_loading.setVisible(false);
     lbl_loading.setFont(new java.awt.Font("Verdana", 0, 12));
+    lbl_blank.setVisible(true);
+    lbl_blank.setFont(new java.awt.Font("Verdana", 0, 12));
 
     tbl_summary.setAutoCreateRowSorter(true);
     tbl_summary.getTableHeader().setReorderingAllowed(false);
@@ -325,8 +339,9 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
         }
       }
     });
-
     btn_next_page.setEnabled(false);
+    btn_next_page.setToolTipText(MessageManager
+            .getString("label.next_page_tooltop"));
     btn_next_page.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_next_page.setText(MessageManager.getString("action.next_page"));
     btn_next_page.addActionListener(new java.awt.event.ActionListener()
@@ -350,6 +365,8 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     });
 
     btn_prev_page.setEnabled(false);
+    btn_prev_page.setToolTipText(MessageManager
+            .getString("label.prev_page_tooltop"));
     btn_prev_page.setFont(new java.awt.Font("Verdana", 0, 12));
     btn_prev_page.setText(MessageManager.getString("action.prev_page"));
     btn_prev_page.addActionListener(new java.awt.event.ActionListener()
@@ -433,7 +450,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
         }
         txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
                 tooltipText));
-        searchAction();
+        searchAction(true);
       }
     });
 
@@ -465,7 +482,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     });
 
     final DeferredTextInputListener listener = new DeferredTextInputListener(
-            2500,
+            1500,
             new ActionListener()
             {
               @Override
@@ -473,7 +490,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
               {
                 if (!getTypedText().equalsIgnoreCase(lastSearchTerm))
                 {
-                  searchAction();
+                  searchAction(true);
                   lastSearchTerm = getTypedText();
                 }
               }
@@ -490,7 +507,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
       @Override
       public void focusLost(FocusEvent e)
       {
-        listener.stop();
+//        listener.stop();
       }
     });
 
@@ -518,6 +535,10 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
           btn_back.setEnabled(false);
           btn_cancel.setEnabled(false);
           btn_ok.setEnabled(false);
+          btn_next_page.setEnabled(false);
+          btn_prev_page.setEnabled(false);
+          txt_search.setEnabled(false);
+          cmb_searchTarget.setEnabled(false);
           previousWantedFields = getFTSRestClient()
                   .getAllDefaulDisplayedDataColumns()
                   .toArray(new Object[0]);
@@ -526,9 +547,12 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
         {
           btn_back.setEnabled(true);
           btn_cancel.setEnabled(true);
+          refreshPaginatorState();
+          txt_search.setEnabled(true);
+          cmb_searchTarget.setEnabled(true);
           if (wantedFieldsUpdated())
           {
-            searchAction();
+            searchAction(true);
           }
           else
           {
@@ -552,6 +576,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     pnl_inputs.add(txt_search);
     pnl_inputs.add(lbl_loading);
     pnl_inputs.add(lbl_warning);
+    pnl_inputs.add(lbl_blank);
     pnl_inputs.add(btn_prev_page);
     pnl_inputs.add(btn_next_page);
 
@@ -671,9 +696,11 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
   protected void checkForErrors()
   {
     lbl_warning.setVisible(false);
+    lbl_blank.setVisible(true);
     if (errorWarning.length() > 0)
     {
       lbl_loading.setVisible(false);
+      lbl_blank.setVisible(false);
       lbl_warning.setToolTipText(JvSwingUtils.wrapTooltip(true,
               errorWarning.toString()));
       lbl_warning.setVisible(true);
@@ -755,6 +782,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     lbl_loading.setVisible(false);
     errorWarning.setLength(0);
     lbl_warning.setVisible(false);
+    lbl_blank.setVisible(true);
     btn_ok.setEnabled(false);
     mainFrame.setTitle(getFTSFrameTitle());
     referesh();
@@ -789,8 +817,52 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
   @Override
   public void setSearchInProgress(Boolean isSearchInProgress)
   {
+    lbl_blank.setVisible(!isSearchInProgress);
     lbl_loading.setVisible(isSearchInProgress);
   }
+
+  @Override
+  public void prevPageAction()
+  {
+    if (offSet >= pageLimit)
+    {
+      offSet = offSet - pageLimit;
+      searchAction(false);
+    }
+    else
+    {
+      refreshPaginatorState();
+    }
+  }
+
+  @Override
+  public void nextPageAction()
+  {
+    offSet = offSet + pageLimit;
+    searchAction(false);
+
+  }
+
+  public void refreshPaginatorState()
+  {
+    // System.out.println("resultSet count : " + resultSetCount);
+    // System.out.println("offSet : " + offSet);
+    // System.out.println("page limit : " + pageLimit);
+    setPrevPageButtonEnabled(false);
+    setNextPageButtonEnabled(false);
+    if (resultSetCount == 0 && pageLimit == 0)
+    {
+      return;
+    }
+    if (resultSetCount >= pageLimit)
+    {
+      setNextPageButtonEnabled(true);
+    }
+    if (offSet >= pageLimit)
+    {
+      setPrevPageButtonEnabled(true);
+    }
+  }
   public void referesh()
   {
     mainFrame.setTitle(getFTSFrameTitle());
index ca1a902..4f308e3 100644 (file)
@@ -41,6 +41,7 @@ public class PDBFTSPanel extends GFTSPanel
 
   public PDBFTSPanel(SequenceFetcher seqFetcher)
   {
+    pageLimit = PDBFTSRestClient.getInstance().getDefaultResponsePageSize();
     this.seqFetcher = seqFetcher;
     this.progressIdicator = (seqFetcher == null) ? null : seqFetcher
             .getProgressIndicator();
@@ -48,8 +49,12 @@ public class PDBFTSPanel extends GFTSPanel
 
 
   @Override
-  public void searchAction()
+  public void searchAction(boolean isFreshSearch)
   {
+    if (isFreshSearch)
+    {
+      offSet = 0;
+    }
     new Thread()
     {
       @Override
@@ -75,6 +80,7 @@ public class PDBFTSPanel extends GFTSPanel
           request.setResponseSize(100);
           request.setFieldToSearchBy("(" + searchTarget + ":");
           request.setSearchTerm(searchTerm + ")");
+          request.setOffSet(offSet);
           request.setWantedFields(wantedFields);
           FTSRestClientI pdbRestCleint = PDBFTSRestClient.getInstance();
           FTSRestResponse resultList;
@@ -100,14 +106,29 @@ public class PDBFTSPanel extends GFTSPanel
           }
 
           long endTime = System.currentTimeMillis();
-          int resultSetCount = resultList.getNumberOfItemsFound();
-          String result = (resultSetCount > 1) ? MessageManager
+          totalResultSetCount = resultList.getNumberOfItemsFound();
+          resultSetCount = resultList.getSearchSummary().size();
+          String result = (resultSetCount > 0) ? MessageManager
                   .getString("label.results") : MessageManager
                   .getString("label.result");
-          updateSearchFrameTitle(defaultFTSFrameTitle + " - "
-                  + resultSetCount + " " + result + " ("
-                  + (endTime - startTime) + " milli secs)");
+         
+          if (isPaginationEnabled() && resultSetCount > 0)
+          {
+            updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
+                    + " " + (offSet + 1) + " to "
+                    + (offSet + resultSetCount) + " of "
+                    + totalResultSetCount
+                    + " " + " (" + (endTime - startTime) + " milli secs)");
+          }
+          else
+          {
+            updateSearchFrameTitle(defaultFTSFrameTitle + " - "
+                    + resultSetCount + " " + result + " ("
+                    + (endTime - startTime) + " milli secs)");
+          }
+          
           setSearchInProgress(false);
+          refreshPaginatorState();
         }
       }
     }.start();
@@ -164,7 +185,6 @@ public class PDBFTSPanel extends GFTSPanel
               false);
     } catch (Exception e)
     {
-      // TODO Auto-generated catch block
       e.printStackTrace();
     }
     int[] selectedRows = getResultTable().getSelectedRows();
@@ -217,8 +237,6 @@ public class PDBFTSPanel extends GFTSPanel
     return pdbIdWithChainCode;
   }
 
-
-
   @Override
   public FTSRestClientI getFTSRestClient()
   {
@@ -231,25 +249,10 @@ public class PDBFTSPanel extends GFTSPanel
     return ftsFrameTitle;
   }
 
-
-  @Override
-  public void prevPageAction()
-  {
-    // TODO pagination not yet implemented for PDB FTS
-
-  }
-
-  @Override
-  public void nextPageAction()
-  {
-    // TODO pagination not yet implemented for PDB FTS
-
-  }
-
   @Override
   public boolean isPaginationEnabled()
   {
-    return false;
+    return true;
   }
 
 }
index 08803b0..29450e8 100644 (file)
@@ -86,6 +86,7 @@ public class PDBFTSRestClient extends FTSRestClient
               .getWantedFields());
       int responseSize = (pdbRestRequest.getResponseSize() == 0) ? getDefaultResponsePageSize()
               : pdbRestRequest.getResponseSize();
+      int offSet = pdbRestRequest.getOffSet();
       String sortParam = null;
       if (pdbRestRequest.getFieldToSortBy() == null
               || pdbRestRequest.getFieldToSortBy().trim().isEmpty())
@@ -128,6 +129,7 @@ public class PDBFTSRestClient extends FTSRestClient
                 .queryParam("wt", "json").queryParam("fl", wantedFields)
                 .queryParam("rows", String.valueOf(responseSize))
                 .queryParam("q", query)
+                .queryParam("start", String.valueOf(offSet))
                 .queryParam("sort", sortParam).queryParam("facet", "true")
                 .queryParam("facet.pivot", facetPivot)
                 .queryParam("facet.pivot.mincount", facetPivotMinCount);
@@ -137,6 +139,7 @@ public class PDBFTSRestClient extends FTSRestClient
         webResource = client.resource(PDB_SEARCH_ENDPOINT)
                 .queryParam("wt", "json").queryParam("fl", wantedFields)
                 .queryParam("rows", String.valueOf(responseSize))
+                .queryParam("start", String.valueOf(offSet))
                 .queryParam("q", query)
                 .queryParam("sort", sortParam);
       }
@@ -160,7 +163,7 @@ public class PDBFTSRestClient extends FTSRestClient
         else
         {
           errorMessage = getMessageByHTTPStatusCode(clientResponse
-                  .getStatus());
+.getStatus(), "PDB");
           throw new Exception(errorMessage);
         }
       }
@@ -185,9 +188,8 @@ public class PDBFTSRestClient extends FTSRestClient
       else if (exceptionMsg.contains("UnknownHostException"))
       {
         // The server 'www.ebi.ac.uk' is unreachable
-        throw new Exception(
-                MessageManager
-                        .getString("exception.pdb_server_unreachable"));
+        throw new Exception(MessageManager.formatMessage(
+                "exception.fts_server_unreachable", "PDB Solr"));
       }
       else
       {
@@ -196,35 +198,6 @@ public class PDBFTSRestClient extends FTSRestClient
     }
   }
 
-  public String getMessageByHTTPStatusCode(int code)
-  {
-    String message = "";
-    switch (code)
-    {
-    case 410:
-      message = MessageManager
-              .getString("exception.pdb_rest_service_no_longer_available");
-      break;
-    case 403:
-    case 404:
-      message = MessageManager.getString("exception.resource_not_be_found");
-      break;
-    case 408:
-    case 409:
-    case 500:
-    case 501:
-    case 502:
-    case 503:
-    case 504:
-    case 505:
-      message = MessageManager.getString("exception.pdb_server_error");
-      break;
-
-    default:
-      break;
-    }
-    return message;
-  }
 
   /**
    * Process error response from PDB server if/when one occurs.
@@ -407,6 +380,12 @@ public class PDBFTSRestClient extends FTSRestClient
       {
         return Objects.hash(primaryKey1, this.toString());
       }
+
+      @Override
+      public boolean equals(Object that)
+      {
+        return this.toString().equals(that.toString());
+      }
     };
   }
 
index 57689f9..8a21ffb 100644 (file)
@@ -27,6 +27,7 @@ import jalview.fts.api.FTSRestClientI;
 import jalview.fts.core.FTSRestClient;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.core.FTSRestResponse;
+import jalview.util.MessageManager;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -49,58 +50,95 @@ public class UniProtFTSRestClient extends FTSRestClient
 
   @Override
   public FTSRestResponse executeRequest(FTSRestRequest uniportRestRequest)
+          throws Exception
   {
-    ClientConfig clientConfig = new DefaultClientConfig();
-    Client client = Client.create(clientConfig);
+    try
+    {
+      ClientConfig clientConfig = new DefaultClientConfig();
+      Client client = Client.create(clientConfig);
 
-    String wantedFields = getDataColumnsFieldsAsCommaDelimitedString(uniportRestRequest
-            .getWantedFields());
-    int responseSize = (uniportRestRequest.getResponseSize() == 0) ? getDefaultResponsePageSize()
-            : uniportRestRequest.getResponseSize();
+      String wantedFields = getDataColumnsFieldsAsCommaDelimitedString(uniportRestRequest
+              .getWantedFields());
+      int responseSize = (uniportRestRequest.getResponseSize() == 0) ? getDefaultResponsePageSize()
+              : uniportRestRequest.getResponseSize();
 
-    int offSet = (uniportRestRequest.getOffSet() == 0) ? getDefaultResponsePageSize()
-            : uniportRestRequest.getOffSet();
+      int offSet = uniportRestRequest.getOffSet();
 
-    String query = uniportRestRequest.getFieldToSearchBy()
-            .equalsIgnoreCase("Search All") ? uniportRestRequest
-            .getSearchTerm()
-            : uniportRestRequest.getFieldToSearchBy() + ":"
-                    + uniportRestRequest.getSearchTerm();
+      String query = uniportRestRequest.getFieldToSearchBy()
+              .equalsIgnoreCase("Search All") ? uniportRestRequest
+              .getSearchTerm() : uniportRestRequest.getFieldToSearchBy()
+              + ":" + uniportRestRequest.getSearchTerm();
 
-    // + (uniportRestRequest.isAllowUnpublishedEntries() ? ""
-    // : " AND status:REL");
-    // System.out.println(">>>>> Query : " + query);
-    // System.out.println(">>>>> Columns : " + wantedFields);
-    WebResource webResource = null;
-    webResource = client.resource(UNIPROT_SEARCH_ENDPOINT)
-            .queryParam("format", "tab")
-            .queryParam("columns", wantedFields)
-            .queryParam("limit", String.valueOf(responseSize))
-            .queryParam("offset", String.valueOf(offSet))
-            .queryParam("sort", "score")
-            .queryParam("query", query);
-    // Execute the REST request
-    ClientResponse clientResponse = webResource
-            .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
-    String uniProtTabDelimittedResponseString = clientResponse
-            .getEntity(String.class);
-    // Make redundant objects eligible for garbage collection to conserve
-    // memory
-    clientResponse = null;
-    client = null;
-    // System.out.println(">>>>> response : "
-    // + uniProtTabDelimittedResponseString);
-    return parseUniprotResponse(uniProtTabDelimittedResponseString,
-            uniportRestRequest);
+      // + (uniportRestRequest.isAllowUnpublishedEntries() ? ""
+      // : " AND status:REL");
+      // System.out.println(">>>>> Query : " + query);
+      // System.out.println(">>>>> Columns : " + wantedFields);
+      // System.out.println(">>>>> Response size: " + responseSize
+      // + " offset : "
+      // + offSet);
+      WebResource webResource = null;
+      webResource = client.resource(UNIPROT_SEARCH_ENDPOINT)
+              .queryParam("format", "tab")
+              .queryParam("columns", wantedFields)
+              .queryParam("limit", String.valueOf(responseSize))
+              .queryParam("offset", String.valueOf(offSet))
+              .queryParam("sort", "score").queryParam("query", query);
+      // Execute the REST request
+      ClientResponse clientResponse = webResource.accept(
+              MediaType.TEXT_PLAIN).get(ClientResponse.class);
+      String uniProtTabDelimittedResponseString = clientResponse
+              .getEntity(String.class);
+      // Make redundant objects eligible for garbage collection to conserve
+      // memory
+      // System.out.println(">>>>> response : "
+      // + uniProtTabDelimittedResponseString);
+      if (clientResponse.getStatus() != 200)
+      {
+        String errorMessage = getMessageByHTTPStatusCode(
+                clientResponse.getStatus(), "Uniprot");
+        throw new Exception(errorMessage);
 
+      }
+      clientResponse = null;
+      client = null;
+      return parseUniprotResponse(uniProtTabDelimittedResponseString,
+              uniportRestRequest);
+    } catch (Exception e)
+    {
+      String exceptionMsg = e.getMessage();
+      if (exceptionMsg.contains("SocketException"))
+      {
+        // No internet connection
+        throw new Exception(
+                MessageManager
+                        .getString("exception.unable_to_detect_internet_connection"));
+      }
+      else if (exceptionMsg.contains("UnknownHostException"))
+      {
+        // The server 'http://www.uniprot.org' is unreachable
+        throw new Exception(MessageManager.formatMessage(
+                "exception.fts_server_unreachable", "Uniprot"));
+      }
+      else
+      {
+        throw e;
+      }
+    }
   }
 
+
   public FTSRestResponse parseUniprotResponse(
           String uniProtTabDelimittedResponseString,
           FTSRestRequest uniprotRestRequest)
   {
     FTSRestResponse searchResult = new FTSRestResponse();
     List<FTSData> result = null;
+    if (uniProtTabDelimittedResponseString == null
+            || uniProtTabDelimittedResponseString.trim().isEmpty())
+    {
+      searchResult.setNumberOfItemsFound(0);
+      return searchResult;
+    }
     String[] foundDataRow = uniProtTabDelimittedResponseString.split("\n");
     if (foundDataRow != null && foundDataRow.length > 0)
     {
@@ -156,6 +194,7 @@ public class UniProtFTSRestClient extends FTSRestClient
     }
     return result;
   }
+
   public static FTSData getFTSData(String tabDelimittedDataStr,
           FTSRestRequest request)
   {
@@ -242,6 +281,12 @@ public class UniProtFTSRestClient extends FTSRestClient
       {
         return Objects.hash(primaryKey1, this.toString());
       }
+
+      @Override
+      public boolean equals(Object that)
+      {
+        return this.toString().equals(that.toString());
+      }
     };
   }
 
index 3681a23..acf2fb0 100644 (file)
@@ -40,29 +40,24 @@ public class UniprotFTSPanel extends GFTSPanel
 
   private String ftsFrameTitle = defaultFTSFrameTitle;
 
-  private int resultSetCount;
 
-  private int offSet;
-
-  private static int pageLimit = UniProtFTSRestClient.getInstance()
-          .getDefaultResponsePageSize();
 
   public UniprotFTSPanel(SequenceFetcher seqFetcher)
   {
+    pageLimit = UniProtFTSRestClient.getInstance()
+            .getDefaultResponsePageSize();
     this.seqFetcher = seqFetcher;
     this.progressIdicator = (seqFetcher == null) ? null : seqFetcher
             .getProgressIndicator();
   }
 
   @Override
-  public void searchAction()
-  {
-    offSet = 0;
-    executeSearch();
-  }
-
-  public void executeSearch()
+  public void searchAction(boolean isFreshSearch)
   {
+    if (isFreshSearch)
+    {
+      offSet = 0;
+    }
     new Thread()
   {
       @Override
@@ -80,7 +75,8 @@ public class UniprotFTSPanel extends GFTSPanel
 
           wantedFields = UniProtFTSRestClient.getInstance()
                   .getAllDefaulDisplayedDataColumns();
-          String searchTerm = txt_search.getText();
+          String searchTerm = decodeSearchTerm(txt_search.getText(),
+                  searchTarget);
 
           FTSRestRequest request = new FTSRestRequest();
           request.setFieldToSearchBy(searchTarget);
@@ -114,13 +110,14 @@ public class UniprotFTSPanel extends GFTSPanel
 
           long endTime = System.currentTimeMillis();
           resultSetCount = resultList.getNumberOfItemsFound();
-          String result = (resultSetCount > 1) ? MessageManager
+          String result = (resultSetCount > 0) ? MessageManager
                   .getString("label.results") : MessageManager
                   .getString("label.result");
-          if (isPaginationEnabled() && resultSetCount > 1)
+          if (isPaginationEnabled() && resultSetCount > 0)
           {
             updateSearchFrameTitle(defaultFTSFrameTitle + " - " + result
-                    + " " + offSet + " to " + (offSet + resultSetCount)
+                    + " " + (offSet + 1) + " to "
+                    + (offSet + resultSetCount)
                     + " " + " (" + (endTime - startTime) + " milli secs)");
           }
           else
@@ -137,44 +134,33 @@ public class UniprotFTSPanel extends GFTSPanel
 
   }
 
-
-
-  public void refreshPaginatorState()
-  {
-    // System.out.println("resultSet count : " + resultSetCount);
-    // System.out.println("offSet : " + offSet);
-    // System.out.println("page limit : " + pageLimit);
-    setPrevPageButtonEnabled(false);
-    setNextPageButtonEnabled(false);
-    if (resultSetCount >= pageLimit)
-    {
-      setNextPageButtonEnabled(true);
-    }
-    if (offSet >= pageLimit)
-    {
-      setPrevPageButtonEnabled(true);
-    }
-  }
-
-  @Override
-  public void prevPageAction()
+  public String decodeSearchTerm(String enteredText, String targetField)
   {
-    if (offSet >= pageLimit)
+    int searchTargetLength = targetField.equalsIgnoreCase("Search All") ? 0
+            : targetField.length() + 1;
+    String searchTarget = targetField.equalsIgnoreCase("Search All") ? ""
+            : targetField + ":";
+    String foundSearchTerms = enteredText;
+    StringBuilder foundSearchTermsBuilder = new StringBuilder();
+    if (enteredText.contains(";"))
     {
-      offSet = offSet - pageLimit;
-      executeSearch();
-    }else{
-      refreshPaginatorState();
+      String[] searchTerms = enteredText.split(";");
+      for (String searchTerm : searchTerms)
+      {
+        foundSearchTermsBuilder.append(searchTarget).append(searchTerm)
+                .append(" OR ");
+      }
+      int endIndex = foundSearchTermsBuilder.lastIndexOf(" OR ");
+      foundSearchTerms = foundSearchTermsBuilder.toString();
+      if (foundSearchTerms.contains(" OR "))
+      {
+        foundSearchTerms = foundSearchTerms.substring(searchTargetLength,
+                endIndex);
+      }
     }
+    return foundSearchTerms;
   }
 
-  @Override
-  public void nextPageAction()
-  {
-    offSet = offSet + pageLimit;
-    executeSearch();
-
-  }
 
   @Override
   public boolean isPaginationEnabled()
index cde4afe..1dc9b8d 100644 (file)
@@ -21,7 +21,7 @@ public class EnsemblXrefTest
            "{\"primary_id\":\"GO:0000165\",\"dbname\":\"GO\"}]";
   //@formatter:on
 
-  @Test(groups = "functional")
+  @Test(groups = "Functional")
   public void testGetCrossReferences()
   {
     System.out.println(JSON);
index 6837847..ac1d304 100644 (file)
@@ -90,7 +90,7 @@ public class PDBFTSPanelTest
     assertEquals(expectedString, outcome);
   }
 
-  @Test(groups = { "Network", "External" }, timeOut = 7000)
+  @Test(groups = { "External" }, timeOut = 7000)
   public void txt_search_ActionPerformedTest()
   {
     PDBFTSPanel searchPanel = new PDBFTSPanel(null);
index d6203c6..ebc0405 100644 (file)
@@ -191,7 +191,7 @@ public class PDBFTSRestClientTest
   }
 
   @Test(
-    groups = { "External", "Network" },
+    groups = { "External" },
     expectedExceptions = Exception.class)
   public void testForExpectedRuntimeException() throws Exception
   {
@@ -206,6 +206,7 @@ public class PDBFTSRestClientTest
     PDBFTSRestClient.getInstance().executeRequest(request);
   }
 
+    // JBP: Is this actually external ?  Looks like it is mocked
   @Test(groups = { "External" })
   public void parsePDBJsonResponseTest()
   {
index ce4d1bc..c894fd1 100644 (file)
@@ -27,7 +27,7 @@ import org.testng.annotations.Test;
 
 public class XfamFetcherTest
 {
-  @Test(groups = { "network" })
+  @Test(groups = { "External" })
   public void testRfamSeed() throws Exception
   {
     // RfamFull rff = new RfamFull();
@@ -41,7 +41,7 @@ public class XfamFetcherTest
                     + " didn't contain more than one sequence.");
   }
 
-  @Test(groups = { "network" })
+  @Test(groups = { "External" })
   public void testPfamFullAndSeed() throws Exception
   {
     PfamFull pff = new PfamFull();
index 64840c2..557ef7e 100644 (file)
@@ -40,7 +40,7 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-@Test(groups = { "Network" })
+@Test(groups = { "External" })
 public class DisorderAnnotExportImport
 {
   public static String testseqs = "examples/uniref50.fa";