JAL-2071 improvement to get column data files as InputStream
[jalview.git] / src / jalview / fts / service / pdb / PDBFTSRestClient.java
index be1c9ee..08803b0 100644 (file)
@@ -49,7 +49,7 @@ import com.sun.jersey.api.client.config.ClientConfig;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 
 /**
- * A rest client for querying the Search endpoint of the PDB REST API
+ * A rest client for querying the Search endpoint of the PDB API
  * 
  * @author tcnofoegbu
  *
@@ -61,8 +61,6 @@ public class PDBFTSRestClient extends FTSRestClient
 
   public static final String PDB_SEARCH_ENDPOINT = "http://www.ebi.ac.uk/pdbe/search/pdb/select?";
 
-  private static int DEFAULT_RESPONSE_SIZE = 200;
-
   protected PDBFTSRestClient()
   {
   }
@@ -86,7 +84,7 @@ public class PDBFTSRestClient extends FTSRestClient
 
       String wantedFields = getDataColumnsFieldsAsCommaDelimitedString(pdbRestRequest
               .getWantedFields());
-      int responseSize = (pdbRestRequest.getResponseSize() == 0) ? DEFAULT_RESPONSE_SIZE
+      int responseSize = (pdbRestRequest.getResponseSize() == 0) ? getDefaultResponsePageSize()
               : pdbRestRequest.getResponseSize();
       String sortParam = null;
       if (pdbRestRequest.getFieldToSortBy() == null
@@ -347,32 +345,23 @@ public class PDBFTSRestClient extends FTSRestClient
         primaryKey = fieldData;
         summaryRowData[colCounter++] = primaryKey;
       }
+      else if (fieldData == null || fieldData.isEmpty())
+      {
+        summaryRowData[colCounter++] = null;
+      }
       else
       {
-        if (field.getGroup().getName().equals("Quality Measures"))
+        try
         {
-          try
-          {
-            if (fieldData == null || fieldData.isEmpty())
-            {
-              summaryRowData[colCounter++] = null;
-            }
-            else
-            {
-              Double value = Double.valueOf(fieldData);
-              summaryRowData[colCounter++] = value;
-            }
-          } catch (Exception e)
-          {
-            e.printStackTrace();
-            System.out.println("offending value:" + fieldData);
-            summaryRowData[colCounter++] = 0.0;
-          }
-        }
-        else
+          summaryRowData[colCounter++] = (field.getDataColumnClass() == Integer.class) ? Integer
+                  .valueOf(fieldData)
+                  : (field.getDataColumnClass() == Double.class) ? Double
+                          .valueOf(fieldData)
+                          : fieldData;
+        } catch (Exception e)
         {
-          summaryRowData[colCounter++] = (fieldData == null || fieldData
-                  .isEmpty()) ? null : fieldData;
+          e.printStackTrace();
+            System.out.println("offending value:" + fieldData);
         }
       }
     }
@@ -422,9 +411,9 @@ public class PDBFTSRestClient extends FTSRestClient
   }
 
   @Override
-  public String getColumnDataConfigFile()
+  public String getColumnDataConfigFileName()
   {
-    return getFile("fts/pdb_data_columns.conf");
+    return "/fts/pdb_data_columns.txt";
   }